Changes as discussed with itojun on tech-kern. I have modified the enums

to have KFS or PFS differentiators.  Further I have wrapped the enum in
procfs in "#ifdef _KERNEL" as it is done in kernfs.

To see the discussion go to http://mail-index.NetBSD.org/tech-kern/2003/09/
and look for "Mismatched enums in include files" in the list.
This commit is contained in:
darcy 2003-09-27 13:29:02 +00:00
parent 3942bb7a51
commit 566d30be44
8 changed files with 243 additions and 241 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kernfs.h,v 1.19 2003/09/26 03:08:18 atatat Exp $ */
/* $NetBSD: kernfs.h,v 1.20 2003/09/27 13:29:02 darcy Exp $ */
/*
* Copyright (c) 1992, 1993
@ -43,20 +43,20 @@
* The different types of node in a kernfs filesystem
*/
typedef enum {
Kern, /* the filesystem itself (.) */
Kroot, /* the filesystem root (..) */
Knull, /* none aplicable */
Ktime, /* boottime */
Kint, /* integer */
Kstring, /* string */
Khostname, /* hostname */
Kavenrun, /* loadavg */
Kdevice, /* device file (rootdev/rrootdev) */
Kmsgbuf, /* msgbuf */
Kipsecsadir, /* ipsec security association (top dir) */
Kipsecspdir, /* ipsec security policy (top dir) */
Kipsecsa, /* ipsec security association entry */
Kipsecsp, /* ipsec security policy entry */
KFSkern, /* the filesystem itself (.) */
KFSroot, /* the filesystem root (..) */
KFSnull, /* none aplicable */
KFStime, /* boottime */
KFSint, /* integer */
KFSstring, /* string */
KFShostname, /* hostname */
KFSavenrun, /* loadavg */
KFSdevice, /* device file (rootdev/rrootdev) */
KFSmsgbuf, /* msgbuf */
KFSipsecsadir, /* ipsec security association (top dir) */
KFSipsecspdir, /* ipsec security policy (top dir) */
KFSipsecsa, /* ipsec security association entry */
KFSipsecsp, /* ipsec security policy entry */
} kfstype;
/*
@ -79,7 +79,7 @@ struct kernfs_node {
kfstype kfs_type; /* type of procfs node */
mode_t kfs_mode; /* mode bits for stat() */
long kfs_fileno; /* unique file id */
u_int32_t kfs_value; /* SA id or SP id (Kint) */
u_int32_t kfs_value; /* SA id or SP id (KFSint) */
const struct kern_target *kfs_kt;
void *kfs_v; /* pointer to secasvar/secpolicy/mbuf */
long kfs_cookie; /* fileno cookie */

View File

