From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
BAREBOX <barebox@lists.infradead.org>
Subject: Re: [PATCH v2 03/13] fs: implement mknod
Date: Mon, 15 Dec 2025 12:19:39 +0100 [thread overview]
Message-ID: <aeb89a86-309e-415d-8fb9-dc3993f7e7c4@pengutronix.de> (raw)
In-Reply-To: <20251209-devfs-v2-3-62ae16698cff@pengutronix.de>
On 12/9/25 1:51 PM, Sascha Hauer wrote:
> This implements mknod for the barebox VFS. Use the cdevname for
> connecting a device special node with a cdev. In Linux this is done with
> major/minor numbers which shouldn't be necessary for barebox as we do
> not intend to mount filesystems which contain device special nodes, but
> instead create them in ramfs. If a mounted filesystem contains special
> nodes then these won't work with barebox.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
With two minor points below addressed:
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> fs/devfs.c | 13 +++++++++++++
> fs/fs.c | 35 +++++++++++++++++++++++++++++++++++
> include/fcntl.h | 6 ++++++
> include/linux/fs.h | 13 +++++++++++++
> 4 files changed, 67 insertions(+)
>
> diff --git a/fs/devfs.c b/fs/devfs.c
> index 15c7a63d3949a5fa7c5ec15f58bc9f4c53b7852b..be3272be49e66eb843823b3ff664a1565f326790 100644
> --- a/fs/devfs.c
> +++ b/fs/devfs.c
> @@ -103,6 +103,12 @@ static int devfs_open(struct inode *inode, struct file *f)
> struct devfs_inode *node = container_of(inode, struct devfs_inode, inode);
> struct cdev *cdev = node->cdev;
>
> + if (inode->cdevname) {
> + cdev = cdev_by_name(inode->cdevname);
> + if (!cdev)
> + return -ENOENT;
> + }
> +
> f->f_size = cdev->flags & DEVFS_IS_CHARACTER_DEV ?
> FILE_SIZE_STREAM : cdev->size;
> f->private_data = cdev;
> @@ -188,6 +194,13 @@ static const struct file_operations devfs_file_operations = {
> .memmap = devfs_memmap,
> };
>
> +void init_special_inode(struct inode *inode, umode_t mode, const char *cdevname)
> +{
> + inode->i_mode = mode;
> + inode->i_fop = &devfs_file_operations;
> + inode->cdevname = strdup(cdevname);
xstrdup_const? or return an error?
> +}
> +
> static int devfs_lookup_revalidate(struct dentry *dentry, unsigned int flags)
> {
> struct devfs_inode *dinode;
> diff --git a/fs/fs.c b/fs/fs.c
> index d884726187dd526213f8b51a68a2e0db1bb50e58..45bf89653c7c2e4e9546f1d41f79a6389e0b796d 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -826,6 +826,8 @@ static int dentry_delete_subtree(struct super_block *sb, struct dentry *parent)
>
> static void destroy_inode(struct inode *inode)
> {
> + free(inode->cdevname);
free_const?
Cheers,
Ahmad
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2025-12-15 11:20 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-09 12:51 [PATCH v2 00/13] fs: Use device special nodes for devfs Sascha Hauer
2025-12-09 12:51 ` [PATCH v2 01/13] fs: devfs-core: add devfs_create_link_node() Sascha Hauer
2025-12-15 11:14 ` Ahmad Fatoum
2025-12-09 12:51 ` [PATCH v2 02/13] storage-by-alias: drop fake cdev Sascha Hauer
2025-12-15 11:15 ` Ahmad Fatoum
2025-12-09 12:51 ` [PATCH v2 03/13] fs: implement mknod Sascha Hauer
2025-12-15 11:19 ` Ahmad Fatoum [this message]
2025-12-09 12:51 ` [PATCH v2 04/13] commands: add mknod command Sascha Hauer
2025-12-15 11:21 ` Ahmad Fatoum
2025-12-09 12:51 ` [PATCH v2 05/13] fs: ramfs: add device file support Sascha Hauer
2025-12-15 11:22 ` Ahmad Fatoum
2025-12-09 12:51 ` [PATCH v2 06/13] cdev: add cdev_size() helper Sascha Hauer
2025-12-15 11:22 ` Ahmad Fatoum
2025-12-09 12:51 ` [PATCH v2 07/13] fs: fix st_size for device files Sascha Hauer
2025-12-15 11:24 ` Ahmad Fatoum
2025-12-09 12:51 ` [PATCH v2 08/13] fs: retire devfs as filesystem Sascha Hauer
2025-12-15 11:25 ` Ahmad Fatoum
2025-12-09 12:51 ` [PATCH v2 09/13] fs: include cdevname in struct stat Sascha Hauer
2025-12-15 11:25 ` Ahmad Fatoum
2025-12-09 12:51 ` [PATCH v2 10/13] fs: stat_print: get cdevname from stat Sascha Hauer
2025-12-15 11:26 ` Ahmad Fatoum
2025-12-09 12:51 ` [PATCH v2 11/13] common: cdev-alias: rename struct Sascha Hauer
2025-12-15 11:27 ` Ahmad Fatoum
2025-12-09 12:51 ` [PATCH v2 12/13] fs: replace cdev links with aliases Sascha Hauer
2025-12-15 11:31 ` Ahmad Fatoum
2025-12-15 12:17 ` Sascha Hauer
2025-12-09 12:51 ` [PATCH v2 13/13] ls: use ~0 for FILE_SIZE_STREAM Sascha Hauer
2025-12-15 11:32 ` Ahmad Fatoum
2025-12-15 12:16 ` [PATCH v2 00/13] fs: Use device special nodes for devfs 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=aeb89a86-309e-415d-8fb9-dc3993f7e7c4@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/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