获取 FUSE 版本字符串
Get the FUSE version string
是否有 returnFUSE 版本字符串的函数?
fuse_common.h
有 int fuse_version(void)
,其中 return 是主要版本,乘以 10,再加上次要版本;两者都来自 #define
值。 (例如,This returns 27
在我的平台上)。然而,我正在寻找的是一些 char* fuse_version(void)
会 return 类似 2.7.3
.
的东西
在include/config.h中fuse的源代码中你有:
/* Define to the version of this package. */
#define PACKAGE_VERSION "2.9.4"
此外,lib/helper.c 中有一个函数可以打印它。
static void helper_version(void)
{
fprintf(stderr, "FUSE library version: %s\n", PACKAGE_VERSION);
}
编辑:
我确实意识到包版本控制字符串仅供内部使用,因此您可能受困于 fuse_common.h 公开的主要和次要编号。您可能必须编写一个像@Jay 建议的函数。
正如你自己所说,版本在fuse_common.h
中定义。如果你不想使用 helper_version
,正如@Alexguitar 所说,你可能只需要编写一个小程序来实现它——但似乎只有前两个数字(主要和次要)可用:
#include <fuse/fuse.h>
#include <stdlib.h>
#include <stdio.h>
char* str_fuse_version(void) {
static char str[10] = {0,0,0,0,0,0,0,0,0,0};
if (str[0]==0) {
int v = fuse_version();
int a = v/10;
int b = v%10;
snprintf(str,10,"%d.%d",a,b);
}
return str;
}
int main () {
printf("%s\n", str_fuse_version());
exit(EXIT_SUCCESS);
}
注意:您应该包括 fuse/fuse.h
而不是 fuse_common.h
;另外,编译时可能需要传入-D_FILE_OFFSET_BITS=64
。
$ gcc -Wall fuseversiontest.c -D_FILE_OFFSET_BITS=64 -lfuse
$ ./a.out
2.9
是否有 returnFUSE 版本字符串的函数?
fuse_common.h
有 int fuse_version(void)
,其中 return 是主要版本,乘以 10,再加上次要版本;两者都来自 #define
值。 (例如,This returns 27
在我的平台上)。然而,我正在寻找的是一些 char* fuse_version(void)
会 return 类似 2.7.3
.
在include/config.h中fuse的源代码中你有:
/* Define to the version of this package. */
#define PACKAGE_VERSION "2.9.4"
此外,lib/helper.c 中有一个函数可以打印它。
static void helper_version(void)
{
fprintf(stderr, "FUSE library version: %s\n", PACKAGE_VERSION);
}
编辑:
我确实意识到包版本控制字符串仅供内部使用,因此您可能受困于 fuse_common.h 公开的主要和次要编号。您可能必须编写一个像@Jay 建议的函数。
正如你自己所说,版本在fuse_common.h
中定义。如果你不想使用 helper_version
,正如@Alexguitar 所说,你可能只需要编写一个小程序来实现它——但似乎只有前两个数字(主要和次要)可用:
#include <fuse/fuse.h>
#include <stdlib.h>
#include <stdio.h>
char* str_fuse_version(void) {
static char str[10] = {0,0,0,0,0,0,0,0,0,0};
if (str[0]==0) {
int v = fuse_version();
int a = v/10;
int b = v%10;
snprintf(str,10,"%d.%d",a,b);
}
return str;
}
int main () {
printf("%s\n", str_fuse_version());
exit(EXIT_SUCCESS);
}
注意:您应该包括 fuse/fuse.h
而不是 fuse_common.h
;另外,编译时可能需要传入-D_FILE_OFFSET_BITS=64
。
$ gcc -Wall fuseversiontest.c -D_FILE_OFFSET_BITS=64 -lfuse
$ ./a.out
2.9