mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andries.Brouwer@cwi.nl
To: dwmw2@infradead.org
Cc: linux-kernel@vger.kernel.org
Subject: jffs mknod
Date: Mon, 18 Nov 2002 04:32:07 +0100 (MET)	[thread overview]
Message-ID: <UTC200211180332.gAI3W7l02598.aeb@smtp.cwi.nl> (raw)

A moment ago I moved my old mknod patch to 2.5.recent.
Current source has some strange casting back and forth
between dev_t and int, so having it dev_t everywhere
is certainly an improvement.

While doing so I encountered jffs/inode-v23.c:jffs_mknod().
It does

jffs_mknod(struct inode *dir, struct dentry *dentry, int mode, int rdev) {
	kdev_t dev = to_kdev_t(rdev);
	raw_inode.dsize = sizeof(kdev_t);
	jffs_write_node(c, node, &raw_inode, dentry->d_name.name,
		(unsigned char *)&dev, 0, NULL);
}

a rather strange thing to do. A kdev_t is a kernel-internal thing.
For me it is a pointer, others perhaps think of it as an integer,
but its size and format depend on the kernel version.
Moreover, the result of this will depend on the machine's endianness.
Normally, a filesystem should define its own data format.

What format should be written?

Andries

--- /linux/2.5/linux-2.5.47/linux/fs/jffs/inode-v23.c	Sat Oct 12 19:28:48 2002
+++ /linux/2.5/linux-2.5.47d/linux/fs/jffs/inode-v23.c	Mon Nov 18 04:33:11 2002
@@ -1069,7 +1069,7 @@
 
 
 static int
-jffs_mknod(struct inode *dir, struct dentry *dentry, int mode, int rdev)
+jffs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
 {
 	struct jffs_raw_inode raw_inode;
 	struct jffs_file *dir_f;
@@ -1077,7 +1077,6 @@
 	struct jffs_control *c;
 	struct inode *inode;
 	int result = 0;
-	kdev_t dev = to_kdev_t(rdev);
 	int err;
 
 	D1(printk("***jffs_mknod()\n"));
@@ -1111,7 +1110,7 @@
 	raw_inode.mtime = raw_inode.atime;
 	raw_inode.ctime = raw_inode.atime;
 	raw_inode.offset = 0;
-	raw_inode.dsize = sizeof(kdev_t);
+	raw_inode.dsize = sizeof(dev_t);
 	raw_inode.rsize = 0;
 	raw_inode.nsize = dentry->d_name.len;
 	raw_inode.nlink = 1;
@@ -1121,7 +1120,7 @@
 
 	/* Write the new node to the flash.  */
 	if ((err = jffs_write_node(c, node, &raw_inode, dentry->d_name.name,
-				   (unsigned char *)&dev, 0, NULL)) < 0) {
+				   (unsigned char *)&rdev, 0, NULL)) < 0) {
 		D(printk("jffs_mknod(): jffs_write_node() failed.\n"));
 		result = err;
 		goto jffs_mknod_err;
@@ -1724,9 +1723,9 @@
 		/* If the node is a device of some sort, then the number of
 		   the device should be read from the flash memory and then
 		   added to the inode's i_rdev member.  */
-		kdev_t rdev;
-		jffs_read_data(f, (char *)&rdev, 0, sizeof(kdev_t));
-		init_special_inode(inode, inode->i_mode, kdev_t_to_nr(rdev));
+		dev_t rdev;
+		jffs_read_data(f, (char *)&rdev, 0, sizeof(dev_t));
+		init_special_inode(inode, inode->i_mode, rdev);
 	}
 
 	D3(printk (KERN_NOTICE "read_inode(): up biglock\n"));

                 reply	other threads:[~2002-11-18  3:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=UTC200211180332.gAI3W7l02598.aeb@smtp.cwi.nl \
    --to=andries.brouwer@cwi.nl \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®