Posted Feb 8, 2009 15:24 UTC (Sun) by cbrannon (guest, #56557)
Parent article: lwnfs source code
This code will not compile in 2009. Here is a diff so that it will
compile. I am not a kernel hacker, and I have not tested these changes.
Caveat programmer.
/*
+ * The Linux kernel has changed, so I had to make changes in order to compile
+ * this code. i_blksize is no longer a member of struct inode. However,
+ * i_blkbits remains, and i_blksize = (1 << i_blkbits).
+ * i_blkbits is computed by the function blksize_bits(), which I copied
+ * from linux/include/linux/blkdev.h.
+ * u.generic_ip is no longer part of struct inode; we use i_private instead.
+ * Finally, lfs_get_super was modified to reflect current declarations.
+ * -- Chris Brannon, 02/08/2009
+*/
+
+static inline unsigned int blksize_bits(unsigned int size)
+{
+ unsigned int bits = 8;
+ do {
+ bits++;
+ size >>= 1;
+ } while (size > 256);
+ return bits;
+}
+
+/*
* Boilerplate stuff.
*/
MODULE_LICENSE("GPL");
@@ -38,7 +59,7 @@
if (ret) {
ret->i_mode = mode;
ret->i_uid = ret->i_gid = 0;
- ret->i_blksize = PAGE_CACHE_SIZE;
+ ret->i_blkbits = blksize_bits(PAGE_CACHE_SIZE);
ret->i_blocks = 0;
ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
}
@@ -55,7 +76,7 @@
*/
static int lfs_open(struct inode *inode, struct file *filp)
{
- filp->private_data = inode->u.generic_ip;
+ filp->private_data = inode->i_private;
return 0;
}
@@ -157,7 +178,7 @@
if (! inode)
goto out_dput;
inode->i_fop = &lfs_file_ops;
- inode->u.generic_ip = counter;
+ inode->i_private = counter;
/*
* Put it all into the dentry cache and we're done.
*/
@@ -289,10 +310,11 @@
/*
* Stuff to pass in when registering the filesystem.
*/
-static struct super_block *lfs_get_super(struct file_system_type *fst,
- int flags, const char *devname, void *data)
+static int lfs_get_super(struct file_system_type *fst,
+ int flags, const char *devname, void *data,
+ struct vfsmount *mnt)
{
- return get_sb_single(fst, flags, data, lfs_fill_super);
+ return get_sb_single(fst, flags, data, lfs_fill_super, mnt);
}