linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] sload.f2fs: handle root mount point properly when setting file attribute
@ 2020-08-17  5:01 Daeho Jeong
  2020-08-18  9:01 ` Chao Yu
  0 siblings, 1 reply; 2+ messages in thread
From: Daeho Jeong @ 2020-08-17  5:01 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Daeho Jeong

From: Daeho Jeong <daehojeong@google.com>

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>
---
 fsck/sload.c | 12 ++++++++++--
 1 file 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;
 	}
 
-- 
2.28.0.220.ged08abb693-goog



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [f2fs-dev] [PATCH] sload.f2fs: handle root mount point properly when setting file attribute
  2020-08-17  5:01 [f2fs-dev] [PATCH] sload.f2fs: handle root mount point properly when setting file attribute Daeho Jeong
@ 2020-08-18  9:01 ` Chao Yu
  0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2020-08-18  9:01 UTC (permalink / raw)
  To: Daeho Jeong, linux-f2fs-devel; +Cc: Daeho Jeong

On 2020/8/17 13:01, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.com>
> 
> 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>

Thanks,


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-18  9:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-17  5:01 [f2fs-dev] [PATCH] sload.f2fs: handle root mount point properly when setting file attribute Daeho Jeong
2020-08-18  9:01 ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).