From: Cheyenne Wills Date: Tue, 11 Feb 2020 18:29:42 +0000 (-0700) Subject: LINUX 5.6: use struct proc_ops for proc_create X-Git-Tag: openafs-devel-1_9_0~153 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=1626986bd6d70c526376cf7cedfd3ebbf6d3588a LINUX 5.6: use struct proc_ops for proc_create 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 Reviewed-by: Andrew Deason Reviewed-by: Mark Vitale Reviewed-by: Benjamin Kaduk --- diff --git a/src/afs/LINUX/osi_compat.h b/src/afs/LINUX/osi_compat.h index d236081..4999b89 100644 --- a/src/afs/LINUX/osi_compat.h +++ b/src/afs/LINUX/osi_compat.h @@ -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 } diff --git a/src/afs/LINUX/osi_ioctl.c b/src/afs/LINUX/osi_ioctl.c index 82e907b..1646a15 100644 --- a/src/afs/LINUX/osi_ioctl.c +++ b/src/afs/LINUX/osi_ioctl.c @@ -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; diff --git a/src/afs/LINUX/osi_proc.c b/src/afs/LINUX/osi_proc.c index a1a5724..4ac51d3 100644 --- a/src/afs/LINUX/osi_proc.c +++ b/src/afs/LINUX/osi_proc.c @@ -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; diff --git a/src/cf/linux-kernel-struct.m4 b/src/cf/linux-kernel-struct.m4 index c97450f..003d34a 100644 --- a/src/cf/linux-kernel-struct.m4 +++ b/src/cf/linux-kernel-struct.m4 @@ -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], diff --git a/src/cf/linux-kernel-type.m4 b/src/cf/linux-kernel-type.m4 index 57c8b37..ae59fcc 100644 --- a/src/cf/linux-kernel-type.m4 +++ b/src/cf/linux-kernel-type.m4 @@ -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]) ])