1
0
Fork 0

e2fsprogs: Add option `-0' to set default uid/gid to 0

Signed-off-by: hmz007 <hmz007@gmail.com>
master
hmz007 2 years ago
parent a650dd8ce9
commit 20ae07c6db

@ -42,6 +42,8 @@
/* 64KiB is the minimum blksize to best minimize system call overhead. */
#define COPY_FILE_BUFLEN 65536
int uses_default_owner = 0;
static int ext2_file_type(unsigned int mode)
{
if (LINUX_S_ISREG(mode))
@ -120,8 +122,14 @@ static errcode_t set_inode_extra(ext2_filsys fs, ext2_ino_t ino,
return retval;
}
inode.i_uid = st->st_uid;
inode.i_gid = st->st_gid;
if (uses_default_owner) {
inode.i_uid = 0;
inode.i_gid = 0;
} else {
inode.i_uid = st->st_uid;
inode.i_gid = st->st_gid;
}
inode.i_mode |= st->st_mode;
inode.i_atime = st->st_atime;
inode.i_mtime = st->st_mtime;

@ -91,6 +91,7 @@ static int noaction;
static int num_backups = 2; /* number of backup bg's for sparse_super2 */
static uid_t root_uid;
static gid_t root_gid;
extern int uses_default_owner;
int journal_size;
int journal_flags;
static int lazy_itable_init;
@ -138,7 +139,7 @@ static void usage(void)
"[-r fs-revision] [-E extended-option[,...]]\n"
"\t[-t fs-type] [-T usage-type ] [-U UUID] [-e errors_behavior]"
"[-z undo_file]\n"
"\t[-jnqvDFSV] device [blocks-count]\n"),
"\t[-jnqvDFSV0] device [blocks-count]\n"),
program_name);
exit(1);
}
@ -1631,7 +1632,7 @@ profile_error:
}
while ((c = getopt (argc, argv,
"b:cd:e:g:i:jl:m:no:qr:s:t:vC:DE:FG:I:J:KL:M:N:O:R:ST:U:Vz:")) != EOF) {
"b:cd:e:g:i:jl:m:no:qr:s:t:vC:DE:FG:I:J:KL:M:N:O:R:ST:U:Vz:0")) != EOF) {
switch (c) {
case 'b':
blocksize = parse_num_blocks2(optarg, -1);
@ -1874,6 +1875,10 @@ profile_error:
case 'z':
undo_file = optarg;
break;
case '0':
/* Set default owner/group id to 0 */
uses_default_owner = 1;
break;
default:
usage();
}

Loading…
Cancel
Save