hfs+ journal partition support as read only
authorolivier.hardouin@gmail.com <olivier.hardouin@gmail.com>
Wed, 22 Jun 2016 07:51:18 +0000 (09:51 +0200)
committerJohn Crispin <john@phrozen.org>
Wed, 22 Jun 2016 09:48:11 +0000 (11:48 +0200)
use hfsplus driver to mount hfs+ partition marked as journalled,
read only mounting since partial support from the kernel for write
access (as stated in Documentatiom/filesystems/hfsplus.txt)
add new index 'LASTFS' to be used in case of support for another
driver

Signed-off-by: Olivier Hardouin <olivier.hardouin@gmail.com>
fs.c
include/fs.h
mount.c

diff --git a/fs.c b/fs.c
index fee6608ff364045d55e1375d00ab5cbbae99fda4..ca77a76875cf5b723a1601408c84137c4f8c8b9c 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -153,8 +153,8 @@ static int detect_hfsplus(int fd)
        {
                if(!journal)
                        ret = HFSPLUS;
-       //      else
-       //              ret = HFSPLUSJOURNAL;
+               else
+                       ret = HFSPLUSJOURNAL;
        }
 out:
        free(buffer);
index 1c66db3d750e1b928692a3e739313fe3df21f66a..b86f3831fa699b38b1d19731182e22820e22f6fc 100644 (file)
@@ -1,13 +1,16 @@
-#define NONE           -1
-#define MBR                    2
-#define EXT2           3
-#define EXT3           4
-#define FAT                    5
-#define HFSPLUS                6
-#define EFI                    7
-#define NTFS           8
-#define EXTENDED       9
-#define EXFAT          10
-#define EXT4           11
+#define NONE                   -1
+#define MBR                            2
+#define EXT2                   3
+#define EXT3                   4
+#define FAT                            5
+#define HFSPLUS                        6
+#define EFI                            7
+#define NTFS                   8
+#define EXTENDED               9
+#define EXFAT                  10
+#define EXT4                   11
+#define HFSPLUSJOURNAL 12
+
+#define LASTFS                 HFSPLUSJOURNAL
 
 int detect_fs(char *device);
diff --git a/mount.c b/mount.c
index 219146b33e68f5accebf62f9434928bc72ca992e..0c2862a06f081e1323bff3e18063772526afb1b8 100644 (file)
--- a/mount.c
+++ b/mount.c
@@ -60,7 +60,8 @@ char *fs_names[] = {
        "ntfs",
        "",
        "exfat",
-       "ext4"
+       "ext4",
+       "hfsplusjournal"
 };
 
 #define MAX_MOUNTED            32
@@ -100,7 +101,7 @@ static void mount_dump_uci_state(void)
                ucix_add_option(ctx, mountd, q->serial, "rev", q->rev);
                snprintf(t, 64, "size%d", atoi(&q->dev[3]));
                ucix_add_option(ctx, mountd, q->serial, t, q->size);
-               if(q->fs > MBR && q->fs <= EXT4)
+               if(q->fs > MBR && q->fs <= LASTFS)
                {
                        snprintf(t, 64, "fs%d", atoi(&q->dev[3]));
                        ucix_add_option(ctx, mountd, q->serial, t, fs_names[q->fs]);
@@ -138,7 +139,7 @@ static void mount_add_list(char *name, char *dev, char *serial,
 {
        struct mount *mount;
        char tmp[64], tmp2[64];
-       if(fs <= MBR || fs > EXT4)
+       if(fs <= MBR || fs > LASTFS)
                return;
        mount  = malloc(sizeof(struct mount));
        INIT_LIST_HEAD(&mount->list);
@@ -154,7 +155,7 @@ static void mount_add_list(char *name, char *dev, char *serial,
        mount->mounted = 0;
        mount->fs = fs;
        list_add(&mount->list, &mounts);
-       if((!mount->ignore) && (mount->fs > MBR) && (mount->fs <= EXT4))
+       if((!mount->ignore) && (mount->fs > MBR) && (mount->fs <= LASTFS))
        {
                log_printf("new mount : %s -> %s (%s)\n", name, dev, fs_names[mount->fs]);
                snprintf(tmp, 64, "%s%s", uci_path, name);
@@ -260,12 +261,17 @@ int mount_new(char *path, char *dev)
                        options = "rw,defaults,uid=1000,gid=1000";
                        fstype = "hfsplus";
                }
+               if(mount->fs == HFSPLUSJOURNAL)
+               {
+                       options = "ro,defaults,uid=1000,gid=1000";
+                       fstype = "hfsplus";
+               }
                if(mount->fs == NTFS)
                {
                        options = "force";
                        fstype = "ntfs-3g";
                }
-               if(mount->fs > MBR && mount->fs <= EXT4)
+               if(mount->fs > MBR && mount->fs <= LASTFS)
                {
                        struct uci_context *ctx;
                        char *uci_options, *uci_fstype;