mtd/fs/jffs2 dir.c,1.81,1.82 file.c,1.95,1.96 fs.c,1.31,1.32 os-linux.h,1.36,1.37 super.c,1.89,1.90

David Woodhouse dwmw2 at infradead.org
Sat Oct 11 07:47:26 EDT 2003


Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv21605

Modified Files:
	dir.c file.c fs.c os-linux.h super.c 
Log Message:
dev_t, intent lookups and version.h merges from 2.6

Index: dir.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/dir.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -r1.81 -r1.82
--- dir.c	4 Oct 2003 08:33:06 -0000	1.81
+++ dir.c	11 Oct 2003 11:47:23 -0000	1.82
@@ -22,18 +22,22 @@
 #include <linux/time.h>
 #include "nodelist.h"
 
-/* Urgh. Please tell me there's a nicer way of doing this. */
+/* Urgh. Please tell me there's a nicer way of doing these. */
 #include <linux/version.h>
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,48)
 typedef int mknod_arg_t;
+#define NAMEI_COMPAT(x) ((void *)x)
 #else
 typedef dev_t mknod_arg_t;
+#define NAMEI_COMPAT(x) (x)
 #endif
 
 static int jffs2_readdir (struct file *, void *, filldir_t);
 
-static int jffs2_create (struct inode *,struct dentry *,int);
-static struct dentry *jffs2_lookup (struct inode *,struct dentry *);
+static int jffs2_create (struct inode *,struct dentry *,int,
+			 struct nameidata *);
+static struct dentry *jffs2_lookup (struct inode *,struct dentry *,
+				    struct nameidata *);
 static int jffs2_link (struct dentry *,struct inode *,struct dentry *);
 static int jffs2_unlink (struct inode *,struct dentry *);
 static int jffs2_symlink (struct inode *,struct dentry *,const char *);
@@ -54,8 +58,8 @@
 
 struct inode_operations jffs2_dir_inode_operations =
 {
-	.create =	jffs2_create,
-	.lookup =	jffs2_lookup,
+	.create =	NAMEI_COMPAT(jffs2_create),
+	.lookup =	NAMEI_COMPAT(jffs2_lookup),
 	.link =		jffs2_link,
 	.unlink =	jffs2_unlink,
 	.symlink =	jffs2_symlink,
@@ -73,7 +77,8 @@
    and we use the same hash function as the dentries. Makes this 
    nice and simple
 */
-static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target)
+static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target,
+				   struct nameidata *nd)
 {
 	struct jffs2_inode_info *dir_f;
 	struct jffs2_sb_info *c;
@@ -175,7 +180,8 @@
 /***********************************************************************/
 
 
-static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode)
+static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode,
+			struct nameidata *nd)
 {
 	struct jffs2_raw_inode *ri;
 	struct jffs2_inode_info *f, *dir_f;
@@ -574,6 +580,9 @@
 	uint32_t alloclen, phys_ofs;
 	int ret;
 
+	if (!old_valid_dev(rdev))
+		return -EINVAL;
+
 	ri = jffs2_alloc_raw_inode();
 	if (!ri)
 		return -ENOMEM;
@@ -581,7 +590,7 @@
 	c = JFFS2_SB_INFO(dir_i->i_sb);
 	
 	if (S_ISBLK(mode) || S_ISCHR(mode)) {
-		dev = cpu_to_je16((MAJOR(rdev) << 8) | MINOR(rdev));
+		dev = cpu_to_je16(old_encode_dev(rdev));
 		devlen = sizeof(dev);
 	}
 	

Index: file.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/file.c,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -r1.95 -r1.96
--- file.c	6 Oct 2003 13:46:31 -0000	1.95
+++ file.c	11 Oct 2003 11:47:23 -0000	1.96
@@ -11,6 +11,7 @@
  *
  */
 
+#include <linux/version.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/fs.h>

Index: fs.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/fs.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- fs.c	6 Oct 2003 13:46:31 -0000	1.31
+++ fs.c	11 Oct 2003 11:47:23 -0000	1.32
@@ -11,6 +11,7 @@
  *
  */
 
+#include <linux/version.h>
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -48,8 +49,7 @@
 	   it out again with the appropriate data attached */
 	if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) {
 		/* For these, we don't actually need to read the old node */
-		dev =  (major(inode->i_rdev) << 8) | 
-			minor(inode->i_rdev);
+		dev = old_encode_dev(inode->i_rdev);
 		mdata = (char *)&dev;
 		mdatalen = sizeof(dev);
 		D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of kdev_t\n", mdatalen));
@@ -299,7 +299,8 @@
 	case S_IFSOCK:
 	case S_IFIFO:
 		inode->i_op = &jffs2_file_inode_operations;
-		init_special_inode(inode, inode->i_mode, kdev_t_to_nr(mk_kdev(je16_to_cpu(rdev)>>8, je16_to_cpu(rdev)&0xff)));
+		init_special_inode(inode, inode->i_mode,
+				   old_decode_dev((je16_to_cpu(rdev))));
 		break;
 
 	default:

Index: os-linux.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/os-linux.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- os-linux.h	9 Oct 2003 13:42:42 -0000	1.36
+++ os-linux.h	11 Oct 2003 11:47:23 -0000	1.37
@@ -47,8 +47,8 @@
 #define JFFS2_F_I_GID(f) (OFNI_EDONI_2SFFJ(f)->i_gid)
 
 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,1)
-#define JFFS2_F_I_RDEV_MIN(f) (minor(OFNI_EDONI_2SFFJ(f)->i_rdev))
-#define JFFS2_F_I_RDEV_MAJ(f) (major(OFNI_EDONI_2SFFJ(f)->i_rdev))
+#define JFFS2_F_I_RDEV_MIN(f) (iminor(OFNI_EDONI_2SFFJ(f)))
+#define JFFS2_F_I_RDEV_MAJ(f) (imajor(OFNI_EDONI_2SFFJ(f)))
 #else
 #define JFFS2_F_I_RDEV_MIN(f) (MINOR(to_kdev_t(OFNI_EDONI_2SFFJ(f)->i_rdev)))
 #define JFFS2_F_I_RDEV_MAJ(f) (MAJOR(to_kdev_t(OFNI_EDONI_2SFFJ(f)->i_rdev)))

Index: super.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/super.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -r1.89 -r1.90
--- super.c	6 Oct 2003 12:52:29 -0000	1.89
+++ super.c	11 Oct 2003 11:47:23 -0000	1.90
@@ -14,7 +14,6 @@
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/version.h>
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/list.h>
@@ -172,7 +171,6 @@
 	int err;
 	struct nameidata nd;
 	int mtdnr;
-	kdev_t dev;
 
 	if (!dev_name)
 		return ERR_PTR(-EINVAL);
@@ -226,26 +224,31 @@
 	if (err)
 		return ERR_PTR(err);
 
-	if (!S_ISBLK(nd.dentry->d_inode->i_mode)) {
-		path_release(&nd);
-		return ERR_PTR(-EINVAL);
-	}
+	err = -EINVAL;
+
+	if (!S_ISBLK(nd.dentry->d_inode->i_mode))
+		goto out;
+
 	if (nd.mnt->mnt_flags & MNT_NODEV) {
-		path_release(&nd);
-		return ERR_PTR(-EACCES);
+		err = -EACCES;
+		goto out;
 	}
 
-	dev = nd.dentry->d_inode->i_rdev;
-	path_release(&nd);
-
-	if (major(dev) != MTD_BLOCK_MAJOR) {
+	if (imajor(nd.dentry->d_inode) != MTD_BLOCK_MAJOR) {
 		if (!(flags & MS_VERBOSE)) /* Yes I mean this. Strangely */
 			printk(KERN_NOTICE "Attempt to mount non-MTD device \"%s\" as JFFS2\n",
 			       dev_name);
-		return ERR_PTR(-EINVAL);
+		goto out;
 	}
 
-	return jffs2_get_sb_mtdnr(fs_type, flags, dev_name, data, minor(dev));
+	mtdnr = iminor(nd.dentry->d_inode);
+	path_release(&nd);
+
+	return jffs2_get_sb_mtdnr(fs_type, flags, dev_name, data, mtdnr);
+
+out:
+	path_release(&nd);
+	return ERR_PTR(err);
 }
 
 static void jffs2_put_super (struct super_block *sb)




More information about the linux-mtd-cvs mailing list