diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1996-06-20 14:30:10 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1996-06-20 14:30:10 +0000 |
commit | b616b3bafb6c964e4269531c338a69e8367d4322 (patch) | |
tree | 15ece746a2c0faa39fe0d2d455930c3b08d99768 /sys/miscfs | |
parent | 48f748f3e396a96cbdb1e932b25a60c3c52cea02 (diff) |
add more kernel variables. calculate used/free physmem and vnodes.
Diffstat (limited to 'sys/miscfs')
-rw-r--r-- | sys/miscfs/kernfs/kernfs_vfsops.c | 16 | ||||
-rw-r--r-- | sys/miscfs/kernfs/kernfs_vnops.c | 48 |
2 files changed, 55 insertions, 9 deletions
diff --git a/sys/miscfs/kernfs/kernfs_vfsops.c b/sys/miscfs/kernfs/kernfs_vfsops.c index 6bde34415f3..147b75eeb65 100644 --- a/sys/miscfs/kernfs/kernfs_vfsops.c +++ b/sys/miscfs/kernfs/kernfs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kernfs_vfsops.c,v 1.3 1996/05/02 13:20:16 deraadt Exp $ */ +/* $OpenBSD: kernfs_vfsops.c,v 1.4 1996/06/20 14:30:08 mickey Exp $ */ /* $NetBSD: kernfs_vfsops.c,v 1.26 1996/04/22 01:42:27 christos Exp $ */ /* @@ -52,6 +52,7 @@ #include <sys/mount.h> #include <sys/namei.h> #include <sys/malloc.h> +#include <sys/vmmeter.h> /* for cnt */ #include <miscfs/specfs/specdev.h> #include <miscfs/kernfs/kernfs.h> @@ -257,6 +258,7 @@ kernfs_statfs(mp, sbp, p) struct statfs *sbp; struct proc *p; { + extern long numvnodes; /* XXX */ #ifdef KERNFS_DIAGNOSTIC printf("kernfs_statfs(mp = %x)\n", mp); @@ -267,13 +269,13 @@ kernfs_statfs(mp, sbp, p) #else sbp->f_type = 0; #endif - sbp->f_bsize = DEV_BSIZE; - sbp->f_iosize = DEV_BSIZE; - sbp->f_blocks = 2; /* 1K to keep df happy */ - sbp->f_bfree = 0; + sbp->f_bsize = cnt.v_page_size; + sbp->f_iosize = cnt.v_page_size; + sbp->f_blocks = physmem; + sbp->f_bfree = physmem - cnt.v_wire_count; sbp->f_bavail = 0; - sbp->f_files = 0; - sbp->f_ffree = 0; + sbp->f_files = desiredvnodes; + sbp->f_ffree = desiredvnodes - numvnodes; if (sbp != &mp->mnt_stat) { bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid)); bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN); diff --git a/sys/miscfs/kernfs/kernfs_vnops.c b/sys/miscfs/kernfs/kernfs_vnops.c index 77e48ecb10f..df59b3ce397 100644 --- a/sys/miscfs/kernfs/kernfs_vnops.c +++ b/sys/miscfs/kernfs/kernfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kernfs_vnops.c,v 1.3 1996/04/21 22:28:14 deraadt Exp $ */ +/* $OpenBSD: kernfs_vnops.c,v 1.4 1996/06/20 14:30:09 mickey Exp $ */ /* $NetBSD: kernfs_vnops.c,v 1.43 1996/03/16 23:52:47 christos Exp $ */ /* @@ -65,9 +65,16 @@ #define UIO_MX 32 #define READ_MODE (S_IRUSR|S_IRGRP|S_IROTH) -#define WRITE_MODE (S_IWUSR|S_IRUSR|S_IRGRP|S_IROTH) +#define WRITE_MODE (S_IWUSR|READ_MODE) #define DIR_MODE (S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) +static int byteorder = BYTE_ORDER; +static int posix = _POSIX_VERSION; +static int osrev = BSD; +static int ncpu = 1; /* XXX */ +extern char machine[], cpu_model[]; +extern char ostype[], osrelease[]; + struct kern_target { u_char kt_type; u_char kt_namlen; @@ -81,6 +88,8 @@ struct kern_target { #define KTT_AVENRUN 53 #define KTT_DEVICE 71 #define KTT_MSGBUF 89 +#define KTT_USERMEM 91 +#define KTT_DOMAIN 95 u_char kt_tag; u_char kt_vtype; mode_t kt_mode; @@ -91,19 +100,29 @@ struct kern_target { { DT_DIR, N("."), 0, KTT_NULL, VDIR, DIR_MODE }, { DT_DIR, N(".."), 0, KTT_NULL, VDIR, DIR_MODE }, { DT_REG, N("boottime"), &boottime.tv_sec, KTT_INT, VREG, READ_MODE }, + { DT_REG, N("byteorder"), &byteorder, KTT_INT, VREG, READ_MODE }, { DT_REG, N("copyright"), copyright, KTT_STRING, VREG, READ_MODE }, { DT_REG, N("hostname"), 0, KTT_HOSTNAME, VREG, WRITE_MODE }, + { DT_REG, N("domainname"),0, KTT_DOMAIN, VREG, WRITE_MODE }, { DT_REG, N("hz"), &hz, KTT_INT, VREG, READ_MODE }, { DT_REG, N("loadavg"), 0, KTT_AVENRUN, VREG, READ_MODE }, + { DT_REG, N("machine"), machine, KTT_STRING, VREG, READ_MODE }, + { DT_REG, N("model"), cpu_model, KTT_STRING, VREG, READ_MODE }, { DT_REG, N("msgbuf"), 0, KTT_MSGBUF, VREG, READ_MODE }, + { DT_REG, N("ncpu"), &ncpu, KTT_INT, VREG, READ_MODE }, + { DT_REG, N("ostype"), &ostype, KTT_STRING, VREG, READ_MODE }, + { DT_REG, N("osrelease"), &osrelease, KTT_STRING, VREG, READ_MODE }, + { DT_REG, N("osrev"), &osrev, KTT_INT, VREG, READ_MODE }, { DT_REG, N("pagesize"), &cnt.v_page_size, KTT_INT, VREG, READ_MODE }, { DT_REG, N("physmem"), &physmem, KTT_INT, VREG, READ_MODE }, + { DT_REG, N("posix"), &posix, KTT_INT, VREG, READ_MODE }, #if 0 { DT_DIR, N("root"), 0, KTT_NULL, VDIR, DIR_MODE }, #endif { DT_BLK, N("rootdev"), &rootdev, KTT_DEVICE, VBLK, READ_MODE }, { DT_CHR, N("rrootdev"), &rrootdev, KTT_DEVICE, VCHR, READ_MODE }, { DT_REG, N("time"), 0, KTT_TIME, VREG, READ_MODE }, + { DT_REG, N("usermem"), 0, KTT_USERMEM, VREG, READ_MODE }, { DT_REG, N("version"), version, KTT_STRING, VREG, READ_MODE }, #undef N }; @@ -262,6 +281,19 @@ kernfs_xread(kt, off, bufp, len) break; } + case KTT_DOMAIN: { + char *cp = domainname; + int xlen = domainnamelen; + + if (xlen >= (len-2)) + return (EINVAL); + + bcopy(cp, *bufp, xlen); + (*bufp)[xlen] = '\n'; + (*bufp)[xlen+1] = '\0'; + break; + } + case KTT_AVENRUN: averunnable.fscale = FSCALE; sprintf(*bufp, "%d %d %d %ld\n", @@ -269,6 +301,10 @@ kernfs_xread(kt, off, bufp, len) averunnable.ldavg[2], averunnable.fscale); break; + case KTT_USERMEM: + sprintf(*bufp, "%lu\n", ctob(physmem - cnt.v_wire_count)); + break; + default: return (0); } @@ -288,6 +324,14 @@ kernfs_xwrite(kt, buf, len) { switch (kt->kt_tag) { + case KTT_DOMAIN: + if (buf[len-1] == '\n') + --len; + bcopy(buf, domainname, len); + domainname[len] = '\0'; + domainnamelen = len; + return (0); + case KTT_HOSTNAME: if (buf[len-1] == '\n') --len; |