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. */ /* 64KiB is the minimum blksize to best minimize system call overhead. */
#define COPY_FILE_BUFLEN 65536 #define COPY_FILE_BUFLEN 65536
int uses_default_owner = 0;
static int ext2_file_type(unsigned int mode) static int ext2_file_type(unsigned int mode)
{ {
if (LINUX_S_ISREG(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; return retval;
} }
inode.i_uid = st->st_uid; if (uses_default_owner) {
inode.i_gid = st->st_gid; 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_mode |= st->st_mode;
inode.i_atime = st->st_atime; inode.i_atime = st->st_atime;
inode.i_mtime = st->st_mtime; 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 int num_backups = 2; /* number of backup bg's for sparse_super2 */
static uid_t root_uid; static uid_t root_uid;
static gid_t root_gid; static gid_t root_gid;
extern int uses_default_owner;
int journal_size; int journal_size;
int journal_flags; int journal_flags;
static int lazy_itable_init; static int lazy_itable_init;
@ -138,7 +139,7 @@ static void usage(void)
"[-r fs-revision] [-E extended-option[,...]]\n" "[-r fs-revision] [-E extended-option[,...]]\n"
"\t[-t fs-type] [-T usage-type ] [-U UUID] [-e errors_behavior]" "\t[-t fs-type] [-T usage-type ] [-U UUID] [-e errors_behavior]"
"[-z undo_file]\n" "[-z undo_file]\n"
"\t[-jnqvDFSV] device [blocks-count]\n"), "\t[-jnqvDFSV0] device [blocks-count]\n"),
program_name); program_name);
exit(1); exit(1);
} }
@ -1631,7 +1632,7 @@ profile_error:
} }
while ((c = getopt (argc, argv, 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) { switch (c) {
case 'b': case 'b':
blocksize = parse_num_blocks2(optarg, -1); blocksize = parse_num_blocks2(optarg, -1);
@ -1874,6 +1875,10 @@ profile_error:
case 'z': case 'z':
undo_file = optarg; undo_file = optarg;
break; break;
case '0':
/* Set default owner/group id to 0 */
uses_default_owner = 1;
break;
default: default:
usage(); usage();
} }

Loading…
Cancel
Save