]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
LINUX 5.6: use struct proc_ops for proc_create
authorCheyenne Wills <cwills@sinenomine.net>
Fri, 14 Feb 2020 18:50:03 +0000 (11:50 -0700)
committerStephan Wiesand <stephan.wiesand@desy.de>
Sat, 15 Feb 2020 19:57:56 +0000 (14:57 -0500)
The Linux commit d56c0d45f0e27f814e87a1676b6bdccccbc252e9
(proc: decouple proc from VFS with "struct proc_ops") was merged into
Linux 5.6rc1.  The commit replaces the 'file_operations' parameter for
proc_create with a new structure 'proc_ops'.

Conditionally initialize and use proc_ops structures instead of
file_operations structures for calls to proc_create.

Notes:
 * proc_ops.proc_ioctl is equivalent to file_operations.unlocked_ioctl
 * The macros HAVE_UNLOCKED_IOCTL and HAVE_COMPAT_IOCTL are both
   hardcoded to 1 in linux's fs.h
 * proc_ops.compat_ioctl is conditional on Linux's CONFIG_COMPAT macro
   which is a separate test from the HAVE_COMPAT_IOCTL macro

Reviewed-on: https://gerrit.openafs.org/14063
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 1626986bd6d70c526376cf7cedfd3ebbf6d3588a)

Change-Id: Icaab45f4542131e636f2c60e3efce86c8afc57be
Reviewed-on: https://gerrit.openafs.org/14069
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Yadavendra Yadav <yadayada@in.ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/afs/LINUX/osi_compat.h
src/afs/LINUX/osi_ioctl.c
src/afs/LINUX/osi_proc.c
src/cf/linux-kernel-struct.m4
src/cf/linux-kernel-type.m4

index d236081431d613999fc6222344785245329fb97a..4999b89b93b36b8ce87f37a36e24806f8cdfd33b 100644 (file)
@@ -627,14 +627,18 @@ afs_truncate(struct inode *inode, int len)
 }
 
 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_STRUCT_PROC_OPS)
