Attached is a patch file implementing the changes I was talking about. I'd
appreciate it if someone could test the code for me (on both old and new
kernels).

The change to namei.c was just to get rid of a compilation warning about
mixed declarations and code.

--Nick

On Mon, Jun 29, 2009 at 12:56 PM, Nicholas Mills <[email protected]>wrote:

> All,
>
> In src/kernel/linux-2.6/devpvfs2-req.c:1037 there is a call to
> class_device_create(). Unfortunately, this symbol no longer exists in the
> latest kernel version (2.6.30 and possibly earlier). Documentation seems to
> suggest this call should be replaced with a call to device_create().
>
> The class_device_create issue has been mentioned once before. See
> http://www.beowulf-underground.org/pipermail/pvfs2-developers/2007-April/003346.html
> .
>
>
> Walt,
>
> Don't worry, I promise I'm not changing any kernel code :). I'm just trying
> to get my bearings to see what (if anything) needs to be changed for the
> security implementation.
>
> --Nick
>
>
Index: maint/config/kernel.m4
===================================================================
RCS file: /anoncvs/pvfs2/maint/config/kernel.m4,v
retrieving revision 1.70
diff -u -p -r1.70 kernel.m4
--- maint/config/kernel.m4	6 Apr 2009 15:09:16 -0000	1.70
+++ maint/config/kernel.m4	1 Jul 2009 20:33:34 -0000
@@ -908,18 +908,39 @@ AC_DEFUN([AX_KERNEL_FEATURES],
 	)
 
 	dnl old linux kernels do not have class_create and related functions
-        dnl
-        dnl check for class_device_destroy() to weed out RHEL4 kernels that
-        dnl have some class functions but not others
 	AC_MSG_CHECKING(if kernel has device classes)
 	AC_TRY_COMPILE([
 	    #define __KERNEL__
 	    #include <linux/device.h>
 	], [
-	    class_device_destroy(NULL, "pvfs2")
+	    class_create(NULL, NULL);
 	],
 	AC_MSG_RESULT(yes)
 	AC_DEFINE(HAVE_KERNEL_DEVICE_CLASSES, 1, Define if kernel has device classes),
+	AC_MSG_RESULT(no)
+	)
+
+	AC_MSG_CHECKING(for device_create)
+	AC_TRY_COMPILE([
+	    #define __KERNEL__
+	    #include <linux/device.h>
+	], [
+	    device_create(NULL, NULL, 0, NULL, NULL);
+	],
+	AC_MSG_RESULT(yes)
+	AC_DEFINE(HAVE_KERNEL_DEVICE_CREATE, 1, Define if kernel has device_create),
+	AC_MSG_RESULT(no)
+	)
+
+	AC_MSG_CHECKING(for class_device_create)
+	AC_TRY_COMPILE([
+	    #define __KERNEL__
+	    #include <linux/device.h>
+	], [
+	    class_device_create(NULL, NULL, 0, NULL, NULL);
+	],
+	AC_MSG_RESULT(yes)
+	AC_DEFINE(HAVE_KERNEL_CLASS_DEVICE_CREATE, 1, Define if kernel has class_device_create),
 	AC_MSG_RESULT(no)
 	)
 
Index: src/kernel/linux-2.6/devpvfs2-req.c
===================================================================
RCS file: /anoncvs/pvfs2/src/kernel/linux-2.6/devpvfs2-req.c,v
retrieving revision 1.74
diff -u -p -r1.74 devpvfs2-req.c
--- src/kernel/linux-2.6/devpvfs2-req.c	10 Jun 2008 13:38:00 -0000	1.74
+++ src/kernel/linux-2.6/devpvfs2-req.c	1 Jul 2009 20:33:35 -0000
@@ -1034,9 +1034,17 @@ int pvfs2_dev_init(void)
         ret = PTR_ERR(pvfs2_dev_class);
         return ret;
     }
+#if defined(HAVE_KERNEL_DEVICE_CREATE)
+    device_create(pvfs2_dev_class, NULL,
+                  MKDEV(pvfs2_dev_major, 0), NULL,
+                  "%s", PVFS2_REQDEVICE_NAME);
+#elif defined(HAVE_KERNEL_CLASS_DEVICE_CREATE)
     class_device_create(pvfs2_dev_class, NULL,
                         MKDEV(pvfs2_dev_major, 0), NULL,
                         PVFS2_REQDEVICE_NAME);
+#else
+    #error "Your kernel does not fully implement device classes"
+#endif
 #endif
 
     gossip_debug(GOSSIP_INIT_DEBUG, "*** /dev/%s character device registered ***\n",
@@ -1049,7 +1057,11 @@ int pvfs2_dev_init(void)
 void pvfs2_dev_cleanup(void)
 {
 #ifdef HAVE_KERNEL_DEVICE_CLASSES
+#if defined(HAVE_KERNEL_DEVICE_CREATE)
+    device_destroy(pvfs2_dev_class, MKDEV(pvfs2_dev_major, 0));
+#elif defined(HAVE_KERNEL_CLASS_DEVICE_CREATE)
     class_device_destroy(pvfs2_dev_class, MKDEV(pvfs2_dev_major, 0));
+#endif
     class_destroy(pvfs2_dev_class);
 #endif
     unregister_chrdev(pvfs2_dev_major, PVFS2_REQDEVICE_NAME);
Index: src/kernel/linux-2.6/namei.c
===================================================================
RCS file: /anoncvs/pvfs2/src/kernel/linux-2.6/namei.c,v
retrieving revision 1.85
diff -u -p -r1.85 namei.c
--- src/kernel/linux-2.6/namei.c	30 Jun 2009 16:25:39 -0000	1.85
+++ src/kernel/linux-2.6/namei.c	1 Jul 2009 20:33:35 -0000
@@ -200,9 +200,9 @@ static struct dentry *pvfs2_lookup(
     inode = pvfs2_iget(sb, &new_op->downcall.resp.lookup.refn);
     if (inode && !is_bad_inode(inode))
     {
+        struct dentry *res;
         gossip_debug(GOSSIP_NAME_DEBUG, "%s:%s:%d Found good inode [%lu] with count [%d]\n", 
             __FILE__, __func__, __LINE__, inode->i_ino, (int)atomic_read(&inode->i_count));
-        struct dentry *res;
 
         /* update dentry/inode pair into dcache */
         dentry->d_op = &pvfs2_dentry_operations;
_______________________________________________
Pvfs2-developers mailing list
[email protected]
http://www.beowulf-underground.org/mailman/listinfo/pvfs2-developers

Reply via email to