add exfat support
authorJohn Crispin <blogic@openwrt.org>
Thu, 10 Sep 2015 15:22:34 +0000 (17:22 +0200)
committerJohn Crispin <blogic@openwrt.org>
Thu, 10 Sep 2015 16:04:53 +0000 (18:04 +0200)
Signed-off-by: John Crispin <blogic@openwrt.org>
fs.c
include/fs.h
mount.c

diff --git a/fs.c b/fs.c
index 49ad1d542d3cd8e966934f30a35935f4f146b323..fee6608ff364045d55e1375d00ab5cbbae99fda4 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -123,6 +123,20 @@ out:
        return ret;
 }
 
+static int detect_exfat(int fd)
+{
+       int ret = NONE;
+       unsigned char *buffer = (unsigned char*)malloc(FAT_BUF_SIZE);
+       if(get_buffer(fd, buffer, 0, FAT_BUF_SIZE) != 0)
+               goto out;
+
+       if (!memcmp(buffer + 3, "EXFAT  ", 7))
+               ret = EXFAT;
+out:
+       free(buffer);
+       return ret;
+}
+
 #define HFSPLUS_VOL_JOURNALED  (1 << 13)
 #define HFSPLUS_BUF_SIZE                       512
 static int detect_hfsplus(int fd)
@@ -179,6 +193,7 @@ out:
 
 dfunc funcs[] = {
        detect_ext23,
+       detect_exfat,
        detect_fat,
        detect_ntfs,
        detect_hfsplus,
index be60f2e59a48d0a80661cd361bf62df38789e6fc..1c66db3d750e1b928692a3e739313fe3df21f66a 100644 (file)
@@ -7,6 +7,7 @@
 #define EFI                    7
 #define NTFS           8
 #define EXTENDED       9
-#define EXT4           10
+#define EXFAT          10
+#define EXT4           11
 
 int detect_fs(char *device);
diff --git a/mount.c b/mount.c
index 0370eb992ee038546445fdceb2c2642d28666381..88920407490a97f71f668e320c918090e936cd87 100644 (file)
--- a/mount.c
+++ b/mount.c
@@ -227,6 +227,11 @@ int mount_new(char *path, char *dev)
        pid = autofs_safe_fork();
        if(!pid)
        {
+               if(mount->fs == EXFAT)
+               {
+                       log_printf("mount -t exfat -o rw,uid=1000,gid=1000 /dev/%s %s", mount->dev, tmp);
+                       ret = system_printf("mount -t exfat -o rw,uid=1000,gid=1000 /dev/%s %s", mount->dev, tmp);
+               }
                if(mount->fs == FAT)
                {
                        log_printf("mount -t vfat -o rw,uid=1000,gid=1000 /dev/%s %s", mount->dev, tmp);