From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH 03/10] fs: ramfs: add device file support
Date: Thu, 27 Nov 2025 10:19:25 +0100 [thread overview]
Message-ID: <20251127-devfs-v1-3-4aff12818757@pengutronix.de> (raw)
In-Reply-To: <20251127-devfs-v1-0-4aff12818757@pengutronix.de>
Implement the mknod hook in ramfs for creating device special files.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
fs/ramfs.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/fs/ramfs.c b/fs/ramfs.c
index 1caace0183a58e8a07001eb6ce9df8ea1895ac0b..d86bf6144e8485269c589ba0024377f9852a8eaa 100644
--- a/fs/ramfs.c
+++ b/fs/ramfs.c
@@ -89,6 +89,9 @@ static struct inode *ramfs_get_inode(struct super_block *sb, const struct inode
case S_IFLNK:
inode->i_op = &ramfs_symlink_inode_operations;
break;
+ case S_IFBLK:
+ case S_IFCHR:
+ break;
}
return inode;
@@ -149,6 +152,20 @@ static int ramfs_create(struct inode *dir, struct dentry *dentry, umode_t mode)
return ramfs_mknod(dir, dentry, mode | S_IFREG);
}
+static int __ramfs_mknod(struct inode *dir,struct dentry *dentry, umode_t mode,
+ const char *cdevname)
+{
+ int ret;
+
+ ret = ramfs_mknod(dir, dentry, mode);
+ if (ret)
+ return ret;
+
+ init_special_inode(dentry->d_inode, mode, cdevname);
+
+ return 0;
+}
+
static int ramfs_symlink(struct inode *dir, struct dentry *dentry,
const char *symname)
{
@@ -196,6 +213,7 @@ static const struct inode_operations ramfs_dir_inode_operations =
.unlink = simple_unlink,
.create = ramfs_create,
.tmpfile = ramfs_tmpfile,
+ .mknod = __ramfs_mknod,
};
static struct ramfs_chunk *ramfs_find_chunk(struct ramfs_inode *node,
--
2.47.3
next prev parent reply other threads:[~2025-11-27 9:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-27 9:19 [PATCH 00/10] fs: Use device special nodes for devfs Sascha Hauer
2025-11-27 9:19 ` [PATCH 01/10] fs: implement mknod Sascha Hauer
2025-11-27 9:19 ` [PATCH 02/10] commands: add mknod command Sascha Hauer
2025-11-27 9:19 ` Sascha Hauer [this message]
2025-11-27 9:19 ` [PATCH 04/10] cdev: add cdev_size() helper Sascha Hauer
2025-11-27 9:19 ` [PATCH 05/10] fs: fix st_size for device files Sascha Hauer
2025-11-27 9:19 ` [PATCH 06/10] fs: retire devfs as filesystem Sascha Hauer
2025-11-27 9:19 ` [PATCH 07/10] fs: include cdevname in struct stat Sascha Hauer
2025-11-27 9:19 ` [PATCH 08/10] fs: stat_print: get cdevname from stat Sascha Hauer
2025-11-27 9:19 ` [PATCH 09/10] fs: replace cdev links with aliases Sascha Hauer
2025-11-27 9:19 ` [PATCH 10/10] ls: use ~0 for FILE_SIZE_STREAM Sascha Hauer
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=20251127-devfs-v1-3-4aff12818757@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox