jonathan@jvc.UUCP (Jonathan Hue) (03/29/89)
Since ofiles (recently posted to comp.sources.unix) doesn't support SunOS 3.5, here is my attempt at getting it to work. A slightly different getuser() is needed, so I just stole it from "top". I also added an #ifdef DIRS_NOT_DEVS, if you want the cwd to come out as the inode for the directory, not the inode of the device in /dev it lives on. You can just cc -O -o ofiles ofiles.c on a machine running 3.5 and it should work (define DIRS_NOT_DEVS if you want to). It should still work on 4.0 if you add a -DsunOS4, but we don't have it, so it's not tested. -Jonathan uunet!jvc!jonathan ----------------------------------------------------------------------------- *** ofiles.c.orig Tue Mar 28 14:01:03 1989 --- ofiles.c Tue Mar 28 13:56:17 1989 *************** *** 94,100 **** --- 94,103 ---- #ifdef sun #include <sys/vnode.h> #include <ufs/inode.h> + #include "/sys/specfs/snode.h" + #ifdef sunOS4 #include <kvm.h> + kvm_t *kd; struct snode { struct snode *s_next; struct vnode s_vnode; *************** *** 103,109 **** u_short s_flag; dev_t s_dev; }; ! kvm_t *kd; #endif #ifdef ultrix --- 106,112 ---- u_short s_flag; dev_t s_dev; }; ! #endif #endif #ifdef ultrix *************** *** 343,349 **** goto usage; } ! #ifdef sun if ((kd = kvm_open (NULL, NULL, NULL, O_RDONLY)) == 0) { (void) fprintf(stderr, "%s: can't access memory: ", progname); --- 346,352 ---- goto usage; } ! #ifdef sunOS4 if ((kd = kvm_open (NULL, NULL, NULL, O_RDONLY)) == 0) { (void) fprintf(stderr, "%s: can't access memory: ", progname); *************** *** 434,440 **** flags = 0; if (p.p_stat == 0 || p.p_stat == SZOMB) continue; ! #ifdef sun u = kvm_getu(kd, &p); #else u = getuser(&p); --- 437,443 ---- flags = 0; if (p.p_stat == 0 || p.p_stat == SZOMB) continue; ! #ifdef sunOS4 u = kvm_getu(kd, &p); #else u = getuser(&p); *************** *** 448,460 **** --- 451,471 ---- if (!n_opt) { i = getinode(u->u_rdir, "rdir"); if (check(&s, i)) { + #ifdef DIRS_NOT_DEVS + dirinode = i->i_number; + #else dirinode = s.st_ino; + #endif gotone(u, &p, -1, RDIR); findf++; } i = getinode(u->u_cdir, "cdir"); if (check(&s, i)) { + #ifdef DIRS_NOT_DEVS + dirinode = i->i_number; + #else dirinode = s.st_ino; + #endif gotone(u, &p, -1, CDIR); findf++; } *************** *** 735,746 **** } #endif ! #if !defined(sun) /* * get user page for proc "p" from core or swap * return pointer to user struct */ ! #ifdef DYNIX struct user * getuser(p) struct proc *p; --- 746,757 ---- } #endif ! #if !defined(sunOS4) /* * get user page for proc "p" from core or swap * return pointer to user struct */ ! #if defined(DYNIX) || defined(sun) struct user * getuser(p) struct proc *p; *************** *** 783,788 **** --- 794,800 ---- if (debug) (void) printf("read swap\n"); } else { + #ifdef DYNIX if (k_opt) (void) lseek(kmem, vtophys((ls_t)p->p_uarea), L_SET); else *************** *** 789,794 **** --- 801,826 ---- (void) lseek(kmem, (ls_t)p->p_uarea, L_SET); if (read(kmem, (char *)u, btr) != btr) return (struct user *)NULL; + #else + struct pte uptes[UPAGES]; + register struct pte *pte; + register int n, nbytes; + register caddr_t upage; + + (void) lseek(kmem, p->p_addr, 0); + if (read(kmem, uptes, sizeof(uptes)) < 0) + return((struct user *) NULL); + upage = (caddr_t) u; + pte = uptes; + for (nbytes = sizeof(struct user); nbytes > 0; nbytes -= NBPG) + { + (void) lseek(mem, pte++->pg_pfnum * NBPG, 0); + n = MIN(nbytes, NBPG); + if (read(mem, upage, n) < 0) + return((struct user *) NULL); + upage += n; + } + #endif } return u; }