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
Change-Id: I8570ca499696b4c31b381543107453fbfe355376
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>
}
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
}
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;
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)
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 */
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;
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],
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])
])