Skip to contentSkip to conversation

sload.f2fs: handle root mount point properly when setting file attribute

PATCH In review Daeho Jeong 2 participants 2 messages Aug 17, 2020 – Aug 18, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sload.f2fs: handle root mount point properly when setting file attribute

From: Daeho Jeong <[email protected]>

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.

---
 fsck/sload.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
fsck/sload.c +10 -2
index 59ba4a6..14012fb 100644
@@ -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;
 	}
 
Signature · 8 lines
2.28.0.220.ged08abb693-goog



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Daeho Jeong

From: Daeho Jeong <[email protected]>

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.

Thanks,

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel