* [PATCH 1/2] fs: devfs: Create device files as character devices
@ 2018-09-12 7:09 Sascha Hauer
2018-09-12 7:09 ` [PATCH 2/2] fs: devfs: fix r/w permissions Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2018-09-12 7:09 UTC (permalink / raw)
To: Barebox List
Without this files in /dev/ appear as regular files. copy_file()
stumbles upon this as it tries a truncate() on that files which
then fails. Create the files as character devices so that copy_file()
works as expected.
Fixes: 9137c41915 ("fs: devfs: Switch to dentry cache implementation")
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
fs/devfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/devfs.c b/fs/devfs.c
index 5d0bb2c674..84c619f1ed 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -226,7 +226,7 @@ static struct inode *devfs_get_inode(struct super_block *sb, const struct inode
switch (mode & S_IFMT) {
default:
return NULL;
- case S_IFREG:
+ case S_IFCHR:
inode->i_op = &devfs_file_inode_operations;
inode->i_fop = &devfs_file_operations;
break;
@@ -251,7 +251,7 @@ 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_IFREG | S_IRWXUGO);
+ inode = devfs_get_inode(dir->i_sb, dir, S_IFCHR | S_IRWXUGO);
if (!inode)
return ERR_PTR(-ENOMEM);
--
2.18.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/2] fs: devfs: fix r/w permissions
2018-09-12 7:09 [PATCH 1/2] fs: devfs: Create device files as character devices Sascha Hauer
@ 2018-09-12 7:09 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2018-09-12 7:09 UTC (permalink / raw)
To: Barebox List
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@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
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-09-12 7:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-12 7:09 [PATCH 1/2] fs: devfs: Create device files as character devices Sascha Hauer
2018-09-12 7:09 ` [PATCH 2/2] fs: devfs: fix r/w permissions Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox