[PATCH 1/2] erofs-utils: don't create hardlinked directories
Gao Xiang
hsiangkao at aol.com
Sat Dec 5 04:20:41 AEDT 2020
From: Gao Xiang <hsiangkao at redhat.com>
From: Gao Xiang <hsiangkao at 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 at 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
More information about the Linux-erofs
mailing list