YASUOKA Masahiko <[email protected]> wrotes:
>I'd like to add 'exfat-fuse'.
>
>It is an exFAT file system implementation working on FUSE.  It's
>useful to mount a SDCARD which is used by Android, for example.
>
>ok?

I usually using exfat (older version with my own patches) with
disklabel UID in fstab.

Is it good to replace all open(2) calls with opendev(3)?

--- libexfat/io.c.orig  Fri Jun  3 10:00:35 2016
+++ libexfat/io.c       Sun Jul 10 01:02:19 2016
@@ -36,6 +36,7 @@
 #include <sys/dkio.h>
 #include <sys/ioctl.h>
 #endif
+#include <util.h>
 #include <sys/mount.h>
 
 struct exfat_dev
@@ -45,14 +46,14 @@
        off_t size; /* in bytes */
 };
 
-static int open_ro(const char* spec)
+static int open_ro(const char* spec, char **realpath)
 {
-       return open(spec, O_RDONLY);
+       return opendev(spec, O_RDONLY, OPENDEV_PART, realpath);
 }
 
-static int open_rw(const char* spec)
+static int open_rw(const char* spec, char **realpath)
 {
-       int fd = open(spec, O_RDWR);
+       int fd = opendev(spec, O_RDWR, OPENDEV_PART, realpath);
 #ifdef __linux__
        int ro = 0;
 
@@ -74,6 +75,7 @@
 {
        struct exfat_dev* dev;
        struct stat stbuf;
+       char *realpath;
 
        dev = malloc(sizeof(struct exfat_dev));
        if (dev == NULL)
@@ -85,7 +87,7 @@
        switch (mode)
        {
        case EXFAT_MODE_RO:
-               dev->fd = open_ro(spec);
+               dev->fd = open_ro(spec, &realpath);
                if (dev->fd == -1)
                {
                        free(dev);
@@ -96,7 +98,7 @@
                dev->mode = EXFAT_MODE_RO;
                break;
        case EXFAT_MODE_RW:
-               dev->fd = open_rw(spec);
+               dev->fd = open_rw(spec, &realpath);
                if (dev->fd == -1)
                {
                        free(dev);
@@ -107,13 +109,13 @@
                dev->mode = EXFAT_MODE_RW;
                break;
        case EXFAT_MODE_ANY:
-               dev->fd = open_rw(spec);
+               dev->fd = open_rw(spec, &realpath);
                if (dev->fd != -1)
                {
                        dev->mode = EXFAT_MODE_RW;
                        break;
                }
-               dev->fd = open_ro(spec);
+               dev->fd = open_ro(spec, &realpath);
                if (dev->fd != -1)
                {
                        dev->mode = EXFAT_MODE_RO;
@@ -182,7 +184,7 @@
 
                /* Don't need to check that partition letter is valid as we 
won't get
                   this far otherwise. */
-               partition = strchr(spec, '\0') - 1;
+               partition = strchr(realpath, '\0') - 1;
                pp = &(lab.d_partitions[*partition - 'a']);
                dev->size = DL_GETPSIZE(pp) * lab.d_secsize;
 

I also use mount_exfat-fuse instead of mount.exfat-fuse because of
fstab format.

Reply via email to