Fix mke2fs and debugfs to support large (> 16 bit) uid's and gid's
Mke2fs is supposed to set the uid/gid ownership of the root directory when
a non-rooot user creates the filesystem. This wasn't working correctly
if the uid/gid was > 16 bits. In additional, debugfs wasn't displaying
large uid/gid's correctly. This patch fixes these two programs.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 47748f8..41b09ab 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -477,8 +477,9 @@
static void create_root_dir(ext2_filsys fs)
{
- errcode_t retval;
+ errcode_t retval;
struct ext2_inode inode;
+ __u32 uid, gid;
retval = ext2fs_mkdir(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, 0);
if (retval) {
@@ -492,9 +493,14 @@
_("while reading root inode"));
exit(1);
}
- inode.i_uid = getuid();
- if (inode.i_uid)
- inode.i_gid = getgid();
+ uid = getuid();
+ inode.i_uid = uid;
+ inode.i_uid_high = uid >> 16;
+ if (uid) {
+ gid = getgid();
+ inode.i_gid = gid;
+ inode.i_gid_high = gid >> 16;
+ }
retval = ext2fs_write_new_inode(fs, EXT2_ROOT_INO, &inode);
if (retval) {
com_err("ext2fs_write_inode", retval,