[PATCH] ramfs: skip mknod if inode already exists.

From: Chen Li
Date: Tue Jun 15 2021 - 22:53:33 EST



It's possible we try to mknod a dentry, which have
already bound to an inode, just skip it.

Signed-off-by: Chen Li <chenli@xxxxxxxxxxxxx>
---
fs/ramfs/inode.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index 9ebd17d7befb..6cb1de521142 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -106,6 +106,8 @@ ramfs_mknod(struct user_namespace *mnt_userns, struct inode *dir,
{
struct inode * inode = ramfs_get_inode(dir->i_sb, dir, mode, dev);
int error = -ENOSPC;
+ if (dentry->d_inode)
+ return -EEXIST;

if (inode) {
d_instantiate(dentry, inode);
--
2.32.0