[PATCH] mkreiserfs: set the owner of the root directory to the calling user

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

 



Hi,

Following patch sets the owner of the root directory to the calling
user.

This is also how mke2fs behaves. It enables users to e.g. create a
file system on removeable storage devices and then be able to
actually use them.

Signed-off-by: Ludwig Nussel <ludwig.nussel@xxxxxxx>
Acked-by: Jeff Mahoney <jeffm@xxxxxxxx>

Index: reiserfsprogs-3.6.19/reiserfscore/reiserfslib.c
===================================================================
--- reiserfsprogs-3.6.19.orig/reiserfscore/reiserfslib.c
+++ reiserfsprogs-3.6.19/reiserfscore/reiserfslib.c
@@ -1142,6 +1142,19 @@ int create_dir_sd (reiserfs_filsys_t * f
     memset(&sd, 0, sizeof(sd));
     make_dir_stat_data (fs->fs_blocksize, key_format, get_key_dirid (key),
 			get_key_objectid (key), &ih, &sd);
+    
+    /* if calling user is not root set the owner of the root entry
+     * to the calling user */
+    if(getuid()) {
+	if (key_format == KEY_FORMAT_1) {
+	    struct stat_data_v1 *sd_v1 = (struct stat_data_v1 *)&sd;
+	    set_sd_v1_uid (sd_v1, getuid());
+	    set_sd_v1_gid (sd_v1, getgid());
+	} else {
+	    set_sd_v2_uid (&sd, getuid());
+	    set_sd_v2_gid (&sd, getgid());
+	}
+    }
 
     if (modify_item)
 	modify_item (&ih, &sd);

-- 
 (o_   Ludwig Nussel
 //\   
 V_/_  http://www.suse.de/
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg)
--
To unsubscribe from this list: send the line "unsubscribe reiserfs-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux File System Development]     [Linux BTRFS]     [Linux NFS]     [Linux Filesystems]     [Ext4 Filesystem]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Resources]

  Powered by Linux