[PATCH] Fix journal detection on HFS+.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The code was unconditionally assumming that the volume had a jounal if the
jounal attribute was set in the volume header. However, the volume also has to
have a non-zero journal info block to actually have a journal.

Signed-off-by: Warren Turkal <wt@xxxxxxxxxxxxxxxx>
---
 fs/hfsplus/Makefile     |    5 +++--
 fs/hfsplus/hfsplus_fs.h |    2 ++
 fs/hfsplus/journal.c    |   14 ++++++++++++++
 fs/hfsplus/super.c      |    4 ++--
 4 files changed, 21 insertions(+), 4 deletions(-)
 create mode 100644 fs/hfsplus/journal.c

diff --git a/fs/hfsplus/Makefile b/fs/hfsplus/Makefile
index 3cc0df7..a90cdcb 100644
--- a/fs/hfsplus/Makefile
+++ b/fs/hfsplus/Makefile
@@ -4,6 +4,7 @@
 
 obj-$(CONFIG_HFSPLUS_FS) += hfsplus.o
 
-hfsplus-objs := super.o options.o inode.o ioctl.o extents.o catalog.o dir.o btree.o \
-		bnode.o brec.o bfind.o tables.o unicode.o wrapper.o bitmap.o part_tbl.o
+hfsplus-objs := super.o options.o inode.o ioctl.o extents.o catalog.o dir.o \
+		btree.o bnode.o brec.o bfind.o tables.o unicode.o wrapper.o \
+		bitmap.o part_tbl.o journal.o
 
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index f027a90..9018d2d 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -421,4 +421,6 @@ static inline struct hfsplus_inode_info *HFSPLUS_I(struct inode *inode)
 
 #define kdev_t_to_nr(x)		(x)
 
+bool hfsp_vol_has_journal(struct hfsplus_vh *vhdr);
+
 #endif
diff --git a/fs/hfsplus/journal.c b/fs/hfsplus/journal.c
new file mode 100644
index 0000000..7a5ef2a
--- /dev/null
+++ b/fs/hfsplus/journal.c
@@ -0,0 +1,14 @@
+/*
+ * linux/fs/hfsplus/journal.c
+ * Copyright (c) 2008 Warren Turkal
+ *
+ * Journal related routines
+ */
+
+#include "hfsplus_fs.h"
+
+bool hfsp_vol_has_journal(struct hfsplus_vh *vhdr)
+{
+	return (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED) &&
+				vhdr->journal_info_block);
+}
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index eb74531..9293c9a 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -260,7 +260,7 @@ static int hfsplus_remount(struct super_block *sb, int *flags, char *data)
 			printk(KERN_WARNING "hfs: filesystem is marked locked, leaving read-only.\n");
 			sb->s_flags |= MS_RDONLY;
 			*flags |= MS_RDONLY;
-		} else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) {
+		} else if (hfsp_vol_has_journal(vhdr)) {
 			printk(KERN_WARNING "hfs: filesystem is marked journaled, leaving read-only.\n");
 			sb->s_flags |= MS_RDONLY;
 			*flags |= MS_RDONLY;
@@ -356,7 +356,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
 	} else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) {
 		printk(KERN_WARNING "hfs: Filesystem is marked locked, mounting read-only.\n");
 		sb->s_flags |= MS_RDONLY;
-	} else if ((vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) && !(sb->s_flags & MS_RDONLY)) {
+	} else if (hfsp_vol_has_journal(vhdr) && !(sb->s_flags & MS_RDONLY)) {
 		printk(KERN_WARNING "hfs: write access to a journaled filesystem is not supported, "
 		       "use the force option at your own risk, mounting read-only.\n");
 		sb->s_flags |= MS_RDONLY;
-- 
1.5.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux