mirror of
https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
synced 2024-11-24 10:33:35 +08:00
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>
This commit is contained in:
parent
a25d231a8a
commit
5113a6e32b
@ -1,3 +1,9 @@
|
||||
2007-05-08 Theodore Tso <tytso@mit.edu>
|
||||
|
||||
* debugfs.c (internal_dump_inode), ls.c (list_dir_proc),
|
||||
lsdel.c (do_lsdel): Use inode_uid() and inode_gid() so
|
||||
that the high bits of the uid/gid are displayed.
|
||||
|
||||
2007-04-19 Theodore Tso <tytso@mit.edu>
|
||||
|
||||
* set_fields.c: Add the i_version field to the set_inode_field
|
||||
|
@ -534,7 +534,7 @@ void internal_dump_inode(FILE *out, const char *prefix,
|
||||
prefix,
|
||||
inode->i_mode & 0777, inode->i_flags, inode->i_generation);
|
||||
fprintf(out, "%sUser: %5d Group: %5d Size: ",
|
||||
prefix, inode->i_uid, inode->i_gid);
|
||||
prefix, inode_uid(*inode), inode_gid(*inode));
|
||||
if (LINUX_S_ISREG(inode->i_mode)) {
|
||||
__u64 i_size = (inode->i_size |
|
||||
((unsigned long long)inode->i_size_high << 32));
|
||||
|
@ -88,7 +88,7 @@ static int list_dir_proc(ext2_ino_t dir EXT2FS_ATTR((unused)),
|
||||
}
|
||||
fprintf(ls->f, "%c%6u%c %6o (%d) %5d %5d ", lbr, ino, rbr,
|
||||
inode.i_mode, dirent->name_len >> 8,
|
||||
inode.i_uid, inode.i_gid);
|
||||
inode_uid(inode), inode_gid(inode));
|
||||
if (LINUX_S_ISDIR(inode.i_mode))
|
||||
fprintf(ls->f, "%5d", inode.i_size);
|
||||
else
|
||||
|
@ -23,7 +23,7 @@
|
||||
struct deleted_info {
|
||||
ext2_ino_t ino;
|
||||
unsigned short mode;
|
||||
unsigned short uid;
|
||||
__u32 uid;
|
||||
__u64 size;
|
||||
time_t dtime;
|
||||
int num_blocks;
|
||||
@ -160,7 +160,7 @@ void do_lsdel(int argc, char **argv)
|
||||
|
||||
delarray[num_delarray].ino = ino;
|
||||
delarray[num_delarray].mode = inode.i_mode;
|
||||
delarray[num_delarray].uid = inode.i_uid;
|
||||
delarray[num_delarray].uid = inode_uid(inode);
|
||||
delarray[num_delarray].size = inode.i_size;
|
||||
if (!LINUX_S_ISDIR(inode.i_mode))
|
||||
delarray[num_delarray].size |=
|
||||
|
@ -1,3 +1,8 @@
|
||||
2007-05-08 Theodore Tso <tytso@mit.edu>
|
||||
|
||||
* message.c (expand_inode_expression): Use inode_uid() and
|
||||
inode_gid() macros when printing the uid/gid.
|
||||
|
||||
2007-04-18 Theodore Tso <tytso@mit.edu>
|
||||
|
||||
* e2fsck.conf.5.in (apply): Fix minor typo.
|
||||
|
@ -304,12 +304,10 @@ static _INLINE_ void expand_inode_expression(char ch,
|
||||
inode->i_dir_acl : 0));
|
||||
break;
|
||||
case 'u':
|
||||
printf("%d", (inode->i_uid |
|
||||
(inode->osd2.linux2.l_i_uid_high << 16)));
|
||||
printf("%d", inode_uid(*inode));
|
||||
break;
|
||||
case 'g':
|
||||
printf("%d", (inode->i_gid |
|
||||
(inode->osd2.linux2.l_i_gid_high << 16)));
|
||||
printf("%d", inode_gid(*inode));
|
||||
break;
|
||||
case 't':
|
||||
if (LINUX_S_ISREG(inode->i_mode))
|
||||
|
@ -1,3 +1,9 @@
|
||||
2007-05-08 Eric Sandeen <sandeen@redhat.com>
|
||||
|
||||
* ext2_fs.h (inode_uid, inode_gid): The inode_uid() and
|
||||
inode_gid() macros will automatically add the high bits
|
||||
when reading uid/gid, on platforms that support it.
|
||||
|
||||
2007-04-19 Theodore Tso <tytso@mit.edu>
|
||||
|
||||
* ext2_fs.h, swapfs.c (ext2fs_swap_inode_full): Rename the
|
||||
|
@ -423,7 +423,8 @@ struct ext2_inode_large {
|
||||
#define i_uid_high osd2.linux2.l_i_uid_high
|
||||
#define i_gid_high osd2.linux2.l_i_gid_high
|
||||
#define i_reserved2 osd2.linux2.l_i_reserved2
|
||||
|
||||
#define inode_uid(inode) ((inode).i_uid | (inode).i_uid_high << 16)
|
||||
#define inode_gid(inode) ((inode).i_gid | (inode).i_gid_high << 16)
|
||||
#else
|
||||
#if defined(__GNU__)
|
||||
|
||||
@ -433,6 +434,8 @@ struct ext2_inode_large {
|
||||
#define i_uid_high osd2.hurd2.h_i_uid_high
|
||||
#define i_gid_high osd2.hurd2.h_i_gid_high
|
||||
#define i_author osd2.hurd2.h_i_author
|
||||
#define inode_uid(inode) ((inode).i_uid | (inode).i_uid_high << 16)
|
||||
#define inode_gid(inode) ((inode).i_gid | (inode).i_gid_high << 16)
|
||||
|
||||
#else
|
||||
#if defined(__masix__)
|
||||
@ -441,6 +444,8 @@ struct ext2_inode_large {
|
||||
#define i_frag osd2.masix2.m_i_frag
|
||||
#define i_fsize osd2.masix2.m_i_fsize
|
||||
#define i_reserved2 osd2.masix2.m_i_reserved2
|
||||
#define inode_uid(inode) ((inode).i_uid)
|
||||
#define inode_gid(inode) ((inode).i_gid)
|
||||
|
||||
#endif /* __masix__ */
|
||||
#endif /* __GNU__ */
|
||||
|
@ -1,3 +1,8 @@
|
||||
2007-05-07 Eric Sandeen <sandeen@redhat.com>
|
||||
|
||||
* mke2fs.c (PRS): Make defaults more sane when /etc/mke2fs.conf
|
||||
doesn't exist.
|
||||
|
||||
2007-04-07 Theodore Tso <tytso@mit.edu>
|
||||
|
||||
* util.c (figure_journal_size): Allow the journal size to be up to
|
||||
|
@ -477,8 +477,9 @@ static void setup_lazy_bg(ext2_filsys fs)
|
||||
|
||||
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 @@ static void create_root_dir(ext2_filsys fs)
|
||||
_("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,
|
||||
|
Loading…
Reference in New Issue
Block a user