Skip to content

Commit d002bed

Browse files
weichao-guoersascape
authored andcommitted
init: fix to set sd device label correctly for FS
The sysfs node of sd blk_device is /sys/fs/f2fs/sd-<num>, we shouldn't skip partition number at this time. Bug: 189257443 Test: access sd-<num> sysfs correctly Signed-off-by: Guo Weichao <guoweichao@oppo.com> Signed-off-by: Huang Jianan <huangjianan@oppo.com> Change-Id: Ibcd7bb265f8fca9cd26f8770403f1bafad433acb
1 parent c430aa9 commit d002bed

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

init/mount_handler.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,18 @@ void SetMountProperty(const MountHandlerEntry& entry, bool add) {
9090
auto mount_prop = entry.mount_point;
9191
if (mount_prop == "/") mount_prop = "/root";
9292
std::replace(mount_prop.begin(), mount_prop.end(), '/', '.');
93-
mount_prop = "dev.mnt.blk" + mount_prop;
93+
auto blk_mount_prop = "dev.mnt.blk" + mount_prop;
94+
auto dev_mount_prop = "dev.mnt.dev" + mount_prop;
9495
// Set property even if its value does not change to trigger 'on property:'
9596
// handling, except for clearing non-existent or already clear property.
9697
// Goal is reduction of empty properties and associated triggers.
97-
if (value.empty() && android::base::GetProperty(mount_prop, "").empty()) return;
98-
android::base::SetProperty(mount_prop, value);
98+
if (value.empty() && android::base::GetProperty(blk_mount_prop, "").empty()) return;
99+
android::base::SetProperty(blk_mount_prop, value);
100+
if (!value.empty()) {
101+
android::base::SetProperty(dev_mount_prop, entry.blk_device.substr(strlen(devblock)));
102+
} else {
103+
android::base::SetProperty(dev_mount_prop, "");
104+
}
99105
}
100106

101107
} // namespace

rootdir/init.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,11 +1024,11 @@ on boot
10241024

10251025
# to access F2FS sysfs on dm-<num> directly
10261026
mkdir /dev/sys/fs/by-name 0755 system system
1027-
symlink /sys/fs/f2fs/${dev.mnt.blk.data} /dev/sys/fs/by-name/userdata
1027+
symlink /sys/fs/f2fs/${dev.mnt.dev.data} /dev/sys/fs/by-name/userdata
10281028

10291029
# to access dm-<num> sysfs
10301030
mkdir /dev/sys/block/by-name 0755 system system
1031-
symlink /sys/devices/virtual/block/${dev.mnt.blk.data} /dev/sys/block/by-name/userdata
1031+
symlink /sys/devices/virtual/block/${dev.mnt.dev.data} /dev/sys/block/by-name/userdata
10321032

10331033
# F2FS tuning. Set cp_interval larger than dirty_expire_centisecs, 30 secs,
10341034
# to avoid power consumption when system becomes mostly idle. Be careful

0 commit comments

Comments
 (0)