From 9b579bf0f77b6832897c5b50fa6a5f6b40940717 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Thu, 11 Nov 2004 04:34:40 +0000 Subject: [PATCH] proc-cellservdb-20041110 put a cellservdb in /proc/fs/openafs --- src/afs/LINUX/osi_module.c | 44 ++++++++++++++++++++++++++++++++++++++ src/afs/afs_prototypes.h | 2 ++ src/config/afs_args.h | 1 + 3 files changed, 47 insertions(+) diff --git a/src/afs/LINUX/osi_module.c b/src/afs/LINUX/osi_module.c index af2d9503e..c999d91f2 100644 --- a/src/afs/LINUX/osi_module.c +++ b/src/afs/LINUX/osi_module.c @@ -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); } diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index 33464593c..addebe7f0 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -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); diff --git a/src/config/afs_args.h b/src/config/afs_args.h index 6e0cd5505..e28eae5ff 100644 --- a/src/config/afs_args.h +++ b/src/config/afs_args.h @@ -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 *) -- 2.39.5