This change ensures that the root inode has the correct uid/gid by
calling androidify_inode() on it. It also sets android_configure = 1
when the u/gid mapping is provided.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Google-Bug-Id:
78561186
Google-Bug-Id:
110415537
Test: $ m # With BOARD_SYSTEMIMAGE_UID_MAP=655360 0 5000
$ simg2img ${OUT}/{system.img,system.raw.img}
$ mkdir tmp
$ sudo mount -o loop ${OUT}/system.raw.img tmp
$ stat --format="%u %g" tmp
655360 655360
Change-Id: I842a32b6d64439f9f16b9c6b66de20d4e4418aa8
From AOSP commit:
ee3f0f37c34d68aa7a96a36dea369acae312772c
case 'u':
if (!parse_ugid_map(optarg, &uid_map))
exit(EXIT_FAILURE);
case 'u':
if (!parse_ugid_map(optarg, &uid_map))
exit(EXIT_FAILURE);
break;
case 'g':
if (!parse_ugid_map(optarg, &gid_map))
exit(EXIT_FAILURE);
break;
case 'g':
if (!parse_ugid_map(optarg, &gid_map))
exit(EXIT_FAILURE);
break;
default:
usage(EXIT_FAILURE);
break;
default:
usage(EXIT_FAILURE);
/* Permissions */
if (params->fs_config_func != NULL) {
/* Permissions */
if (params->fs_config_func != NULL) {
- params->fs_config_func(params->filename, S_ISDIR(inode.i_mode),
+ const char *filename = params->filename;
+ if (strcmp(filename, params->mountpoint) == 0) {
+ /* The root of the filesystem needs to be an empty string. */
+ filename = "";
+ }
+ params->fs_config_func(filename, S_ISDIR(inode.i_mode),
params->target_out, &uid, &gid, &imode,
&capabilities);
uid = resolve_ugid(params->uid_map, uid);
params->target_out, &uid, &gid, &imode,
&capabilities);
uid = resolve_ugid(params->uid_map, uid);
if (strlen(mountpoint) == 1 && mountpoint[0] == '/')
params.path = "";
if (strlen(mountpoint) == 1 && mountpoint[0] == '/')
params.path = "";
- retval = set_selinux_xattr(fs, EXT2_ROOT_INO, ¶ms);
- if (retval)
- return retval;
- retval = set_timestamp(fs, EXT2_ROOT_INO, ¶ms);
+ retval = androidify_inode(fs, EXT2_ROOT_INO, ¶ms);
if (retval)
return retval;
if (retval)
return retval;