Get FUSE version string

Is there a function that returns the FUSE version string?

fuse_common.h

has int fuse_version(void)

, which returns the major version times 10 plus the minor version; both of which are derived from values #define

. (for example this returns 27

on my platform). However, I'm looking for a few char* fuse_version(void)

that will return something like 2.7.3

.

+3


source to share


2 answers


As you said yourself, the version is defined in fuse_common.h

. If you don't want to use helper_version

as @Alexguitar said you can just write a small program that does this - but it seems that only the first two numbers (major and minor) are available:

#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);
}

      



Note: you must include fuse/fuse.h

, not fuse_common.h

; Also, when compiling, you may need to pass -D_FILE_OFFSET_BITS=64

.

$ gcc -Wall fuseversiontest.c -D_FILE_OFFSET_BITS=64  -lfuse

$ ./a.out
2.9

      

+2


source


In your fuse source code in include / config.h, you have:

/* Define to the version of this package. */
#define PACKAGE_VERSION "2.9.4"

      

In addition, there is a function in lib / helper.c that prints it.



static void helper_version(void)
{
    fprintf(stderr, "FUSE library version: %s\n", PACKAGE_VERSION);
}

      

Edit:

I understand that package version control strings are for internal use only, so you are probably stuck with major and minor numbers exposed by fuse_common.h. You might have to write a function like @Jay suggests.

+2


source







All Articles