diff options
author | Daeho Jeong <daehojeong@google.com> | 2020-08-17 14:01:30 +0900 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2020-08-20 09:08:34 -0700 |
commit | f7029e2cf2723d13d49c0f6b55d239697ca1b59f (patch) | |
tree | 9aca74376e96cda984fbba93ea911ba9b4afd029 | |
parent | f8410857b7a81b1b347253fcca713d8b105e9e7b (diff) | |
download | f2fs-tools-f7029e2cf2723d13d49c0f6b55d239697ca1b59f.tar.gz |
sload.f2fs: handle root mount point properly when setting file attribute
Need to remove "/" of mount point name from the file path name
when mount point is "/". Otherwise, we will transfer file path
name whose first two characters are like "//" to fs_config function.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fsck/sload.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/fsck/sload.c b/fsck/sload.c index 59ba4a6..14012fb 100644 --- a/fsck/sload.c +++ b/fsck/sload.c @@ -104,10 +104,18 @@ static int set_perms_and_caps(struct dentry *de) uint64_t capabilities = 0; unsigned int uid = 0, gid = 0, imode = 0; char *mnt_path = NULL; + char *mount_path = c.mount_point; - if (asprintf(&mnt_path, "%s%s", c.mount_point, de->path) <= 0) { + /* + * de->path already has "/" in the beginning of it. + * Need to remove "/" when c.mount_point is "/", not to add it twice. + */ + if (strlen(c.mount_point) == 1 && c.mount_point[0] == '/') + mount_path = ""; + + if (asprintf(&mnt_path, "%s%s", mount_path, de->path) <= 0) { ERR_MSG("cannot allocate mount path for %s%s\n", - c.mount_point, de->path); + mount_path, de->path); return -ENOMEM; } |