Linux 3.10: Replace create_proc_entry() with proc_create()
authorMarc Dionne <marc.dionne@your-file-system.com>
Tue, 7 May 2013 00:20:07 +0000 (20:20 -0400)
committerDerrick Brashear <shadow@your-file-system.com>
Tue, 28 May 2013 14:15:06 +0000 (07:15 -0700)
Add an afs_proc_create() compat function that uses the
appropriate kernel function based on a configure test.

Change-Id: I4f3929849af032f2a483bc06bc5769f64085f1c4
Reviewed-on: http://gerrit.openafs.org/9854
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

acinclude.m4
src/afs/LINUX/osi_compat.h
src/afs/LINUX/osi_ioctl.c
src/afs/LINUX/osi_proc.c
src/afs/sysincludes.h

index d84bce5..6ffb686 100644 (file)
@@ -936,6 +936,9 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
                                     [#include <linux/fs.h>
                                      #include <linux/namei.h>],
                                     [path_lookup(NULL, 0, NULL);])
+                AC_CHECK_LINUX_FUNC([proc_create],
+                                    [#include <linux/proc_fs.h>],
+                                    [proc_create(NULL, 0, NULL, NULL);])
                 AC_CHECK_LINUX_FUNC([rcu_read_lock],
                                     [#include <linux/rcupdate.h>],
                                     [rcu_read_lock();])
index dc2c26a..ce9178e 100644 (file)
@@ -595,4 +595,17 @@ afs_truncate(struct inode *inode, int len)
     return code;
 }
 
+static inline struct proc_dir_entry *
+afs_proc_create(char *name, umode_t mode, struct proc_dir_entry *parent, struct file_operations *fops) {
+#if defined(HAVE_LINUX_PROC_CREATE)
+    return proc_create(name, mode, parent, fops);
+#else
+    struct proc_dir_entry *entry;
+    entry = create_proc_entry(name, mode, parent);
+    if (entry)
+       entry->proc_fops = fops;
+    return entry;
+#endif
+}
+
 #endif /* AFS_LINUX_OSI_COMPAT_H */
index 45e0fcd..82e907b 100644 (file)
 #include <linux/ioctl32.h>
 #endif
 
-#include <linux/proc_fs.h>
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/kernel.h>
 
+#include "osi_compat.h"
+
 extern struct proc_dir_entry *openafs_procfs;
 #if defined(NEED_IOCTL32) && !defined(HAVE_COMPAT_IOCTL)
 static int ioctl32_done;
@@ -107,10 +108,10 @@ osi_ioctl_init(void)
 {
     struct proc_dir_entry *entry;
 
-    entry = create_proc_entry(PROC_SYSCALL_NAME, 0666, openafs_procfs);
-    entry->proc_fops = &afs_syscall_fops;
+    entry = afs_proc_create(PROC_SYSCALL_NAME, 0666, openafs_procfs, &afs_syscall_fops);
 #if defined(STRUCT_PROC_DIR_ENTRY_HAS_OWNER)
-    entry->owner = THIS_MODULE;
+    if (entry)
+       entry->owner = THIS_MODULE;
 #endif
 
 #if defined(NEED_IOCTL32) && !defined(HAVE_COMPAT_IOCTL)
index b5219fa..71983dc 100644 (file)
 # include <asm/ia32_unistd.h>
 #endif
 
-#include <linux/proc_fs.h>
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/kernel.h>
 
+#include "osi_compat.h"
+
 struct proc_dir_entry *openafs_procfs;
 
 #ifdef HAVE_LINUX_SEQ_FILE_H
@@ -379,21 +380,18 @@ osi_proc_init(void)
     openafs_procfs = proc_mkdir(path, NULL);
 #endif
 #ifdef HAVE_LINUX_SEQ_FILE_H
-    entry = create_proc_entry("unixusers", 0, openafs_procfs);
-    if (entry) {
-       entry->proc_fops = &afs_unixuser_fops;
+    entry = afs_proc_create("unixusers", 0, openafs_procfs, &afs_unixuser_fops);
 # if defined(STRUCT_PROC_DIR_ENTRY_HAS_OWNER)
+    if (entry)
        entry->owner = THIS_MODULE;
 # endif
-    }
-    entry = create_proc_entry(PROC_CELLSERVDB_NAME, 0, openafs_procfs);
-    if (entry)
-       entry->proc_fops = &afs_csdb_operations;
+    entry = afs_proc_create(PROC_CELLSERVDB_NAME, 0, openafs_procfs, &afs_csdb_operations);
 #else
     entry = create_proc_info_entry(PROC_CELLSERVDB_NAME, (S_IFREG|S_IRUGO), openafs_procfs, csdbproc_info);
 #endif
 #if defined(STRUCT_PROC_DIR_ENTRY_HAS_OWNER)
-    entry->owner = THIS_MODULE;
+    if (entry)
+       entry->owner = THIS_MODULE;
 #endif
 }
 
index e8d072c..34501b5 100644 (file)
@@ -154,6 +154,7 @@ struct xfs_inode_info {
 # include <linux/sched.h>
 # include <linux/mm.h>
 # include <linux/slab.h>
+# include <linux/proc_fs.h>
 # include <linux/string.h>
 # if defined(HAVE_LINUX_SEMAPHORE_H)
 #  include <linux/semaphore.h>