@ -1,4 +1,4 @@
/* $NetBSD: kernfs_subr.c,v 1.4 2003/09/26 03:08:18 atatat Exp $ */
/* $NetBSD: kernfs_subr.c,v 1.5 2003/09/27 13:29:02 darcy Exp $ */
/*
* Copyright (c) 1993
@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kernfs_subr.c,v 1.4 2003/09/26 03:08:18 atatat Exp $");
__KERNEL_RCSID(0, "$NetBSD: kernfs_subr.c,v 1.5 2003/09/27 13:29:02 darcy Exp $");
#ifdef _KERNEL_OPT
#include "opt_ipsec.h"
@ -160,7 +160,7 @@ kernfs_allocvp(mp, vpp, kfs_type, kt, value)
return (0);
} while (lockmgr(&kfs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, 0));
if (kfs_type == Kdevice) {
if (kfs_type == KFSdevice) {
/* /kern/rootdev = look for device and obey */
/* /kern/rrootdev = look for device and obey */
dev_t *dp;
@ -168,7 +168,7 @@ kernfs_allocvp(mp, vpp, kfs_type, kt, value)
#ifdef DIAGNOSTIC
if (!kt)
panic("kernfs: kt == NULL for Kdevice");
panic("kernfs: kt == NULL for KFSdevice");
#endif
dp = kt->kt_data;
loop:
@ -227,35 +227,35 @@ again:
kfs->kfs_kt = kt;
switch (kfs_type) {
case Kern: /* /kern = dr-xr-xr-x */
case KFSkern: /* /kern = dr-xr-xr-x */
kfs->kfs_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
vp->v_type = VDIR;
vp->v_flag = VROOT;
break;
case Knull: /* /kern/?? = -r--r--r-- */
case Ktime: /* /kern/time = -r--r--r-- */
case Kint: /* /kern/?? = -r--r--r-- */
case Kstring: /* /kern/?? = -r--r--r-- */
case Kavenrun: /* /kern/loadavg = -r--r--r-- */
case Kmsgbuf: /* /kern/msgbuf = -r--r--r-- */
case KFSnull: /* /kern/?? = -r--r--r-- */
case KFStime: /* /kern/time = -r--r--r-- */
case KFSint: /* /kern/?? = -r--r--r-- */
case KFSstring: /* /kern/?? = -r--r--r-- */
case KFSavenrun: /* /kern/loadavg = -r--r--r-- */
case KFSmsgbuf: /* /kern/msgbuf = -r--r--r-- */
kfs->kfs_mode = S_IRUSR|S_IRGRP|S_IROTH;
vp->v_type = VREG;
break;
case Kipsecsadir: /* /kern/ipsecsa = dr-x------ */
case Kipsecspdir: /* /kern/ipsecsp = dr-x------ */
case KFSipsecsadir: /* /kern/ipsecsa = dr-x------ */
case KFSipsecspdir: /* /kern/ipsecsp = dr-x------ */
kfs->kfs_mode = S_IRUSR|S_IXUSR;
vp->v_type = VDIR;
break;
case Kipsecsa: /* /kern/ipsecsa/N = -r-------- */
case Kipsecsp: /* /kern/ipsecsp/N = -r-------- */
case KFSipsecsa: /* /kern/ipsecsa/N = -r-------- */
case KFSipsecsp: /* /kern/ipsecsp/N = -r-------- */
kfs->kfs_mode = S_IRUSR;
vp->v_type = VREG;
break;
case Khostname: /* /kern/hostname = -rw-r-r--- */
case KFShostname: /* /kern/hostname = -rw-r-r--- */
kfs->kfs_mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH;
vp->v_type = VREG;
break;
@ -408,7 +408,7 @@ kernfs_revoke_sa(sav)
for (kfs = LIST_FIRST(ppp); kfs; kfs = pnext) {
vp = KERNFSTOV(kfs);
pnext = LIST_NEXT(kfs, kfs_hash);
if (vp->v_usecount > 0 && kfs->kfs_type == Kipsecsa &&
if (vp->v_usecount > 0 && kfs->kfs_type == KFSipsecsa &&
kfs->kfs_value == ntohl(sav->spi)) {
m = key_setdumpsa_spi(sav->spi);
if (!m)
@ -432,7 +432,7 @@ kernfs_revoke_sp(sp)
for (kfs = LIST_FIRST(ppp); kfs; kfs = pnext) {
vp = KERNFSTOV(kfs);
pnext = LIST_NEXT(kfs, kfs_hash);
if (vp->v_usecount > 0 && kfs->kfs_type == Kipsecsa &&
if (vp->v_usecount > 0 && kfs->kfs_type == KFSipsecsa &&
kfs->kfs_value == sp->id)
VOP_REVOKE(vp, REVOKEALL);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: kernfs_vfsops.c,v 1.55 2003/09/26 03:08:18 atatat Exp $ */
/* $NetBSD: kernfs_vfsops.c,v 1.56 2003/09/27 13:29:02 darcy Exp $ */
/*
* Copyright (c) 1992, 1993, 1995
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.55 2003/09/26 03:08:18 atatat Exp $");
__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.56 2003/09/27 13:29:02 darcy Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@ -209,7 +209,7 @@ kernfs_root(mp, vpp)
{
/* setup "." */
return (kernfs_allocvp(mp, vpp, Kern, &kern_targets[0], 0));
return (kernfs_allocvp(mp, vpp, KFSkern, &kern_targets[0], 0));
}
int

View File

@ -1,4 +1,4 @@
/* $NetBSD: kernfs_vnops.c,v 1.97 2003/09/26 03:08:18 atatat Exp $ */
/* $NetBSD: kernfs_vnops.c,v 1.98 2003/09/27 13:29:02 darcy Exp $ */
/*
* Copyright (c) 1992, 1993
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.97 2003/09/26 03:08:18 atatat Exp $");
__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.98 2003/09/27 13:29:02 darcy Exp $");
#ifdef _KERNEL_OPT
#include "opt_ipsec.h"
@ -86,44 +86,44 @@ __KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.97 2003/09/26 03:08:18 atatat Exp
const struct kern_target kern_targets[] = {
/* NOTE: The name must be less than UIO_MX-16 chars in length */
/* name data tag type ro/rw */
{ DT_DIR, N("."), 0, Kern, VDIR, DIR_MODE },
{ DT_DIR, N(".."), 0, Kroot, VDIR, DIR_MODE },
{ DT_REG, N("boottime"), &boottime.tv_sec, Kint, VREG, READ_MODE },
{ DT_DIR, N("."), 0, KFSkern, VDIR, DIR_MODE },
{ DT_DIR, N(".."), 0, KFSroot, VDIR, DIR_MODE },
{ DT_REG, N("boottime"), &boottime.tv_sec, KFSint, VREG, READ_MODE },
/* XXX cast away const */
{ DT_REG, N("copyright"), (void *)copyright,
Kstring, VREG, READ_MODE },
{ DT_REG, N("hostname"), 0, Khostname, VREG, WRITE_MODE },
{ DT_REG, N("hz"), &hz, Kint, VREG, READ_MODE },
KFSstring, VREG, READ_MODE },
{ DT_REG, N("hostname"), 0, KFShostname, VREG, WRITE_MODE },
{ DT_REG, N("hz"), &hz, KFSint, VREG, READ_MODE },
#ifdef IPSEC
{ DT_DIR, N("ipsecsa"), 0, Kipsecsadir, VDIR, UDIR_MODE },
{ DT_DIR, N("ipsecsp"), 0, Kipsecspdir, VDIR, UDIR_MODE },
{ DT_DIR, N("ipsecsa"), 0, KFSipsecsadir, VDIR, UDIR_MODE },
{ DT_DIR, N("ipsecsp"), 0, KFSipsecspdir, VDIR, UDIR_MODE },
#endif
{ DT_REG, N("loadavg"), 0, Kavenrun, VREG, READ_MODE },
{ DT_REG, N("msgbuf"), 0, Kmsgbuf, VREG, READ_MODE },
{ DT_REG, N("pagesize"), &uvmexp.pagesize, Kint, VREG, READ_MODE },
{ DT_REG, N("physmem"), &physmem, Kint, VREG, READ_MODE },
{ DT_REG, N("loadavg"), 0, KFSavenrun, VREG, READ_MODE },
{ DT_REG, N("msgbuf"), 0, KFSmsgbuf, VREG, READ_MODE },
{ DT_REG, N("pagesize"), &uvmexp.pagesize, KFSint, VREG, READ_MODE },
{ DT_REG, N("physmem"), &physmem, KFSint, VREG, READ_MODE },
#if 0
{ DT_DIR, N("root"), 0, Knull, VDIR, DIR_MODE },
{ DT_DIR, N("root"), 0, KFSnull, VDIR, DIR_MODE },
#endif
{ DT_BLK, N("rootdev"), &rootdev, Kdevice, VBLK, READ_MODE },
{ DT_CHR, N("rrootdev"), &rrootdev, Kdevice, VCHR, READ_MODE },
{ DT_REG, N("time"), 0, Ktime, VREG, READ_MODE },
{ DT_BLK, N("rootdev"), &rootdev, KFSdevice, VBLK, READ_MODE },
{ DT_CHR, N("rrootdev"), &rrootdev, KFSdevice, VCHR, READ_MODE },
{ DT_REG, N("time"), 0, KFStime, VREG, READ_MODE },
/* XXX cast away const */
{ DT_REG, N("version"), (void *)version,
Kstring, VREG, READ_MODE },
KFSstring, VREG, READ_MODE },
};
#ifdef IPSEC
const struct kern_target ipsecsa_targets[] = {
/* NOTE: The name must be less than UIO_MX-16 chars in length */
/* name data tag type ro/rw */
{ DT_DIR, N("."), 0, Kipsecsadir, VDIR, DIR_MODE },
{ DT_DIR, N(".."), 0, Kern, VDIR, DIR_MODE },
{ DT_DIR, N("."), 0, KFSipsecsadir, VDIR, DIR_MODE },
{ DT_DIR, N(".."), 0, KFSkern, VDIR, DIR_MODE },
};
const struct kern_target ipsecsp_targets[] = {
/* NOTE: The name must be less than UIO_MX-16 chars in length */
/* name data tag type ro/rw */
{ DT_DIR, N("."), 0, Kipsecspdir, VDIR, DIR_MODE },
{ DT_DIR, N(".."), 0, Kern, VDIR, DIR_MODE },
{ DT_DIR, N("."), 0, KFSipsecspdir, VDIR, DIR_MODE },
{ DT_DIR, N(".."), 0, KFSkern, VDIR, DIR_MODE },
};
#endif
#undef N
@ -246,7 +246,7 @@ kernfs_xread(kfs, off, bufp, len, wrlen)
kt = kfs->kfs_kt;
switch (kfs->kfs_type) {
case Ktime: {
case KFStime: {
struct timeval tv;
microtime(&tv);
@ -254,21 +254,21 @@ kernfs_xread(kfs, off, bufp, len, wrlen)
break;
}
case Kint: {
case KFSint: {
int *ip = kt->kt_data;
snprintf(*bufp, len, "%d\n", *ip);
break;
}
case Kstring: {
case KFSstring: {
char *cp = kt->kt_data;
*bufp = cp;
break;
}
case Kmsgbuf: {
case KFSmsgbuf: {
long n;
/*
@ -302,7 +302,7 @@ kernfs_xread(kfs, off, bufp, len, wrlen)
return (0);
}
case Khostname: {
case KFShostname: {
char *cp = hostname;
int xlen = hostnamelen;
@ -316,7 +316,7 @@ kernfs_xread(kfs, off, bufp, len, wrlen)
break;
}
case Kavenrun:
case KFSavenrun:
averunnable.fscale = FSCALE;
snprintf(*bufp, len, "%d %d %d %ld\n",
averunnable.ldavg[0], averunnable.ldavg[1],
@ -324,7 +324,7 @@ kernfs_xread(kfs, off, bufp, len, wrlen)
break;
#ifdef IPSEC
case Kipsecsa:
case KFSipsecsa:
/*
* Note that SA configuration could be changed during the
* read operation, resulting in garbled output.
@ -344,7 +344,7 @@ kernfs_xread(kfs, off, bufp, len, wrlen)
m_freem(m);
return (0);
case Kipsecsp:
case KFSipsecsp:
/*
* Note that SP configuration could be changed during the
* read operation, resulting in garbled output.
@ -398,7 +398,7 @@ kernfs_xwrite(kfs, buf, len)
{
switch (kfs->kfs_type) {
case Khostname:
case KFShostname:
if (buf[len-1] == '\n')
--len;
memcpy(hostname, buf, len);
@ -452,7 +452,7 @@ kernfs_lookup(v)
wantpunlock = (~cnp->cn_flags & (LOCKPARENT | ISLASTCN));
kfs = VTOKERN(dvp);
switch (kfs->kfs_type) {
case Kern:
case KFSkern:
/*
* Shouldn't get here with .. in the root node.
*/
@ -476,7 +476,7 @@ kernfs_lookup(v)
return (error);
#ifdef IPSEC
case Kipsecsadir:
case KFSipsecsadir:
for (i = 0; i < nipsecsa_targets; i++) {
kt = &ipsecsa_targets[i];
if (cnp->cn_namelen == kt->kt_namlen &&
@ -496,14 +496,14 @@ kernfs_lookup(v)
if (!ep || *ep || ep == pname)
break;
error = kernfs_allocvp(dvp->v_mount, vpp, Kipsecsa, NULL, id);
error = kernfs_allocvp(dvp->v_mount, vpp, KFSipsecsa, NULL, id);
if ((error == 0) && wantpunlock) {
VOP_UNLOCK(dvp, 0);
cnp->cn_flags |= PDIRUNLOCK;
}
return (error);
case Kipsecspdir:
case KFSipsecspdir:
for (i = 0; i < nipsecsp_targets; i++) {
kt = &ipsecsp_targets[i];
if (cnp->cn_namelen == kt->kt_namlen &&
@ -523,7 +523,7 @@ kernfs_lookup(v)
if (!ep || *ep || ep == pname)
break;
error = kernfs_allocvp(dvp->v_mount, vpp, Kipsecsp, NULL, id);
error = kernfs_allocvp(dvp->v_mount, vpp, KFSipsecsp, NULL, id);
if ((error == 0) && wantpunlock) {
VOP_UNLOCK(dvp, 0);
cnp->cn_flags |= PDIRUNLOCK;
@ -556,7 +556,7 @@ kernfs_open(v)
switch (kfs->kfs_type) {
#ifdef IPSEC
case Kipsecsa:
case KFSipsecsa:
m = key_setdumpsa_spi(htonl(kfs->kfs_value));
if (m) {
m_freem(m);
@ -564,7 +564,7 @@ kernfs_open(v)
} else
return (ENOENT);
case Kipsecsp:
case KFSipsecsp:
sp = key_getspbyid(kfs->kfs_value);
if (sp) {
kfs->kfs_v = sp;
@ -592,7 +592,7 @@ kernfs_close(v)
switch (kfs->kfs_type) {
#ifdef IPSEC
case Kipsecsp:
case KFSipsecsp:
key_freesp((struct secpolicy *)kfs->kfs_v);
break;
#endif
@ -668,7 +668,7 @@ kernfs_getattr(v)
vap->va_bytes = 0;
switch (kfs->kfs_type) {
case Kern:
case KFSkern:
#ifdef IPSEC
vap->va_nlink = 4; /* 2 extra subdirs */
#else
@ -677,22 +677,22 @@ kernfs_getattr(v)
vap->va_bytes = vap->va_size = DEV_BSIZE;
break;
case Kroot:
case KFSroot:
vap->va_nlink = 1;
vap->va_bytes = vap->va_size = DEV_BSIZE;
break;
case Knull:
case Ktime:
case Kint:
case Kstring:
case Khostname:
case Kavenrun:
case Kdevice:
case Kmsgbuf:
case KFSnull:
case KFStime:
case KFSint:
case KFSstring:
case KFShostname:
case KFSavenrun:
case KFSdevice:
case KFSmsgbuf:
#ifdef IPSEC
case Kipsecsa:
case Kipsecsp:
case KFSipsecsa:
case KFSipsecsp:
#endif
vap->va_nlink = 1;
total = 0;
@ -706,8 +706,8 @@ kernfs_getattr(v)
break;
#ifdef IPSEC
case Kipsecsadir:
case Kipsecspdir:
case KFSipsecsadir:
case KFSipsecspdir:
vap->va_nlink = 2;
vap->va_bytes = vap->va_size = DEV_BSIZE;
break;
@ -830,7 +830,7 @@ kernfs_readdir(v)
ncookies = uio->uio_resid / UIO_MX;
switch (kfs->kfs_type) {
case Kern:
case KFSkern:
if (i >= nkern_targets)
return (0);
@ -844,7 +844,7 @@ kernfs_readdir(v)
n = 0;
for (; i < nkern_targets && uio->uio_resid >= UIO_MX; i++) {
kt = &kern_targets[i];
if (kt->kt_tag == Kdevice) {
if (kt->kt_tag == KFSdevice) {
dev_t *dp = kt->kt_data;
struct vnode *fvp;
@ -869,7 +869,7 @@ kernfs_readdir(v)
ncookies = n;
break;
case Kroot:
case KFSroot:
if (i >= 2)
return 0;
@ -897,7 +897,7 @@ kernfs_readdir(v)
break;
#ifdef IPSEC
case Kipsecsadir:
case KFSipsecsadir:
/* count SA in the system */
n = 0;
TAILQ_FOREACH(sav, &satailq, tailq) {
@ -969,7 +969,7 @@ kernfs_readdir(v)
ncookies = n;
break;
case Kipsecspdir:
case KFSipsecspdir:
/* count SP in the system */
n = 0;
TAILQ_FOREACH(sp, &sptailq, tailq)
@ -1059,14 +1059,14 @@ kernfs_inactive(v)
VOP_UNLOCK(vp, 0);
switch (kfs->kfs_type) {
#ifdef IPSEC
case Kipsecsa:
case KFSipsecsa:
m = key_setdumpsa_spi(htonl(kfs->kfs_value));
if (m)
m_freem(m);
else
vgone(vp);
break;
case Kipsecsp:
case KFSipsecsp:
sp = key_getspbyid(kfs->kfs_value);
if (sp)
key_freesp(sp);

View File

@ -1,4 +1,4 @@
/* $NetBSD: procfs.h,v 1.48 2003/08/07 16:32:41 agc Exp $ */
/* $NetBSD: procfs.h,v 1.49 2003/09/27 13:29:02 darcy Exp $ */
/*
* Copyright (c) 1993
@ -74,34 +74,36 @@
/* This also pulls in __HAVE_PROCFS_MACHDEP */
#include <sys/ptrace.h>
#ifdef _KERNEL
/*
* The different types of node in a procfs filesystem
*/
typedef enum {
Proot, /* the filesystem root */
Pcurproc, /* symbolic link for curproc */
Pself, /* like curproc, but this is the Linux name */
Pproc, /* a process-specific sub-directory */
Pfile, /* the executable file */
Pmem, /* the process's memory image */
Pregs, /* the process's register set */
Pfpregs, /* the process's FP register set */
Pctl, /* process control */
Pstat, /* process status (if -o linux) */
Pstatus, /* process status */
Pnote, /* process notifier */
Pnotepg, /* process group notifier */
Pmap, /* memory map */
Pcmdline, /* process command line args */
Pmeminfo, /* system memory info (if -o linux) */
Pcpuinfo, /* CPU info (if -o linux) */
Pmaps, /* memory map, Linux style (if -o linux) */
Pfd, /* a directory containing the processes open fd's */
Puptime, /* elapsed time since (if -o linux) */
PFSroot, /* the filesystem root */
PFScurproc, /* symbolic link for curproc */
PFSself, /* like curproc, but this is the Linux name */
PFSproc, /* a process-specific sub-directory */
PFSfile, /* the executable file */
PFSmem, /* the process's memory image */
PFSregs, /* the process's register set */
PFSfpregs, /* the process's FP register set */
PFSctl, /* process control */
PFSstat, /* process status (if -o linux) */
PFSstatus, /* process status */
PFSnote, /* process notifier */
PFSnotepg, /* process group notifier */
PFSmap, /* memory map */
PFScmdline, /* process command line args */
PFSmeminfo, /* system memory info (if -o linux) */
PFScpuinfo, /* CPU info (if -o linux) */
PFSmaps, /* memory map, Linux style (if -o linux) */
PFSfd, /* a directory containing the processes open fd's */
PFSuptime, /* elapsed time since (if -o linux) */
#ifdef __HAVE_PROCFS_MACHDEP
PROCFS_MACHDEP_NODE_TYPES
#endif
} pfstype;
#endif
/*
* control data for the proc file system.
@ -143,7 +145,7 @@ struct procfs_args {
#define UIO_MX 32
#define PROCFS_FILENO(pid, type, fd) \
(((type) < Pproc) ? ((type) + 2) : \
(((type) < PFSproc) ? ((type) + 2) : \
(((fd) == -1) ? ((((pid)+1) << 5) + ((int) (type))) : \
((((pid)+1) << 16) | ((fd) << 5) | ((int) (type)))))

View File

@ -1,4 +1,4 @@
/* $NetBSD: procfs_subr.c,v 1.57 2003/08/07 16:32:42 agc Exp $ */
/* $NetBSD: procfs_subr.c,v 1.58 2003/09/27 13:29:02 darcy Exp $ */
/*
* Copyright (c) 1993
@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.57 2003/08/07 16:32:42 agc Exp $");
__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.58 2003/09/27 13:29:02 darcy Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -161,20 +161,20 @@ procfs_allocvp(mp, vpp, pid, pfs_type, fd)
pfs->pfs_fd = fd;
switch (pfs_type) {
case Proot: /* /proc = dr-xr-xr-x */
case PFSroot: /* /proc = dr-xr-xr-x */
pfs->pfs_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
vp->v_type = VDIR;
vp->v_flag = VROOT;
break;
case Pcurproc: /* /proc/curproc = lr-xr-xr-x */
case Pself: /* /proc/self = lr-xr-xr-x */
case PFScurproc: /* /proc/curproc = lr-xr-xr-x */
case PFSself: /* /proc/self = lr-xr-xr-x */
pfs->pfs_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
vp->v_type = VLNK;
break;
case Pproc: /* /proc/N = dr-xr-xr-x */
case Pfd:
case PFSproc: /* /proc/N = dr-xr-xr-x */
case PFSfd:
if (fd == -1) { /* /proc/N/fd = dr-xr-xr-x */
pfs->pfs_mode = S_IRUSR|S_IXUSR;
vp->v_type = VDIR;
@ -223,29 +223,29 @@ procfs_allocvp(mp, vpp, pid, pfs_type, fd)
}
break;
case Pfile: /* /proc/N/file = -rw------- */
case Pmem: /* /proc/N/mem = -rw------- */
case Pregs: /* /proc/N/regs = -rw------- */
case Pfpregs: /* /proc/N/fpregs = -rw------- */
case PFSfile: /* /proc/N/file = -rw------- */
case PFSmem: /* /proc/N/mem = -rw------- */
case PFSregs: /* /proc/N/regs = -rw------- */
case PFSfpregs: /* /proc/N/fpregs = -rw------- */
pfs->pfs_mode = S_IRUSR|S_IWUSR;
vp->v_type = VREG;
break;
case Pctl: /* /proc/N/ctl = --w------ */
case Pnote: /* /proc/N/note = --w------ */
case Pnotepg: /* /proc/N/notepg = --w------ */
case PFSctl: /* /proc/N/ctl = --w------ */
case PFSnote: /* /proc/N/note = --w------ */
case PFSnotepg: /* /proc/N/notepg = --w------ */
pfs->pfs_mode = S_IWUSR;
vp->v_type = VREG;
break;
case Pmap: /* /proc/N/map = -r--r--r-- */
case Pmaps: /* /proc/N/maps = -r--r--r-- */
case Pstatus: /* /proc/N/status = -r--r--r-- */
case Pstat: /* /proc/N/stat = -r--r--r-- */
case Pcmdline: /* /proc/N/cmdline = -r--r--r-- */
case Pmeminfo: /* /proc/meminfo = -r--r--r-- */
case Pcpuinfo: /* /proc/cpuinfo = -r--r--r-- */
case Puptime: /* /proc/uptime = -r--r--r-- */
case PFSmap: /* /proc/N/map = -r--r--r-- */
case PFSmaps: /* /proc/N/maps = -r--r--r-- */
case PFSstatus: /* /proc/N/status = -r--r--r-- */
case PFSstat: /* /proc/N/stat = -r--r--r-- */
case PFScmdline: /* /proc/N/cmdline = -r--r--r-- */
case PFSmeminfo: /* /proc/meminfo = -r--r--r-- */
case PFScpuinfo: /* /proc/cpuinfo = -r--r--r-- */
case PFSuptime: /* /proc/uptime = -r--r--r-- */
pfs->pfs_mode = S_IRUSR|S_IRGRP|S_IROTH;
vp->v_type = VREG;
break;
@ -311,9 +311,9 @@ procfs_rw(v)
l = proc_representative_lwp(p);
switch (pfs->pfs_type) {
case Pregs:
case Pfpregs:
case Pmem:
case PFSregs:
case PFSfpregs:
case PFSmem:
#if defined(__HAVE_PROCFS_MACHDEP) && defined(PROCFS_MACHDEP_PROTECT_CASES)
PROCFS_MACHDEP_PROTECT_CASES
#endif
@ -331,47 +331,47 @@ procfs_rw(v)
}
switch (pfs->pfs_type) {
case Pnote:
case Pnotepg:
case PFSnote:
case PFSnotepg:
return (procfs_donote(curp, p, pfs, uio));
case Pregs:
case PFSregs:
return (procfs_doregs(curp, l, pfs, uio));
case Pfpregs:
case PFSfpregs:
return (procfs_dofpregs(curp, l, pfs, uio));
case Pctl:
case PFSctl:
return (procfs_doctl(curp, l, pfs, uio));
case Pstatus:
case PFSstatus:
return (procfs_dostatus(curp, l, pfs, uio));
case Pstat:
case PFSstat:
return (procfs_do_pid_stat(curp, l, pfs, uio));
case Pmap:
case PFSmap:
return (procfs_domap(curp, p, pfs, uio, 0));
case Pmaps:
case PFSmaps:
return (procfs_domap(curp, p, pfs, uio, 1));
case Pmem:
case PFSmem:
return (procfs_domem(curp, p, pfs, uio));
case Pcmdline:
case PFScmdline:
return (procfs_docmdline(curp, p, pfs, uio));
case Pmeminfo:
case PFSmeminfo:
return (procfs_domeminfo(curp, p, pfs, uio));
case Pcpuinfo:
case PFScpuinfo:
return (procfs_docpuinfo(curp, p, pfs, uio));
case Pfd:
case PFSfd:
return (procfs_dofd(curp, p, pfs, uio));
case Puptime:
case PFSuptime:
return (procfs_douptime(curp, p, pfs, uio));
#ifdef __HAVE_PROCFS_MACHDEP

View File

@ -1,4 +1,4 @@
/* $NetBSD: procfs_vfsops.c,v 1.49 2003/08/07 16:32:42 agc Exp $ */
/* $NetBSD: procfs_vfsops.c,v 1.50 2003/09/27 13:29:02 darcy Exp $ */
/*
* Copyright (c) 1993
@ -76,7 +76,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.49 2003/08/07 16:32:42 agc Exp $");
__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.50 2003/09/27 13:29:02 darcy Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@ -208,7 +208,7 @@ procfs_root(mp, vpp)
struct vnode **vpp;
{
return (procfs_allocvp(mp, vpp, 0, Proot, -1));
return (procfs_allocvp(mp, vpp, 0, PFSroot, -1));
}
/* ARGSUSED */

View File

@ -1,4 +1,4 @@
/* $NetBSD: procfs_vnops.c,v 1.108 2003/09/07 00:25:04 itojun Exp $ */
/* $NetBSD: procfs_vnops.c,v 1.109 2003/09/27 13:29:02 darcy Exp $ */
/*
* Copyright (c) 1993, 1995
@ -76,7 +76,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.108 2003/09/07 00:25:04 itojun Exp $");
__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.109 2003/09/27 13:29:02 darcy Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -122,22 +122,22 @@ static const struct proc_target {
} proc_targets[] = {
#define N(s) sizeof(s)-1, s
/* name type validp */
{ DT_DIR, N("."), Pproc, NULL },
{ DT_DIR, N(".."), Proot, NULL },
{ DT_DIR, N("fd"), Pfd, NULL },
{ DT_REG, N("file"), Pfile, procfs_validfile },
{ DT_REG, N("mem"), Pmem, NULL },
{ DT_REG, N("regs"), Pregs, procfs_validregs },
{ DT_REG, N("fpregs"), Pfpregs, procfs_validfpregs },
{ DT_REG, N("ctl"), Pctl, NULL },
{ DT_REG, N("stat"), Pstat, procfs_validfile_linux },
{ DT_REG, N("status"), Pstatus, NULL },
{ DT_REG, N("note"), Pnote, NULL },
{ DT_REG, N("notepg"), Pnotepg, NULL },
{ DT_REG, N("map"), Pmap, procfs_validmap },
{ DT_REG, N("maps"), Pmaps, procfs_validmap },
{ DT_REG, N("cmdline"), Pcmdline, NULL },
{ DT_REG, N("exe"), Pfile, procfs_validfile_linux },
{ DT_DIR, N("."), PFSproc, NULL },
{ DT_DIR, N(".."), PFSroot, NULL },
{ DT_DIR, N("fd"), PFSfd, NULL },
{ DT_REG, N("file"), PFSfile, procfs_validfile },
{ DT_REG, N("mem"), PFSmem, NULL },
{ DT_REG, N("regs"), PFSregs, procfs_validregs },
{ DT_REG, N("fpregs"), PFSfpregs, procfs_validfpregs },
{ DT_REG, N("ctl"), PFSctl, NULL },
{ DT_REG, N("stat"), PFSstat, procfs_validfile_linux },
{ DT_REG, N("status"), PFSstatus, NULL },
{ DT_REG, N("note"), PFSnote, NULL },
{ DT_REG, N("notepg"), PFSnotepg, NULL },
{ DT_REG, N("map"), PFSmap, procfs_validmap },
{ DT_REG, N("maps"), PFSmaps, procfs_validmap },
{ DT_REG, N("cmdline"), PFScmdline, NULL },
{ DT_REG, N("exe"), PFSfile, procfs_validfile_linux },
#ifdef __HAVE_PROCFS_MACHDEP
PROCFS_MACHDEP_NODETYPE_DEFNS
#endif
@ -152,9 +152,9 @@ static const int nproc_targets = sizeof(proc_targets) / sizeof(proc_targets[0]);
static const struct proc_target proc_root_targets[] = {
#define N(s) sizeof(s)-1, s
/* name type validp */
{ DT_REG, N("meminfo"), Pmeminfo, procfs_validfile_linux },
{ DT_REG, N("cpuinfo"), Pcpuinfo, procfs_validfile_linux },
{ DT_REG, N("uptime"), Puptime, procfs_validfile_linux },
{ DT_REG, N("meminfo"), PFSmeminfo, procfs_validfile_linux },
{ DT_REG, N("cpuinfo"), PFScpuinfo, procfs_validfile_linux },
{ DT_REG, N("uptime"), PFSuptime, procfs_validfile_linux },
#undef N
};
static const int nproc_root_targets =
@ -288,7 +288,7 @@ procfs_open(v)
return (ENOENT); /* was ESRCH, jsp */
switch (pfs->pfs_type) {
case Pmem:
case PFSmem:
if (((pfs->pfs_flags & FWRITE) && (ap->a_mode & O_EXCL)) ||
((pfs->pfs_flags & O_EXCL) && (ap->a_mode & FWRITE)))
return (EBUSY);
@ -328,7 +328,7 @@ procfs_close(v)
struct pfsnode *pfs = VTOPFS(ap->a_vp);
switch (pfs->pfs_type) {
case Pmem:
case PFSmem:
if ((ap->a_fflag & FWRITE) && (pfs->pfs_flags & O_EXCL))
pfs->pfs_flags &= ~(FWRITE|O_EXCL);
break;
@ -509,9 +509,9 @@ procfs_getattr(v)
/* first check the process still exists */
switch (pfs->pfs_type) {
case Proot:
case Pcurproc:
case Pself:
case PFSroot:
case PFScurproc:
case PFSself:
procp = 0;
break;
@ -549,9 +549,9 @@ procfs_getattr(v)
vap->va_atime = vap->va_mtime = vap->va_ctime;
switch (pfs->pfs_type) {
case Pmem:
case Pregs:
case Pfpregs:
case PFSmem:
case PFSregs:
case PFSfpregs:
#if defined(__HAVE_PROCFS_MACHDEP) && defined(PROCFS_MACHDEP_PROTECT_CASES)
PROCFS_MACHDEP_PROTECT_CASES
#endif
@ -563,21 +563,21 @@ procfs_getattr(v)
if (procp->p_flag & P_SUGID)
vap->va_mode &= ~(S_IRUSR|S_IWUSR);
/* FALLTHROUGH */
case Pctl:
case Pstatus:
case Pstat:
case Pnote:
case Pnotepg:
case Pmap:
case Pmaps:
case Pcmdline:
case PFSctl:
case PFSstatus:
case PFSstat:
case PFSnote:
case PFSnotepg:
case PFSmap:
case PFSmaps:
case PFScmdline:
vap->va_nlink = 1;
vap->va_uid = procp->p_ucred->cr_uid;
vap->va_gid = procp->p_ucred->cr_gid;
break;
case Pmeminfo:
case Pcpuinfo:
case Puptime:
case PFSmeminfo:
case PFScpuinfo:
case PFSuptime:
vap->va_nlink = 1;
vap->va_uid = vap->va_gid = 0;
break;
@ -597,7 +597,7 @@ procfs_getattr(v)
*/
switch (pfs->pfs_type) {
case Proot:
case PFSroot:
/*
* Set nlink to 1 to tell fts(3) we don't actually know.
*/
@ -607,7 +607,7 @@ procfs_getattr(v)
vap->va_bytes = vap->va_size = DEV_BSIZE;
break;
case Pcurproc: {
case PFScurproc: {
char buf[16]; /* should be enough */
vap->va_nlink = 1;
vap->va_uid = 0;
@ -617,14 +617,14 @@ procfs_getattr(v)
break;
}
case Pself:
case PFSself:
vap->va_nlink = 1;
vap->va_uid = 0;
vap->va_gid = 0;
vap->va_bytes = vap->va_size = sizeof("curproc");
break;
case Pfd:
case PFSfd:
if (pfs->pfs_fd != -1) {
struct file *fp;
struct proc *pown;
@ -648,18 +648,18 @@ procfs_getattr(v)
break;
}
/*FALLTHROUGH*/
case Pproc:
case PFSproc:
vap->va_nlink = 2;
vap->va_uid = procp->p_ucred->cr_uid;
vap->va_gid = procp->p_ucred->cr_gid;
vap->va_bytes = vap->va_size = DEV_BSIZE;
break;
case Pfile:
case PFSfile:
error = EOPNOTSUPP;
break;
case Pmem:
case PFSmem:
vap->va_bytes = vap->va_size =
ctob(procp->p_vmspace->vm_tsize +
procp->p_vmspace->vm_dsize +
@ -667,30 +667,30 @@ procfs_getattr(v)
break;
#if defined(PT_GETREGS) || defined(PT_SETREGS)
case Pregs:
case PFSregs:
vap->va_bytes = vap->va_size = sizeof(struct reg);
break;
#endif
#if defined(PT_GETFPREGS) || defined(PT_SETFPREGS)
case Pfpregs:
case PFSfpregs:
vap->va_bytes = vap->va_size = sizeof(struct fpreg);
break;
#endif
case Pctl:
case Pstatus:
case Pstat:
case Pnote:
case Pnotepg:
case Pcmdline:
case Pmeminfo:
case Pcpuinfo:
case Puptime:
case PFSctl:
case PFSstatus:
case PFSstat:
case PFSnote:
case PFSnotepg:
case PFScmdline:
case PFSmeminfo:
case PFScpuinfo:
case PFSuptime:
vap->va_bytes = vap->va_size = 0;
break;
case Pmap:
case Pmaps:
case PFSmap:
case PFSmaps:
/*
* Advise a larger blocksize for the map files, so that
* they may be read in one pass.
@ -813,7 +813,7 @@ procfs_lookup(v)
wantpunlock = (~cnp->cn_flags & (LOCKPARENT | ISLASTCN));
pfs = VTOPFS(dvp);
switch (pfs->pfs_type) {
case Proot:
case PFSroot:
/*
* Shouldn't get here with .. in the root node.
*/
@ -825,7 +825,7 @@ procfs_lookup(v)
if (iscurproc || isself) {
error = procfs_allocvp(dvp->v_mount, vpp, 0,
iscurproc ? Pcurproc : Pself, -1);
iscurproc ? PFScurproc : PFSself, -1);
if ((error == 0) && (wantpunlock)) {
VOP_UNLOCK(dvp, 0);
cnp->cn_flags |= PDIRUNLOCK;
@ -858,14 +858,14 @@ procfs_lookup(v)
if (p == NULL)
break;
error = procfs_allocvp(dvp->v_mount, vpp, pid, Pproc, -1);
error = procfs_allocvp(dvp->v_mount, vpp, pid, PFSproc, -1);
if ((error == 0) && (wantpunlock)) {
VOP_UNLOCK(dvp, 0);
cnp->cn_flags |= PDIRUNLOCK;
}
return (error);
case Pproc:
case PFSproc:
/*
* do the .. dance. We unlock the directory, and then
* get the root dir. That will automatically return ..
@ -896,7 +896,7 @@ procfs_lookup(v)
break;
found:
if (pt->pt_pfstype == Pfile) {
if (pt->pt_pfstype == PFSfile) {
fvp = p->p_textvp;
/* We already checked that it exists. */
VREF(fvp);
@ -917,7 +917,7 @@ procfs_lookup(v)
}
return (error);
case Pfd: {
case PFSfd: {
int fd;
struct file *fp;
/*
@ -930,7 +930,7 @@ procfs_lookup(v)
VOP_UNLOCK(dvp, 0);
cnp->cn_flags |= PDIRUNLOCK;
error = procfs_allocvp(dvp->v_mount, vpp, pfs->pfs_pid,
Pproc, -1);
PFSproc, -1);
if ((error == 0) && (wantpunlock == 0) &&
((error = vn_lock(dvp, LK_EXCLUSIVE)) == 0))
cnp->cn_flags &= ~PDIRUNLOCK;
@ -961,7 +961,7 @@ procfs_lookup(v)
symlink:
FILE_UNUSE(fp, p);
error = procfs_allocvp(dvp->v_mount, vpp, pfs->pfs_pid,
Pfd, fd);
PFSfd, fd);
break;
}
if ((error == 0) && (wantpunlock)) {
@ -1051,7 +1051,7 @@ procfs_readdir(v)
* all that is needed to is copy out all the entries
* from the procent[] table (top of this file).
*/
case Pproc: {
case PFSproc: {
struct proc *p;
if (i >= nproc_targets)
@ -1088,7 +1088,7 @@ procfs_readdir(v)
break;
}
case Pfd: {
case PFSfd: {
struct proc *p;
struct filedesc *fdp;
struct file *fp;
@ -1132,7 +1132,7 @@ procfs_readdir(v)
for (; uio->uio_resid >= UIO_MX && i < fdp->fd_nfiles; i++) {
if ((fp = fd_getfile(fdp, i - 2)) == NULL)
continue;
d.d_fileno = PROCFS_FILENO(pfs->pfs_pid, Pfd, i - 2);
d.d_fileno = PROCFS_FILENO(pfs->pfs_pid, PFSfd, i - 2);
d.d_namlen = snprintf(d.d_name, sizeof(d.d_name),
"%lld", (long long)(i - 2));
d.d_type = VREG;
@ -1156,7 +1156,7 @@ procfs_readdir(v)
#endif
*/
case Proot: {
case PFSroot: {
int pcnt = i, nc = 0;
const struct proclist_desc *pd;
volatile struct proc *p;
@ -1186,7 +1186,7 @@ procfs_readdir(v)
switch (i) {
case 0: /* `.' */
case 1: /* `..' */
d.d_fileno = PROCFS_FILENO(0, Proot, -1);
d.d_fileno = PROCFS_FILENO(0, PFSroot, -1);
d.d_namlen = i + 1;
memcpy(d.d_name, "..", d.d_namlen);
d.d_name[i + 1] = '\0';
@ -1194,14 +1194,14 @@ procfs_readdir(v)
break;
case 2:
d.d_fileno = PROCFS_FILENO(0, Pcurproc, -1);
d.d_fileno = PROCFS_FILENO(0, PFScurproc, -1);
d.d_namlen = sizeof("curproc") - 1;
memcpy(d.d_name, "curproc", sizeof("curproc"));
d.d_type = DT_LNK;
break;
case 3:
d.d_fileno = PROCFS_FILENO(0, Pself, -1);
d.d_fileno = PROCFS_FILENO(0, PFSself, -1);
d.d_namlen = sizeof("self") - 1;
memcpy(d.d_name, "self", sizeof("self"));
d.d_type = DT_LNK;
@ -1214,7 +1214,7 @@ procfs_readdir(v)
if (!p)
goto done;
}
d.d_fileno = PROCFS_FILENO(p->p_pid, Pproc, -1);
d.d_fileno = PROCFS_FILENO(p->p_pid, PFSproc, -1);
d.d_namlen = sprintf(d.d_name, "%ld",
(long)p->p_pid);
d.d_type = DT_DIR;
@ -1296,9 +1296,9 @@ procfs_readlink(v)
int error = 0;
struct pfsnode *pfs = VTOPFS(ap->a_vp);
if (pfs->pfs_fileno == PROCFS_FILENO(0, Pcurproc, -1))
if (pfs->pfs_fileno == PROCFS_FILENO(0, PFScurproc, -1))
len = sprintf(buf, "%ld", (long)curproc->p_pid);
else if (pfs->pfs_fileno == PROCFS_FILENO(0, Pself, -1))
else if (pfs->pfs_fileno == PROCFS_FILENO(0, PFSself, -1))
len = sprintf(buf, "%s", "curproc");
else {
struct file *fp;