From 6fe57dcfdae6efbf1aaf8e994e280c813c8c30dd Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Fri, 15 Apr 2005 20:32:31 +0000 Subject: [PATCH] make-linux-proc-cellservdb-info-20050415 use info hook instead of read so we can have larger than a slab --- src/afs/LINUX/osi_module.c | 70 +++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/src/afs/LINUX/osi_module.c b/src/afs/LINUX/osi_module.c index 4a9cc9917..5120c509a 100644 --- a/src/afs/LINUX/osi_module.c +++ b/src/afs/LINUX/osi_module.c @@ -67,6 +67,74 @@ static struct file_operations afs_syscall_fops = { #endif }; +int +csdbproc_info(char *buffer, char **start, off_t offset, int +length) +{ + int len = 0; + off_t pos = 0; + int cnt; + struct afs_q *cq, *tq; + struct cell *tc; + char tbuffer[16]; + /* 90 - 64 cellname, 10 for 32 bit num and index, plus + decor */ + char temp[91]; + afs_uint32 addr; + + ObtainReadLock(&afs_xcell); + + for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { + tc = QTOC(cq); tq = QNext(cq); + + pos += 90; + + if (pos <= offset) { + len = 0; + } else { + sprintf(temp, ">%s #(%d/%d)\n", tc->cellName, + tc->cellNum, tc->cellIndex); + sprintf(buffer + len, "%-89s\n", temp); + len += 90; + if (pos >= offset+length) { + ReleaseReadLock(&afs_xcell); + goto done; + } + } + + for (cnt = 0; cnt < MAXCELLHOSTS; cnt++) { + if (!tc->cellHosts[cnt]) break; + pos += 90; + if (pos <= offset) { + len = 0; + } else { + addr = ntohl(tc->cellHosts[cnt]->addr->sa_ip); + sprintf(tbuffer, "%d.%d.%d.%d", + (int)((addr>>24) & 0xff), +(int)((addr>>16) & 0xff), + (int)((addr>>8) & 0xff), (int)( addr & 0xff)); + sprintf(temp, "%s #%s%s\n", tbuffer, tbuffer); + sprintf(buffer + len, "%-89s\n", temp); + len += 90; + if (pos >= offset+length) { + ReleaseReadLock(&afs_xcell); + goto done; + } + } + } + } + + ReleaseReadLock(&afs_xcell); + +done: + *start = buffer + len - (pos - offset); + len = pos - offset; + if (len > length) + len = length; + return len; +} + + int csdbproc_read(char *buffer, char **start, off_t offset, int count, int *eof, void *data) @@ -450,7 +518,7 @@ afsproc_init(void) entry1->owner = THIS_MODULE; - entry = create_proc_read_entry(PROC_CELLSERVDB_NAME, (S_IFREG|S_IRUGO), openafs_procfs, csdbproc_read, NULL); + entry = create_proc_info_entry(PROC_CELLSERVDB_NAME, (S_IFREG|S_IRUGO), openafs_procfs, csdbproc_info); entry = create_proc_read_entry(PROC_PEER_NAME, (S_IFREG|S_IRUGO), openafs_procfs, peerproc_read, NULL); -- 2.39.5