2 * node.c - common node reading functions for lsof
7 * Copyright 1994 Purdue Research Foundation, West Lafayette, Indiana
8 * 47907. All rights reserved.
10 * Written by Victor A. Abell
12 * This software is not subject to any license of the American Telephone
13 * and Telegraph Company or the Regents of the University of California.
15 * Permission is granted to anyone to use this software for any purpose on
16 * any computer system, and to alter it and redistribute it freely, subject
17 * to the following restrictions:
19 * 1. Neither the authors nor Purdue University are responsible for any
20 * consequences of the use of this software.
22 * 2. The origin of this software must not be misrepresented, either by
23 * explicit claim or by omission. Credit to the authors and Purdue
24 * University must appear in documentation and sources.
26 * 3. Altered versions must be plainly marked as such, and must not be
27 * misrepresented as being the original software.
29 * 4. This notice may not be removed or altered.
33 static char copyright[] =
34 "@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n";
35 static char *rcsid = "$Id: node.c,v 1.5 2000/08/01 17:08:05 abe Exp $";
43 * print_kptr() - print kernel pointer
47 print_kptr(kp, buf, bufl)
48 KA_T kp; /* kernel pointer address */
49 char *buf; /* optional destination buffer */
50 size_t bufl; /* size of buf[] */
54 (void) snpf(buf ? buf : dbuf,
55 buf ? bufl : sizeof(dbuf),
57 return(buf ? buf : dbuf);
61 #if defined(HASCDRNODE)
63 * readcdrnode() - read CD-ROM node
68 KA_T ca; /* cdrnode kernel address */
69 struct cdrnode *c; /* cdrnode buffer */
71 if (kread((KA_T)ca, (char *)c, sizeof(struct cdrnode))) {
72 (void) snpf(Namech, Namechl, "can't read cdrnode at %s",
73 print_kptr(ca, (char *)NULL, 0));
78 #endif /* defined(HASCDRNODE) */
81 #if defined(HASFIFONODE)
83 * readfifonode() - read fifonode
88 KA_T fa; /* fifonode kernel address */
89 struct fifonode *f; /* fifonode buffer */
91 if (kread((KA_T)fa, (char *)f, sizeof(struct fifonode))) {
92 (void) snpf(Namech, Namechl, "can't read fifonode at %s",
93 print_kptr(fa, (char *)NULL, 0));
98 #endif /* defined(HASFIFONODE) */
101 #if defined(HASGNODE)
103 * readgnode() - read gnode
108 KA_T ga; /* gnode kernel address */
109 struct gnode *g; /* gnode buffer */
111 if (kread((KA_T)ga, (char *)g, sizeof(struct gnode))) {
112 (void) snpf(Namech, Namechl, "can't read gnode at %s",
113 print_kptr(ga, (char *)NULL, 0));
118 #endif /* defined(HASGNODE) */
121 #if defined(HASHSNODE)
123 * readhsnode() - read High Sierra file system node
128 KA_T ha; /* hsnode kernel address */
129 struct hsnode *h; /* hsnode buffer */
131 if (kread((KA_T)ha, (char *)h, sizeof(struct hsnode))) {
132 (void) snpf(Namech, Namechl, "can't read hsnode at %s",
133 print_kptr(ha, (char *)NULL, 0));
138 #endif /* defined(HASHSNODE) */
141 #if defined(HASINODE)
143 * readinode() - read inode
148 KA_T ia; /* inode kernel address */
149 struct inode *i; /* inode buffer */
151 if (kread((KA_T)ia, (char *)i, sizeof(struct inode))) {
152 (void) snpf(Namech, Namechl, "can't read inode at %s",
153 print_kptr(ia, (char *)NULL, 0));
158 #endif /* defined(HASINODE) */
161 #if defined(HASPIPENODE)
163 * readpipenode() - read pipe node
168 KA_T pa; /* pipe node kernel address */
169 struct pipenode *p; /* pipe node buffer */
171 if (kread((KA_T)pa, (char *)p, sizeof(struct pipenode))) {
172 (void) snpf(Namech, Namechl, "can't read pipenode at %s",
173 print_kptr(pa, (char *)NULL, 0));
178 #endif /* defined(HASPIPENODE) */
181 #if defined(HASRNODE)
183 * readrnode() - read rnode
188 KA_T ra; /* rnode kernel space address */
189 struct rnode *r; /* rnode buffer pointer */
191 if (kread((KA_T)ra, (char *)r, sizeof(struct rnode))) {
192 (void) snpf(Namech, Namechl, "can't read rnode at %s",
193 print_kptr(ra, (char *)NULL, 0));
198 #endif /* defined(HASRNODE) */
201 #if defined(HASSNODE)
203 * readsnode() - read snode
208 KA_T sa; /* snode kernel space address */
209 struct snode *s; /* snode buffer pointer */
211 if (kread((KA_T)sa, (char *)s, sizeof(struct snode))) {
212 (void) snpf(Namech, Namechl, "can't read snode at %s",
213 print_kptr(sa, (char *)NULL, 0));
218 #endif /* defined(HASSNODE) */
221 #if defined(HASTMPNODE)
223 * readtnode() - read tmpnode
228 KA_T ta; /* tmpnode kernel space address */
229 struct tmpnode *t; /* tmpnode buffer pointer */
231 if (kread((KA_T)ta, (char *)t, sizeof(struct tmpnode))) {
232 (void) snpf(Namech, Namechl, "can't read tmpnode at %s",
233 print_kptr(ta, (char *)NULL, 0));
238 #endif /* defined(HASTMPNODE) */
241 #if defined(HASVNODE)
243 * readvnode() - read vnode
248 KA_T va; /* vnode kernel space address */
249 struct vnode *v; /* vnode buffer pointer */
251 if (kread((KA_T)va, (char *)v, sizeof(struct vnode))) {
252 (void) snpf(Namech, Namechl, "can't read vnode at %s",
253 print_kptr(va, (char *)NULL, 0));
258 #endif /* defined(HASVNODE) */