[PATCH 2/2] fs: devfs: fix r/w permissions

Sascha Hauer s.hauer at pengutronix.de
Wed Sep 12 00:09:08 PDT 2018


The real r/w flags were lost in the switch to dentry cache
implementation. Restore them.

Fixes: 9137c41915 ("fs: devfs: Switch to dentry cache implementation")

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 fs/devfs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/devfs.c b/fs/devfs.c
index 84c619f1ed..d2b801036e 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -251,10 +251,15 @@ static struct dentry *devfs_lookup(struct inode *dir, struct dentry *dentry,
 	if (!cdev)
 		return ERR_PTR(-ENOENT);
 
-	inode = devfs_get_inode(dir->i_sb, dir, S_IFCHR | S_IRWXUGO);
+	inode = devfs_get_inode(dir->i_sb, dir, S_IFCHR);
 	if (!inode)
 		return ERR_PTR(-ENOMEM);
 
+	if (cdev->ops->write)
+		inode->i_mode |= S_IWUSR;
+	if (cdev->ops->read)
+		inode->i_mode |= S_IRUSR;
+
 	dinode = container_of(inode, struct devfs_inode, inode);
 
 	inode->i_size = cdev->size;
-- 
2.18.0




More information about the barebox mailing list