All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wyatt Banks <wyatt@banksresearch.com>
To: linux-kernel@vger.kernel.org
Cc: zippel@linux-m68k.org
Subject: [PATCH] HFSPlus: simplify inode mode settting logic
Date: Sat, 23 Jun 2007 19:29:14 -0400	[thread overview]
Message-ID: <467DACCA.7070002@banksresearch.com> (raw)

From:	Wyatt Banks <wyatt@banksresearch.com>

HFSPlus: Fix broken inode mode setting logic.  Fix broken umask mount option.

Signed-off-by:	Wyatt Banks <wyatt@banksresearch.com>
---
Patched against 2.6.21.5

hfsplus_cat_read_inode() decides if the selected inode is a directory or not.
It then sets the 3rd parameter of hfsplus_get_perms() accordingly.  Inside
hfsplus_get_perms() it again decides based on its 3rd parameter if the inode
is a directory or not.  Besides this redundancy, mode is the BSD file type and mode
bits (see Apple TechNote 1150 for details) and is never 0.  This makes a large
portion of the branching logic unused.  What actually does happen in the branching
is that the UGO mode bits are combined with the directory or regular file bit after
the 2nd decision and this resultant mode is assigned to the inode.  This also loses
suid, sgid, sticky, pipe, fifo, etc.

This patch also fixes the umask mount option as a result.  I figured instead of
filing a bug report, I'd just go ahead and fix it. :-)

diff -uprN -X linux-2.6.21.5/Documentation/dontdiff linux-2.6.21.5/fs/hfsplus/inode.c linux-2.6.21.5-devel/fs/hfsplus/inode.c
--- linux-2.6.21.5/fs/hfsplus/inode.c	2007-06-11 14:37:06.000000000 -0400
+++ linux-2.6.21.5-devel/fs/hfsplus/inode.c	2007-06-23 18:23:57.000000000 -0400
@@ -173,7 +173,7 @@ out:
	return NULL;
 }

-static void hfsplus_get_perms(struct inode *inode, struct hfsplus_perm *perms, int dir)
+static void hfsplus_get_perms(struct inode *inode, struct hfsplus_perm *perms)
 {
	struct super_block *sb = inode->i_sb;
	u16 mode;
@@ -188,14 +188,7 @@ static void hfsplus_get_perms(struct ino
	if (!inode->i_gid && !mode)
		inode->i_gid = HFSPLUS_SB(sb).gid;

-	if (dir) {
-		mode = mode ? (mode & S_IALLUGO) :
-			(S_IRWXUGO & ~(HFSPLUS_SB(sb).umask));
-		mode |= S_IFDIR;
-	} else if (!mode)
-		mode = S_IFREG | ((S_IRUGO|S_IWUGO) &
-			~(HFSPLUS_SB(sb).umask));
-	inode->i_mode = mode;
+	inode->i_mode = mode & ~(HFSPLUS_SB(sb).umask);

	HFSPLUS_I(inode).rootflags = perms->rootflags;
	HFSPLUS_I(inode).userflags = perms->userflags;
@@ -415,7 +408,7 @@ int hfsplus_cat_read_inode(struct inode
			/* panic? */;
		hfs_bnode_read(fd->bnode, &entry, fd->entryoffset,
					sizeof(struct hfsplus_cat_folder));
-		hfsplus_get_perms(inode, &folder->permissions, 1);
+		hfsplus_get_perms(inode, &folder->permissions);
		inode->i_nlink = 1;
		inode->i_size = 2 + be32_to_cpu(folder->valence);
		inode->i_atime = hfsp_mt2ut(folder->access_date);
@@ -435,7 +428,7 @@ int hfsplus_cat_read_inode(struct inode

		hfsplus_inode_read_fork(inode, HFSPLUS_IS_DATA(inode) ?
					&file->data_fork : &file->rsrc_fork);
-		hfsplus_get_perms(inode, &file->permissions, 0);
+		hfsplus_get_perms(inode, &file->permissions);
		inode->i_nlink = 1;
		if (S_ISREG(inode->i_mode)) {
			if (file->permissions.dev)

             reply	other threads:[~2007-06-23 23:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-23 23:29 Wyatt Banks [this message]
2007-06-24 16:27 ` [PATCH] HFSPlus: simplify inode mode settting logic Roman Zippel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=467DACCA.7070002@banksresearch.com \
    --to=wyatt@banksresearch.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zippel@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.