make-linux-proc-cellservdb-info-20050415
authorDerrick Brashear <shadow@dementia.org>
Fri, 15 Apr 2005 20:32:31 +0000 (20:32 +0000)
committerDerrick Brashear <shadow@dementia.org>
Fri, 15 Apr 2005 20:32:31 +0000 (20:32 +0000)
use info hook instead of read so we can have larger than a slab

src/afs/LINUX/osi_module.c

index 4a9cc99..5120c50 100644 (file)
@@ -68,6 +68,74 @@ static struct file_operations afs_syscall_fops = {
 };
 
 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);