linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ludwig Nussel <ludwig.nussel@suse.de>
To: linux-fsdevel@vger.kernel.org
Cc: Ludwig Nussel <ludwig.nussel@suse.de>
Subject: [PATCH 2/2] implement uid mount option for ext3
Date: Wed,  8 Apr 2009 15:21:17 +0200	[thread overview]
Message-ID: <1239196877-7290-3-git-send-email-ludwig.nussel@suse.de> (raw)
In-Reply-To: <1239196877-7290-1-git-send-email-ludwig.nussel@suse.de>

Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
---
 fs/ext3/inode.c            |   11 ++++++++++-
 fs/ext3/super.c            |    8 +++++++-
 include/linux/ext3_fs_sb.h |    1 +
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 5fa453b..d4c8525 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -2729,6 +2729,9 @@ struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
 		inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
 		inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
 	}
+	if (EXT3_SB(sb)->s_uid && inode->i_uid == 0) {
+		inode->i_uid = EXT3_SB(sb)->s_uid;
+	}
 	inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
 	inode->i_size = le32_to_cpu(raw_inode->i_size);
 	inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
@@ -2868,7 +2871,13 @@ static int ext3_do_update_inode(handle_t *handle,
 
 	ext3_get_inode_flags(ei);
 	raw_inode->i_mode = cpu_to_le16(inode->i_mode);
-	if(!(test_opt(inode->i_sb, NO_UID32))) {
+	if (EXT3_SB(inode->i_sb)->s_uid &&
+	    inode->i_uid == EXT3_SB(inode->i_sb)->s_uid) {
+		raw_inode->i_uid_high = 0;
+		raw_inode->i_uid_low  = 0;
+		raw_inode->i_gid_high = 0;
+		raw_inode->i_gid_low  = 0;
+	} else if(!(test_opt(inode->i_sb, NO_UID32))) {
 		raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
 		raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
 /*
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 4a97041..5122213 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -790,7 +790,7 @@ enum {
 	Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
 	Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
 	Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
-	Opt_grpquota
+	Opt_grpquota, Opt_uid
 };
 
 static const match_table_t tokens = {
@@ -843,6 +843,7 @@ static const match_table_t tokens = {
 	{Opt_usrquota, "usrquota"},
 	{Opt_barrier, "barrier=%u"},
 	{Opt_resize, "resize"},
+	{Opt_uid, "uid=%u"},
 	{Opt_err, NULL},
 };
 
@@ -1194,6 +1195,11 @@ set_qf_format:
 		case Opt_bh:
 			clear_opt(sbi->s_mount_opt, NOBH);
 			break;
+		case Opt_uid:
+			if (match_int(&args[0], &option))
+				return 0;
+			sbi->s_uid = option;
+			break;
 		default:
 			printk (KERN_ERR
 				"EXT3-fs: Unrecognized mount option \"%s\" "
diff --git a/include/linux/ext3_fs_sb.h b/include/linux/ext3_fs_sb.h
index f07f34d..751058a 100644
--- a/include/linux/ext3_fs_sb.h
+++ b/include/linux/ext3_fs_sb.h
@@ -47,6 +47,7 @@ struct ext3_sb_info {
 	ext3_fsblk_t s_sb_block;
 	uid_t s_resuid;
 	gid_t s_resgid;
+	uid_t s_uid;                    /* map root owned files to this uid */
 	unsigned short s_mount_state;
 	unsigned short s_pad;
 	int s_addr_per_block_bits;
-- 
1.6.0.2


  parent reply	other threads:[~2009-04-08 13:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-08 13:21 [RFC] [PATCH 0/2] implement uid mount option for ext2 and ext3 Ludwig Nussel
2009-04-08 13:21 ` [PATCH 1/2] implement uid mount option for ext2 Ludwig Nussel
2009-04-08 13:21 ` Ludwig Nussel [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-07-23 11:36 [PATCH 0/2] implement uid mount option for ext2 and ext3 Ludwig Nussel
2009-07-23 11:36 ` [PATCH 1/2] implement uid mount option for ext2 Ludwig Nussel
2009-07-23 11:36   ` [PATCH 2/2] implement uid mount option for ext3 Ludwig Nussel
2009-07-24 10:30 ` [PATCH 0/2] implement uid mount option for ext2 and ext3, try 2 Ludwig Nussel
2009-07-24 10:30   ` [PATCH 1/2] implement uid mount option for ext2 Ludwig Nussel
2009-07-24 10:30     ` [PATCH 2/2] implement uid mount option for ext3 Ludwig Nussel

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=1239196877-7290-3-git-send-email-ludwig.nussel@suse.de \
    --to=ludwig.nussel@suse.de \
    --cc=linux-fsdevel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).