From 90703b86d9d787ba69d67566cb75d8378b56171d Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Fri, 17 Nov 2023 09:04:26 -0800 Subject: [PATCH] Use the dm target for userdata Framework or applications can try to find userdata dm target from "/proc/mounts" which gives "/dev/block/mapper/userdata". That causes breaking the assumption in all the places. Bug: 311165039 Change-Id: I9ea1b4589cdd52021d9807f7240c2e4b6d6d05ef Signed-off-by: Jaegeuk Kim --- fs_mgr/fs_mgr.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp index d55f8d3bf..faea5eb7a 100644 --- a/fs_mgr/fs_mgr.cpp +++ b/fs_mgr/fs_mgr.cpp @@ -828,7 +828,14 @@ static int __mount(const std::string& source, const std::string& target, const F << ",type=" << entry.fs_type << ", gc_allowance=" << gc_allowance << "%)=" << ret << "(" << save_errno << ")"; } - ret = mount(source.c_str(), target.c_str(), entry.fs_type.c_str(), mountflags, + + // Let's get the raw dm target, if it's a symlink, since some existing applications + // rely on /proc/mounts to find the userdata's dm target path. Don't break that assumption. + std::string real_source; + if (!android::base::Realpath(source, &real_source)) { + real_source = source; + } + ret = mount(real_source.c_str(), target.c_str(), entry.fs_type.c_str(), mountflags, opts.c_str()); save_errno = errno; if (try_f2fs_gc_allowance) gc_allowance += 10;