Search code examples
cfuse

Get the 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, multiplied by 10, plus the minor version; both of which are derived from #define values. (e.g., This returns 27 on my platform). What I'm looking for, however, is some char* fuse_version(void) that would return something like 2.7.3.


Solution

  • 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 may just write a small program that does it -- but it seems that only the two first 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 should include fuse/fuse.h and not fuse_common.h; also, you may need to pass -D_FILE_OFFSET_BITS=64 when compiling.

    $ gcc -Wall fuseversiontest.c -D_FILE_OFFSET_BITS=64  -lfuse
    
    $ ./a.out
    2.9