linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Daeho Jeong <daeho43@gmail.com>
To: linux-f2fs-devel@lists.sourceforge.net
Cc: Daeho Jeong <daehojeong@google.com>
Subject: [f2fs-dev] [PATCH] sload.f2fs: handle root mount point properly when setting file attribute
Date: Mon, 17 Aug 2020 14:01:30 +0900	[thread overview]
Message-ID: <20200817050130.3504967-1-daeho43@gmail.com> (raw)

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

             reply	other threads:[~2020-08-17  5:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-17  5:01 Daeho Jeong [this message]
2020-08-18  9:01 ` [f2fs-dev] [PATCH] sload.f2fs: handle root mount point properly when setting file attribute Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200817050130.3504967-1-daeho43@gmail.com \
    --to=daeho43@gmail.com \
    --cc=daehojeong@google.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).