Remove DUX/OSF code
[openafs.git] / src / venus / kdump.c
index dd1b458..bb80880 100644 (file)
@@ -106,10 +106,6 @@ struct ncp_sb_info {
 #define _KERNEL 1
 #endif
 
-#ifndef        AFS_OSF_ENV
-#include <sys/param.h>
-#endif
-
 #ifndef AFS_LINUX20_ENV
 #include <nlist.h>
 #endif
@@ -119,47 +115,6 @@ struct ncp_sb_info {
 #endif
 
 #include <afs/stds.h>
-#include <sys/types.h>
-
-#if defined(AFS_OSF_ENV)
-#define        KERNEL
-#define        UNIX_LOCKS
-#define        _KERNEL 1
-#ifdef _KERN_LOCK_H_
-#include FFFFF
-#endif
-#include <sys/time.h>
-#include <kern/lock.h>
-#include <sys/vnode.h>
-#include <arch/alpha/pmap.h>
-
-/*
- * beginning with DUX 4.0A, the system header files define the macros
- *
- * KSEG_TO_PHYS()
- * IS_KSEG_VA()
- * IS_SEG1_VA()
- *
- * to be calls to the kernel functions
- *
- * kseg_to_phys()
- * is_kseg_va()
- * is_seg1_va()
- *
- * when _KERNEL is defined, and expressions otherwise.  Since need
- * to define _KERNEL, we redefine these kernel functions as macros
- * for the expressions that we would have gotten if _KERNEL had not
- * been defined.  Yes, this duplicates code from the header files, but
- * there's no simple way around it.
- */
-
-#define kseg_to_phys(addr) ((vm_offset_t)(addr) - UNITY_BASE)
-#define is_kseg_va(x)   (((unsigned long)(x) & SEG1_BASE) == UNITY_BASE)
-#define is_seg1_va(x)   (((unsigned long)(x) & SEG1_BASE) == SEG1_BASE)
-
-#undef KERNEL
-#undef  _KERNEL
-#endif
 
 #ifdef AFS_SUN5_ENV /*XXXXX*/
 #include <sys/t_lock.h>
@@ -187,10 +142,6 @@ struct vnode foo;
 #include <sys/user.h>
 #endif
 
-#ifndef AFS_LINUX20_ENV
-#include <sys/socket.h>
-#endif
-
 #ifndef AFS_LINUX26_ENV
 #include <sys/file.h>
 #endif
@@ -213,9 +164,7 @@ struct vnode foo;
 # include <netinet/in.h>       /* struct in_addr */
 #endif
 
-#include <arpa/inet.h>         /* inet_ntoa() */
-
-#if defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV)
+#if defined(AFS_SGI_ENV)
 #ifdef       AFS_SGI_ENV
 #include <sys/vnode.h>
 #endif /* AFS_SGI_ENV */
@@ -339,7 +288,6 @@ typedef enum _spustate {    /* FROM /etc/conf/h/_types.h */
 #endif
 #endif
 #endif
-#include <signal.h>
 #endif
 
 /* AFS includes */
@@ -368,15 +316,6 @@ typedef kmutex_t afs_kmutex_t;
 typedef kcondvar_t afs_kcondvar_t;
 #endif /* AFS_SUN5_ENV */
 
-#ifdef AFS_DUX40_ENV
-#define RX_ENABLE_LOCKS
-typedef struct {
-    unsigned long lock;
-    void *owner;
-} afs_kmutex_t;
-typedef int afs_kcondvar_t;
-#endif /* AFS_DUX40_ENV */
-
 #ifdef AFS_HPUX110_ENV
 #define RX_ENABLE_LOCKS
 typedef struct {
@@ -462,15 +401,6 @@ extern off64_t lseek64();
 
 #undef KERNEL
 
-#if defined(AFS_OSF_ENV) && !defined(v_count)
-#define v_count         v_usecount
-#endif
-
-#ifdef AFS_OSF_ENV
-#define        KERNELBASE      0x80000000
-#define        coreadj(x)      ((int)x - KERNELBASE)
-#endif
-
 #if defined(AFS_SGI_ENV)
 #define UNIX "/unix"
 #else
@@ -626,9 +556,6 @@ PrintIPAddr(int addr)
 
 #ifdef AFS_LINUX20_ENV
 /* Find symbols in a live kernel. */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
 
 #ifdef AFS_LINUX26_ENV
 #define KSYMS "/proc/kallsyms"
@@ -683,7 +610,7 @@ read_ksyms(void)
     }
 
     availksyms = KSYM_ALLOC_BASE;
-    ksyms = (symlist_t *) malloc(availksyms * sizeof(symlist_t));
+    ksyms = malloc(availksyms * sizeof(symlist_t));
     if (!ksyms) {
        printf("Can't malloc %d elements for symbol list.\n", availksyms);
        exit(1);
@@ -693,8 +620,7 @@ read_ksyms(void)
     while (fgets(line, MAXLINE, fp)) {
        if (nksyms >= availksyms) {
            availksyms += KSYM_ALLOC_STEP;
-           ksyms =
-               (symlist_t *) realloc(ksyms, availksyms * sizeof(symlist_t));
+           ksyms = realloc(ksyms, availksyms * sizeof(symlist_t));
            if (!ksyms) {
                printf("Failed to realloc %d symbols.\n", availksyms);
                exit(1);
@@ -939,7 +865,7 @@ main(int argc, char **argv)
     sigaction(SIGSEGV, &nsa, NULL);
 #endif
 
-    ts = cmd_CreateSyntax(NULL, cmdproc, NULL,
+    ts = cmd_CreateSyntax(NULL, cmdproc, NULL, 0,
                          "Read internal cache manager structs");
     cmd_AddParm(ts, "-kobj", CMD_SINGLE, CMD_OPTIONAL,
                "kernel object (default /vmunix)");
@@ -1060,15 +986,6 @@ findsym(char *sname, off_t * offset)
                    errno, strerror(errno));
            exit(1);
        }
-#if    defined(AFS_OSF_ENV)
-       if (mem) {
-           long X;
-
-           X = coreadj(request[0].n_value);
-           request[0].n_value = X;
-       }
-#endif /* defined(AFS_OSF_ENV) */
-
        *offset = request[0].n_value;
        if (!request[0].n_value) {
            printf("(WARNING) Couldn't find %s in %s. Proceeding..\n", sname,
@@ -1362,14 +1279,12 @@ add_found_server(struct server *sep)
     if (NserversFound >= NserversAllocated) {
        NserversAllocated += SF_ALLOCATION_STEP;
        if (!serversFound) {
-           serversFound =
-               (struct server **)malloc(NserversAllocated *
-                                        sizeof(struct server *));
+           serversFound = malloc(NserversAllocated *
+                                 sizeof(struct server *));
        } else {
-           serversFound =
-               (struct server **)realloc((char *)serversFound,
-                                         NserversAllocated *
-                                         sizeof(struct server *));
+           serversFound = realloc(serversFound,
+                                  NserversAllocated *
+                                  sizeof(struct server *));
        }
        if (!serversFound) {
            printf("Can't allocate %lu bytes for list of found servers.\n",
@@ -1629,7 +1544,7 @@ print_dcaches(int pnt)
     kread(kmem, symoff, (char *)&count, sizeof count);
     findsym("afs_indexTable", &symoff);
     kread(kmem, symoff, (char *)&table, sizeof(long));
-    ptr = (long *)malloc(count * sizeof(long));
+    ptr = malloc(count * sizeof(long));
     kread(kmem, table, (char *)ptr, count * sizeof(long));
     for (i = 0, j = 0; i < count; i++) {
        if (dp = (struct dcache *)ptr[i]) {
@@ -1668,7 +1583,7 @@ print_DindexTimes(int pnt)
     kread(kmem, symoff, (char *)&count, sizeof count);
     findsym("afs_indexTimes", &symoff);
     kread(kmem, symoff, (char *)&table, sizeof(long));
-    ptr = (afs_hyper_t *) malloc(count * sizeof(afs_hyper_t));
+    ptr = malloc(count * sizeof(afs_hyper_t));
     kread(kmem, table, (char *)ptr, count * sizeof(afs_hyper_t));
     for (i = 0, j = 0; i < count; i++) {
        if (pnt)
@@ -1704,7 +1619,7 @@ print_DdvnextTbl(int pnt)
     kread(kmem, symoff, (char *)&count, sizeof count);
     findsym("afs_dvnextTbl", &symoff);
     kread(kmem, symoff, (char *)&table, sizeof(long));
-    ptr = (afs_int32 *) malloc(count * sizeof(afs_int32));
+    ptr = malloc(count * sizeof(afs_int32));
     kread(kmem, table, (char *)ptr, count * sizeof(afs_int32));
     for (i = 0, j = 0; i < count; i++) {
        if (pnt)
@@ -1733,7 +1648,7 @@ print_DdcnextTbl(int pnt)
     kread(kmem, symoff, (char *)&count, sizeof count);
     findsym("afs_dcnextTbl", &symoff);
     kread(kmem, symoff, (char *)&table, sizeof(long));
-    ptr = (afs_int32 *) malloc(count * sizeof(afs_int32));
+    ptr = malloc(count * sizeof(afs_int32));
     kread(kmem, table, (char *)ptr, count * sizeof(afs_int32));
     for (i = 0, j = 0; i < count; i++) {
        if (pnt)
@@ -1763,7 +1678,7 @@ print_DindexFlags(int pnt)
     kread(kmem, symoff, (char *)&count, sizeof count);
     findsym("afs_indexFlags", &symoff);
     kread(kmem, symoff, (char *)&table, sizeof(long));
-    flags = (unsigned char *)malloc(count * sizeof(char));
+    flags = malloc(count * sizeof(char));
     kread(kmem, table, flags, count * sizeof(char));
     for (i = 0, j = 0; i < count; i++) {
        if (pnt)
@@ -1792,7 +1707,7 @@ print_buffers(int pnt)
     kread(kmem, symoff, (char *)&table, sizeof(long));
     findsym("nbuffers", &symoff);
     kread(kmem, symoff, (char *)&count, sizeof(int));
-    buffers = (unsigned char *)malloc(count * sizeof(struct buffer));
+    buffers = malloc(count * sizeof(struct buffer));
     kread(kmem, table, buffers, count * sizeof(struct buffer));
     bp = (struct buffer *)buffers;
     for (i = 0, j = 0; i < count; i++, bp++) {
@@ -2216,79 +2131,6 @@ readmem(kmem, buf, vad, len)
 }
 #endif
 
-#ifdef AFS_OSF_ENV
-static
-read_addr(int fd, unsigned long addr, unsigned long *val)
-{
-    if (lseek(fd, addr, SEEK_SET) == -1)
-       return (0);
-    if (read(fd, val, sizeof(long)) != sizeof(long))
-       return (0);
-    return (1);
-}
-
-static pt_entry_t *ptes = NULL;
-static
-addr_to_offset(unsigned long addr, unsigned long *ret, int fd)
-{
-    off_t symoff;
-    pt_entry_t pte, *val;
-    char *str, *ptr;
-
-    if (IS_SEG1_VA(addr)) {
-       if (ptes == NULL) {
-           int i, loc;
-           unsigned long loc1, loc2[2];
-           findsym("kernel_pmap", &symoff);
-           loc1 = coreadj(symoff);
-           /*printf("ptes=%lx -> %lx\n", symoff, loc1); */
-           if (lseek(fd, loc1, L_SET /*0 */ ) != loc1) {
-               perror("lseek");
-               exit(1);
-           }
-           if ((i = read(fd, (char *)&loc1, sizeof(long))) != sizeof(long)) {
-               printf("Read of kerne_map failed\n");
-               return;         /*exit(1); */
-           }
-           loc = loc1;
-           /*printf("loc1 %lx -> %lx\n",  loc1, loc); */
-           if (lseek(fd, loc, L_SET /*0 */ ) != loc) {
-               perror("lseek");
-               exit(1);
-           }
-           if ((i =
-                read(fd, (char *)loc2,
-                     2 * sizeof(long))) != 2 * sizeof(long)) {
-               printf("Read of kerne_map failed\n");
-               return;         /*exit(1); */
-           }
-           ptes = (pt_entry_t *) loc2[1];
-           /*printf("ptes=%lx\n", ptes); */
-
-       }
-       if (!addr_to_offset
-           ((unsigned long)(ptes + LEVEL1_PT_OFFSET(addr)),
-            (unsigned long *)&val, fd))
-           return (0);
-       if (!read_addr(fd, (unsigned long)val, (unsigned long *)&pte))
-           return (0);
-       val = ((pt_entry_t *) PTETOPHYS(&pte)) + LEVEL2_PT_OFFSET(addr);
-       if (!read_addr(fd, (unsigned long)val, (unsigned long *)&pte))
-           return (0);
-       val = ((pt_entry_t *) PTETOPHYS(&pte)) + LEVEL3_PT_OFFSET(addr);
-       if (!read_addr(fd, (unsigned long)val, (unsigned long *)&pte))
-           return (0);
-       *ret = PTETOPHYS(&pte) + (addr & ((1 << PGSHIFT) - 1));
-       return (1);
-    } else if (IS_KSEG_VA(addr)) {
-       *ret = KSEG_TO_PHYS(addr);
-       return (1);
-    } else {
-       return (0);
-    }
-}
-#endif
-
 #ifndef AFS_KDUMP_LIB
 void
 kread(int kmem, off_t loc, void *buf, KDUMP_SIZE_T len)
@@ -2297,19 +2139,6 @@ kread(int kmem, off_t loc, void *buf, KDUMP_SIZE_T len)
 
     memset(buf, 0, len);
 
-#ifdef AFS_OSF_ENV
-    if (mem) {
-       unsigned long ret;
-       i = addr_to_offset(loc, &ret, kmem);
-       if (i == 1)
-           loc = ret;
-       else {
-           unsigned long loc1;
-           loc1 = coreadj(loc);
-           loc = loc1;
-       }
-    }
-#else
 #if    defined(sparc) && !defined(__linux__)
 #ifndef AFS_SUN5_ENV
     if (mem) {
@@ -2320,7 +2149,6 @@ kread(int kmem, off_t loc, void *buf, KDUMP_SIZE_T len)
     }
 #endif
 #endif
-#endif
 #if    ! defined(AFS_SUN5_ENV)
 #if defined(AFS_SGI61_ENV) && !defined(AFS_32BIT_KERNEL_ENV)
     if (lseek64(kmem, loc, L_SET /*0 */ ) != loc)
@@ -2675,13 +2503,13 @@ print_volume(int kmem, struct volume *vep, struct volume *ptr, int pnt)
           vep->backVol);
 #ifdef AFS33
     printf
-       ("\trwVol=%d, AcTime=%d, copyDate=%d, expTime=%d, vtix=%d, refC=%d, states=%x\n",
-        vep->rwVol, vep->accessTime, vep->copyDate, vep->expireTime,
+       ("\trwVol=%d, setupTime=%d, copyDate=%d, expTime=%d, vtix=%d, refC=%d, states=%x\n",
+        vep->rwVol, vep->setupTime, vep->copyDate, vep->expireTime,
         vep->vtix, vep->refCount, vep->states);
 #else
     printf
-       ("\trwVol=%d, AcTime=%d, copyDate=%d, vtix=%d, refC=%d, states=%x\n",
-        vep->rwVol, vep->accessTime, vep->copyDate, vep->vtix, vep->refCount,
+       ("\trwVol=%d, setupTime=%d, copyDate=%d, vtix=%d, refC=%d, states=%x\n",
+        vep->rwVol, vep->setupTime, vep->copyDate, vep->vtix, vep->refCount,
         vep->states);
 #endif
     printf("\tVolume's statuses: ");
@@ -3016,17 +2844,6 @@ print_vlru(int kmem)
     printf("\n\nPrinting vcache VLRU info (oldest first)...\n\n");
     findsym("afs_cacheStats", &symoff);
     kread(kmem, symoff, (char *)&maxvcount, sizeof maxvcount);
-#ifdef AFS_OSF_ENV
-    findsym("afs_maxvcount", &symoff);
-    kread(kmem, symoff, (char *)&maxvcount, sizeof maxvcount);
-    findsym("afs_vcount", &symoff);
-    kread(kmem, symoff, (char *)&vcount, sizeof vcount);
-    findsym("max_vnodes", &symoff);
-    kread(kmem, symoff, (char *)&nvnode, sizeof nvnode);
-    printf("max number of vcache entries = %d\n", maxvcount);
-    printf("number of vcaches in use = %d\n", vcount);
-    printf("total number of system vnode entries = %d\n", nvnode);
-#endif
     findsym("VLRU", &symoff);
     kread(kmem, symoff, (char *)&VLRU, sizeof VLRU);
     vlru_addr = (u_long) symoff;
@@ -3253,11 +3070,9 @@ print_global_afs_cache(int kmem)
     findsym("afs_mariner", &symoff);
     kread(kmem, symoff, (char *)&count, sizeof count);
     printf("\tafs_mariner = 0x%x\n", count);
-#ifndef        AFS_OSF_ENV
     findsym("freeVCList", &symoff);
     kread(kmem, symoff, (char *)&count, sizeof count);
     printf("\tafs_freeVCList = 0x%x XXX\n", count);
-#endif
     findsym("afs_freeDCList", &symoff);
     kread(kmem, symoff, (char *)&count, sizeof count);
     printf("\tfreeDCList = 0x%x\n", count);
@@ -4369,7 +4184,6 @@ print_cmstats(struct afs_CMStats *cmp)
     printf("\t%10d afs_ConnByHost\n", cmp->callInfo.C_afs_ConnByHost);
     printf("\t%10d afs_ConnByMHosts\n", cmp->callInfo.C_afs_ConnByMHosts);
     printf("\t%10d afs_Analyze\n", cmp->callInfo.C_afs_Analyze);
-    printf("\t%10d afs_CheckLocks\n", cmp->callInfo.C_afs_CheckLocks);
     printf("\t%10d CheckVLServer\n", cmp->callInfo.C_CheckVLServer);
     printf("\t%10d afs_CheckCacheResets\n",
           cmp->callInfo.C_afs_CheckCacheResets);