From mboxrd@z Thu Jan 1 00:00:00 1970 From: Warren Turkal Subject: [PATCH 2/2] Fix journal detection on HFS+. Date: Wed, 19 Nov 2008 18:26:00 -0800 Message-ID: <1227147960-32355-3-git-send-email-wt@penguintechs.org> References: <1227147960-32355-1-git-send-email-wt@penguintechs.org> <1227147960-32355-2-git-send-email-wt@penguintechs.org> Cc: linux-fsdevel@vger.kernel.org, Warren Turkal To: Andrew Morton Return-path: Received: from rv-out-0506.google.com ([209.85.198.234]:60977 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751687AbYKTC0H (ORCPT ); Wed, 19 Nov 2008 21:26:07 -0500 Received: by rv-out-0506.google.com with SMTP id k40so234677rvb.1 for ; Wed, 19 Nov 2008 18:26:06 -0800 (PST) In-Reply-To: <1227147960-32355-2-git-send-email-wt@penguintechs.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: The code currently mounts an HFS+ volume read-only (unless given the "force" mount option) if it detects that the HFS+ volume has a journal. The code was unconditionally assuming that the volume had a jounal if the journal 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. In this patch, I refactored the journal detection into a function since the logic is used twice. The journal detection also uses the better logic to determine if there is a journal. Signed-off-by: Warren Turkal --- fs/hfsplus/super.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c index eb74531..4f00a84 100644 --- a/fs/hfsplus/super.c +++ b/fs/hfsplus/super.c @@ -15,10 +15,17 @@ #include #include +#include "hfsplus_fs.h" + static struct inode *hfsplus_alloc_inode(struct super_block *sb); static void hfsplus_destroy_inode(struct inode *inode); +static bool hfsplus_vol_has_journal(struct hfsplus_vh *vhdr); -#include "hfsplus_fs.h" +static bool hfsplus_vol_has_journal(struct hfsplus_vh *vhdr) +{ + return (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED) && + vhdr->journal_info_block); +} struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino) { @@ -260,7 +267,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 (hfsplus_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 +363,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 (hfsplus_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