Description: Required changes to run fuseiso using fuse3
Bug-Debian: https://bugs.debian.org/1084486
Forwarded: not-needed
Author: Sven Geuer <sge@debian.org>
Last-Update: 2024-10-16
--- a/configure.in
+++ b/configure.in
@@ -7,7 +7,7 @@
 AC_PROG_CC
 AM_PROG_LIBTOOL
 
-PKG_CHECK_MODULES([FUSE],[fuse],[],[AC_MSG_ERROR([libfuse is required])])
+PKG_CHECK_MODULES([FUSE],[fuse3 >= 3.14.0],[],[AC_MSG_ERROR([libfuse3 is required])])
 PKG_CHECK_MODULES([GLIB],[glib-2.0],[],[AC_MSG_ERROR([glib-2.0 is required])])
 
 AC_OUTPUT(Makefile src/Makefile zAppRun/Makefile)
--- a/src/fuseiso.c
+++ b/src/fuseiso.c
@@ -38,7 +38,7 @@
 
 #include <linux/iso_fs.h>
 
-#define FUSE_USE_VERSION 22
+#define FUSE_USE_VERSION 314
 #include <fuse.h>
 
 #include <zlib.h>
@@ -214,7 +214,7 @@
     return 0;
 };
 
-static int isofs_getattr(const char *path, struct stat *stbuf)
+static int isofs_getattr(const char *path, struct stat *stbuf, struct fuse_file_info *UNUSED(fi))
 {
     return isofs_real_getattr(path, stbuf);
 }
@@ -238,7 +238,7 @@
     return 0;
 };
 
-static void* isofs_init() {
+static void* isofs_init(struct fuse_conn_info *UNUSED(conn), struct fuse_config *cfg) {
     int rc;
     if(maintain_mtab) {
         rc = add_mtab_record();
@@ -246,6 +246,7 @@
             exit(EXIT_FAILURE);
         };
     };
+    cfg->use_ino = 1;
     return isofs_real_init();
 };
 
@@ -261,11 +262,11 @@
 };
 
 static int isofs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t UNUSED(offset),
-    struct fuse_file_info *UNUSED(fi)) {
+    struct fuse_file_info *UNUSED(fi), enum fuse_readdir_flags UNUSED(flags)) {
     return isofs_real_readdir(path, buf, filler);
 };
 
-static int isofs_statfs(const char *UNUSED(path), struct statfs *stbuf)
+static int isofs_statfs(const char *UNUSED(path), struct statvfs *stbuf)
 {
     return isofs_real_statfs(stbuf);
 }
@@ -340,7 +341,7 @@
         exit(EXIT_FAILURE);
     };
     
-    imagefile = normalize_name(argv[optind]);
+    imagefile = normalize_name(argv[optind++]);
     
     image_fd = open(imagefile, O_RDONLY);
     if(image_fd == -1) {
@@ -349,42 +350,16 @@
         exit(EXIT_FAILURE);
     };
     
-    mount_point = normalize_name(argv[optind + 1]);
+    mount_point = normalize_name(argv[optind]);
     
-    // with space for possible -o use_ino arguments
-    char **nargv = (char **) malloc((argc + 2) * sizeof(char *));
-    int nargc = argc - optind;
+    int nargc = 1 + argc - optind;
+    char **nargv = (char **) malloc((nargc) * sizeof(char *));
     
     nargv[0] = argv[0];
     
     int i;
-    int next_opt = 0;
-    int use_ino_found = 0;
     for(i = 0; i < nargc - 1; ++i) {
-        if(next_opt && !use_ino_found) {
-            if(strstr(argv[i + optind + 1], "use_ino")) { // ok, already there
-                use_ino_found = 1;
-                nargv[i + 1] = argv[i + optind + 1];
-            } else { // add it
-                char* str = (char*) malloc(strlen(argv[i + optind + 1]) + 10);
-                strcpy(str, argv[i + optind + 1]);
-                strcat(str, ",use_ino");
-                nargv[i + 1] = str;
-                use_ino_found = 1;
-            };
-        } else {
-            nargv[i + 1] = argv[i + optind + 1];
-        };
-        // check if this is -o string mean that next argument should be options string
-        if(i > 1 && nargv[i + 1][0] == '-' && nargv[i + 1][1] == 'o') {
-            next_opt = 1;
-        };
-    };
-    if(!use_ino_found) {
-        nargv[nargc] = "-o";
-        nargc++;
-        nargv[nargc] = "use_ino";
-        nargc++;
+        nargv[i + 1] = argv[optind + i];
     };
     
     if(!iocharset) {
@@ -417,5 +392,5 @@
     // will exit in case of failure
     rc = isofs_real_preinit(imagefile, image_fd);
     
-    return fuse_main(nargc, nargv, &isofs_oper);
+    return fuse_main(nargc, nargv, &isofs_oper, NULL);
 };
--- a/src/isofs.h
+++ b/src/isofs.h
@@ -25,8 +25,8 @@
 #include <linux/iso_fs.h>
 #include <linux/rock.h>
 
-typedef int (*isofs_dir_fill_t) (void *buf, const char *name,
-    const struct stat *stat, off_t off);
+#define FUSE_USE_VERSION 314
+#include <fuse.h>
 
 typedef struct _isofs_context {
     char *imagefile;
@@ -154,11 +154,11 @@
 void* isofs_real_init();
 
 int isofs_real_opendir(const char *path);
-int isofs_real_readdir(const char *path, void *filler_buf, isofs_dir_fill_t filler);
+int isofs_real_readdir(const char *path, void *filler_buf, fuse_fill_dir_t filler);
 int isofs_real_getattr(const char *path, struct stat *stbuf);
 int isofs_real_readlink(const char *path, char *target, size_t size);
 int isofs_real_open(const char *path);
 int isofs_real_read(const char *path, char *out_buf, size_t size, off_t offset);
-int isofs_real_statfs(struct statfs *stbuf);
+int isofs_real_statfs(struct statvfs *stbuf);
 
 #endif // _ISOFS_H
--- a/src/isofs.c
+++ b/src/isofs.c
@@ -32,7 +32,7 @@
 #include <zlib.h>
 #include <dirent.h>
 #include <pthread.h>
-#include <sys/statfs.h>
+#include <sys/statvfs.h>
 #include <iconv.h>
 
 #include "isofs.h"
@@ -1346,7 +1346,7 @@
     return 0;
 };
 
-int isofs_real_readdir(const char *path, void *filler_buf, isofs_dir_fill_t filler) {
+int isofs_real_readdir(const char *path, void *filler_buf, fuse_fill_dir_t filler) {
     if(path[0] == '\0') {
         fprintf(stderr, "readdir: attempt to read empty path name\n");
         return -EINVAL;
@@ -1517,7 +1517,7 @@
                 struct stat st;
                 memset(& st, '\0', sizeof(struct stat));
                 isofs_direntry2stat(& st, inode);
-                rc = filler(filler_buf, entry, & st, 0);
+                rc = filler(filler_buf, entry, & st, 0, 0);
                 if(rc) {
                     printf("readdir: filler return with %d, entry %s\n", rc, entry);
                     isofs_free_inode(inode);
@@ -1820,7 +1820,7 @@
     return total_size;
 };
 
-int isofs_real_statfs(struct statfs *stbuf) {
+int isofs_real_statfs(struct statvfs *stbuf) {
     stbuf->f_type = ISOFS_SUPER_MAGIC;
     stbuf->f_bsize = context.data_size; // or PAGE_CACHE_SIZE?
     stbuf->f_blocks = 0; // while it is possible to calculate this, i see no reasons to do so
@@ -1828,6 +1828,7 @@
     stbuf->f_bavail = 0;
     stbuf->f_files = 0;
     stbuf->f_ffree = 0;
-    stbuf->f_namelen = NAME_MAX - 1; // ? not sure..
+    stbuf->f_favail = 0;
+    stbuf->f_namemax = NAME_MAX - 1; // ? not sure..
     return 0;
 };
