LINUX 5.3.0: Check for 'recurse' arg in keyring_search
[openafs.git] / src / afs / LINUX / osi_proc.c
index ecb1457..a1a5724 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
@@ -134,21 +135,32 @@ static void *
 uu_start(struct seq_file *m, loff_t *pos)
 {
     struct unixuser *tu;
+    void *ret;
     loff_t n = 0;
     afs_int32 i;
 
+    AFS_GLOCK();
     ObtainReadLock(&afs_xuser);
-    if (!*pos)
-       return (void *)(1);
+
+    if (!*pos) {
+       ret = (void *)(1);
+       goto done;
+    }
+
+    ret = NULL;
 
     for (i = 0; i < NUSERS; i++) {
        for (tu = afs_users[i]; tu; tu = tu->next) {
-           if (++n == *pos)
-               return tu;
+           if (++n == *pos) {
+               ret = tu;
+               goto done;
+           }
        }
     }
 
-    return NULL;
+ done:
+    AFS_GUNLOCK();
+    return ret;
 }
 
 static void *
@@ -173,7 +185,9 @@ uu_next(struct seq_file *m, void *p, loff_t *pos)
 static void
 uu_stop(struct seq_file *m, void *p)
 {
+    AFS_GLOCK();
     ReleaseReadLock(&afs_xuser);
+    AFS_GUNLOCK();
 }
 
 static int
@@ -195,6 +209,8 @@ uu_show(struct seq_file *m, void *p)
        return 0;
     }
 
+    AFS_GLOCK();
+
     tu->refCount++;
     ReleaseReadLock(&afs_xuser);
 
@@ -250,6 +266,8 @@ uu_show(struct seq_file *m, void *p)
     afs_PutUser(tu, READ_LOCK);
     ObtainReadLock(&afs_xuser);
 
+    AFS_GUNLOCK();
+
     return 0;
 }
 
@@ -289,6 +307,8 @@ csdbproc_info(char *buffer, char **start, off_t offset, int length)
        decor */
     char temp[91];
     afs_uint32 addr;
+
+    AFS_GLOCK();
     
     ObtainReadLock(&afs_xcell);
 
@@ -335,6 +355,8 @@ csdbproc_info(char *buffer, char **start, off_t offset, int length)
     ReleaseReadLock(&afs_xcell);
     
 done:
+    AFS_GUNLOCK();
+
     *start = buffer + len - (pos - offset);
     len = pos - offset;
     if (len > length)
@@ -359,21 +381,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
 }