u_int32_t lpf_inum;
u_int32_t lpf_dnum;
u_int32_t lpf_ino;
+ u_int32_t root_uid;
+ u_int32_t root_gid;
/* defragmentation parameters */
int defrag_shrink;
free(buf);
return 0;
}
+
+static inline int parse_root_owner(char *ids,
+ u_int32_t *root_uid, u_int32_t *root_gid)
+{
+ char *uid = ids;
+ char *gid = NULL;
+ int i;
+
+ /* uid:gid */
+ for (i = 0; i < strlen(ids) - 1; i++)
+ if (*(ids + i) == ':')
+ gid = ids + i + 1;
+ if (!gid)
+ return -1;
+
+ *root_uid = atoi(uid);
+ *root_gid = atoi(gid);
+ return 0;
+}
+
#endif /*__F2FS_FS_H */
c.trim = 1;
c.kd = -1;
c.fixed_time = -1;
+
+ /* default root owner */
+ c.root_uid = getuid();
+ c.root_gid = getgid();
}
#ifdef HAVE_SETMNTENT
.B \-q
]
[
+.B \-R
+.I root_owner
+]
+[
.B \-s
.I #-of-segments-per-section
]
Quiet mode.
With it, mkfs.f2fs does not show any messages include the basic messages.
.TP
+.BI \-R
+Give root_owner option for initial uid/gid assignment.
+Default is set by getuid()/getgid(), and assigned by "-R $uid:$gid".
+.TP
.BI \-s " #-of-segments-per-section"
Specify the number of segments per section. A section consists of
multiple consecutive segments, and is the unit of garbage collection.
raw_node->i.i_links = cpu_to_le32(3);
else
raw_node->i.i_links = cpu_to_le32(2);
- raw_node->i.i_uid = cpu_to_le32(getuid());
- raw_node->i.i_gid = cpu_to_le32(getgid());
+ raw_node->i.i_uid = cpu_to_le32(c.root_uid);
+ raw_node->i.i_gid = cpu_to_le32(c.root_gid);
blk_size_bytes = 1 << get_sb(log_blocksize);
raw_node->i.i_size = cpu_to_le64(1 * blk_size_bytes); /* dentry */
raw_node->i.i_mode = cpu_to_le16(0x8180);
raw_node->i.i_links = cpu_to_le32(1);
- raw_node->i.i_uid = cpu_to_le32(getuid());
- raw_node->i.i_gid = cpu_to_le32(getgid());
+ raw_node->i.i_uid = cpu_to_le32(c.root_uid);
+ raw_node->i.i_gid = cpu_to_le32(c.root_gid);
raw_node->i.i_size = cpu_to_le64(1024 * 6); /* Hard coded */
raw_node->i.i_blocks = cpu_to_le64(1 + QUOTA_DATA(qtype));
raw_node->i.i_mode = cpu_to_le16(0x41c0); /* 0700 */
raw_node->i.i_links = cpu_to_le32(2);
- raw_node->i.i_uid = cpu_to_le32(getuid());
- raw_node->i.i_gid = cpu_to_le32(getgid());
+ raw_node->i.i_uid = cpu_to_le32(c.root_uid);
+ raw_node->i.i_gid = cpu_to_le32(c.root_gid);
blk_size_bytes = 1 << get_sb(log_blocksize);
raw_node->i.i_size = cpu_to_le64(1 * blk_size_bytes);
MSG(0, " -o overprovision ratio [default:5]\n");
MSG(0, " -O feature1[feature2,feature3,...] e.g. \"encrypt\"\n");
MSG(0, " -q quiet mode\n");
+ MSG(0, " -R root_owner [default: 0:0]\n");
MSG(0, " -s # of segments per section [default:1]\n");
MSG(0, " -S sparse mode\n");
MSG(0, " -t 0: nodiscard, 1: discard [default:1]\n");
static void f2fs_parse_options(int argc, char *argv[])
{
- static const char *option_string = "qa:c:d:e:E:g:il:mo:O:s:S:z:t:fw:V";
+ static const char *option_string = "qa:c:d:e:E:g:il:mo:O:R:s:S:z:t:fw:V";
int32_t option=0;
while ((option = getopt(argc,argv,option_string)) != EOF) {
if (parse_feature(feature_table, optarg))
mkfs_usage();
break;
+ case 'R':
+ if (parse_root_owner(optarg, &c.root_uid, &c.root_gid))
+ mkfs_usage();
+ break;
case 's':
c.segs_per_sec = atoi(optarg);
break;