]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-proc-cellservdb-20041110
authorDerrick Brashear <shadow@dementia.org>
Tue, 7 Dec 2004 05:50:07 +0000 (05:50 +0000)
committerDerrick Brashear <shadow@dementia.org>
Tue, 7 Dec 2004 05:50:07 +0000 (05:50 +0000)
put a cellservdb in /proc/fs/openafs

(cherry picked from commit 9b579bf0f77b6832897c5b50fa6a5f6b40940717)

src/afs/LINUX/osi_module.c
src/afs/afs_prototypes.h
src/config/afs_args.h

index af2d9503ec9fd86c8aacc1dc37907b04b8fadab8..c999d91f2f681f4b3b429816c4913cc1aecd4241 100644 (file)
@@ -138,12 +138,53 @@ static struct file_operations afs_syscall_fops = {
     .ioctl = afs_ioctl,
 };
 
+int
+csdbproc_read(char *buffer, char **start, off_t offset, int count,
+             int *eof, void *data)
+{
+    int len, i, j;
+    struct afs_q *cq, *tq;
+    struct cell *tc;
+    void *ret = NULL;
+    char tbuffer[16];
+    afs_uint32 addr;
+    
+    len = 0;
+    ObtainReadLock(&afs_xcell);
+    for (cq = CellLRU.next; cq != &CellLRU; cq = tq) {
+       tc = QTOC(cq); tq = QNext(cq);
+       len += sprintf(buffer + len, ">%s #(%d/%d)\n", tc->cellName, 
+                      tc->cellNum, tc->cellIndex);
+       for (j = 0; j < MAXCELLHOSTS; j++) {
+           if (!tc->cellHosts[j]) break;
+           addr = ntohl(tc->cellHosts[j]->addr->sa_ip);
+           sprintf(tbuffer, "%d.%d.%d.%d", 
+                   (int)((addr>>24) & 0xff), (int)((addr>>16) & 0xff),
+                   (int)((addr>>8)  & 0xff), (int)( addr      & 0xff));
+            len += sprintf(buffer + len, "%s #%s\n", tbuffer, tbuffer);
+       }
+    }
+    ReleaseReadLock(&afs_xcell);
+    
+    if (offset >= len) {
+       *start = buffer;
+       *eof = 1;
+       return 0;
+    }
+    *start = buffer + offset;
+    if ((len -= offset) > count)
+       return count;
+    *eof = 1;
+    return len;
+}
+
 static struct proc_dir_entry *openafs_procfs;
 
 static int
 afsproc_init()
 {
     struct proc_dir_entry *entry1;
+    struct proc_dir_entry *entry2;
 
     openafs_procfs = proc_mkdir(PROC_FSDIRNAME, proc_root_fs);
     entry1 = create_proc_entry(PROC_SYSCALL_NAME, 0666, openafs_procfs);
@@ -152,12 +193,15 @@ afsproc_init()
 
     entry1->owner = THIS_MODULE;
 
+    entry2 = create_proc_read_entry(PROC_CELLSERVDB_NAME, (S_IFREG|S_IRUGO), openafs_procfs, csdbproc_read, NULL);
+
     return 0;
 }
 
 static void
 afsproc_exit()
 {
+    remove_proc_entry(PROC_CELLSERVDB_NAME, openafs_procfs);
     remove_proc_entry(PROC_SYSCALL_NAME, openafs_procfs);
     remove_proc_entry(PROC_FSDIRNAME, proc_root_fs);
 }
index 33464593c51b176edc56a8f7baf84fb47ca92332..addebe7f0ed55255aefee87f7f75b25c472b554f 100644 (file)
@@ -196,6 +196,8 @@ extern void afs_DequeueCallback(struct vcache *avc);
 
 /* afs_cell.c */
 extern afs_rwlock_t afs_xcell;
+extern struct afs_q CellLRU;           
+
 extern void afs_CellInit(void);
 extern void shutdown_cell(void);
 extern int afs_cellname_init(ino_t inode, int lookupcode);
index 6e0cd5505e487a9c4ace734a14fe0c9f752b9791..e28eae5ffb507e64feb4ce06aa0932fdf9f9706f 100644 (file)
@@ -180,6 +180,7 @@ typedef struct cm_initparams_v1 {
 #define PROC_SYSCALL_NAME "afs_ioctl"
 #define PROC_SYSCALL_FNAME "/proc/fs/openafs/afs_ioctl"
 #define PROC_SYSCALL_ARLA_FNAME "/proc/fs/nnpfs/afs_ioctl"
+#define PROC_CELLSERVDB_NAME "CellServDB"
 #define VIOC_SYSCALL_TYPE 'C' 
 #define VIOC_SYSCALL _IOW(VIOC_SYSCALL_TYPE,1,void *)