+afs_proc_create(char *name, umode_t mode, struct proc_dir_entry *parent, struct proc_ops *ops) {
+#else
+afs_proc_create(char *name, umode_t mode, struct proc_dir_entry *parent, struct file_operations *ops) {
+#endif
 #if defined(HAVE_LINUX_PROC_CREATE)
-    return proc_create(name, mode, parent, fops);
+    return proc_create(name, mode, parent, ops);
 #else
     struct proc_dir_entry *entry;
     entry = create_proc_entry(name, mode, parent);
     if (entry)
-       entry->proc_fops = fops;
+       entry->proc_fops = ops;
     return entry;
 #endif
 }
index 82e907bf68ff88e7b120c0c91e0c696657182d5a..1646a151825217ceab273bcbfdeb61d9f4e4e996 100644 (file)
@@ -91,24 +91,31 @@ static long afs_unlocked_ioctl(struct file *file, unsigned int cmd,
     return afs_ioctl(FILE_INODE(file), file, cmd, arg);
 }
 #endif
-
-static struct file_operations afs_syscall_fops = {
-#ifdef HAVE_UNLOCKED_IOCTL
-    .unlocked_ioctl = afs_unlocked_ioctl,
+#if defined(HAVE_LINUX_STRUCT_PROC_OPS)
+static struct proc_ops afs_syscall_ops = {
+    .proc_ioctl = afs_unlocked_ioctl,
+# ifdef STRUCT_PROC_OPS_HAS_PROC_COMPAT_IOCTL
+    .proc_compat_ioctl = afs_unlocked_ioctl,
+# endif
+};
 #else
+static struct file_operations afs_syscall_ops = {
+# ifdef HAVE_UNLOCKED_IOCTL
+    .unlocked_ioctl = afs_unlocked_ioctl,
+# else
     .ioctl = afs_ioctl,
-#endif
-#ifdef HAVE_COMPAT_IOCTL
+# endif
+# ifdef HAVE_COMPAT_IOCTL
     .compat_ioctl = afs_unlocked_ioctl,
-#endif
+# endif
 };
-
+#endif /* HAVE_LINUX_STRUCT_PROC_OPS */
 void
 osi_ioctl_init(void)
 {
     struct proc_dir_entry *entry;
 
-    entry = afs_proc_create(PROC_SYSCALL_NAME, 0666, openafs_procfs, &afs_syscall_fops);
+    entry = afs_proc_create(PROC_SYSCALL_NAME, 0666, openafs_procfs, &afs_syscall_ops);
 #if defined(STRUCT_PROC_DIR_ENTRY_HAS_OWNER)
     if (entry)
        entry->owner = THIS_MODULE;
index a1a57240508753f14ab2ab669f2e8c826695863a..4ac51d3f42a836ad7bfe82dc465fc3856e4e58f4 100644 (file)
@@ -124,12 +124,21 @@ afs_csdb_open(struct inode *inode, struct file *file)
     return seq_open(file, &afs_csdb_op);
 }
 
+#if defined(HAVE_LINUX_STRUCT_PROC_OPS)
+static struct proc_ops afs_csdb_operations = {
+    .proc_open    = afs_csdb_open,
+    .proc_read    = seq_read,
+    .proc_lseek  = seq_lseek,
+    .proc_release = seq_release,
+};
+#else
 static struct file_operations afs_csdb_operations = {
     .open    = afs_csdb_open,
     .read    = seq_read,
     .llseek  = seq_lseek,
     .release = seq_release,
 };
+#endif /* HAVE_LINUX_STRUCT_PROC_OPS */
 
 static void *
 uu_start(struct seq_file *m, loff_t *pos)
@@ -284,13 +293,21 @@ afs_unixuser_open(struct inode *inode, struct file *file)
     return seq_open(file, &afs_unixuser_seqop);
 }
 
-static struct file_operations afs_unixuser_fops = {
+#if defined(HAVE_LINUX_STRUCT_PROC_OPS)
+static struct proc_ops afs_unixuser_ops = {
+    .proc_open = afs_unixuser_open,
+    .proc_read = seq_read,
+    .proc_lseek = seq_lseek,
+    .proc_release = seq_release,
+};
+#else
+static struct file_operations afs_unixuser_ops = {
     .open    = afs_unixuser_open,
     .read    = seq_read,
     .llseek  = seq_lseek,
     .release = seq_release,
 };
-
+#endif /* HAVE_LINUX_STRUCT_PROC_OPS */
 
 #else /* HAVE_LINUX_SEQ_FILE_H */
 
@@ -381,7 +398,7 @@ osi_proc_init(void)
     openafs_procfs = proc_mkdir(path, NULL);
 #endif
 #ifdef HAVE_LINUX_SEQ_FILE_H
-    entry = afs_proc_create("unixusers", 0, openafs_procfs, &afs_unixuser_fops);
+    entry = afs_proc_create("unixusers", 0, openafs_procfs, &afs_unixuser_ops);
 # if defined(STRUCT_PROC_DIR_ENTRY_HAS_OWNER)
     if (entry)
        entry->owner = THIS_MODULE;
index c97450f9334bafeb21072ef0e2b5c497bfbdf4ee..003d34ab89f8ad3810ecda98b527c777e27c3139 100644 (file)
@@ -30,6 +30,7 @@ AC_CHECK_LINUX_STRUCT([key_type], [preparse], [key-type.h])
 AC_CHECK_LINUX_STRUCT([msghdr], [msg_iter], [socket.h])
 AC_CHECK_LINUX_STRUCT([nameidata], [path], [namei.h])
 AC_CHECK_LINUX_STRUCT([proc_dir_entry], [owner], [proc_fs.h])
+AC_CHECK_LINUX_STRUCT([proc_ops], [proc_compat_ioctl], [proc_fs.h])
 AC_CHECK_LINUX_STRUCT([super_block], [s_bdi], [fs.h])
 AC_CHECK_LINUX_STRUCT([super_block], [s_d_op], [fs.h])
 AC_CHECK_LINUX_STRUCT([super_operations], [alloc_inode],
index 57c8b3729fee1ad103483fff19453e643fe0a4d1..ae59fccfb975735c358ef721c7e568df4f9607f5 100644 (file)
@@ -2,4 +2,5 @@ AC_DEFUN([OPENAFS_LINUX_KERNEL_TYPE_CHECKS],[
 dnl Type existence checks
 AC_CHECK_LINUX_TYPE([struct vfs_path], [dcache.h])
 AC_CHECK_LINUX_TYPE([kuid_t], [uidgid.h])
+AC_CHECK_LINUX_TYPE([struct proc_ops], [proc_fs.h])
 ])