All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gao Xiang via Linux-erofs <linux-erofs@lists.ozlabs.org>
To: linux-erofs@lists.ozlabs.org
Subject: [PATCH 1/2] erofs-utils: don't create hardlinked directories
Date: Sat,  5 Dec 2020 01:20:41 +0800	[thread overview]
Message-ID: <20201204172042.24180-1-hsiangkao@aol.com> (raw)
In-Reply-To: 20201204172042.24180-1-hsiangkao.ref@aol.com

From: Gao Xiang <hsiangkao@redhat.com>

From: Gao Xiang <hsiangkao@aol.com>

Fix an issue which behaves the same as the following
mkisofs BZ due to bindmount:
https://bugzilla.redhat.com/show_bug.cgi?id=1749860

Fixes: a17497f0844a ("erofs-utils: introduce inode operations")
Signed-off-by: Gao Xiang <hsiangkao@aol.com>
---
regression testcases will be uploaded to:
https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git/log/?h=experimental-tests
for now (erofs-utils v1.3 will include testcases then.)

 lib/inode.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib/inode.c b/lib/inode.c
index 388d21db3845..1cf813daa396 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -823,9 +823,16 @@ struct erofs_inode *erofs_iget_from_path(const char *path, bool is_src)
 	if (ret)
 		return ERR_PTR(-errno);
 
-	inode = erofs_iget(st.st_ino);
-	if (inode)
-		return inode;
+	/*
+	 * lookup in hash table first, if it already exists we have a
+	 * hard-link, just return it. Also don't lookup for directories
+	 * since hard-link directory isn't allowed.
+	 */
+	if (!S_ISDIR(st.st_mode)) {
+		inode = erofs_iget(st.st_ino);
+		if (inode)
+			return inode;
+	}
 
 	/* cannot find in the inode cache */
 	inode = erofs_new_inode();
-- 
2.24.0


       reply	other threads:[~2020-12-04 17:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20201204172042.24180-1-hsiangkao.ref@aol.com>
2020-12-04 17:20 ` Gao Xiang via Linux-erofs [this message]
2020-12-04 17:20   ` [PATCH 2/2] erofs-utils: fix cross-device sub-mounts Gao Xiang via Linux-erofs
2020-12-04 17:56     ` [PATCH v2 2/2] erofs-utils: fix cross-device submounts Gao Xiang via Linux-erofs
2020-12-05  7:53       ` Li GuiFu via Linux-erofs
2020-12-05  7:53   ` [PATCH 1/2] erofs-utils: don't create hardlinked directories Li GuiFu via Linux-erofs

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=20201204172042.24180-1-hsiangkao@aol.com \
    --to=linux-erofs@lists.ozlabs.org \
    --cc=hsiangkao@aol.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.