summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
Diffstat (limited to 'sbin')
-rw-r--r--sbin/Makefile12
-rw-r--r--sbin/atm/atm/atm.813
-rw-r--r--sbin/atm/atm/atm.h4
-rw-r--r--sbin/atm/fore_dnld/fore_dnld.c8
-rw-r--r--sbin/atm/ilmid/ilmid.c2830
-rw-r--r--sbin/camcontrol/camcontrol.815
-rw-r--r--sbin/camcontrol/camcontrol.c72
-rw-r--r--sbin/ccdconfig/ccdconfig.88
-rw-r--r--sbin/disklabel/disklabel.54
-rw-r--r--sbin/disklabel/disklabel.864
-rw-r--r--sbin/disklabel/disklabel.c36
-rw-r--r--sbin/disklabel/pathnames.h2
-rw-r--r--sbin/dset/Makefile7
-rw-r--r--sbin/dset/dset.878
-rw-r--r--sbin/dset/dset.c433
-rw-r--r--sbin/dump/traverse.c8
-rw-r--r--sbin/fsck/dir.c87
-rw-r--r--sbin/fsck/fsck.878
-rw-r--r--sbin/fsck/fsck.h47
-rw-r--r--sbin/fsck/inode.c91
-rw-r--r--sbin/fsck/main.c42
-rw-r--r--sbin/fsck/pass1.c107
-rw-r--r--sbin/fsck/pass1b.c4
-rw-r--r--sbin/fsck/pass2.c60
-rw-r--r--sbin/fsck/pass3.c68
-rw-r--r--sbin/fsck/pass4.c69
-rw-r--r--sbin/fsck/pass5.c35
-rw-r--r--sbin/fsck/preen.c60
-rw-r--r--sbin/fsck/setup.c46
-rw-r--r--sbin/fsck/utilities.c50
-rw-r--r--sbin/fsdb/fsdb.c6
-rw-r--r--sbin/i386/fdisk/fdisk.84
-rw-r--r--sbin/i386/fdisk/fdisk.c6
-rw-r--r--sbin/i386/mount_msdos/mount_msdos.813
-rw-r--r--sbin/init/init.813
-rw-r--r--sbin/ipfw/ipfw.841
-rw-r--r--sbin/ipfw/ipfw.c296
-rw-r--r--sbin/kldload/kldload.820
-rw-r--r--sbin/kldstat/kldstat.814
-rw-r--r--sbin/kldstat/kldstat.c4
-rw-r--r--sbin/kldunload/kldunload.820
-rw-r--r--sbin/kldunload/kldunload.c12
-rw-r--r--sbin/mount/Makefile5
-rw-r--r--sbin/mount/mount_ufs.c36
-rw-r--r--sbin/mount_null/mount_null.812
-rw-r--r--sbin/mount_portal/Makefile4
-rw-r--r--sbin/mount_portal/activate.c4
-rw-r--r--sbin/mount_portal/mount_portal.816
-rw-r--r--sbin/mount_portal/mount_portal.c4
-rw-r--r--sbin/mount_portal/portald.h4
-rw-r--r--sbin/mount_portal/pt_conf.c3
-rw-r--r--sbin/mount_portal/pt_tcp.c8
-rw-r--r--sbin/mount_portal/pt_tcplisten.c206
-rw-r--r--sbin/mount_umap/mount_umap.812
-rw-r--r--sbin/mount_union/mount_union.812
-rw-r--r--sbin/mountd/mountd.c42
-rw-r--r--sbin/natd/README53
-rw-r--r--sbin/natd/samples/natd.cf.sample94
-rw-r--r--sbin/natd/samples/natd.test14
-rw-r--r--sbin/newfs/newfs.817
-rw-r--r--sbin/newfs_msdos/newfs_msdos.c16
-rw-r--r--sbin/nologin/nologin.512
-rw-r--r--sbin/ping/ping.820
-rw-r--r--sbin/ping/ping.c55
-rw-r--r--sbin/reboot/boot_i386.889
-rw-r--r--sbin/restore/dirs.c10
-rw-r--r--sbin/restore/interactive.c8
-rw-r--r--sbin/restore/restore.84
-rw-r--r--sbin/restore/symtab.c10
-rw-r--r--sbin/restore/tape.c30
-rw-r--r--sbin/shutdown/shutdown.820
-rw-r--r--sbin/shutdown/shutdown.c34
-rw-r--r--sbin/sysctl/Makefile10
-rw-r--r--sbin/sysctl/pathconf.c240
-rw-r--r--sbin/sysctl/sysctl.8243
-rw-r--r--sbin/sysctl/sysctl.c502
-rw-r--r--sbin/tunefs/tunefs.84
-rw-r--r--sbin/tunefs/tunefs.c51
-rw-r--r--sbin/vinum/Makefile24
-rw-r--r--sbin/vinum/commands.c306
-rw-r--r--sbin/vinum/list.c202
-rw-r--r--sbin/vinum/v.c122
-rw-r--r--sbin/vinum/vext.h52
-rw-r--r--sbin/vinum/vinum.8530
84 files changed, 3080 insertions, 4947 deletions
diff --git a/sbin/Makefile b/sbin/Makefile
index 63337224be0ad..aa64712aafd57 100644
--- a/sbin/Makefile
+++ b/sbin/Makefile
@@ -1,16 +1,16 @@
# @(#)Makefile 8.5 (Berkeley) 3/31/94
-# $Id: Makefile,v 1.61 1998/12/28 11:06:21 sos Exp $
+# $Id: Makefile,v 1.56 1998/09/15 11:44:41 phk Exp $
# XXX MISSING: icheck ncheck
-SUBDIR= adjkerntz \
- atm \
+SUBDIR= atm \
badsect \
camcontrol \
ccdconfig \
clri \
disklabel \
dmesg \
+ dset \
dump \
dumpfs \
dumpon \
@@ -54,8 +54,8 @@ SUBDIR= adjkerntz \
savecore \
shutdown \
slattach \
- spppcontrol \
startslip \
+ spppcontrol \
swapon \
tunefs \
umount \
@@ -65,4 +65,8 @@ SUBDIR= adjkerntz \
SUBDIR+= ${MACHINE_ARCH}
.endif
+.if ${MACHINE_ARCH} == "i386"
+SUBDIR+=adjkerntz
+.endif
+
.include <bsd.subdir.mk>
diff --git a/sbin/atm/atm/atm.8 b/sbin/atm/atm/atm.8
index 9dc923178fb8e..51b39f9a5f019 100644
--- a/sbin/atm/atm/atm.8
+++ b/sbin/atm/atm/atm.8
@@ -22,7 +22,7 @@
.\" Copies of this Software may be made, however, the above copyright
.\" notice must be reproduced on all copies.
.\"
-.\" @(#) $Id: atm.8,v 1.1 1998/09/15 08:22:45 phk Exp $
+.\" @(#) $Id: atm.1,v 1.4 1998/08/26 21:38:28 johnc Exp $
.\"
.\"
.de EX \"Begin example
@@ -178,22 +178,19 @@ Two types of interfaces are supported:
physical interfaces and network interfaces.
A physical interface represents a physical point of attachment to an
ATM network.
-A physical interface has an ATM address associated with it, except
-when the PVC-only signalling manager is being used.
+A physical interface has an ATM address associated with it.
.PP
A network interface is a logical interface.
One or more network interfaces are associated with a physical
interface; each network interface has an IP address associated with it.
+For interfaces controlled by the SPANS or PVC signalling managers,
+there must be one and
+only one network interface associated with each physical interface.
For UNI-controlled interfaces, there can be up to 256 network
interfaces associated with a physical interface.
In this case, the correspondence between the network interface and
the ATM address is determined by the selector field (the last
byte) of the physical interface's ATM address.
-For PVC-only interfaces, there can be up to 256 logical interfaces
-associated with each physical interface.
-For interfaces controlled by the SPANS signalling manager,
-there must be one and
-only one network interface associated with each physical interface.
.SS "Keyword and Documentation Conventions"
Command and subcommand keywords can be abbreviated by simply giving
enough of the first part of the keyword to make it unique.
diff --git a/sbin/atm/atm/atm.h b/sbin/atm/atm/atm.h
index f903bd781babd..efb8d1eaa069c 100644
--- a/sbin/atm/atm/atm.h
+++ b/sbin/atm/atm/atm.h
@@ -23,7 +23,7 @@
* Copies of this Software may be made, however, the above copyright
* notice must be reproduced on all copies.
*
- * @(#) $Id: atm.h,v 1.1 1998/09/15 08:22:45 phk Exp $
+ * @(#) $Id: atm.h,v 1.9 1998/07/09 21:23:53 johnc Exp $
*
*/
@@ -35,7 +35,7 @@
*
*/
-#define MAX_NIFS 256 /* Max network interfaces */
+#define MAX_NIFS 32 /* Max network interfaces */
#define MIN_VCI 32 /* Smallest non-reserved VCI */
#ifndef TRUE
diff --git a/sbin/atm/fore_dnld/fore_dnld.c b/sbin/atm/fore_dnld/fore_dnld.c
index d0e965e96e47c..6ecafa5d49b90 100644
--- a/sbin/atm/fore_dnld/fore_dnld.c
+++ b/sbin/atm/fore_dnld/fore_dnld.c
@@ -23,7 +23,7 @@
* Copies of this Software may be made, however, the above copyright
* notice must be reproduced on all copies.
*
- * @(#) $Id: fore_dnld.c,v 1.1 1998/09/15 08:22:47 phk Exp $
+ * @(#) $Id: fore_dnld.c,v 1.15 1998/08/26 23:29:32 mks Exp $
*
*/
@@ -37,7 +37,7 @@
*/
#ifndef lint
-static char *RCSid = "@(#) $Id: fore_dnld.c,v 1.1 1998/09/15 08:22:47 phk Exp $";
+static char *RCSid = "@(#) $Id: fore_dnld.c,v 1.15 1998/08/26 23:29:32 mks Exp $";
#endif
#include <sys/types.h>
@@ -407,7 +407,7 @@ unsigned short crctab[1<<B] = {
* -1 unable to send file
*/
int
-xmitfile ( filename )
+sendfile ( filename )
char *filename;
{
int fd;
@@ -1202,7 +1202,7 @@ char *argv[];
sndfile = objfile;
if ( ext && !binary )
- err = xmitfile ( sndfile );
+ err = sendfile ( sndfile );
else
err = sendbinfile ( sndfile, ram );
diff --git a/sbin/atm/ilmid/ilmid.c b/sbin/atm/ilmid/ilmid.c
index 9da24241f7266..e515a1088f995 100644
--- a/sbin/atm/ilmid/ilmid.c
+++ b/sbin/atm/ilmid/ilmid.c
@@ -23,7 +23,7 @@
* Copies of this Software may be made, however, the above copyright
* notice must be reproduced on all copies.
*
- * @(#) $Id: ilmid.c,v 1.1 1998/09/15 08:22:47 phk Exp $
+ * @(#) $Id: ilmid.c,v 1.9 1998/08/13 20:15:28 jpt Exp $
*
*/
@@ -45,24 +45,40 @@
*
*/
-#include <sys/param.h>
-
#ifndef lint
-__RCSID("@(#) $Id: ilmid.c,v 1.1 1998/09/15 08:22:47 phk Exp $");
+static char *RCSid = "@(#) $Id: ilmid.c,v 1.9 1998/08/13 20:15:28 jpt Exp $";
#endif
+#include <sys/types.h>
+#include <sys/param.h>
+
+#if (defined(BSD) && (BSD >= 199103))
#include <err.h>
-#include <errno.h>
+#endif
+
+#ifdef BSD
+#if __FreeBSD_version < 300001
+#include <stdlib.h>
+#ifdef sun
+#include <unistd.h>
+#endif /* sun */
+#else
+#include <unistd.h>
+#endif /* __FreeBSD_version >= 300001 */
+#endif /* BSD */
+
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
+#include <sys/errno.h>
#include <string.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
#include <syslog.h>
-#include <time.h>
-#include <unistd.h>
#include <sys/socket.h>
-#include <sys/sockio.h>
#include <net/if.h>
#include <netinet/in.h>
+
#include <netatm/port.h>
#include <netatm/atm.h>
#include <netatm/atm_if.h>
@@ -70,30 +86,36 @@ __RCSID("@(#) $Id: ilmid.c,v 1.1 1998/09/15 08:22:47 phk Exp $");
#include <netatm/atm_sap.h>
#include <netatm/atm_sys.h>
#include <netatm/atm_ioctl.h>
+
#include <dev/hea/eni_stats.h>
#include <dev/hfa/fore_aali.h>
#include <dev/hfa/fore_slave.h>
#include <dev/hfa/fore_stats.h>
-
-#include <libatm.h>
+#include <netatm/uni/unisig_var.h>
#define MAX_LEN 9180
#define MAX_UNITS 8
/*
+ * Time to sleep between loops
+ */
+#define SLEEP_TIME 10
+/*
+ * Time to pass between sending coldStart TRAPs
+ */
+#define TRAP_TIME 5
+
+/*
* Define some ASN types
*/
#define ASN_INTEGER 0x02
#define ASN_OCTET 0x04
-#define ASN_NULL 0x05
#define ASN_OBJID 0x06
#define ASN_SEQUENCE 0x30
#define ASN_IPADDR 0x40
#define ASN_TIMESTAMP 0x43
-static char *Var_Types[] = { "", "", "ASN_INTEGER", "", "ASN_OCTET", "ASN_NULL", "ASN_OBJID" };
-
/*
* Define SNMP PDU types
*/
@@ -103,167 +125,360 @@ static char *Var_Types[] = { "", "", "ASN_INTEGER", "", "ASN_OCTET", "ASN_NULL",
#define PDU_TYPE_SET 0xA3
#define PDU_TYPE_TRAP 0xA4
-static char *PDU_Types[] = { "GET REQUEST", "GETNEXT REQUEST", "GET RESPONSE", "SET REQUEST",
- "TRAP" };
-
/*
- * Define TRAP codes
+ * Every SNMP PDU has the first four fields of this header. The only type
+ * which doesn't have the last three fields is the TRAP type.
*/
-#define TRAP_COLDSTART 0
-#define TRAP_WARMSTART 1
-#define TRAP_LINKDOWN 2
-#define TRAP_LINKUP 3
-#define TRAP_AUTHFAIL 4
-#define TRAP_EGPLOSS 5
-#define TRAP_ENTERPRISE 6
+struct snmp_header {
+ int pdulen;
+ int version;
+ char community[64];
+ int pdutype;
+ int reqid;
+ int error;
+ int erridx;
+};
+typedef struct snmp_header Snmp_Header;
/*
- * Define SNMP Version numbers
+ * Define our internal representation of an OBJECT IDENTIFIER
*/
-#define SNMP_VERSION_1 1
-#define SNMP_VERSION_2 2
+struct objid {
+ int oid[128];
+};
+typedef struct objid Objid;
/*
- * Max string length for Variable
+ * Define some OBJET IDENTIFIERS that we'll try to reply to:
+ *
+ * sysUpTime: number of time ticks since this deamon came up
+ * netpfx_oid: network prefix table
+ * unitype: is this a PRIVATE or PUBLIC network link
+ * univer: which version of UNI are we running
+ * devtype: is this a USER or NODE ATM device
+ * setprefix: used when the switch wants to tell us its NSAP prefix
+ * foresiggrp: FORE specific Objid we see alot of (being connected to FORE
+ * switches...)
*/
-#define STRLEN 128
-
+Objid sysObjId = { 8, 43, 6, 1, 2, 1, 1, 2, 0 };
+Objid sysUpTime = { 8, 43, 6, 1, 2, 1, 1, 3, 0 };
+Objid foresiggrp = { 18, 43, 6, 1, 4, 1, 326, 2, 2, 2, 1, 6, 2, 1, 1, 1, 20, 0, 0 };
+Objid portidx = { 12, 43, 6, 1, 4, 1, 353, 2, 1, 1, 1, 1, 0 };
+Objid myipnm = { 10, 43, 6, 1, 4, 1, 353, 2, 1, 2, 0 };
+Objid layeridx = { 12, 43, 6, 1, 4, 1, 353, 2, 2, 1, 1, 1, 0 };
+Objid maxvcc = { 12, 43, 6, 1, 4, 1, 353, 2, 2, 1, 1, 3, 0 };
+Objid unitype = { 12, 43, 6, 1, 4, 1, 353, 2, 2, 1, 1, 8, 0 };
+Objid univer = { 12, 43, 6, 1, 4, 1, 353, 2, 2, 1, 1, 9, 0 };
+Objid devtype = { 12, 43, 6, 1, 4, 1, 353, 2, 2, 1, 1, 10, 0 };
+Objid netpfx_oid = { 9, 43, 6, 1, 4, 1, 353, 2, 7, 1 };
+Objid setprefix = { 12, 43, 6, 1, 4, 1, 353, 2, 7, 1, 1, 3, 0 };
/*
- * Unknown variable
+ * (Partialy) pre-encoded SNMP responses
*/
-#define VAR_UNKNOWN -1
/*
- * Define our internal representation of an OBJECT IDENTIFIER
+ * sysObjId reply
*/
-struct objid {
- int oid[128];
+u_char sysObjId_Resp[] = {
+ 54, /* <--- len */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x32, /* <--- len */
+ 0x02, 0x01, 0x00, /* (Version - 1) */
+ 0x04, 0x04, 0x49, 0x4c, 0x4d, 0x49, /* Community: ILMI */
+ PDU_TYPE_GETRESP, /* GET Response */
+ 0x27, /* <--- len */
+ 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, /* <--- request id */
+ 0x02, 0x01, 0x00, /* Error Status */
+ 0x02, 0x01, 0x00, /* Error Index */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x17, /* <--- len */
+ 0x82, 0x00, 0x14, /* <--- len */
+ 0x06, 0x08, /* Objid: 1.3.6.1.4.1.1.2.0 */
+ 0x2b, 0x06, 0x01, 0x04, 0x01, 0x01, 0x02, 0x00,
+ 0x06, 0x08, /* Objid: 1.3.6.1.4.1.9999.1 */
+ 0x2b, 0x06, 0x01, 0x04, 0x01, 0xce, 0x0f, 0x01
};
-typedef struct objid Objid;
/*
- * Define a Veriable classso that we can handle multiple GET/SET's
- * per PDU.
+ * sysUpTime: reply to a sysUpTime GET request
*/
-typedef struct variable Variable;
-struct variable {
- Objid oid;
- int type;
- union {
- int ival; /* INTEGER/TIMESTAMP */
- Objid oval; /* OBJID */
- long aval; /* IPADDR */
- char sval[STRLEN]; /* OCTET */
- } var;
- Variable *next;
+u_char sysUpTime_Resp[] = {
+ 45, /* <--- len */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x29, /* <--- len */
+ 0x02, 0x01, 0x00, /* (Version - 1) */
+ 0x04, 0x04, 0x49, 0x4c, 0x4d, 0x49, /* Community - ILMI */
+ PDU_TYPE_GETRESP, /* GET Response */
+ 0x1e, /* <--- len */
+ 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, /* <--- request id */
+ 0x02, 0x01, 0x00, /* Error Status */
+ 0x02, 0x01, 0x00, /* Error Index */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x0E, /* <--- len */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x0A, /* <--- len */
+ /* Objid: .1.3.6.1.2.1.1.3.0 */
+ 0x06, 0x08, 0x2b, 0x06, 0x01, 0x02, 0x01, 0x01, 0x03, 0x00,
+ /* <--- uptime */
};
/*
- * Every SNMP PDU has the first four fields of this header. The only type
- * which doesn't have the last three fields is the TRAP type.
+ * coldStart TRAP to start the ILMI protocol
*/
-struct snmp_header {
- int pdulen;
- int version;
- char community[64];
- int pdutype;
+u_char coldStart_Trap[] = {
+ 60,
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x38, /* <--- len */
+ 0x02, 0x01, 0x00, /* (Version - 1) */
+ 0x04, 0x04, 0x49, 0x4c, 0x4d, 0x49, /* Community: ILMI */
+ PDU_TYPE_TRAP, /* TRAP */
+ 0x2d, /* <--- len */
+ 0x06, 0x08, /* Objid: .1.3.6.1.4.1.3.1.1 */
+ 0x2b, 0x06, 0x01, 0x04, 0x01, 0x03, 0x01, 0x01,
+ 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, /* IP address - 0.0.0.0 */
+ 0x02, 0x01, 0x00, /* generic trap */
+ 0x02, 0x01, 0x00, /* specific trap */
+ 0x43, 0x01, 0x00, /* Time ticks - 0 */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x10, /* <--- len */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x0c, /* <-- len */
+ 0x06, 0x08, /* Objid: 1.3.6.1.2.1.1.3.0 */
+ 0x2b, 0x06, 0x01, 0x02, 0x01, 0x01, 0x03, 0x00,
+ 0x05, 0x00 /* Null */
+};
- /* GET/GETNEXT/GETRESP/SET */
- int reqid;
- int error;
- int erridx;
-
- /* TRAP */
- Objid enterprise;
- int ipaddr;
- int generic_trap;
- int specific_trap;
-
- int varlen;
- Variable *head,
- *tail;
+u_char GetNext_Resp[] = {
+ 49,
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x2d, /* <--- len */
+ 0x02, 0x01, 0x00, /* (Version - 1) */
+ 0x04, 0x04, 0x49, 0x4c, 0x4d, 0x49, /* Community: ILMI */
+ PDU_TYPE_GETRESP, /* PDU_TYPE_GETRESP */
+ 0x22, /* <--- len */
+ 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, /* Request ID */
+ 0x02, 0x01, 0x02, /* Error Status */
+ 0x02, 0x01, 0x01, /* Error Index */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x12, /* <--- len */
+ 0x30, /* Seqence of */
+ 0x82, 0x00, 0x0e, /* <--- len */
+ 0x06, 0x0a, /* Objid: .1.3.6.4.1.353.2.7.1 */
+ 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x61, 0x02, 0x07, 0x01,
+ 0x05, 0x00 /* Get response: NULL */
};
-typedef struct snmp_header Snmp_Header;
-Snmp_Header *ColdStart_Header;
-Snmp_Header *PDU_Header;
+/*
+ * Reply to GET myIpNm
+ */
+u_char MyIpNm_Resp[] = {
+ 54,
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x32, /* <--- len */
+ 0x02, 0x01, 0x00, /* (Version - 1) */
+ 0x04, 0x04, 0x49, 0x4c, 0x4d, 0x49, /* Community: ILMI */
+ PDU_TYPE_GETRESP, /* PDU_TYPE_GETRESP */
+ 0x27, /* <--- len */
+ 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, /* Request ID */
+ 0x02, 0x01, 0x00, /* Error Status */
+ 0x02, 0x01, 0x00, /* Error Index */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x17, /* <--- len */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x13, /* <--- len */
+ /* Objid: .1.3.6.1.4.1.353.2.1.2.1 */
+ 0x06, 0x0B, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x61, 0x02,
+ 0x01, 0x02, 0x01,
+ 0x40, 0x04, 0x00, 0x00, 0x00, 0x00 /* IP address */
+};
/*
- * Define some OBJET IDENTIFIERS that we'll try to reply to:
- *
- * sysUpTime: number of time ticks since this deamon came up
- * netpfx_oid: network prefix table
- * unitype: is this a PRIVATE or PUBLIC network link
- * univer: which version of UNI are we running
- * devtype: is this a USER or NODE ATM device
- * setprefix: used when the switch wants to tell us its NSAP prefix
- * foresiggrp: FORE specific Objid we see alot of (being connected to FORE
- * switches...)
+ * Reply to GET portIndex - we're always 1 + unit number
*/
-Objid Objids[] = {
-#define SYS_OBJID 0
- {{ 8, 43, 6, 1, 2, 1, 1, 2, 0 }},
-#define UPTIME_OBJID 1
- {{ 8, 43, 6, 1, 2, 1, 1, 3, 0 }},
-#define PORT_OBJID 2
- {{ 12, 43, 6, 1, 4, 1, 353, 2, 1, 1, 1, 1, 0 }},
-#define IPNM_OBJID 3
- {{ 10, 43, 6, 1, 4, 1, 353, 2, 1, 2, 0 }},
-#define LAYER_OBJID 4
- {{ 12, 43, 6, 1, 4, 1, 353, 2, 2, 1, 1, 1, 0 }},
-#define MAXVCC_OBJID 5
- {{ 12, 43, 6, 1, 4, 1, 353, 2, 2, 1, 1, 3, 0 }},
-#define UNITYPE_OBJID 6
- {{ 12, 43, 6, 1, 4, 1, 353, 2, 2, 1, 1, 8, 0 }},
-#define UNIVER_OBJID 7
- {{ 12, 43, 6, 1, 4, 1, 353, 2, 2, 1, 1, 9, 0 }},
-#define DEVTYPE_OBJID 8
- {{ 12, 43, 6, 1, 4, 1, 353, 2, 2, 1, 1, 10, 0 }},
-#define ADDRESS_OBJID 9
- {{ 8, 43, 6, 1, 4, 1, 353, 2, 6 }},
-#define NETPFX_OBJID 10
- {{ 9, 43, 6, 1, 4, 1, 353, 2, 7, 1 }},
-#define MY_OBJID 11
- {{ 7, 43, 6, 1, 4, 1, 9999, 1 }},
-#define SETPFX_OBJID 12
- {{ 12, 43, 6, 1, 4, 1, 353, 2, 7, 1, 1, 3, 0 }},
-#define ENTERPRISE_OBJID 13
- {{ 8, 43, 6, 1, 4, 1, 3, 1, 1 }},
-#define ATMF_PORTID 14
- {{ 10, 43, 6, 1, 4, 1, 353, 2, 1, 4, 0 }},
-#define ATMF_SYSID 15
- {{ 12, 43, 6, 1, 4, 1, 353, 2, 1, 1, 1, 8, 0 }},
+u_char PortIndex_Resp[] = {
+ 53,
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x31, /* <-- len */
+ 0x02, 0x01, 0x00, /* (Version - 1) */
+ 0x04, 0x04, 0x49, 0x4c, 0x4d, 0x49, /* Community: ILMI */
+ PDU_TYPE_GETRESP,
+ 0x26, /* <-- len */
+ 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, /* Request ID */
+ 0x02, 0x01, 0x00, /* Error Status */
+ 0x02, 0x01, 0x00, /* Error Index */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x16, /* <--- len */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x12, /* <--- len */
+ /* Objid: .1.3.6.1.4.1.353.2.1.1.1.1.x */
+ 0x06, 0x0d, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x61, 0x02,
+ 0x01, 0x01, 0x01, 0x01, 0x00,
+ 0x02, 0x01, 0x00, /* Value */
};
-#define NUM_OIDS (sizeof(Objids)/sizeof(Objid))
+/*
+ * Reply to GET MaxVcc
+ */
+u_char maxVCC_Resp[] = {
+ 52, /* <--- len */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x30, /* <--- len */
+ 0x02, 0x01, 0x01, /* (Version - 1) */
+ 0x04, 0x04, 0x49, 0x4c, 0x4d, 0x49, /* Community: ILMI */
+ PDU_TYPE_GETRESP, /* GET Response */
+ 0x25, /* <--- len */
+ 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, /* <--- request id */
+ 0x02, 0x01, 0x00, /* Error Status */
+ 0x02, 0x01, 0x00, /* Error Index */
+ 0x30, /* Sequence of */
+ 0x82, 0x16, /* <--- len */
+ 0x30, /* Sequence of */
+ 0x82, 0x13, /* <--- len */
+ 0x06, 0x0d, /* Objid: 1.3.6.1.4.1.353.2.2.1.1.3.0 */
+ 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x61, 0x02,
+ 0x02, 0x01, 0x01, 0x03, 0x00,
+ 0x02, 0x02, 0x04, 0x00 /* Value = 1024 */
+};
+
+/*
+ * Reply to GET uniType - we only support PRIVATE
+ */
+u_char UniType_Resp[] = {
+ 53,
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x31, /* <--- len */
+ 0x02, 0x01, 0x00, /* (Version - 1) */
+ 0x04, 0x04, 0x49, 0x4c, 0x4d, 0x49, /* Community: ILMI */
+ PDU_TYPE_GETRESP, /* PDU_TYPE_GETRESP */
+ 0x26, /* <--- len */
+ 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, /* Request ID */
+ 0x02, 0x01, 0x00, /* Error Status */
+ 0x02, 0x01, 0x00, /* Error Index */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x16, /* <--- len */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x12, /* <--- len */
+ /* Objid: .1.3.6.1.4.1.353.2.2.1.1.8.0 */
+ 0x06, 0x0d, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x61, 0x02, 0x02,
+ 0x01, 0x01, 0x08, 0x00,
+ 0x02, 0x01, 0x02 /* Get response: Integer */
+ /* = UNITYPE_PRIVATE (2) */
+};
-#define UNIVER_UNI20 1
#define UNIVER_UNI30 2
#define UNIVER_UNI31 3
#define UNIVER_UNI40 4
-#define UNIVER_UNKNOWN 5
-#define UNITYPE_PUBLIC 1
-#define UNITYPE_PRIVATE 2
+/*
+ * Reply to GET uniVer
+ */
+u_char UniVer_Resp[] = {
+ 53,
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x31, /* <--- len */
+ 0x02, 0x01, 0x00, /* (Version - 1) */
+ 0x04, 0x04, 0x49, 0x4c, 0x4d, 0x49, /* Community: ILMI */
+ PDU_TYPE_GETRESP, /* PDU_TYPE_GETRESP */
+ 0x26, /* <--- len */
+ 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, /* Request ID */
+ 0x02, 0x01, 0x00, /* Error Status */
+ 0x02, 0x01, 0x00, /* Error Index */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x16, /* <--- len */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x12, /* <--- len */
+ /* Objid: .1.3.6.1.4.1.353.2.2.1.1.9.0 */
+ 0x06, 0x0d, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x61, 0x02, 0x02,
+ 0x01, 0x01, 0x09, 0x00,
+ 0x02, 0x01, 0x02 /* Get response: Integer */
+ /* = UNIVER_UNI30 (2) */
+};
-#define DEVTYPE_USER 1
-#define DEVTYPE_NODE 2
+/*
+ * Reply to GET devType - we're a host therefore we're type USER
+ */
+u_char DevType_Resp[] = {
+ 53,
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x31, /* <--- len */
+ 0x02, 0x01, 0x00, /* (Version -1) */
+ 0x04, 0x04, 0x49, 0x4c, 0x4d, 0x49, /* Community: ILMI */
+ PDU_TYPE_GETRESP, /* PDU_TYPE_GETRESP */
+ 0x26, /* <--- len */
+ 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, /* Request ID */
+ 0x02, 0x01, 0x00, /* Error Status */
+ 0x02, 0x01, 0x00, /* Error Index */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x16, /* <--- len */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x12, /* <--- len */
+ /* Objid: .1.3.6.1.4.1.353.2.2.1.1.10.0 */
+ 0x06, 0x0d, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x61, 0x02, 0x02,
+ 0x01, 0x01, 0x0a, 0x00,
+ 0x02, 0x01, 0x01 /* Get response: Integer */
+ /* = DEVTYPE_USER (1) */
+};
/*
- * ILMI protocol states
+ * Reply to GET foreSigGroup.* with noSuchError
*/
-enum ilmi_states {
- ILMI_UNKNOWN, /* Uninitialized */
- ILMI_COLDSTART, /* We need to send a COLD_START trap */
- ILMI_INIT, /* Ensure that switch has reset */
- ILMI_REG, /* Looking for SET message */
- ILMI_RUNNING /* Normal processing */
+u_char NoSuchFore_Resp[] = {
+ 85,
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x51, /* <--- len */
+ 0x02, 0x01, 0x00, /* (Version - 1) */
+ 0x04, 0x04, 0x49, 0x4c, 0x4d, 0x49, /* Community: ILMI */
+ PDU_TYPE_GETRESP, /* PDU_TYPE_GETRESP */
+ 0x46, /* <--- len */
+ 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, /* Request ID */
+ 0x02, 0x01, 0x02, /* Error Status: noSuch (2) */
+ 0x02, 0x01, 0x01, /* Error Index */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x36, /* <--- len */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x17, /* <--- len */
+ /* Objid: .1.3.6.1.5.1.326.2.2.2.1.6.2.1.1.1.20.0.0 */
+ 0x06, 0x13,
+ 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x46,
+ 0x02, 0x02, 0x02, 0x01, 0x06, 0x02, 0x01, 0x01,
+ 0x01, 0x14, 0x00, 0x00,
+ 0x05, 0x00, /* NULL */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x17, /* <--- len */
+ /* Objid: .1.3.6.1.5.1.326.2.2.2.1.6.2.1.1.1.21.0.0 */
+ 0x06, 0x13,
+ 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x46,
+ 0x02, 0x02, 0x02, 0x01, 0x06, 0x02, 0x01, 0x01,
+ 0x01, 0x15, 0x00, 0x00,
+ 0x05, 0x00 /* NULL */
+};
+
+u_char NetPrefix_Resp[] = {
+ 50,
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x00, /* <--- len */
+ 0x02, 0x01, 0x00, /* (Version - 1) */
+ 0x04, 0x04, 0x49, 0x4c, 0x4d, 0x49, /* Community: ILMI */
+ PDU_TYPE_SET, /* PDU_TYPE_SET */
+ 0x00, /* <--- len */
+ 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, /* Request ID */
+ 0x02, 0x01, 0x00,
+ 0x02, 0x01, 0x00,
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x00, /* <--- len */
+ 0x30, /* Sequence of */
+ 0x82, 0x00, 0x00, /* <--- len */
+ /* Objid: .1.3.6.1.4.1.353.2.6.1.1.3.0. */
+ 0x06, 0x00,
+ 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x61, 0x02,
+ 0x06, 0x01, 0x01, 0x03, 0x00
+ /* Remainder of Objid plus SET value INTEGER =1 */
};
/*
* Our (incrementing) Request ID
*/
-int Req_ID;
+int Req_ID = 0;
/*
* Temporary buffer for building response packets. Should help ensure
@@ -287,15 +502,18 @@ char *Traps[] = { "coldStart", "warmStart", "linkDown", "linkUp",
int NUnits;
-
/*
- * fd for units which have seen a coldStart TRAP and are now exchaning SNMP requests
+ * Time last coldStart trap was sent to this unit
+ */
+time_t last_trap[MAX_UNITS];
+/*
+ * fd for units still awiting coldStart TRAP from network side
*/
-int ilmi_fd[MAX_UNITS + 1];
+int trap_fd[MAX_UNITS];
/*
- * enum ilmi_states for this unit
+ * fd for units which have seen a coldStart TRAP and are now exchaning SNMP requests
*/
-int ilmi_state[MAX_UNITS + 1];
+int ilmi_fd[MAX_UNITS];
/*
* Local copy for HARP physical configuration information
*/
@@ -306,17 +524,11 @@ struct air_cfg_rsp Cfg[MAX_UNITS + 1];
struct air_int_rsp Intf[MAX_UNITS + 1];
/*
- * addressEntry table
- */
-Objid addressEntry[MAX_UNITS + 1];
-
-/*
* When this daemon started
*/
struct timeval starttime;
int Debug_Level = 0;
-int foregnd = 0; /* run in the foreground? */
char *progname;
char hostname[80];
@@ -325,6 +537,14 @@ char hostname[80];
#define LOG_FILE "/var/log/ilmid"
FILE *Log; /* File descriptor for log messages */
+extern int errno;
+
+#ifdef sun
+extern char *optarg;
+extern int optind, opterr;
+extern int getopt __P((int, char **, char *));
+#endif /* sun */
+
void set_reqid __P ( ( u_char *, int ) );
void Increment_DL __P ( ( int ) );
void Decrement_DL __P ( ( int ) );
@@ -354,11 +574,10 @@ write_timestamp()
clock = time ( (time_t)NULL );
tm = localtime ( &clock );
- if ( Log && Debug_Level > 1 )
- if ( Log != stderr )
- fprintf ( Log, "%.3s %2d %.2d:%.2d:%.2d %s: ",
- Months[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min,
- tm->tm_sec, hostname );
+ if ( Log )
+ fprintf ( Log, "%.3s %2d %.2d:%.2d:%.2d %s: ",
+ Months[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min,
+ tm->tm_sec, hostname );
return;
@@ -398,10 +617,8 @@ hexdump ( bp, len )
for ( ; j < 8 && j + i < len; j++ )
if ( Log )
fprintf ( Log, "%.2x ", *bp++ );
- if ( Log ) {
+ if ( Log )
fprintf ( Log, " " );
- fflush ( Log );
- }
for ( ; j < 12 && j + i < len; j++ )
if ( Log )
fprintf ( Log, "%.2x ", *bp++ );
@@ -410,10 +627,8 @@ hexdump ( bp, len )
for ( ; j < 16 && j + i < len; j++ )
if ( Log )
fprintf ( Log, "%.2x ", *bp++ );
- if ( Log ) {
+ if ( Log )
fprintf ( Log, "\n" );
- fflush ( Log );
- }
}
return;
@@ -431,32 +646,24 @@ hexdump ( bp, len )
*
* Arguments:
* bufp - pointer to buffer pointer
- * plen - pointer to PDU length or NULL if not a concern
*
* Returns:
* bufp - updated buffer pointer
- * plen - (possibly) adjusted pdu length
* <len> - decoded length
*
*/
int
-asn_get_pdu_len ( bufp, plen )
- u_char **bufp;
- int *plen;
+asn_get_pdu_len ( bufp )
+ u_char **bufp;
{
u_char *bp = *bufp;
int len = 0;
int i, b;
b = *bp++;
- if ( plen )
- (*plen)--;
if ( b & 0x80 ) {
- for ( i = 0; i < (b & ~0x80); i++ ) {
+ for ( i = 0; i < (b & ~0x80); i++ )
len = len * 256 + *bp++;
- if ( plen )
- (*plen)--;
- }
} else
len = b;
@@ -513,18 +720,15 @@ asn_get_encoded ( bufp, len )
*
* Arguments:
* bufp - pointer to the buffer pointer
- * plen - pointer to PDU length or NULL if not a concern
*
* Returns:
* bufp - updated buffer pointer
- * plen - (possibly) updated PDU length
* <val> - value of encoded integer
*
*/
int
-asn_get_int ( bufp, plen )
- u_char **bufp;
- int *plen;
+asn_get_int ( bufp )
+ u_char **bufp;
{
int i;
int len;
@@ -532,69 +736,14 @@ asn_get_int ( bufp, plen )
u_char *bp = *bufp;
len = *bp++;
- if ( plen )
- (*plen)--;
for ( i = 0; i < len; i++ ) {
v = (v * 256) + *bp++;
- if ( plen )
- (*plen)--;
}
*bufp = bp;
return ( v );
}
/*
- * Set a BER encoded integer
- *
- * Arguments:
- * bufp - pointer to buffer pointer where we are to set int in
- * val - integer value to set
- *
- * Returns:
- * none
- * <bufp> - updated buffer pointer
- *
- */
-void
-asn_set_int ( bufp, val )
- u_char **bufp;
- int val;
-{
- union {
- int i;
- u_char c[4];
- } u;
- int len = sizeof(int);
- int i = 0;
- u_char *bp = *bufp;
-
- /* Check for special case where val == 0 */
- if ( val == 0 ) {
- *bp++ = 1;
- *bp++ = 0;
- *bufp = bp;
- return;
- }
-
- u.i = htonl ( val );
-
- while ( u.c[i] == 0 && i++ < sizeof(int) )
- len--;
-
- if ( u.c[i] > 0x7f ) {
- i--;
- len++;
- }
-
- *bp++ = len;
- UM_COPY ( (caddr_t)&u.c[sizeof(int)-len], bp, len );
- bp += len;
- *bufp = bp;
-
- return;
-}
-
-/*
* Utility to print a object identifier
*
* Arguments:
@@ -633,19 +782,16 @@ print_objid ( objid )
* Arguments:
* bufp - pointer to buffer pointer
* objid - pointer to objid buffer
- * plen - pointer to PDU length or NULL of not a concern
*
* Returns:
* bufp - updated buffer pointer
* objid - internal representation of encoded objid
- * plen - (possibly) adjusted PDU length
*
*/
void
-asn_get_objid ( bufp, objid, plen )
- u_char **bufp;
- Objid *objid;
- int *plen;
+asn_get_objid ( bufp, objid )
+ u_char **bufp;
+ Objid *objid;
{
int len;
u_char *bp = *bufp;
@@ -653,53 +799,17 @@ asn_get_objid ( bufp, objid, plen )
int oidlen = 0;
len = *bp++;
- if ( plen )
- (*plen)--;
while ( len ) {
*ip++ = asn_get_encoded ( &bp, &len );
- if ( plen )
- (*plen)--;
oidlen++;
}
objid->oid[0] = oidlen;
*bufp = bp;
- return;
-}
-
-/*
- * Put OBJID - assumes elements <= 16383 for two byte coding
- *
- */
-int
-asn_put_objid ( bufp, objid )
- u_char **bufp;
- Objid *objid;
-{
- int len = 0;
- u_char *bp = *bufp;
- u_char *cpp;
- int i;
-
- cpp = bp;
- *bp++ = objid->oid[0];
- len++;
- for ( i = 1; i <= objid->oid[0]; i++ ) {
- u_int c = objid->oid[i];
-
- while ( c > 127 ) {
- *bp++ = ( ( c >> 7 ) & 0x7f ) | 0x80;
- len++;
- c &= 0x7f; /* XXX - assumption of two bytes */
- (*cpp)++;
- }
- *bp++ = c;
- len++;
- }
-
- *bufp = bp;
- return ( len );
+ if ( Debug_Level > 1 )
+ print_objid ( objid );
+ return;
}
/*
@@ -711,19 +821,16 @@ asn_put_objid ( bufp, objid )
* Arguments:
* bufp - pointer to buffer pointer
* octet - pointer to octet buffer
- * plen - pointer to PDU length
*
* Returns:
* bufp - updated buffer pointer
* octet - encoded Octet String
- * plen - (possibly) adjusted PDU length
*
*/
void
-asn_get_octet ( bufp, octet, plen )
- u_char **bufp;
- char *octet;
- int *plen;
+asn_get_octet ( bufp, octet )
+ u_char **bufp;
+ char *octet;
{
u_char *bp = *bufp;
int i = 0;
@@ -733,13 +840,10 @@ asn_get_octet ( bufp, octet, plen )
* &i is really a dummy value here as we don't keep track
* of the ongoing buffer length
*/
- len = asn_get_encoded ( &bp, &i, plen );
+ len = asn_get_encoded ( &bp, &i );
- for ( i = 0; i < len; i++ ) {
+ for ( i = 0; i < len; i++ )
*octet++ = *bp++;
- if ( plen )
- (*plen)--;
- }
*bufp = bp;
@@ -761,133 +865,22 @@ void
print_header ( Hdr )
Snmp_Header *Hdr;
{
- Variable *var;
-
if ( Log ) {
write_timestamp();
fprintf ( Log,
- "Pdu len: %d Version: %d Community: \"%s\" Pdu Type: 0x%x %s\n",
+ "Pdu len: %d Version: %d Community: \"%s\" Pdu Type: 0x%x\n",
Hdr->pdulen, Hdr->version + 1, Hdr->community,
- Hdr->pdutype, PDU_Types[Hdr->pdutype - PDU_TYPE_GET] );
- write_timestamp();
- if ( Hdr->pdutype != PDU_TYPE_TRAP && Log )
- fprintf ( Log, "\tReq Id: 0x%x Error: %d Error Index: %d\n",
- Hdr->reqid, Hdr->error, Hdr->erridx );
- }
-
- var = Hdr->head;
- while ( var ) {
- if ( Log ) {
- write_timestamp();
- fprintf ( Log, " Variable Type: %d", var->type );
- if ( Var_Types[var->type] )
- fprintf ( Log, " %s", Var_Types[var->type] );
- fprintf ( Log, "\n\tObject: " );
- print_objid ( &var->oid );
- fprintf ( Log, "\tValue: " );
- switch ( var->type ) {
- case ASN_INTEGER:
- fprintf ( Log, "%d (0x%x)\n", var->var.ival, var->var.ival );
- break;
- case ASN_NULL:
- fprintf ( Log, "NULL" );
- break;
- default:
- fprintf ( Log, "[0x%x]", var->type );
- break;
- }
- fprintf ( Log, "\n" );
- }
- var = var->next;
+ Hdr->pdutype );
}
+ if ( Hdr->pdutype != PDU_TYPE_TRAP && Log )
+ fprintf ( Log, "\tReq Id: 0x%x Error: %d Error Index: %d\n",
+ Hdr->reqid, Hdr->error, Hdr->erridx );
return;
}
/*
- * Pull OID's from GET/SET message
- *
- * Arguments:
- * h - pointer to Snmp_Header
- * bp - pointer to input PDU
- *
- * Returns:
- * none
- *
- */
-void
-parse_oids ( h, bp )
- Snmp_Header *h;
- caddr_t *bp;
-{
- int len = h->varlen;
- int sublen;
- Variable *var;
- caddr_t bufp = *bp;
-
- while ( len > 0 ) {
- if ( *bufp++ == ASN_SEQUENCE ) {
- len--;
-
- /* Create new Variable instance */
- if ( ( var = (Variable *)UM_ALLOC(sizeof(Variable)) ) == NULL )
- {
- *bp = bufp;
- return;
- }
- /* Link to tail */
- if ( h->tail )
- h->tail->next = var;
- /* Set head iff NULL */
- if ( h->head == NULL ) {
- h->head = var;
- }
- /* Adjust tail */
- h->tail = var;
-
- /* Get length of variable sequence */
- sublen = asn_get_pdu_len ( &bufp, &len );
- /* Should be OBJID type */
- if ( *bufp++ != ASN_OBJID ) {
- *bp = bufp;
- return;
- }
- asn_get_objid ( &bufp, &var->oid, &len );
- var->type = *bufp++;
- len--;
- switch ( var->type ) {
- case ASN_INTEGER:
- var->var.ival = asn_get_int ( &bufp, &len );
- break;
- case ASN_NULL:
- bufp++;
- len--;
- break;
- case ASN_OBJID:
- asn_get_objid ( &bufp, &var->var.oval, &len );
- break;
- case ASN_OCTET:
- asn_get_octet ( &bufp, var->var.sval, &len );
- break;
- default:
- if ( Log ) {
- write_timestamp();
- fprintf ( Log, "Unknown variable type: %d\n",
- var->type );
- }
- break;
- }
- var->next = NULL;
- } else
- break;
- }
-
- *bp = bufp;
- return;
-}
-
-/*
* Crack the SNMP header
*
* Pull the PDU length, SNMP version, SNMP community and PDU type.
@@ -908,8 +901,6 @@ asn_get_header ( bufp )
{
Snmp_Header *h;
u_char *bp = *bufp;
- int len = 0;
- int dummy = 0;
/*
* Allocate memory to hold the SNMP header
@@ -918,11 +909,6 @@ asn_get_header ( bufp )
return ( (Snmp_Header *)NULL );
/*
- * Ensure that we wipe the slate clean
- */
- UM_ZERO ( h, sizeof ( Snmp_Header ) );
-
- /*
* PDU has to start as SEQUENCE OF
*/
if ( *bp++ != ASN_SEQUENCE ) /* Class == Universial, f == 1, tag == SEQUENCE */
@@ -931,7 +917,7 @@ asn_get_header ( bufp )
/*
* Get the length of remaining PDU data
*/
- h->pdulen = asn_get_pdu_len ( &bp, NULL );
+ h->pdulen = asn_get_pdu_len ( &bp );
/*
* We expect to find an integer encoding Version-1
@@ -939,7 +925,7 @@ asn_get_header ( bufp )
if ( *bp++ != ASN_INTEGER ) {
return ( (Snmp_Header *)NULL );
}
- h->version = asn_get_int ( &bp, NULL );
+ h->version = asn_get_int ( &bp );
/*
* After the version, we need the community name
@@ -947,7 +933,8 @@ asn_get_header ( bufp )
if ( *bp++ != ASN_OCTET ) {
return ( (Snmp_Header *)NULL );
}
- asn_get_octet ( &bp, h->community, NULL );
+ UM_ZERO ( h->community, sizeof ( h->community ) );
+ asn_get_octet ( &bp, h->community );
/*
* Single byte PDU type
@@ -959,43 +946,31 @@ asn_get_header ( bufp )
*/
if ( h->pdutype != PDU_TYPE_TRAP ) { /* TRAP uses different format */
- (void) asn_get_pdu_len ( &bp, &dummy );
+ bp++; /* Skip over data len */
/* Request ID */
if ( *bp++ != ASN_INTEGER ) {
- UM_FREE ( h );
return ( (Snmp_Header *)NULL );
}
- h->reqid = asn_get_int ( &bp, NULL );
+ h->reqid = asn_get_int ( &bp );
/* Error Status */
if ( *bp++ != ASN_INTEGER ) {
- UM_FREE ( h );
return ( (Snmp_Header *)NULL );
}
- h->error = asn_get_int ( &bp, NULL );
+ h->error = asn_get_int ( &bp );
/* Error Index */
if ( *bp++ != ASN_INTEGER ) {
- UM_FREE ( h );
- return ( (Snmp_Header *)NULL );
- }
- h->erridx = asn_get_int ( &bp, NULL );
-
- /* Sequence of... */
- if ( *bp++ != ASN_SEQUENCE ) {
- UM_FREE ( h );
return ( (Snmp_Header *)NULL );
}
- h->varlen = ( asn_get_pdu_len ( &bp, &len ) - 1 );
- h->varlen += ( len - 1 );
+ h->erridx = asn_get_int ( &bp );
- parse_oids ( h, &bp );
}
*bufp = bp;
- if ( Log && Debug_Level )
+ if ( Debug_Level > 2 )
print_header ( h );
return ( h );
@@ -1003,7 +978,7 @@ asn_get_header ( bufp )
}
/*
- * Compare two internal OID representations
+ * Compare to internal OID representations
*
* Arguments:
* oid1 - Internal Object Identifier
@@ -1019,54 +994,18 @@ oid_cmp ( oid1, oid2 )
Objid *oid1, *oid2;
{
int i;
- int len;
/*
* Compare lengths
*/
- if ( !(oid1->oid[0] == oid2->oid[0] ) )
+ if ( !(oid1->oid[0] == oid2->oid[0]) )
/* Different lengths */
return ( 1 );
- len = oid1->oid[0];
-
- /*
- * value by value compare
- */
- for ( i = 1; i <= len; i++ ) {
- if ( !(oid1->oid[i] == oid2->oid[i]) )
- /* values don't match */
- return ( 1 );
- }
-
- /* Objid's are identical */
- return ( 0 );
-}
-
-/*
- * Compare two internal OID representations
- *
- * Arguments:
- * oid1 - Internal Object Identifier
- * oid2 - Internal Object Identifier
- * len - Length of OID to compare
- *
- * Returns:
- * 0 - Objid's match
- * 1 - Objid's don't match
- *
- */
-int
-oid_ncmp ( oid1, oid2, len )
- Objid *oid1, *oid2;
- int len;
-{
- int i;
-
/*
* value by value compare
*/
- for ( i = 1; i <= len; i++ ) {
+ for ( i = 1; i <= oid1->oid[0]; i++ ) {
if ( !(oid1->oid[i] == oid2->oid[i]) )
/* values don't match */
return ( 1 );
@@ -1077,50 +1016,35 @@ oid_ncmp ( oid1, oid2, len )
}
/*
- * Find the index of a OBJID which matches this Variable instance
- *
- * Arguments:
- * var - pointer to Variable instance
- *
- * Returns:
- * idx - index of matched Variable instance
- * -1 - no matching Variable found
+ * Encode a timeval as the number of time ticks
*
- */
-int
-find_var ( var )
- Variable *var;
-{
- int i;
-
- for ( i = 0; i < NUM_OIDS; i++ )
- if ( oid_cmp ( &var->oid, &Objids[i] ) == 0 ) {
- return ( i );
- }
-
- return ( -1 );
-
-}
-
-/*
- * Return the time process has been running as a number of ticks
+ * Time ticks are the number of 100th's of a second since some event.
+ * For sysUpTime, this is the time ticks since the application started,
+ * not since the host came up. We only support encoding ticks since we
+ * started running (what we are calling 'starttime').
*
* Arguments:
- * none
+ * bufp - pointer to buffer pointer
*
* Returns:
- * number of ticks
+ * bufp - updated buffper pointer
+ * len - number of bytes to encode time ticks value
+ * - ticks since 'starttime' encoded in buffer
*
*/
int
-get_ticks()
+asn_encode_ticks ( bufp, ret )
+ u_char **bufp;
+ int *ret;
{
- struct timeval timenow;
- struct timeval timediff;
+ struct timeval timenow;
+ struct timeval timediff;
+ u_char *bp = *bufp;
+ int len, ticks;
(void) gettimeofday ( &timenow, NULL );
/*
- * Adjust for subtraction
+ * Adjust for subtraction
*/
timenow.tv_sec--;
timenow.tv_usec += 1000000;
@@ -1140,252 +1064,139 @@ get_ticks()
}
/*
- * Compute number of ticks
+ * Compute 100th's of second in diff time structure
*/
- return ( ( timediff.tv_sec * 100 ) + ( timediff.tv_usec / 10000 ) );
+ *ret = ticks = (timediff.tv_sec * 100) + (timediff.tv_usec / 10000);
+
+ /*
+ * The rest of this is just plain gross. I'm sure there
+ * are better ways to do this...
+ */
+
+ /* Compute time ticks length */
+ if ( ticks < 0xFF )
+ len = 1;
+ else if ( ticks < 0xFFFF )
+ len = 2;
+ else if ( ticks < 0xFFFFFF )
+ len = 3;
+ else
+ len = 4;
+
+ /*
+ * Encode time ticks
+ */
+ *bp++ = ASN_TIMESTAMP; /* Time Ticks */
+ *bp++ = len; /* length of value */
+
+ /* there's always a better way but this is quick and dirty... */
+ if ( ticks > 0xFFFFFF ) {
+ *bp++ = ( ticks & 0xFF000000 ) >> 24;
+ ticks &= 0xFFFFFF;
+ }
+ if ( ticks > 0xFFFF ) {
+ *bp++ = ( ticks & 0xFF0000 ) >> 16;
+ ticks &= 0xFFFF;
+ }
+ if ( ticks > 0xFF ) {
+ *bp++ = ( ticks & 0xFF00 ) >> 8;
+ ticks &= 0xFF;
+ }
+ *bp++ = ticks;
+ *bufp = bp;
+ return ( len + 2 );
}
/*
- * Build a response PDU
+ * Send back up sysUpTime response
*
* Arguments:
- * hdr - pointer to PDU Header with completed Variable list
- *
+ * sd - socket descriptor to send reply on
+ * reqid - original GET request id
+ *
* Returns:
- * none
+ * none - response sent
*
*/
void
-build_pdu ( hdr, type )
- Snmp_Header *hdr;
- int type;
+send_uptime_resp ( sd, reqid )
+ int sd;
+ int reqid;
{
- u_char *bp = Resp_Buf;
- u_char *vpp;
- u_char *ppp;
- int erridx = 0;
- int varidx = 1;
- int varlen = 0;
- int pdulen = 0;
- int traplen = 0;
- Variable *var;
-
- /*
- * Clear out the reply
- */
- UM_ZERO ( Resp_Buf, sizeof(Resp_Buf) );
-
- /* [0] is reserved for overall length */
- bp++;
-
- /* Start with SEQUENCE OF */
- *bp++ = ASN_SEQUENCE;
- /* - assume we can code length in two octets */
- *bp++ = 0x82;
- bp++;
- bp++;
- /* Version */
- *bp++ = ASN_INTEGER;
- asn_set_int ( &bp, hdr->version );
- /* Community name */
- *bp++ = ASN_OCTET;
- *bp++ = strlen ( hdr->community );
- UM_COPY ( hdr->community, bp, strlen ( hdr->community ) );
- bp += strlen ( hdr->community );
- /* PDU Type */
- *bp++ = type;
- ppp = bp;
- /* Length of OID data - assume it'll fit in one octet */
- bp++;
-
- if ( type != PDU_TYPE_TRAP ) {
- /* Sequence ID */
- *bp++ = ASN_INTEGER;
- asn_set_int ( &bp, hdr->reqid );
- /*
- * Check to see if all the vaiables were resolved - we do this
- * by looking for something which still has a ASN_NULL value.
- */
- var = hdr->head;
- if ( type == PDU_TYPE_GETRESP ) {
- while ( var && erridx == 0 ) {
- if ( var->type != ASN_NULL ) {
- varidx++;
- var = var->next;
- } else
- erridx = varidx;
- }
- }
-
- /* Error status */
- *bp++ = ASN_INTEGER;
- *bp++ = 0x01; /* length = 1 */
- if ( erridx )
- *bp++ = 0x02; /* NoSuch */
- else
- *bp++ = 0x00; /* NoError */
- /* Error Index */
- *bp++ = ASN_INTEGER;
- *bp++ = 0x01; /* length = 1 */
- *bp++ = erridx; /* index - 0 if no error */
- } else {
- /* type == PDU_TYPE_TRAP */
-
- /* Fill in ENTERPRISE OBJID */
- *bp++ = ASN_OBJID;
- (void) asn_put_objid ( &bp, &hdr->enterprise );
-
- /* Fill in IP address */
- *bp++ = ASN_IPADDR;
- *bp++ = sizeof ( hdr->ipaddr );
- UM_COPY ( (caddr_t)&hdr->ipaddr, bp, sizeof(hdr->ipaddr) );
- bp += sizeof(hdr->ipaddr);
-
- /* Fill in generic and specific trap types */
- *bp++ = ASN_INTEGER;
- asn_set_int ( &bp, hdr->generic_trap );
- *bp++ = ASN_INTEGER;
- asn_set_int ( &bp, hdr->specific_trap );
-
- /* Fill in time-stamp - assume 0 for now */
- *bp++ = ASN_TIMESTAMP;
- asn_set_int ( &bp, 0 );
-
- /* encoded length */
- traplen = ( bp - ppp - 1 );
+ int len;
+ short *sp;
+ u_long *ip;
+ u_char *bp;
+ short val;
+ int ticks;
- /* Continue with variable processing */
- }
+ COPY_RESP ( sysUpTime_Resp );
- /* SEQUENCE OF */
- *bp++ = ASN_SEQUENCE;
- *bp++ = 0x82;
- /* - assume we can code length in two octets */
- vpp = bp;
- varlen = 0;
- bp++;
- bp++;
-
- /* Install Variables */
- var = hdr->head;
- varidx = 1;
- while ( var ) {
- u_char *bpp;
- int len = 0;
-
- /* SEQUENCE OF */
- *bp++ = ASN_SEQUENCE;
- *bp++ = 0x82;
- /* - assume we can code length in two octets */
- bpp = bp;
- bp++;
- bp++;
- /* OBJID */
- *bp++ = ASN_OBJID;
- len++;
- len += asn_put_objid ( &bp, &var->oid );
+ bp = (u_char *)&Resp_Buf[Resp_Buf[0]+1];
+ len = asn_encode_ticks ( &bp, &ticks );
- if ( erridx && varidx >= erridx ) {
- /* Code this variable as NULL */
- *bp++ = ASN_NULL;
- len++;
- bp++;
- len++;
- } else {
- u_char *lpp;
- /* Variable type */
- *bp++ = var->type;
- len++;
- lpp = bp;
- switch ( var->type ) {
- case ASN_INTEGER:
- asn_set_int ( &bp, var->var.ival );
- len += ( *lpp + 1 );
- break;
- case ASN_OCTET:
- *bp++ = var->var.sval[0];
- len++;
- UM_COPY ( (caddr_t)&var->var.sval[1],
- bp, var->var.sval[0] );
- len += var->var.sval[0];
- bp += var->var.sval[0];
- break;
- case ASN_NULL:
- *bp++ = 0x00;
- len++;
- break;
- case ASN_OBJID:
- len += asn_put_objid ( &bp, &var->var.oval );
- break;
- case ASN_SEQUENCE:
- break;
- case ASN_IPADDR:
- *bp++ = 4;
- len++;
- UM_COPY ( (caddr_t)&var->var.aval, bp, 4 );
- len += 4;
- bp += 4;
- break;
- case ASN_TIMESTAMP:
- asn_set_int ( &bp, var->var.ival );
- len += ( *lpp + 1 );
- break;
- default:
- break;
- }
- }
+ /*
+ * Adjust overall length
+ */
+ bp = (u_char *)&Resp_Buf[0];
+ *bp += len;
- /* Accumulate total Variable sequence length */
- varlen += (len + 4);
+ /*
+ * Adjust sequence lengths - works because this is my
+ * PDU and I know all the variable lengths are fixed (ie.
+ * reqid is always 4 byte encoded).
+ */
+#ifndef sun
+ sp = (short *)&Resp_Buf[3];
+ val = ntohs ( *sp );
+ *sp = htons ( val + len );
+ Resp_Buf[15] += len;
+ sp = (u_short *)&Resp_Buf[30];
+ val = ntohs ( *sp );
+ *sp = htons ( val + len );
+ sp = (u_short *)&Resp_Buf[34];
+ val = ntohs ( *sp );
+ *sp = htons ( val + len );
+#else
+ /* Sun SPARCs have alignment requirements */
+ Resp_Buf[4] += len;
+ Resp_Buf[15] += len;
+ Resp_Buf[31] += len;
+ Resp_Buf[35] += len;
+#endif /* sun */
- /* Fill in length of this sequence */
- bpp[1] = len & 0xff;
- bpp[0] = len >> 8;
+ /*
+ * Store the original request ID in the response
+ */
+ set_reqid ( Resp_Buf, reqid );
+#ifdef notdef
+#ifndef sun
+ ip = (u_long *)&Resp_Buf[18];
+ *ip = htonl ( reqid );
+#else
+ /* Sun SPARCs have alignment requirements */
+ UM_COPY ( (caddr_t)&reqid, (caddr_t)&Resp_Buf[18], sizeof(reqid) );
+#endif /* sun */
+#endif
- var = var->next;
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "\tSend sysUpTime: %d\n", ticks );
}
-
- /* Fill in length of Variable sequence */
- vpp[1] = varlen & 0xff;
- vpp[0] = varlen >> 8;
-
- if ( type != PDU_TYPE_TRAP ) {
- /* Fill in length of data AFTER PDU type */
- *ppp = varlen + 12 + ppp[2]; /* + length of reqid */
- } else {
- /* Fill in length of data AFTER PDU type */
- *ppp = varlen + traplen + 4; /* + length of initial sequence of */
+ if ( Debug_Level > 4 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "\n===== Sent %d bytes =====\n", Resp_Buf[0] );
+ hexdump ( (u_char *)&Resp_Buf[1], Resp_Buf[0] );
}
-
- /* Fill in overall sequence length */
- pdulen = *ppp + 7 + strlen ( hdr->community );
- Resp_Buf[4] = pdulen & 0x7f;
- Resp_Buf[3] = pdulen >> 8;
-
- pdulen = bp - Resp_Buf - 1;
-
- Resp_Buf[0] = pdulen;
-
- hdr->pdutype = type;
+ /*
+ * Send response
+ */
+ write ( sd, (caddr_t)&Resp_Buf[1], Resp_Buf[0] );
return;
-}
-void
-free_pdu ( hdr )
-Snmp_Header *hdr;
-{
- Variable *var;
-
- while ( hdr->head ) {
- var = hdr->head->next; /* Save next link */
- UM_FREE ( hdr->head ); /* Free current var */
- hdr->head = var; /* Set head to next link */
- }
-
- UM_FREE ( hdr ); /* Free fixed portion */
}
/*
@@ -1410,7 +1221,11 @@ set_reqid ( resp, reqid )
u_char c[4];
} u;
+#ifndef sun
u.i = htonl(reqid);
+#else
+ u.i = reqid;
+#endif /* !sun */
/*
* Replace the current Request ID with the supplied value
@@ -1418,6 +1233,7 @@ set_reqid ( resp, reqid )
UM_COPY ( (caddr_t)&u.c[4-resp[17]], bp, resp[17] );
return;
+
}
/*
@@ -1433,77 +1249,24 @@ set_reqid ( resp, reqid )
*
*/
void
-send_resp ( intf, Hdr, resp )
- int intf;
- Snmp_Header *Hdr;
+send_resp ( sd, reqid, resp )
+ int sd;
+ int reqid;
u_char *resp;
{
- int n;
- if ( ilmi_fd[intf] > 0 ) {
- n = write ( ilmi_fd[intf], (caddr_t)&resp[1], resp[0] );
- if ( Log && Debug_Level > 1 ) {
+ set_reqid ( resp, reqid );
+
+ if ( Debug_Level > 1 && Log ) {
write_timestamp();
- fprintf ( Log, "===== Sent %d of %d bytes (%d) =====\n", n, resp[0], ilmi_fd[intf] );
- print_header ( Hdr );
- if ( Debug_Level > 2 )
- hexdump ( (u_char *)&resp[1], resp[0] );
- }
+ fprintf ( Log, "===== Sent %d bytes =====\n", resp[0] );
+ hexdump ( (u_char *)&resp[1], resp[0] );
}
+ write ( sd, (caddr_t)&resp[1], resp[0] );
- free_pdu ( Hdr );
return;
}
-/*
- * Build a COLD_START TRAP PDU
- *
- */
-Snmp_Header *
-build_cold_start()
-{
- Snmp_Header *hdr;
- Variable *var;
-
- hdr = (Snmp_Header *)UM_ALLOC (sizeof(Snmp_Header));
-
- hdr->pdulen = 0;
- hdr->version = SNMP_VERSION_1 - 1;
- snprintf ( hdr->community, sizeof(hdr->community), "ILMI" );
-
- hdr->ipaddr = 0x0; /* 0.0.0.0 */
- hdr->generic_trap = TRAP_COLDSTART;
- hdr->specific_trap = 0;
- UM_COPY ( (caddr_t)&Objids[ENTERPRISE_OBJID], (caddr_t)&hdr->enterprise,
- sizeof(Objid) );
-
- hdr->head = (Variable *)UM_ALLOC(sizeof(Variable));
- var = hdr->head;
- UM_COPY ( (caddr_t)&Objids[UPTIME_OBJID], (caddr_t)&var->oid,
- sizeof(Objid) );
- var->type = ASN_NULL;
-
- return ( hdr );
-}
-
-/*
- * Build a Generic PDU Header
- *
- */
-Snmp_Header *
-build_generic_header()
-{
- Snmp_Header *hdr;
-
- hdr = (Snmp_Header *)UM_ALLOC(sizeof(Snmp_Header));
-
- hdr->pdulen = 0;
- hdr->version = SNMP_VERSION_1 - 1;
- snprintf ( hdr->community, sizeof(hdr->community), "ILMI" );
-
- return ( hdr );
-}
-
/*
* Initialize information on what physical adapters HARP knows about
*
@@ -1522,7 +1285,7 @@ void
init_ilmi()
{
struct air_cfg_rsp *cfg_info = NULL;
- struct air_int_rsp *intf_info = NULL;
+ struct air_intf_rsp *intf_info = NULL;
int buf_len;
/*
@@ -1536,6 +1299,10 @@ init_ilmi()
UM_ZERO ( Cfg, sizeof(Cfg) );
UM_ZERO ( Intf, sizeof(Intf) );
NUnits = 0;
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "NUnits: %d\n", NUnits );
+ }
return;
}
@@ -1547,8 +1314,12 @@ init_ilmi()
* Compute how many units information was returned for
*/
NUnits = buf_len / sizeof(struct air_cfg_rsp);
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "NUnits: %d\n", NUnits );
+ }
/* Housecleaning */
- UM_FREE ( cfg_info );
+ free ( cfg_info );
cfg_info = NULL;
/*
* Get the per interface information
@@ -1567,7 +1338,7 @@ init_ilmi()
*/
UM_COPY ( intf_info, (caddr_t)Intf, buf_len );
/* Housecleaning */
- UM_FREE ( intf_info );
+ free ( intf_info );
intf_info = NULL;
return;
@@ -1599,15 +1370,28 @@ ilmi_open ()
struct t_atm_qos qos;
struct t_atm_app_name appname;
Atm_addr subaddr;
+ char buffer[MAX_LEN+1];
char nifname[IFNAMSIZ];
int optlen;
int unit = 0;
+ struct timer_elem *open_timer,
+ *state_timer;
u_char sig_proto;
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "ilmi_open()\n" );
+ }
init_ilmi();
for ( unit = 0; unit < NUnits; unit++ ) {
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "Unit: %d Sig: %d Trap: %d Ilmi: %d\n",
+ unit, Intf[unit].anp_sig_proto, trap_fd[unit],
+ ilmi_fd[unit] );
+ }
/*
* ILMI only makes sense for UNI signalling protocols
*/
@@ -1616,11 +1400,16 @@ ilmi_open ()
sig_proto != ATM_SIG_UNI40 )
continue;
- if ( ilmi_fd[unit] == -1 ) {
+ /*
+ * If we're waiting for a coldStart TRAP, we'll be in trap_fd[],
+ * If we're processing ILMI, we'll be in ilmi_fd[], otherwise,
+ * this unit hasn't been opened yet.
+ */
+ if ( trap_fd[unit] == -1 && ilmi_fd[unit] == -1 ) {
- ilmi_fd[unit] = socket ( AF_ATM, SOCK_SEQPACKET, ATM_PROTO_AAL5 );
+ trap_fd[unit] = socket ( AF_ATM, SOCK_SEQPACKET, ATM_PROTO_AAL5 );
- if ( ilmi_fd[unit] < 0 ) {
+ if ( trap_fd[unit] < 0 ) {
perror ( "open" );
continue;
}
@@ -1633,13 +1422,14 @@ ilmi_open ()
write_timestamp();
fprintf ( Log, "No nif on unit %d\n", unit );
}
- close ( ilmi_fd[unit] );
+ close ( trap_fd[unit] );
+ trap_fd[unit] = -1;
ilmi_fd[unit] = -1;
continue;
}
- sprintf ( nifname, "%s0", Intf[unit].anp_nif_pref );
+ sprintf ( nifname, "%s0\0", Intf[unit].anp_nif_pref );
optlen = sizeof ( nifname );
- if ( setsockopt ( ilmi_fd[unit], T_ATM_SIGNALING,
+ if ( setsockopt ( trap_fd[unit], T_ATM_SIGNALING,
T_ATM_NET_INTF, (caddr_t)nifname, optlen ) < 0 ) {
perror ( "setsockopt" );
if ( Log ) {
@@ -1652,8 +1442,9 @@ ilmi_open ()
write_timestamp();
fprintf ( Log, "nifname: closing unit %d\n", unit );
}
- close ( ilmi_fd[unit] );
- ilmi_fd[unit] = -1;
+ close ( trap_fd[unit] );
+ trap_fd[unit] = -1;
+ ilmi_fd[unit] = -1;
continue;
}
@@ -1662,9 +1453,9 @@ ilmi_open ()
*/
UM_ZERO ( (caddr_t) &satm, sizeof(satm) );
satm.satm_family = AF_ATM;
-#if (defined(BSD) && (BSD >= 199103))
+#ifndef sun
satm.satm_len = sizeof(satm);
-#endif
+#endif /* sun */
satm.satm_addr.t_atm_sap_addr.SVE_tag_addr = T_ATM_PRESENT;
satm.satm_addr.t_atm_sap_addr.SVE_tag_selector = T_ATM_ABSENT;
@@ -1690,14 +1481,15 @@ ilmi_open ()
aal5.backward_max_SDU_size = MAX_LEN;
aal5.SSCS_type = T_ATM_NULL;
optlen = sizeof(aal5);
- if ( setsockopt ( ilmi_fd[unit], T_ATM_SIGNALING, T_ATM_AAL5,
+ if ( setsockopt ( trap_fd[unit], T_ATM_SIGNALING, T_ATM_AAL5,
(caddr_t) &aal5, optlen ) < 0 ) {
perror ( "setsockopt(aal5)" );
if ( Debug_Level > 1 && Log ) {
write_timestamp();
fprintf ( Log, "aal5: closing unit %d\n", unit );
}
- close ( ilmi_fd[unit] );
+ close ( trap_fd[unit] );
+ trap_fd[unit] = -1;
ilmi_fd[unit] = -1;
continue;
}
@@ -1718,7 +1510,7 @@ ilmi_open ()
traffic.backward.tagging = T_NO;
traffic.best_effort = T_YES;
optlen = sizeof(traffic);
- if (setsockopt(ilmi_fd[unit], T_ATM_SIGNALING, T_ATM_TRAFFIC,
+ if (setsockopt(trap_fd[unit], T_ATM_SIGNALING, T_ATM_TRAFFIC,
(caddr_t)&traffic, optlen) < 0) {
perror("setsockopt(traffic)");
}
@@ -1728,7 +1520,7 @@ ilmi_open ()
bearer.clipping_susceptibility = T_NO;
bearer.connection_configuration = T_ATM_1_TO_1;
optlen = sizeof(bearer);
- if (setsockopt(ilmi_fd[unit], T_ATM_SIGNALING, T_ATM_BEARER_CAP,
+ if (setsockopt(trap_fd[unit], T_ATM_SIGNALING, T_ATM_BEARER_CAP,
(caddr_t)&bearer, optlen) < 0) {
perror("setsockopt(bearer)");
}
@@ -1737,7 +1529,7 @@ ilmi_open ()
qos.forward.qos_class = T_ATM_QOS_CLASS_0;
qos.backward.qos_class = T_ATM_QOS_CLASS_0;
optlen = sizeof(qos);
- if (setsockopt(ilmi_fd[unit], T_ATM_SIGNALING, T_ATM_QOS, (caddr_t)&qos,
+ if (setsockopt(trap_fd[unit], T_ATM_SIGNALING, T_ATM_QOS, (caddr_t)&qos,
optlen) < 0) {
perror("setsockopt(qos)");
}
@@ -1745,14 +1537,14 @@ ilmi_open ()
subaddr.address_format = T_ATM_ABSENT;
subaddr.address_length = 0;
optlen = sizeof(subaddr);
- if (setsockopt(ilmi_fd[unit], T_ATM_SIGNALING, T_ATM_DEST_SUB,
+ if (setsockopt(trap_fd[unit], T_ATM_SIGNALING, T_ATM_DEST_SUB,
(caddr_t)&subaddr, optlen) < 0) {
perror("setsockopt(dest_sub)");
}
strncpy(appname.app_name, "ILMI", T_ATM_APP_NAME_LEN);
optlen = sizeof(appname);
- if (setsockopt(ilmi_fd[unit], T_ATM_SIGNALING, T_ATM_APP_NAME,
+ if (setsockopt(trap_fd[unit], T_ATM_SIGNALING, T_ATM_APP_NAME,
(caddr_t)&appname, optlen) < 0) {
perror("setsockopt(appname)");
}
@@ -1760,14 +1552,15 @@ ilmi_open ()
/*
* Now try to connect to destination
*/
- if ( connect ( ilmi_fd[unit], (struct sockaddr *) &satm,
+ if ( connect ( trap_fd[unit], (struct sockaddr *) &satm,
sizeof(satm)) < 0 ) {
perror ( "connect" );
if ( Debug_Level > 1 && Log ) {
write_timestamp();
fprintf ( Log, "connect: closing unit %d\n", unit );
}
- close ( ilmi_fd[unit] );
+ close ( trap_fd[unit] );
+ trap_fd[unit] = -1;
ilmi_fd[unit] = -1;
continue;
}
@@ -1776,44 +1569,61 @@ ilmi_open ()
write_timestamp();
fprintf ( Log, "***** opened unit %d\n", unit );
}
-
- ilmi_state[unit] = ILMI_COLDSTART;
-
+ /*
+ * Send coldStart TRAP
+ */
+ if ( Debug_Level > 4 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "===== Sent %d bytes =====\n",
+ coldStart_Trap[0] );
+ hexdump ( (u_char *)&coldStart_Trap[1], coldStart_Trap[0] );
+ }
+ if ( Debug_Level && Log ) {
+ write_timestamp();
+ fprintf ( Log, "\tSend coldStart TRAP to unit %d\n", unit );
+ }
+ last_trap[unit] = time ( (time_t *)NULL );
+ write ( trap_fd[unit], (caddr_t)&coldStart_Trap[1],
+ coldStart_Trap[0] );
}
}
+ signal ( SIGALRM, ilmi_open );
+ alarm ( SLEEP_TIME );
+
return;
}
/*
- * Get our local IP address for this interface
+ * Send our local IP address for this interface
*
* Arguments:
- * s - socket to find address for
- * aval - pointer to variable to store address in
+ * s - socket to send message on
+ * hdr - pointer to internal SNMP header
*
* Returns:
* none
*
*/
void
-get_local_ip ( s, aval )
- int s;
- long *aval;
+send_myipnm ( s, hdr )
+ int s;
+ Snmp_Header *hdr;
{
- char intf_name[IFNAMSIZ];
- int namelen = IFNAMSIZ;
- struct air_netif_rsp *net_info = NULL;
+ char intf_name[IFNAMSIZ];
+ int namelen = IFNAMSIZ;
+ struct air_netif_rsp *net_info = NULL;
struct sockaddr_in *sin;
- /*
- * Get physical interface name
- */
+ COPY_RESP ( MyIpNm_Resp );
+
if ( getsockopt ( s, T_ATM_SIGNALING, T_ATM_NET_INTF,
- (caddr_t) intf_name, &namelen ) )
- return;
+ (caddr_t) intf_name, &namelen ) ) {
+ perror ( "Couldn't get socket name" );
+ return;
+ }
/*
* Get network interface information for this physical interface
@@ -1825,14 +1635,23 @@ get_local_ip ( s, aval )
sin = (struct sockaddr_in *)&net_info->anp_proto_addr;
/*
- * Fill in answer
+ * Copy interface's IP address into reply packet
*/
- UM_COPY ( (caddr_t)&sin->sin_addr.s_addr, aval, 4 );
+ UM_COPY ( (caddr_t)&sin->sin_addr.s_addr, (caddr_t)&Resp_Buf[51],
+ 4 );
+
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "\tSend NM IP address\n" );
+ }
- UM_FREE ( net_info );
+ send_resp ( s, hdr->reqid, Resp_Buf );
+ /*
+ * Clean up
+ */
+ free ( net_info );
return;
-
}
/*
@@ -1853,29 +1672,40 @@ get_local_ip ( s, aval )
*
*/
void
-set_prefix ( oid, hdr, intf )
+set_prefix ( oid, hdr, buf, s )
Objid *oid;
Snmp_Header *hdr;
- int intf;
+ u_char *buf;
+ int s;
{
- struct atmsetreq asr;
- Atm_addr *aa;
- int fd;
- int i;
+ struct atmsetreq asr;
+ Atm_addr *aa;
+ int fd;
+ int i;
+ u_char *cpp;
+ int len; /* PDU length before completion */
+
+ /*
+ * If we don't reply to the SET then it keeps getting retransmitted.
+ */
+ buf[14] = PDU_TYPE_GETRESP;
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "\tSend SET_RESPONSE\n" );
+ }
+ send_resp ( s, hdr->reqid, buf );
/*
* Build IOCTL request to set prefix
*/
asr.asr_opcode = AIOCS_SET_PRF;
- strncpy ( asr.asr_prf_intf, Intf[intf].anp_intf,
+ strncpy ( asr.asr_prf_intf, Intf[0].anp_intf,
sizeof(asr.asr_prf_intf ) );
/*
* Pull prefix out of received Objid
- * save in set_prefix IOCTL and addressEntry table
*/
- for ( i = 0; i < oid->oid[13]; i++ ) {
+ for ( i = 0; i < oid->oid[13]; i++ )
asr.asr_prf_pref[i] = oid->oid[i + 14];
- }
/*
* Pass new prefix to the HARP kernel
@@ -1888,10 +1718,9 @@ set_prefix ( oid, hdr, intf )
syslog ( LOG_ERR, "ilmid: error setting prefix: %m" );
if ( Log ) {
write_timestamp();
- fprintf ( Log, "errno %d setting prefix\n",
+ fprintf ( Log, "ilmid: errno %d setting prefix\n",
errno );
}
- close ( fd );
return;
}
}
@@ -1902,58 +1731,375 @@ set_prefix ( oid, hdr, intf )
*/
init_ilmi();
- aa = &Intf[intf].anp_addr;
+ aa = &Intf[0].anp_addr;
/*
- * Copy our NSAP into addressEntry table
+ * Finish building SET NSAP packet
*/
- addressEntry[intf].oid[0] = 0;
+ COPY_RESP ( NetPrefix_Resp );
+
+ len = Resp_Buf[0];
+ cpp = &Resp_Buf[len + 1]; /* Set to end of response buffer */
+ len++;
+ *cpp++ = aa->address_length;
for ( i = 0; i < aa->address_length; i++ ) {
- addressEntry[intf].oid[0]++; /* Increment length */
- addressEntry[intf].oid[i + 1] = (int)((u_char *)(aa->address))[i];
+ u_char c = ((u_char *)(aa->address))[i];
+ if ( c > 127 ) {
+ *cpp++ = ( c >> 7 ) | 0x80;
+ len++;
+ c &= 0x7f;
+ }
+ *cpp++ = c;
+ len++;
+ }
+ /*
+ * Pack "set = 1" onto end
+ */
+ *cpp++ = 0x02;
+ *cpp++ = 0x01;
+ *cpp++ = 0x01;
+ len += 3;
+
+ /*
+ * Go back and patch up lengths...
+ */
+ Resp_Buf[0] = len;
+ Resp_Buf[4] = (u_char)(len - 4);
+ Resp_Buf[15] = (u_char)(len - 15);
+ Resp_Buf[31] = (u_char)(len - 31);
+ Resp_Buf[35] = (u_char)(len - 35);
+ Resp_Buf[37] = (u_char)(len - 40);
+
+ /*
+ * Set reqid
+ */
+ set_reqid ( Resp_Buf, Req_ID++ );
+
+ /*
+ * Send SET
+ */
+ if ( Debug_Level > 2 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "===== Send SET: %d bytes =====\n",
+ Resp_Buf[0] );
+ hexdump ( (u_char *)&Resp_Buf[1], Resp_Buf[0] );
}
+ write ( s, (caddr_t)&Resp_Buf[1], Resp_Buf[0] );
return;
}
+Objid oid;
+
+/*
+ * Parse an ASN_TYPE_SET pdu
+ *
+ * Crack apart the various pieces of a SET message. The OBJID being set is
+ * left in oid which is compared and handled else where.
+ *
+ * Arguments:
+ * bp - pointer to current location in PDU buffer
+ *
+ * Returns:
+ * bp - updated buffer pointer
+ * 0 - no error
+ * -1 - error in PDU
+ *
+ */
+int
+process_set ( bp )
+ caddr_t *bp;
+{
+ caddr_t bufp = *bp;
+ int pdulen;
+ int b;
+
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "SET:: " );
+ }
+ /*
+ * Should be SEQUENCE OF
+ */
+ if ( *bufp++ != ASN_SEQUENCE ) {
+ *bp = bufp;
+ return ( -1 );
+ }
+ pdulen = asn_get_pdu_len ( &bufp );
+ /*
+ * Should be SEQUENCE OF
+ */
+ if ( *bufp++ != ASN_SEQUENCE ) {
+ *bp = bufp;
+ return ( -1 );
+ }
+ pdulen = asn_get_pdu_len ( &bufp );
+ /*
+ * Should be OBJID
+ */
+ if ( *bufp++ != ASN_OBJID ) {
+ *bp = bufp;
+ return ( -1 );
+ }
+ asn_get_objid ( &bufp, &oid );
+ /*
+ * Should be <= value>
+ */
+ switch ( *bufp++ ) {
+ case ASN_INTEGER:
+ b = asn_get_int ( &bufp );
+ if ( Debug_Level > 5 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "Value = %d\n", b );
+ }
+ break;
+ case ASN_OBJID:
+ break;
+ }
+
+ /*
+ * Return updated pointer
+ */
+ *bp = bufp;
+
+ return ( 0 );
+}
+
+int specific_trap;
+int generic_trap;
+int trap_time;
+u_char trap_ip[5];
+Objid trap_oid;
+Objid extra_trap_oid;
+
+/*
+ * Parse an ASN_TYPE_TRAP pdu
+ *
+ * Crack apart the various pieces of a TRAP message. The information elements are
+ * left in global space and used elsewhere if anyone cares (which they currently don't).
+ *
+ * Arguments:
+ * bp - pointer to current location in PDU buffer
+ * sd - socket descriptor pdu arrived on
+ *
+ * Returns:
+ * bp - updated buffer pointer
+ * 0 - no error
+ * -1 - error in PDU
+ *
+ */
+int
+process_trap ( bp, sd )
+ caddr_t *bp;
+ int sd;
+{
+ caddr_t bufp = *bp;
+ int pdulen;
+ int i;
+
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "TRAP:: " );
+ }
+ /*
+ * Should be pdulen
+ */
+ pdulen = *bufp++;
+ /*
+ * Should be OBJID
+ */
+ if ( *bufp++ != ASN_OBJID ) {
+ if ( Log )
+ fprintf ( Log, "\n" );
+ *bp = bufp;
+ return ( -1 );
+ }
+ asn_get_objid ( &bufp, &trap_oid );
+ /*
+ * First oid coded as 40 * X + Y
+ */
+ if ( Debug_Level > 5 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "%d.%d", trap_oid.oid[1] / 40,
+ trap_oid.oid[1] % 40 );
+ for ( i = 2; i <= trap_oid.oid[0]; i++ )
+ fprintf ( Log, ".%d", trap_oid.oid[i] );
+ fprintf ( Log, "\n" );
+ }
+ /*
+ * Should be OCTET STRING
+ */
+ if ( *bufp++ != ASN_IPADDR ) {
+ if ( Debug_Level > 5 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "Expected IP ADDRESS\n" );
+ }
+ *bp = bufp;
+ return ( -1 );
+ }
+ asn_get_octet ( &bufp, trap_ip );
+ if ( Debug_Level > 5 && Log) {
+ write_timestamp();
+ fprintf ( Log, "\tIP: %d.%d.%d.%d",
+ trap_ip[0], trap_ip[1], trap_ip[2], trap_ip[3] );
+ }
+ /*
+ * Should be Generic Trap followed by Specific Trap
+ */
+ if ( *bufp++ != ASN_INTEGER ) {
+ if ( Log )
+ fprintf ( Log, "\n" );
+ *bp = bufp;
+ return ( -1 );
+ }
+ generic_trap = asn_get_int ( &bufp );
+ if ( Debug_Level > 5 && Log ) {
+ fprintf ( Log, " Generic Trap: %s (%d)",
+ Traps[generic_trap], generic_trap );
+ }
+ if ( *bufp++ != ASN_INTEGER ) {
+ if ( Log )
+ fprintf ( Log, "\n" );
+ *bp = bufp;
+ return ( -1 );
+ }
+ specific_trap = asn_get_int ( &bufp );
+ if ( Debug_Level > 5 && Log ) {
+ fprintf ( Log, " Specific Trap: 0x%x\n",
+ specific_trap );
+ }
+ /*
+ * Should be TIMESTAMP
+ */
+ if ( *bufp++ != ASN_TIMESTAMP ) {
+ if ( Log )
+ fprintf ( Log, "\n" );
+ *bp = bufp;
+ return ( -1 );
+ }
+ trap_time = asn_get_int ( &bufp );
+ if ( Debug_Level > 5 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "\tTimestamp: %d seconds", trap_time );
+ }
+ /*
+ * Should be SEQUENCE OF
+ */
+ if ( *bufp++ != ASN_SEQUENCE ) {
+ *bp = bufp;
+ return ( -1 );
+ }
+ pdulen = asn_get_pdu_len ( &bufp );
+ /*
+ * Should be OBJID
+ */
+ if ( *bufp++ != ASN_OBJID ) {
+ *bp = bufp;
+ return ( -1 );
+ }
+ asn_get_objid ( &bufp, &extra_trap_oid );
+ if ( Debug_Level > 5 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "\tExtra Objid: " );
+ fprintf ( Log, "%d.%d", extra_trap_oid.oid[1] / 40,
+ extra_trap_oid.oid[1] % 40 );
+ for ( i = 2; i <= extra_trap_oid.oid[0]; i++ )
+ fprintf ( Log, ".%d", extra_trap_oid.oid[i] );
+ fprintf ( Log, "\n" );
+ }
+ /*
+ * Whole thing ended with a NULL
+ */
+ bufp++;
+ bufp++;
+
+ /*
+ * Return updated pointer
+ */
+ *bp = bufp;
+
+ if ( generic_trap == 0 ) {
+ write ( sd, (caddr_t)&coldStart_Trap[1],
+ coldStart_Trap[0] );
+ }
+
+ return ( 0 );
+
+}
+
+u_char No_Such[] = { 37,
+ 0x30, 0x82, 0x00, 0x00,
+ 0x02, 0x01, 0x00,
+ 0x04, 0x04, 0x49, 0x4c, 0x4d, 0x49,
+ PDU_TYPE_GETRESP,
+ 0x00,
+ 0x02, 0x04, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x01, 0x02,
+ 0x02, 0x01, 0x01,
+ 0x30, 0x82, 0x00, 0x00,
+ 0x30, 0x82, 0x00, 0x00,
+ 0x06, 0x00
+ };
void
-set_address ( hdr, intf )
- Snmp_Header *hdr;
- int intf;
+send_no_such ( s, Hdr, op )
+ int s;
+ Snmp_Header *Hdr;
+ Objid *op;
{
- Variable *var;
- int i, j;
-
- PDU_Header = build_generic_header();
- PDU_Header->head = (Variable *)UM_ALLOC(sizeof(Variable));
- var = PDU_Header->head;
- /* Copy generic addressEntry OBJID */
- UM_COPY ( (caddr_t)&Objids[ADDRESS_OBJID], (caddr_t)&var->oid,
- sizeof(Objid) );
- /* Set specific instance */
- i = var->oid.oid[0] + 1; /* Get length */
- var->oid.oid[i++] = 1;
- var->oid.oid[i++] = 1;
- var->oid.oid[i++] = 3;
- var->oid.oid[i++] = 0;
-
- /* Copy in address length */
- var->oid.oid[i++] = addressEntry[intf].oid[0];
-
- /* Copy in address */
- for ( j = 0; j < addressEntry[intf].oid[0]; j++ )
- var->oid.oid[i++] = addressEntry[intf].oid[j + 1];
- var->oid.oid[0] = i - 1; /* Set new length */
-
- /* Set == VALID */
- var->type = ASN_INTEGER;
- var->var.ival = 1;
-
- build_pdu ( PDU_Header, PDU_TYPE_SET );
- send_resp ( intf, PDU_Header, Resp_Buf );
+ u_char *cp, *cpp;
+ int len;
+ int i;
+
+ len = No_Such[0];
+
+ UM_COPY ( No_Such, Resp_Buf, len + 1 );
+
+ cp = cpp = (u_char *)&Resp_Buf[len];
+
+ /*
+ * Copy OID into response buffer
+ */
+ *cp++ = op->oid[0];
+ for ( i = 1; i <= op->oid[0]; i++ ) {
+ u_int c = op->oid[i];
+
+ if ( c > 127 ) {
+ *cp++ = ( c >> 7 ) | 0x80;
+ len++;
+ c &= 0x7f;
+ /*
+ * Increment OID length
+ */
+ *cpp += 1;
+ }
+ *cp++ = c;
+ len++;
+ }
+ /*
+ * Finish off with a NULL
+ */
+ *cp++ = 0x05;
+ *cp++ = 0x00;
+ len += 2;
+
+ /*
+ * Patch up all the length locations
+ */
+ Resp_Buf[0] = len;
+ Resp_Buf[4] = len - 4;
+ Resp_Buf[15] = len - 15;
+ Resp_Buf[31] = len - 31;
+ Resp_Buf[35] = len - 35;
+
+ /*
+ * Send Response
+ */
+ send_resp ( s, Hdr->reqid, Resp_Buf );
+
+ return;
}
/*
@@ -1997,20 +2143,13 @@ Increment_DL ( sig )
int sig;
{
Debug_Level++;
- if ( Debug_Level && Log == (FILE *)NULL ) {
- if ( foregnd ) {
- Log = stderr;
- } else {
- if ( ( Log = fopen ( LOG_FILE, "a" ) ) == NULL )
- Log = NULL;
- }
- if ( Log ) {
+ if ( Debug_Level && Log == (FILE *)NULL )
+ if ( ( Log = fopen ( LOG_FILE, "a" ) ) == NULL )
+ Log = NULL;
+ else
setbuf ( Log, NULL );
- write_timestamp();
- fprintf ( Log, "Raised Debug_Level to %d\n", Debug_Level );
- }
- }
signal ( SIGUSR1, Increment_DL );
+ alarm ( SLEEP_TIME );
return;
}
@@ -2034,388 +2173,37 @@ Decrement_DL ( sig )
if ( Debug_Level <= 0 ) {
Debug_Level = 0;
if ( Log ) {
- write_timestamp();
- fprintf ( Log, "Lowered Debug_Level to %d\n", Debug_Level );
- if ( !foregnd )
- fclose ( Log );
+ fclose ( Log );
Log = NULL;
}
}
signal ( SIGUSR2, Decrement_DL );
+ alarm ( SLEEP_TIME );
return;
}
-/*
- * Loop through GET variable list looking for matches
- *
- */
-void
-process_get ( hdr, intf )
- Snmp_Header *hdr;
- int intf;
-{
- Variable *var;
- int idx;
-
- var = hdr->head;
- while ( var ) {
- idx = find_var ( var );
- switch ( idx ) {
- case SYS_OBJID:
- var->type = ASN_OBJID;
- UM_COPY ( (caddr_t)&Objids[MY_OBJID],
- (caddr_t)&var->var.oval,
- sizeof(Objid) );
- break;
- case UPTIME_OBJID:
- var->type = ASN_TIMESTAMP;
- var->var.ival = get_ticks();
- break;
- case UNITYPE_OBJID:
- var->type = ASN_INTEGER;
- var->var.ival = UNITYPE_PRIVATE;
- break;
- case UNIVER_OBJID:
- var->type = ASN_INTEGER;
- switch ( Intf[intf].anp_sig_proto ) {
- case ATM_SIG_UNI30:
- var->var.ival = UNIVER_UNI30;
- break;
- case ATM_SIG_UNI31:
- var->var.ival = UNIVER_UNI31;
- break;
- case ATM_SIG_UNI40:
- var->var.ival = UNIVER_UNI40;
- break;
- default:
- var->var.ival = UNIVER_UNKNOWN;
- break;
- }
- break;
- case DEVTYPE_OBJID:
- var->type = ASN_INTEGER;
- var->var.ival = DEVTYPE_USER;
- break;
- case MAXVCC_OBJID:
- var->type = ASN_INTEGER;
- var->var.ival = 1024;
- break;
- case PORT_OBJID:
- var->type = ASN_INTEGER;
- var->var.ival = intf + 1;
- break;
- case IPNM_OBJID:
- var->type = ASN_IPADDR;
- get_local_ip ( ilmi_fd[intf],
- &var->var.ival );
- break;
- case ADDRESS_OBJID:
- break;
- case ATMF_PORTID:
- var->type = ASN_INTEGER;
- var->var.ival = 0x30 + intf;
- break;
- case ATMF_SYSID:
- var->type = ASN_OCTET;
- var->var.sval[0] = 6;
- UM_COPY ( (caddr_t)&Cfg[intf].acp_macaddr,
- (caddr_t)&var->var.sval[1], 6 );
- break;
- default:
- /* NO_SUCH */
- break;
- }
- var = var->next;
- }
- build_pdu ( hdr, PDU_TYPE_GETRESP );
- send_resp ( intf, hdr, Resp_Buf );
-
-}
-
-/*
- * ILMI State Processing Loop
- *
- *
- */
-void
-ilmi_do_state ()
-{
- struct timeval tvp;
- fd_set rfd;
- u_char buf[1024];
- Variable *var;
- int intf;
- int maxfd = 0;
-
- /*
- * Loop forever
- */
- for ( ; ; ) {
- int count;
- int n;
- caddr_t bpp;
- Snmp_Header *Hdr;
-
- /*
- * SunOS CC doesn't allow automatic aggregate initialization.
- * Initialize to zero which effects a poll operation.
- */
- tvp.tv_sec = 15;
- tvp.tv_usec = 0;
-
- /*
- * Clear fd_set and initialize to check this interface
- */
- FD_ZERO ( &rfd );
- for ( intf = 0; intf < MAX_UNITS; intf++ )
- if ( ilmi_fd[intf] > 0 ) {
- FD_SET ( ilmi_fd[intf], &rfd );
- maxfd = MAX ( maxfd, ilmi_fd[intf] );
- }
-
- /*
- * Check for new interfaces
- */
- ilmi_open();
-
- for ( intf = 0; intf < MAX_UNITS; intf++ ) {
- /*
- * Do any pre-message state processing
- */
- switch ( ilmi_state[intf] ) {
- case ILMI_COLDSTART:
- /*
- * Clear addressTable
- */
- UM_ZERO ( (caddr_t)&addressEntry[intf], sizeof(Objid) );
-
- /*
- * Start by sending a COLD_START trap. This should cause the
- * remote end to clear the associated prefix/address table(s).
- */
- /* Build ColdStart TRAP header */
- ColdStart_Header = build_cold_start();
- build_pdu ( ColdStart_Header, PDU_TYPE_TRAP );
- send_resp ( intf, ColdStart_Header, Resp_Buf );
-
- /*
- * Start a timeout so that if the next state fails, we re-enter
- * ILMI_COLDSTART.
- */
- /* atm_timeout() */
-
- /* Enter new state */
- ilmi_state[intf] = ILMI_INIT;
- /* fall into ILMI_INIT */
-
- case ILMI_INIT:
- /*
- * After a COLD_START, we need to check that the remote end has
- * cleared any tables. Send a GET_NEXT request to check for this.
- * In the event that the table is not empty, or that no reply is
- * received, return to COLD_START state.
- */
- PDU_Header = build_generic_header();
- PDU_Header->head = (Variable *)UM_ALLOC(sizeof(Variable));
- var = PDU_Header->head;
- UM_COPY ( (caddr_t)&Objids[ADDRESS_OBJID], (caddr_t)&var->oid,
- sizeof(Objid) );
- var->type = ASN_NULL;
- var->next = NULL;
-
- /*
- * Send GETNEXT request looking for empty ATM Address Table
- */
- PDU_Header->reqid = Req_ID++;
- build_pdu ( PDU_Header, PDU_TYPE_GETNEXT );
- send_resp ( intf, PDU_Header, Resp_Buf );
-
- /*
- * Start a timeout while looking for SET message. If we don't receive
- * a SET, then go back to COLD_START state.
- */
- /* atm_timeout() */
- break;
-
- case ILMI_RUNNING:
- /* Normal SNMP processing */
- break;
-
- default:
- break;
- }
- }
-
- count = select ( maxfd + 1, &rfd, NULL, NULL, &tvp );
-
- for ( intf = 0; intf < MAX_UNITS; intf++ ) {
- /*
- * Check for received messages
- */
- if ( ilmi_fd[intf] > 0 && FD_ISSET ( ilmi_fd[intf], & rfd ) ) {
-
- n = read ( ilmi_fd[intf], (caddr_t)&buf[1], sizeof(buf) - 1 );
- if ( n == -1 && ( errno == ECONNRESET || errno == EBADF ) ) {
- ilmi_state[intf] = ILMI_COLDSTART;
- close ( ilmi_fd[intf] );
- ilmi_fd[intf] = -1;
- } else {
- if ( Log && Debug_Level > 1 ) fprintf ( Log, "***** state %d ***** read %d bytes from %d (%d) ***** %s *****\n",
- ilmi_state[intf], n, intf, ilmi_fd[intf], PDU_Types[buf[14] - 0xA0] ); {
- if ( Debug_Level > 2 )
- hexdump ( (caddr_t)&buf[1], n );
- }
- bpp = (caddr_t)&buf[1];
- if ( ( Hdr = asn_get_header ( &bpp ) ) == NULL )
- continue;
-
- /* What we do with this messages depends upon the state we're in */
- switch ( ilmi_state[intf] ) {
- case ILMI_COLDSTART:
- /* We should never be in this state here */
- free_pdu ( Hdr );
- break;
- case ILMI_INIT:
- /* The only messages we care about are GETNEXTs, GETRESPs, and TRAPs */
- switch ( Hdr->pdutype ) {
- case PDU_TYPE_GETNEXT:
- /*
- * Should be because the remote side is attempting
- * to verify that our table is empty
- */
- if ( oid_ncmp ( (caddr_t)&Hdr->head->oid,
- (caddr_t)&Objids[ADDRESS_OBJID],
- Objids[ADDRESS_OBJID].oid[0] ) == 0 ) {
- if ( addressEntry[intf].oid[0] ) {
- /* XXX - FIXME */
- /* Our table is not empty - return address */
- }
- }
- build_pdu ( Hdr, PDU_TYPE_GETRESP );
- send_resp ( intf, Hdr, Resp_Buf );
- break;
- case PDU_TYPE_GETRESP:
- /*
- * This should be in response to our GETNEXT.
- * Check the OIDs and go onto ILMI_RUNNING if
- * the address table is empty. We can cheat and
- * not check sequence numbers because we only send
- * the one GETNEXT request and ILMI says we shouldn't
- * have interleaved sessions.
- */
- /*
- * First look for empty table. If found, go to next state.
- */
- if ( oid_ncmp ( &Objids[ADDRESS_OBJID], &Hdr->head->oid,
- Objids[ADDRESS_OBJID].oid[0] ) == 1 ) {
- ilmi_state[intf] = ILMI_RUNNING; /* ILMI_REG; */
- } else {
- /*
- * Check to see if this matches our address
- * and if so, that it's a VALID entry.
- */
- Atm_addr *aa;
- int l;
- int match = 1;
-
- aa = &Intf[intf].anp_addr;
- if ( aa->address_length == Hdr->head->oid.oid[13] ) {
- for ( l = 0; l < aa->address_length; l++ ) {
- if ( (int)((u_char *)(aa->address))[l] !=
- Hdr->head->oid.oid[14 + l] ) {
- match = 0;
- }
- }
- }
- if ( match ) {
- if ( Hdr->head->var.ival == 1 ) {
- ilmi_state[intf] = ILMI_RUNNING;
- }
- }
- }
- free_pdu ( Hdr );
- break;
- case PDU_TYPE_SET:
- /* Look for SET_PREFIX Objid */
- if ( oid_ncmp ( (caddr_t)&Hdr->head->oid,
- (caddr_t)&Objids[SETPFX_OBJID],
- Objids[SETPFX_OBJID].oid[0] ) == 0 ) {
- set_prefix ( &Hdr->head->oid, Hdr, intf );
- /* Reply to SET before sending our ADDRESS */
- build_pdu(Hdr, PDU_TYPE_GETRESP);
- send_resp( intf, Hdr, Resp_Buf );
- set_address ( Hdr, intf );
- } else {
- build_pdu(Hdr, PDU_TYPE_GETRESP);
- send_resp( intf, Hdr, Resp_Buf );
- }
- break;
- case PDU_TYPE_TRAP:
- /* Remote side wants us to start fresh */
- free_pdu ( Hdr );
- break;
- default:
- /* Ignore */
- free_pdu ( Hdr );
- break;
- }
- break;
- case ILMI_REG:
- break;
- case ILMI_RUNNING:
- /* We'll take anything here */
- switch ( Hdr->pdutype ) {
- case PDU_TYPE_GET:
- process_get ( Hdr, intf );
- break;
- case PDU_TYPE_GETRESP:
- /* Ignore GETRESPs */
- free_pdu ( Hdr );
- break;
- case PDU_TYPE_GETNEXT:
- build_pdu ( Hdr, PDU_TYPE_GETRESP );
- send_resp ( intf, Hdr, Resp_Buf );
- break;
- case PDU_TYPE_SET:
- /* Look for SET_PREFIX Objid */
- if ( oid_ncmp ( (caddr_t)&Hdr->head->oid,
- (caddr_t)&Objids[SETPFX_OBJID],
- Objids[SETPFX_OBJID].oid[0] ) == 0 ) {
- set_prefix ( &Hdr->head->oid, Hdr, intf );
- /* Reply to SET before sending our ADDRESS */
- build_pdu(Hdr, PDU_TYPE_GETRESP);
- send_resp( intf, Hdr, Resp_Buf );
- set_address ( Hdr, intf );
- } else {
- build_pdu(Hdr, PDU_TYPE_GETRESP);
- send_resp( intf, Hdr, Resp_Buf );
- }
- break;
- case PDU_TYPE_TRAP:
- free_pdu ( Hdr );
- break;
- }
- break;
- default:
- /* Unknown state */
- free_pdu ( Hdr );
- break;
- }
- } /* if n > 0 */
- } /* if received message */
- } /* for each interface */
- } /* for ever loop */
-
-}
-
-int
main ( argc, argv )
int argc;
char *argv[];
{
+ u_char buf[256], set_buf[256];
+ char community[1024];
+ u_char *bufp;
+ int s;
int c;
+ int foregnd = 0; /* run in the foreground? */
+ int pdulen;
+ int version;
+ int pdutype;
+ int reqid;
+ int error_status;
+ int error_ptr;
+ int b;
int i;
+ int lerr = 0;
int Reset = 0; /* Should we send a coldStart and exit? */
+ Snmp_Header *Hdr;
+ int n;
/*
* What are we running as? (argv[0])
@@ -2460,10 +2248,34 @@ main ( argc, argv )
* If we're not doing debugging, run in the background
*/
if ( foregnd == 0 ) {
+#ifdef sun
+ int pid, fd;
+
+ if ( ( pid = fork() ) < 0 ) {
+ fprintf ( stderr, "fork failed\n" );
+ exit ( 1 );
+ } else if (pid != 0) {
+ /* Parent process - exit and allow child to run */
+ exit ( 0 );
+ }
+ /* Child process */
+ if ( ( lerr = setpgrp ( 0, getpid() ) ) < 0 ) {
+ fprintf ( stderr, "Can't set process group" );
+ exit ( 1 );
+ }
+ if ( ( fd = open ( "/dev/tty", O_RDWR ) ) >= 0 ) {
+ ioctl ( fd, TIOCNOTTY, (char *)NULL );
+ close ( fd );
+ }
+ /* close all open descriptors */
+ for ( fd = 3; fd < getdtablesize(); fd++ )
+ close ( fd );
+#else
if ( daemon ( 0, 0 ) )
err ( 1, "Can't fork" );
+#endif
} else
- ; /* setbuf ( stdout, NULL ); */
+ setbuf ( stdout, NULL );
signal ( SIGUSR1, Increment_DL );
signal ( SIGUSR2, Decrement_DL );
@@ -2471,16 +2283,11 @@ main ( argc, argv )
/*
* Open log file
*/
- if ( Debug_Level ) {
- if ( foregnd ) {
- Log = stderr;
- } else {
- if ( ( Log = fopen ( LOG_FILE, "a" ) ) == NULL )
- Log = NULL;
- }
- }
- if ( Log )
- setbuf ( Log, NULL );
+ if ( Debug_Level )
+ if ( ( Log = fopen ( LOG_FILE, "a" ) ) == NULL )
+ Log = NULL;
+ else
+ setbuf ( Log, NULL );
/*
* Get our startup time
@@ -2489,13 +2296,12 @@ main ( argc, argv )
starttime.tv_sec--;
starttime.tv_usec += 1000000;
- /* Randomize starting request ID */
- Req_ID = starttime.tv_sec;
-
/*
* Reset all the interface descriptors
*/
for ( i = 0; i < MAX_UNITS; i++ ) {
+ trap_fd[i] = -1;
+ last_trap[i] = (time_t)0;
ilmi_fd[i] = -1;
}
/*
@@ -2508,23 +2314,497 @@ main ( argc, argv )
*/
if ( Reset ) {
for ( i = 0; i < MAX_UNITS; i++ )
- if ( ilmi_fd[i] >= 0 ) {
- /* Build ColdStart TRAP header */
- ColdStart_Header = build_cold_start();
- build_pdu ( ColdStart_Header, PDU_TYPE_TRAP );
- send_resp ( i, ColdStart_Header, Resp_Buf );
+ if ( trap_fd[i] >= 0 ) {
if ( Debug_Level > 1 && Log ) {
write_timestamp();
- fprintf ( Log, "Close ilmi_fd[%d]: %d\n",
- i, ilmi_fd[i] );
+ fprintf ( Log, "Close trap_fd[%d]: %d\n",
+ i, trap_fd[i] );
}
- close ( ilmi_fd[i] );
+ close ( trap_fd[i] );
}
exit ( 2 );
}
- ilmi_do_state();
+ /*
+ * For ever...
+ */
+ for ( ; ; ) {
+ int maxfd = 0;
+ int count;
+ struct timeval tvp;
+ fd_set rfd;
+ time_t curtime;
+
+ ilmi_open();
+
+ /*
+ * SunOS CC doesn't allow automatic aggregate initialization.
+ * Make everybody happy and do it here...
+ */
+ tvp.tv_sec = 15;
+ tvp.tv_usec = 0;
+
+ curtime = time ( (time_t *)NULL );
+
+ /*
+ * Check for TRAP messages
+ */
+ FD_ZERO ( &rfd );
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "Check Traps: " );
+ }
+ for ( i = 0; i < MAX_UNITS; i++ ) {
+ if ( Debug_Level > 1 && Log )
+ fprintf ( Log, "trap_fd[%d]: %d ", i, trap_fd[i] );
+ if ( trap_fd[i] != -1 ) {
+ /*
+ * If we haven't sent a coldStart trap recently,
+ * send one now
+ */
+ if ( last_trap[i] + TRAP_TIME < curtime ) {
+ last_trap[i] = curtime;
+ /*
+ * Send coldStart TRAP
+ */
+ if ( Debug_Level > 4 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "===== Sent %d bytes =====\n",
+ coldStart_Trap[0] );
+ hexdump ( (u_char *)&coldStart_Trap[1],
+ coldStart_Trap[0] );
+ }
+ if ( Debug_Level && Log ) {
+ write_timestamp();
+ fprintf ( Log,
+ "\tSend coldStart TRAP to unit %d\n", i );
+ }
+ write ( trap_fd[i], (caddr_t)&coldStart_Trap[1],
+ coldStart_Trap[0] );
+ }
+ if ( (trap_fd[i] >= 0) &&
+ FD_SET ( trap_fd[i], &rfd )) {
+ maxfd = MAX ( maxfd, trap_fd[i] );
+ }
+ }
+ }
+ if ( Debug_Level > 1 && Log )
+ fprintf ( Log, "maxfd: %d\n", maxfd );
+
+ if ( maxfd ) {
+ count = select ( maxfd + 1, &rfd, NULL, NULL, &tvp );
+
+ if ( count > 0 ) {
+ for ( i = 0; i < MAX_UNITS; i++ ) {
+ if ( trap_fd[i] >= 0 && FD_ISSET ( trap_fd[i], &rfd ) ) {
+ s = trap_fd[i];
+
+ n = read ( s, (caddr_t)&buf[1], sizeof(buf) - 1 );
+ if ( n == -1 && ( errno == ECONNRESET ||
+ errno == EBADF ) ) {
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log,
+ "Bad read: close trap_fd[%d]: %d\n",
+ i, trap_fd[i] );
+ }
+ close ( trap_fd[i] );
+ trap_fd[i] = -1;
+ ilmi_fd[i] = -1;
+ }
+ if ( n ) {
+ buf[0] = n;
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "***** Read %d bytes *****\n",
+ n );
+ hexdump ( (caddr_t)&buf[1], n );
+ }
+ bufp = buf;
+ /*
+ * Skip length byte
+ */
+ bufp++;
+ /*
+ * Crack the header
+ */
+ if ( ( Hdr = asn_get_header ( &bufp ) ) == NULL )
+ continue;
+ pdutype = Hdr->pdutype;
+ /*
+ * Only interested in TRAP messages
+ */
+ switch ( pdutype ) {
+ /*
+ * FORE switches often go straight to SET prefix
+ * after receiving a coldStart TRAP from us
+ */
+ case PDU_TYPE_SET:
+ /*
+ * Make a copy of this PDU so that a
+ * SET NSAP prefix can reply to it.
+ */
+ UM_COPY ( buf, set_buf, sizeof(buf) );
+
+ lerr = process_set ( &bufp );
+ /*
+ * Can't do a simple oid_cmp since we
+ * don't yet know what the prefix is.
+ * If it looks like a SET netPrefix.0,
+ * then compare the portion leading up
+ * to the NSAP prefix part.
+ */
+ if ( oid.oid[0] == 26 ) {
+ oid.oid[0] = 12;
+ if ( oid_cmp ( &setprefix, &oid ) == 0 ) {
+ oid.oid[0] = 26;
+ set_prefix ( &oid, Hdr, set_buf, s );
+ }
+ }
+ /*
+ * We now move from awaiting TRAP to processing ILMI
+ */
+ ilmi_fd[i] = trap_fd[i];
+ trap_fd[i] = -1;
+ break;
+ case PDU_TYPE_TRAP:
+ lerr = process_trap ( &bufp, trap_fd[i] );
+ /*
+ * We now move from awaiting TRAP to processing ILMI
+ */
+ ilmi_fd[i] = trap_fd[i];
+ trap_fd[i] = -1;
+ break;
+ }
+ } /* if n */
+ } /* if FD_ISSET */
+ } /* for i */
+ } /* if count */
+ }
+
+ /*
+ * Reset from TRAP checking
+ */
+ maxfd = 0;
+ errno = 0;
+ /*
+ * Check for ILMI messages
+ */
+ FD_ZERO ( &rfd );
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "Check Ilmis: " );
+ }
+ for ( i = 0; i < MAX_UNITS; i++ ) {
+ if ( Debug_Level > 1 && Log )
+ fprintf ( Log, "ilmi_fd[%d]: %d ", i, ilmi_fd[i] );
+ if ( ilmi_fd[i] != -1 ) {
+ if ( (ilmi_fd[i] >= 0) &&
+ FD_SET ( ilmi_fd[i], &rfd )) {
+ maxfd = MAX ( maxfd, ilmi_fd[i] );
+ }
+ }
+ }
+ if ( Debug_Level > 1 && Log )
+ fprintf ( Log, "maxfd: %d\n", maxfd );
+
+ if ( maxfd ) {
+ count = select ( maxfd + 1, &rfd, NULL, NULL, &tvp );
+
+ if ( count > 0 ) {
+ for ( i = 0; i < MAX_UNITS; i++ ) {
+ if ( ilmi_fd[i] >= 0 && FD_ISSET ( ilmi_fd[i], &rfd ) ) {
+
+ s = ilmi_fd[i];
+
+ n = read ( s, (caddr_t)&buf[1], sizeof(buf) - 1 );
+ if ( n == -1 && ( errno == ECONNRESET ||
+ errno == EBADF ) ) {
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log,
+ "Bad read: close ilmi_fd[%d]: %d\n",
+ i, ilmi_fd[i] );
+ }
+ close ( ilmi_fd[i] );
+ trap_fd[i] = -1;
+ ilmi_fd[i] = -1;
+ }
+ if ( n ) {
+ buf[0] = n;
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log,
+ "***** Read %d bytes *****\n",
+ n );
+ hexdump ( (caddr_t)&buf[1], n );
+ }
+ bufp = buf;
+ /*
+ * Skip length byte
+ */
+ bufp++;
+ /*
+ * Crack the header
+ */
+ if ( ( Hdr = asn_get_header ( &bufp ) )
+ == NULL )
+ continue;
+ pdutype = Hdr->pdutype;
+
+ /*
+ * Do the operation...
+ */
+ switch ( pdutype ) {
+
+ case PDU_TYPE_GET:
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "GET:: " );
+ }
+ /*
+ * Should be SEQUENCE OF
+ */
+ if ( *bufp++ != ASN_SEQUENCE ) {
+ lerr = 1;
+ break;
+ }
+ pdulen = asn_get_pdu_len ( &bufp );
+ /*
+ * Should be SEQUENCE OF
+ */
+ if ( *bufp++ != ASN_SEQUENCE ) {
+ lerr = 1;
+ break;
+ }
+ pdulen = asn_get_pdu_len ( &bufp );
+ /*
+ * Should be OBJID
+ */
+ if ( *bufp++ != ASN_OBJID ) {
+ lerr = 1;
+ break;
+ }
+ asn_get_objid ( &bufp, &oid );
+ /*
+ * Ended with a NULL
+ */
+ bufp++;
+ bufp++;
+ /*
+ * If GET sysObjId.0
+ */
+ if (oid_cmp(&sysObjId, &oid) == 0 ) {
+ send_resp ( s, Hdr->reqid,
+ sysObjId_Resp );
+
+ } else
+ /*
+ * If GET sysUpTime.0
+ */
+ if (oid_cmp(&sysUpTime, &oid) == 0 ) {
+ send_uptime_resp ( s,
+ Hdr->reqid );
+ } else
+ /*
+ * If GET myIpNm.0
+ */
+ if ( oid_cmp ( &myipnm, &oid ) == 0 ) {
+ send_myipnm ( s, Hdr );
+ } else
+ /*
+ * If GET uniType.0
+ */
+ if ( oid_cmp ( &unitype, &oid ) == 0 ) {
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log,
+ "\tSend uniType\n" );
+ }
+ send_resp ( s, Hdr->reqid,
+ UniType_Resp );
+ } else
+ /*
+ * If GET uniVer.0
+ */
+ if ( oid_cmp ( &univer, &oid ) == 0 ) {
+ int p = UniVer_Resp[0];
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log,
+ "\tSend uniVer\n" );
+ }
+ switch (Intf[i].anp_sig_proto) {
+ case ATM_SIG_UNI30:
+ UniVer_Resp[p] =
+ UNIVER_UNI30;
+ break;
+ case ATM_SIG_UNI31:
+ UniVer_Resp[p] =
+ UNIVER_UNI31;
+ break;
+ case ATM_SIG_UNI40:
+ UniVer_Resp[p] =
+ UNIVER_UNI40;
+ break;
+ }
+ send_resp ( s, Hdr->reqid,
+ UniVer_Resp );
+ } else
+ /*
+ * If GET devType.0
+ */
+ if ( oid_cmp ( &devtype, &oid ) == 0 ) {
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log,
+ "\tSend devType\n" );
+ }
+ send_resp ( s, Hdr->reqid,
+ DevType_Resp );
+ } else
+ /*
+ * If GET foreSigGrp....0
+ */
+ if (oid_cmp(&foresiggrp, &oid) == 0) {
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log,
+ "\tSend noSuchVar\n" );
+ }
+ send_resp ( s, Hdr->reqid,
+ NoSuchFore_Resp );
+ } else
+ if ( oid_cmp(&layeridx, &oid) == 0 ) {
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log,
+ "\t*** LayerIndex\n" );
+ }
+ } else
+ if ( oid_cmp(&maxvcc, &oid) == 0 ) {
+ send_resp ( s, Hdr->reqid,
+ maxVCC_Resp );
+ } else
+ if ( oid_cmp ( &portidx, &oid ) == 0 ) {
+ int p = PortIndex_Resp[0];
+ PortIndex_Resp[p] = i + 1;
+ send_resp ( s, Hdr->reqid,
+ PortIndex_Resp );
+ } else
+ send_no_such ( s, Hdr, &oid );
+ break;
+
+ case PDU_TYPE_GETNEXT:
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log, "GET_NEXT:: " );
+ }
+ /*
+ * Should be SEQUENCE OF
+ */
+ if ( *bufp++ != ASN_SEQUENCE ) {
+ lerr = 1;
+ break;
+ }
+ pdulen = asn_get_pdu_len ( &bufp );
+ /*
+ * Should be SEQUENCE OF
+ */
+ if ( *bufp++ != ASN_SEQUENCE ) {
+ lerr = 1;
+ break;
+ }
+ pdulen = asn_get_pdu_len ( &bufp );
+ /*
+ * Should be OBJID
+ */
+ if ( *bufp++ != ASN_OBJID ) {
+ lerr = 1;
+ break;
+ }
+ asn_get_objid ( &bufp, &oid );
+ /*
+ * Ended with a NULL
+ */
+ bufp++;
+ bufp++;
+ /*
+ * If this is a GET_NEXT netPrefix then
+ * the other side probably restarted
+ * and is looking for a table empty
+ * indication before restarting the
+ * ILMI protocol.
+ */
+ if ( oid_cmp(&netpfx_oid, &oid) == 0 ) {
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log,
+ "\tSend GET_RESP:\n" );
+ }
+ send_resp ( s, Hdr->reqid,
+ GetNext_Resp );
+ }
+ break;
+
+ case PDU_TYPE_GETRESP:
+ if ( Debug_Level > 1 && Log ) {
+ write_timestamp();
+ fprintf ( Log,
+ "GET_RESP:: \n" );
+ }
+ /*
+ * Ignore any responses to our GETs.
+ * (We don't send any GETs.)
+ */
+ break;
+
+ case PDU_TYPE_SET:
+ /*
+ * Make a copy of this PDU so that a
+ * SET NSAP prefix can reply to it.
+ */
+ UM_COPY ( buf, set_buf, sizeof(buf) );
+
+ if ( process_set ( &bufp ) < 0 )
+ break;
+
+ /*
+ * Can't do a simple oid_cmp since we
+ * don't know what the prefix is yet.
+ * If it looks like a SET netPrefix.0,
+ * then compare the portion leading up
+ * to the NSAP prefix part.
+ */
+ if ( oid.oid[0] == 26 ) {
+ oid.oid[0] = 12;
+ if ( oid_cmp(&setprefix,&oid)
+ == 0 ) {
+ oid.oid[0] = 26;
+ set_prefix ( &oid, Hdr,
+ set_buf, s );
+ }
+ }
+ break;
+
+ case PDU_TYPE_TRAP:
+ lerr = process_trap ( &bufp, s );
+ break;
+ }
+ /*
+ * Forget about this PDU
+ */
+ free ( Hdr );
+ Hdr = NULL;
- exit(0);
+ } /* end of read(s) */
+ } /* end if FD_ISSET(s) */
+ } /* end of for ( i... */
+ } /* end of if ( count ) */
+ } else {
+ sleep ( SLEEP_TIME );
+ }
+ } /* end of for ever */
+
}
diff --git a/sbin/camcontrol/camcontrol.8 b/sbin/camcontrol/camcontrol.8
index 1ab0f8ffc3bce..641797df9e2c5 100644
--- a/sbin/camcontrol/camcontrol.8
+++ b/sbin/camcontrol/camcontrol.8
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: camcontrol.8,v 1.8 1998/12/02 22:42:36 billf Exp $
+.\" $Id: camcontrol.8,v 1.6 1998/10/03 19:15:53 ken Exp $
.\"
.Dd September 14, 1998
.Dt CAMCONTROL 8
@@ -67,9 +67,6 @@ eject
rescan
.Aq bus Ns Op :target:lun
.Nm camcontrol
-reset
-.Aq bus Ns Op :target:lun
-.Nm camcontrol
defects
.Op generic args
.Aq Fl f Ar format
@@ -79,7 +76,7 @@ defects
modepage
.Op generic args
.Aq Fl m Ar page
-.Op Fl P Ar pgctl
+.Op Fl P Ar pagectl
.Op Fl e
.Op Fl d
.Nm camcontrol
@@ -187,12 +184,6 @@ Tell the kernel to scan the given bus (XPT_SCAN_BUS), or bus:target:lun
(XPT_SCAN_LUN) for new devices or devices that have gone away. The user
may only specify a bus to scan, or a lun. Scanning all luns on a target
isn't supported.
-.It reset
-Tell the kernel to reset the given bus (XPT_RESET_BUS) by issuing a SCSI bus
-reset for that bus, or to reset the given bus:target:lun
-(XPT_RESET_DEV), typically by issuing a BUS DEVICE RESET message after
-connecting to that device. Note that this can have a destructive impact
-on the system.
.It defects
Send the SCSI READ DEFECT DATA (10) command (0x37) to the given device, and
print out any combination of: the total number of defects, the primary
@@ -246,7 +237,7 @@ This flag allows the user to edit values in the mode page.
.It Fl m Ar mode_page
This specifies the number of the mode page the user would like to view
and/or edit. This argument is mandatory.
-.It Fl P Ar pgctl
+.It Fl P page_ctl
This allows the user to specify the page control field. Possible values are:
.Bl -tag -width xxx -compact
.It 0
diff --git a/sbin/camcontrol/camcontrol.c b/sbin/camcontrol/camcontrol.c
index fb2f05e943a5d..3403b39eea844 100644
--- a/sbin/camcontrol/camcontrol.c
+++ b/sbin/camcontrol/camcontrol.c
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: camcontrol.c,v 1.8 1998/12/20 20:32:34 mjacob Exp $
+ * $Id: camcontrol.c,v 1.4 1998/10/13 16:23:26 ken Exp $
*/
#include <sys/ioctl.h>
@@ -64,7 +64,6 @@ typedef enum {
CAM_ARG_DEVTREE = 0x00000009,
CAM_ARG_USAGE = 0x0000000a,
CAM_ARG_DEBUG = 0x0000000b,
- CAM_ARG_RESET = 0x0000000c,
CAM_ARG_OPT_MASK = 0x0000000f,
CAM_ARG_VERBOSE = 0x00000010,
CAM_ARG_DEVICE = 0x00000020,
@@ -116,7 +115,6 @@ struct camcontrol_opts option_table[] = {
{"stop", CAM_ARG_STARTSTOP, NULL},
{"eject", CAM_ARG_STARTSTOP | CAM_ARG_EJECT, NULL},
{"rescan", CAM_ARG_RESCAN, NULL},
- {"reset", CAM_ARG_RESET, NULL},
{"cmd", CAM_ARG_SCSI_CMD, scsicmd_opts},
{"command", CAM_ARG_SCSI_CMD, scsicmd_opts},
{"defects", CAM_ARG_READ_DEFECTS, readdefect_opts},
@@ -152,9 +150,9 @@ static int scsidoinquiry(struct cam_device *device, int argc, char **argv,
static int scsiinquiry(struct cam_device *device, int retry_count, int timeout);
static int scsiserial(struct cam_device *device, int retry_count, int timeout);
static int scsixferrate(struct cam_device *device);
-static int dorescan_or_reset(int argc, char **argv, int rescan);
-static int rescan_or_reset_bus(int bus, int rescan);
-static int scanlun_or_reset_dev(int bus, int target, int lun, int scan);
+static int dorescan(int argc, char **argv);
+static int rescanbus(int bus);
+static int scanlun(int bus, int target, int lun);
static int readdefects(struct cam_device *device, int argc, char **argv,
char *combinedopt, int retry_count, int timeout);
static void modepage(struct cam_device *device, int argc, char **argv,
@@ -350,9 +348,6 @@ getdevtree(void)
dev_result->path_id,
dev_result->target_id,
dev_result->target_lun);
-
- need_close = 1;
-
break;
}
case DEV_MATCH_PERIPH: {
@@ -361,14 +356,14 @@ getdevtree(void)
periph_result =
&ccb.cdm.matches[i].result.periph_result;
- if (need_close > 1)
+ if (need_close)
fprintf(stdout, ",");
fprintf(stdout, "%s%d",
periph_result->periph_name,
periph_result->unit_number);
- need_close++;
+ need_close = 1;
break;
}
default:
@@ -802,16 +797,14 @@ scsixferrate(struct cam_device *device)
}
static int
-dorescan_or_reset(int argc, char **argv, int rescan)
+dorescan(int argc, char **argv)
{
- static const char *must =
- "you must specify a bus, or a bus:target:lun to %s";
int error = 0;
int bus = -1, target = -1, lun = -1;
char *tstr, *tmpstr = NULL;
if (argc < 3) {
- warnx(must, rescan? "rescan" : "reset");
+ warnx("you must specify a bus, or a bus:target:lun to rescan");
return(1);
}
/*
@@ -840,12 +833,13 @@ dorescan_or_reset(int argc, char **argv, int rescan)
arglist |= CAM_ARG_LUN;
} else {
error = 1;
- warnx(must, rescan? "rescan" : "reset");
+ warnx("you must specify either a bus or");
+ warnx("a bus, target and lun for rescanning");
}
}
} else {
error = 1;
- warnx(must, rescan? "rescan" : "reset");
+ warnx("you must at least specify a bus to rescan");
}
@@ -853,19 +847,20 @@ dorescan_or_reset(int argc, char **argv, int rescan)
if ((arglist & CAM_ARG_BUS)
&& (arglist & CAM_ARG_TARGET)
&& (arglist & CAM_ARG_LUN))
- error = scanlun_or_reset_dev(bus, target, lun, rescan);
+ error = scanlun(bus, target, lun);
else if (arglist & CAM_ARG_BUS)
- error = rescan_or_reset_bus(bus, rescan);
+ error = rescanbus(bus);
else {
error = 1;
- warnx(must, rescan? "rescan" : "reset");
+ warnx("you must specify either a bus or");
+ warnx("a bus, target and lun for rescanning");
}
}
return(error);
}
static int
-rescan_or_reset_bus(int bus, int rescan)
+rescanbus(int bus)
{
union ccb ccb;
int fd;
@@ -881,7 +876,7 @@ rescan_or_reset_bus(int bus, int rescan)
return(1);
}
- ccb.ccb_h.func_code = rescan? XPT_SCAN_BUS : XPT_RESET_BUS;
+ ccb.ccb_h.func_code = XPT_SCAN_BUS;
ccb.ccb_h.path_id = bus;
ccb.ccb_h.target_id = CAM_TARGET_WILDCARD;
ccb.ccb_h.target_lun = CAM_LUN_WILDCARD;
@@ -899,19 +894,17 @@ rescan_or_reset_bus(int bus, int rescan)
close(fd);
if ((ccb.ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
- fprintf(stdout, "%s of bus %d was successful\n",
- rescan? "Re-scan" : "Reset", bus);
+ fprintf(stdout, "Re-scan of bus %d was successful\n", bus);
return(0);
} else {
- fprintf(stdout, "%s of bus %d returned error %#x\n",
- rescan? "Re-scan" : "Reset", bus,
- ccb.ccb_h.status & CAM_STATUS_MASK);
+ fprintf(stdout, "Re-scan of bus %d returned error %#x\n",
+ bus, ccb.ccb_h.status & CAM_STATUS_MASK);
return(1);
}
}
static int
-scanlun_or_reset_dev(int bus, int target, int lun, int scan)
+scanlun(int bus, int target, int lun)
{
union ccb ccb;
int fd;
@@ -938,7 +931,7 @@ scanlun_or_reset_dev(int bus, int target, int lun, int scan)
return(1);
}
- ccb.ccb_h.func_code = (scan)? XPT_SCAN_LUN : XPT_RESET_DEV;
+ ccb.ccb_h.func_code = XPT_SCAN_LUN;
ccb.ccb_h.path_id = bus;
ccb.ccb_h.target_id = target;
ccb.ccb_h.target_lun = lun;
@@ -956,13 +949,12 @@ scanlun_or_reset_dev(int bus, int target, int lun, int scan)
close(fd);
if ((ccb.ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
- fprintf(stdout, "%s of %d:%d:%d was successful\n",
- scan? "Re-scan" : "Reset", bus, target, lun);
+ fprintf(stdout, "Re-scan of %d:%d:%d was successful\n",
+ bus, target, lun);
return(0);
} else {
- fprintf(stdout, "%s of %d:%d:%d returned error %#x\n",
- scan? "Re-scan" : "Reset", bus, target, lun,
- ccb.ccb_h.status & CAM_STATUS_MASK);
+ fprintf(stdout, "Re-scan of %d:%d:%d returned error %#x\n",
+ bus, target, lun, ccb.ccb_h.status & CAM_STATUS_MASK);
return(1);
}
}
@@ -1797,7 +1789,6 @@ usage(void)
" camcontrol stop [generic args]\n"
" camcontrol eject [generic args]\n"
" camcontrol rescan <bus[:target:lun]>\n"
-" camcontrol reset <bus[:target:lun]>\n"
" camcontrol defects [generic args] <-f format> [-P][-G]\n"
" camcontrol modepage [generic args] <-m page> [-P pagectl][-e][-d]\n"
" camcontrol cmd [generic args] <-c cmd [args]> \n"
@@ -1812,7 +1803,6 @@ usage(void)
"stop send a Stop Unit command to the device\n"
"eject send a Stop Unit command to the device with the eject bit set\n"
"rescan rescan the given bus, or bus:target:lun\n"
-"reset reset the given bus, or bus:target:lun\n"
"defects read the defect list of the specified device\n"
"modepage display or edit (-e) the given mode page\n"
"cmd send the given scsi command, may need -i or -o as well\n"
@@ -1999,8 +1989,7 @@ main(int argc, char **argv)
* commands, we don't use a passthrough device at all, just the
* transport layer device.
*/
- if (((arglist & CAM_ARG_OPT_MASK) != CAM_ARG_RESCAN)
- && ((arglist & CAM_ARG_OPT_MASK) != CAM_ARG_RESET)
+ if (((arglist & CAM_ARG_OPT_MASK) != CAM_ARG_RESCAN)
&& ((arglist & CAM_ARG_OPT_MASK) != CAM_ARG_DEVTREE)
&& ((arglist & CAM_ARG_OPT_MASK) != CAM_ARG_USAGE)
&& ((arglist & CAM_ARG_OPT_MASK) != CAM_ARG_DEBUG)) {
@@ -2011,7 +2000,7 @@ main(int argc, char **argv)
}
/*
- * Reset optind to 2, and reset getopt, so these routines can parse
+ * Reset optind to 2, and reset getopt, so these routines cam parse
* the arguments again.
*/
optind = 2;
@@ -2037,10 +2026,7 @@ main(int argc, char **argv)
timeout);
break;
case CAM_ARG_RESCAN:
- error = dorescan_or_reset(argc, argv, 1);
- break;
- case CAM_ARG_RESET:
- error = dorescan_or_reset(argc, argv, 0);
+ error = dorescan(argc, argv);
break;
case CAM_ARG_READ_DEFECTS:
error = readdefects(cam_dev, argc, argv, combinedopt,
diff --git a/sbin/ccdconfig/ccdconfig.8 b/sbin/ccdconfig/ccdconfig.8
index cd0ffd4fa7b15..16974e3b505c3 100644
--- a/sbin/ccdconfig/ccdconfig.8
+++ b/sbin/ccdconfig/ccdconfig.8
@@ -30,7 +30,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: ccdconfig.8,v 1.5 1998/06/04 06:41:26 charnier Exp $
+.\" $Id$
.\"
.Dd July 17, 1995
.Dt CCDCONFIG 8
@@ -135,15 +135,15 @@ argument is optional.
#
.Pp
# ccd ileave flags component devices
-ccd0 16 none /dev/da2e /dev/da3e
+ccd0 16 none /dev/sd2e /dev/sd3e
.Ed
.Pp
.Sh EXAMPLE
The following command, executed from the command line, would configure ccd0
-with 4 components (/dev/da2e, /dev/da3e, /dev/da4e, /dev/da5e), and an
+with 4 components (/dev/sd2e, /dev/sd3e, /dev/sd4e, /dev/sd5e), and an
interleave factor of 32 blocks.
.Bd -unfilled -offset indent
-# ccdconfig ccd0 32 0 /dev/da2e /dev/da3e /dev/da4e /dev/da5e
+# ccdconfig ccd0 32 0 /dev/sd2e /dev/sd3e /dev/sd4e /dev/sd5e
.Ed
.Pp
.Sh FILES
diff --git a/sbin/disklabel/disklabel.5 b/sbin/disklabel/disklabel.5
index 7698a63310719..8090bdc5d53d1 100644
--- a/sbin/disklabel/disklabel.5
+++ b/sbin/disklabel/disklabel.5
@@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)disklabel.5.5 8.1 (Berkeley) 6/5/93
-.\" $Id: disklabel.5,v 1.4 1998/06/04 06:49:12 charnier Exp $
+.\" $Id$
.\"
.Dd June 5, 1993
.Dt DISKLABEL 5
@@ -142,7 +142,7 @@ struct disklabel {
* the disklabel is read off the disk or in-core copy.
* d_boot0 and d_boot1 are the (optional) names of the
* primary (block 0) and secondary (block 1-15) bootstraps
- * as found in /boot. These are returned when using
+ * as found in /usr/mdec. These are returned when using
* getdiskbyname(3)
to retrieve the values from /etc/disktab.
*/
diff --git a/sbin/disklabel/disklabel.8 b/sbin/disklabel/disklabel.8
index 9dfca468e1ddc..91362465ec186 100644
--- a/sbin/disklabel/disklabel.8
+++ b/sbin/disklabel/disklabel.8
@@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94
-.\" $Id: disklabel.8,v 1.9 1998/11/28 09:43:31 rnordier Exp $
+.\" $Id: disklabel.8,v 1.7 1997/06/23 04:02:17 steve Exp $
.\"
.Dd April 19, 1994
.Dt DISKLABEL 8
@@ -116,7 +116,7 @@ option to install bootstrap code.
These variants are described later.
.Pp
The first form of the command (read) is used to examine the label on the named
-disk drive (e.g. da0 or /dev/rda0c).
+disk drive (e.g. sd0 or /dev/rsd0c).
It will display all of the parameters associated with the drive
and its partition layout.
Unless the
@@ -135,7 +135,7 @@ The second form of the command, with the
flag, is used to write a standard label on the designated drive.
The required arguments to
.Nm
-are the drive to be labeled (e.g. da0), and
+are the drive to be labeled (e.g. sd0), and
the drive type as described in the
.Xr disktab 5
file.
@@ -251,19 +251,25 @@ indicates the primary boot program and
the secondary boot program.
If the names are not explicitly given, standard boot programs will be used.
The boot programs are located in
-.Pa /boot .
+.Pa /usr/mdec .
The names of the programs are taken from the ``b0'' and ``b1'' parameters
of the
.Xr disktab 5
entry for the disk if
.Ar disktype
was given and its disktab entry exists and includes those parameters.
-Otherwise, the default boot image names are used, these being:
-.Pa /boot/boot1
+Otherwise, boot program names are derived from the name of the disk.
+These names are of the form
+.Pa basename Ns boot
+for the primary (or only) bootstrap, and
+.Pf boot Pa basename
+for the secondary bootstrap;
+for example,
+.Pa /usr/mdec/sdboot
and
-.Pa /boot/boot2
-for the standard stage1 and stage2 boot images (details may vary
-on architectures like the Alpha, where only a single-stage boot is used).
+.Pa /usr/mdec/bootsd
+if the disk device is
+.Em sd0 .
.Pp
The first of the three boot-installation forms is used to install
bootstrap code without changing the existing label.
@@ -275,55 +281,55 @@ except that they will install bootstrap code in addition to a new label.
.Sh FILES
.Bl -tag -width Pa -compact
.It Pa /etc/disktab
-.It Pa /boot/
-.It Pa /boot/boot<n>
+.It Pa /usr/mdec/ Ns Em xx Ns boot
+.It Pa /usr/mdec/boot Ns Em xx
.El
.Sh EXAMPLES
-.Dl disklabel da0
+.Dl disklabel sd0
.Pp
-Display the in-core label for da0 as obtained via
-.Pa /dev/rda0c .
+Display the in-core label for sd0 as obtained via
+.Pa /dev/rsd0c .
.Pp
-.Dl disklabel -w -r /dev/rda0c da2212 foo
+.Dl disklabel -w -r /dev/rsd0c sd2212 foo
.Pp
-Create a label for da0 based on information for ``da2212'' found in
+Create a label for sd0 based on information for ``sd2212'' found in
.Pa /etc/disktab .
Any existing bootstrap code will be clobbered.
.Pp
-.Dl disklabel -e -r da0
+.Dl disklabel -e -r sd0
.Pp
-Read the on-disk label for da0, edit it and reinstall in-core as well
+Read the on-disk label for sd0, edit it and reinstall in-core as well
as on-disk.
Existing bootstrap code is unaffected.
.Pp
-.Dl disklabel -r -w da0 auto
+.Dl disklabel -r -w sd0 auto
.Pp
-Try to auto-detect the required information from da0, and write a new
+Try to auto-detect the required information from sd0, and write a new
label to the disk. Use another disklabel -e command to edit the
partitioning and file system information.
.Pp
-.Dl disklabel -R da0 mylabel
+.Dl disklabel -R sd0 mylabel
.Pp
-Restore the on-disk and in-core label for da0 from information in
+Restore the on-disk and in-core label for sd0 from information in
.Pa mylabel .
Existing bootstrap code is unaffected.
.Pp
-.Dl disklabel -B da0
+.Dl disklabel -B sd0
.Pp
-Install a new bootstrap on da0.
+Install a new bootstrap on sd0.
The boot code comes from
-.Pa /boot/boot1
+.Pa /usr/mdec/sdboot
and possibly
-.Pa /boot/boot2 .
+.Pa /usr/mdec/bootsd .
On-disk and in-core labels are unchanged.
.Pp
-.Dl disklabel -w -B /dev/rda0c -b newboot da2212
+.Dl disklabel -w -B /dev/rsd0c -b newboot sd2212
.Pp
Install a new label and bootstrap.
-The label is derived from disktab information for ``da2212'' and
+The label is derived from disktab information for ``sd2212'' and
installed both in-core and on-disk.
The bootstrap code comes from the file
-.Pa /boot/newboot .
+.Pa /usr/mdec/newboot .
.Sh SEE ALSO
.Xr disklabel 5 ,
.Xr disktab 5
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index ff04e4b9d17c5..be60d542768a3 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)disklabel.c 8.2 (Berkeley) 1/7/94";
/* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */
#endif
static const char rcsid[] =
- "$Id: disklabel.c,v 1.23 1998/10/23 18:57:39 bde Exp $";
+ "$Id: disklabel.c,v 1.20 1998/08/21 23:44:16 gpalmer Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -76,6 +76,12 @@ static const char rcsid[] =
* for the label on such machines.
*/
+#ifdef tahoe
+#define RAWPARTITION 'a'
+#else
+#define RAWPARTITION 'c'
+#endif
+
#ifndef BBSIZE
#define BBSIZE 8192 /* size of boot area, with label */
#endif
@@ -226,7 +232,7 @@ main(argc, argv)
dkname = argv[0];
if (dkname[0] != '/') {
- (void)sprintf(np, "%sr%s%c", _PATH_DEV, dkname, 'a' + RAW_PART);
+ (void)sprintf(np, "%sr%s%c", _PATH_DEV, dkname, RAWPARTITION);
specname = np;
np += strlen(specname) + 1;
} else
@@ -477,7 +483,7 @@ l_perror(s)
case ESRCH:
warnx("%s: no disk label on disk;", s);
fprintf(stderr,
- "use \"disklabel -r\" to install initial label\n");
+ "use \"disklabel -r\" to install initial label\n");
break;
case EINVAL:
@@ -490,8 +496,8 @@ l_perror(s)
break;
case EXDEV:
- warnx("%s: '%c' partition must start at beginning of disk",
- s, 'a' + RAW_PART);
+ warnx(
+ "%s: labeled partition or 'a' partition must start at beginning of disk", s);
break;
default:
@@ -595,13 +601,25 @@ makebootarea(boot, dp, f)
*np++ = '\0';
if (!xxboot) {
- (void)sprintf(boot0, "%s/boot1", _PATH_BOOTDIR);
- xxboot = boot0;
+ (void)sprintf(np, "%s/%sboot",
+ _PATH_BOOTDIR, dkbasename);
+ if (access(np, F_OK) < 0 && dkbasename[0] == 'r')
+ dkbasename++;
+ xxboot = np;
+ (void)sprintf(xxboot, "%s/%sboot",
+ _PATH_BOOTDIR, dkbasename);
+ np += strlen(xxboot) + 1;
}
#if NUMBOOT > 1
if (!bootxx) {
- (void)sprintf(boot1, "%s/boot2", _PATH_BOOTDIR);
- bootxx = boot1;
+ (void)sprintf(np, "%s/boot%s",
+ _PATH_BOOTDIR, dkbasename);
+ if (access(np, F_OK) < 0 && dkbasename[0] == 'r')
+ dkbasename++;
+ bootxx = np;
+ (void)sprintf(bootxx, "%s/boot%s",
+ _PATH_BOOTDIR, dkbasename);
+ np += strlen(bootxx) + 1;
}
#endif
}
diff --git a/sbin/disklabel/pathnames.h b/sbin/disklabel/pathnames.h
index a24bdefe68d1a..def3297d205ee 100644
--- a/sbin/disklabel/pathnames.h
+++ b/sbin/disklabel/pathnames.h
@@ -35,6 +35,6 @@
#include <paths.h>
-#define _PATH_BOOTDIR "/boot"
+#define _PATH_BOOTDIR "/usr/mdec"
#undef _PATH_TMP
#define _PATH_TMP "/tmp/EdDk.aXXXXXX"
diff --git a/sbin/dset/Makefile b/sbin/dset/Makefile
new file mode 100644
index 0000000000000..ce15a61510aab
--- /dev/null
+++ b/sbin/dset/Makefile
@@ -0,0 +1,7 @@
+PROG= dset
+DPADD= ${LIBKVM}
+LDADD= -lkvm
+CFLAGS+=-I${.CURDIR}/../../sys/
+MAN8= dset.8
+
+.include <bsd.prog.mk>
diff --git a/sbin/dset/dset.8 b/sbin/dset/dset.8
new file mode 100644
index 0000000000000..ed88d4ed06b77
--- /dev/null
+++ b/sbin/dset/dset.8
@@ -0,0 +1,78 @@
+.\"
+.\" Copyright (c) 1996 Joerg Wunsch
+.\"
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+.\"
+.\" $Id: dset.8,v 1.6 1997/02/22 14:32:15 peter Exp $
+.\" "
+.Dd May 2, 1996
+.Dt DSET 8
+.Os FreeBSD
+.Sh NAME
+.Nm dset
+.Nd "update the boot file to the current configuration"
+.Sh SYNOPSIS
+.Nm dset
+.Op Fl vqt
+.Sh DESCRIPTION
+.Nm Dset
+records the configuration changes for ISA devices that have been made
+from
+.Em UserConfig
+after booting with the
+.Fl c
+option. The changes (if any) are recorded to the file name returned by
+.Xr getbootfile 3 .
+.Nm Dset
+is typically called from within
+.Pa /etc/rc .
+.Pp
+.Nm Dset
+understands the following options:
+.Bl -tag -width indent -compact
+.It Fl v
+Verbose; tell what is being done.
+.It Fl q
+Quiet; don't print any error messages.
+.It Fl t
+Test only; don't actually record any changes to the boot file, print
+only what would have been done. This implies
+.Fl v .
+.El
+.Sh DIAGNOSTICS
+The
+.Nm
+utility exits with status 0 on success, or with status 1 if any
+problem occurred. Unless
+.Fl q
+has been specified, a short message hinting to the cause of the problem
+will be printed to standard error output.
+.Sh SEE ALSO
+.Xr getbootfile 3 ,
+.Xr boot_i386 8 ,
+.Xr rc 8
+.Sh HISTORY
+The
+.Nm
+command appeared in
+.Fx 2.0.5 .
diff --git a/sbin/dset/dset.c b/sbin/dset/dset.c
new file mode 100644
index 0000000000000..210e92aa053b3
--- /dev/null
+++ b/sbin/dset/dset.c
@@ -0,0 +1,433 @@
+/*
+ * Copyright (c) 1995 Ugen J.S.Antsilevich
+ *
+ * Redistribution and use in source forms, with and without modification,
+ * are permitted provided that this entire comment appears intact.
+ *
+ * Redistribution in binary form may occur without any restrictions.
+ * Obviously, it would be nice if you gave credit where credit is due
+ * but requiring it would be too onerous.
+ *
+ * This software is provided ``AS IS'' without any warranties of any kind.
+ *
+ * Device configuration to kernel image saving utility.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "$Id: dset.c,v 1.13 1998/06/28 19:06:17 bde Exp $";
+#endif /* not lint */
+
+#include <err.h>
+#include <fcntl.h>
+#include <kvm.h>
+#include <a.out.h>
+#include <limits.h>
+#include <paths.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/param.h>
+#include "i386/isa/isa_device.h"
+
+#include "i386/isa/pnp.h"
+struct pnp_cinfo new_ov[MAX_PNP_LDN];
+struct pnp_cinfo old_ov[MAX_PNP_LDN];
+
+#define TRUE 1
+#define FALSE 0
+
+struct nlist nl[] = {
+#define N_TABTTY 0
+ {"_isa_devtab_tty"},
+#define N_TABBIO 1
+ {"_isa_devtab_bio"},
+#define N_TABNET 2
+ {"_isa_devtab_net"},
+#define N_TABCAM 3
+ {"_isa_devtab_cam"},
+#define N_TABNULL 4
+ {"_isa_devtab_null"},
+ {""},
+};
+#define N_TABLAST N_TABNULL
+
+struct nlist nlk[] = {
+ {"_isa_devlist"},
+ {""},
+};
+
+struct nlist nlaux[] = {
+ {"_num_eisa_slots"},
+ {""},
+};
+
+struct nlist nlpnp[] = {
+ {"_pnp_ldn_overrides"},
+ {""},
+};
+
+struct nlist nlconfig[] = {
+ {"config.o"},
+ {""},
+};
+
+int quiet = FALSE;
+
+void
+fatal(name, str)
+ char *name, *str;
+{
+ if (quiet)
+ exit(1);
+ if (str)
+ errx(1, "%s: %s", name, str);
+ else
+ errx(1, "%s", name);
+}
+
+void
+error(name, str)
+ char *name, *str;
+{
+ if (quiet)
+ return;
+ if (str)
+ warnx("%s: %s", name, str);
+ else
+ warnx("%s", name);
+}
+
+void
+usage()
+{
+ fprintf(stderr, "usage: dset [-qtv]\n");
+ exit(1);
+}
+
+int
+main(ac, av)
+ int ac;
+ char **av;
+{
+ int f, res, s, i;
+ int modified,dev_found;
+ int sym;
+ u_long pos, entry, pos1, pos_t;
+ u_long flags;
+ struct isa_device buf, buf1;
+ struct isa_driver dbuf;
+ char nbuf[5];
+ struct stat fst;
+ struct exec es;
+ kvm_t *kd;
+ static char errb[_POSIX2_LINE_MAX];
+ const char *kernel = NULL;
+
+ char ch;
+ int testonly = FALSE;
+ int verbose = FALSE;
+
+ while ((ch = getopt(ac, av, "qtv")) != -1)
+ switch (ch) {
+ case 'q':
+ quiet = TRUE;
+ break;
+ case 't':
+ testonly = TRUE;
+ /* In test mode we want to be verbose */
+
+ case 'v':
+ verbose = TRUE;
+ break;
+
+ case '?':
+ default:
+ usage();
+ }
+
+
+ kernel = getbootfile();
+ if (verbose)
+ printf("Boot image: %s\n", kernel);
+
+ if (!(kd = kvm_open(NULL, NULL, NULL, O_RDONLY, errb)))
+ fatal("kvm_open", NULL);
+
+ if (kvm_nlist(kd, nlk) != 0)
+ fatal("kvm_nlist", NULL);
+
+ if (nlk[0].n_type == 0)
+ fatal("kvm_nlist", "bad symbol type");
+
+ if (nlist(kernel, nl) != 0)
+ fatal("nlist", NULL);
+
+ if (nl[0].n_type == 0)
+ fatal("nlist", "bad symbol type");
+
+ if (stat(kernel, &fst) < 0)
+ fatal("stat", NULL);
+
+ flags = fst.st_flags;
+
+ if (chflags(kernel, (u_long) 0) < 0)
+ fatal("chflags", NULL);
+
+ if ((f = open(kernel, O_RDWR)) <= 0)
+ fatal("open", NULL);
+
+ if (read(f, &es, sizeof(struct exec)) <= 0)
+ fatal("read header", NULL);
+
+ entry = es.a_entry;
+
+ for (sym = 0; sym <= N_TABLAST; sym++) {
+ if (verbose)
+ printf("\nTable: %s\n", nl[sym].n_name);
+ pos = nl[sym].n_value + getpagesize() - entry;
+
+ pos1 = nlk[0].n_value;
+
+ if (lseek(f, pos, SEEK_SET) != pos)
+ fatal("seek", NULL);
+
+ if (verbose)
+ printf("----------------------------------------------------\n");
+
+ do {
+ if ((res = read(f, (char *) &buf, sizeof(struct isa_device)))
+ <= 0)
+ fatal("read", NULL);
+
+
+
+ if (kvm_read(kd, pos1, &pos_t, sizeof(u_long)) < 0)
+ fatal("kvmread", NULL);
+ dev_found = 0;
+
+ while(pos_t!=0) {
+ if (kvm_read(kd, pos_t, &buf1, sizeof(struct isa_device)) < 0)
+ fatal("kvmread", NULL);
+
+ if (buf1.id_id != buf.id_id) {
+ pos_t = (u_long)(buf1.id_next);
+ continue;
+ } else
+ dev_found=1;
+
+ if (buf1.id_driver)
+ if (kvm_read(kd, (u_long) buf1.id_driver,
+ &dbuf, sizeof(struct isa_driver)) < 0) {
+ error("kvm_read", "no driver");
+ } else {
+ if (kvm_read(kd, (u_long) dbuf.name,
+ nbuf, sizeof(nbuf)) < 0) {
+ error("kvm_read", NULL);
+ } else {
+ nbuf[sizeof(nbuf) - 1] = 0;
+ if (verbose)
+ printf("Device: %s%d\n", nbuf, buf1.id_unit);
+ }
+ }
+ else
+ error("kvm_read", "no driver");
+ break;
+
+ };
+
+ if (!dev_found)
+ continue;
+
+ if (buf1.id_id != 0)
+ if (verbose)
+ printf(
+ "kernel: id=%u io=%X irq=%d drq=%d maddr=%p msize=%d flags=%X enabled=%X \n",
+ buf1.id_id, buf1.id_iobase, buf1.id_irq, buf1.id_drq,
+ buf1.id_maddr, buf1.id_msize, buf1.id_flags, buf1.id_enabled);
+
+ if (buf.id_id != 0)
+ if (verbose)
+ printf(
+ "file: id=%u io=%X irq=%d drq=%d maddr=%p msize=%d flags=%X enabled=%X \n",
+ buf.id_id, buf.id_iobase, buf.id_irq, buf.id_drq,
+ buf.id_maddr, buf.id_msize, buf.id_flags, buf.id_enabled);
+
+
+ /*
+ * OK,now we'd compare values and set'em from kernel.
+ */
+ modified = FALSE;
+
+ if (buf.id_iobase != -1 && buf.id_iobase !=
+ buf1.id_iobase) {
+ if (verbose)
+ printf("Setting IO addr\n");
+ buf.id_iobase = buf1.id_iobase;
+ modified = TRUE;
+ }
+ if (buf.id_irq != (u_short)-1 && buf.id_irq != buf1.id_irq) {
+ if (verbose)
+ printf("Setting IRQ\n");
+ buf.id_irq = buf1.id_irq;
+ modified = TRUE;
+ }
+ if (buf.id_drq != -1 && buf.id_drq != buf1.id_drq) {
+ if (verbose)
+ printf("Setting DRQ\n");
+ buf.id_drq = buf1.id_drq;
+ modified = TRUE;
+ }
+ if (buf.id_maddr != (caddr_t)-1 && buf.id_maddr != buf1.id_maddr) {
+ if (verbose)
+ printf("Setting memory addres\n");
+ buf.id_maddr = buf1.id_maddr;
+ modified = TRUE;
+ }
+ if (buf.id_msize != buf1.id_msize) {
+ if (verbose)
+ printf("Setting msize\n");
+ buf.id_msize = buf1.id_msize;
+ modified = TRUE;
+ }
+ if (buf.id_flags != buf1.id_flags) {
+ if (verbose)
+ printf("Setting flags\n");
+ buf.id_flags = buf1.id_flags;
+ modified = TRUE;
+ }
+ if (buf.id_enabled != buf1.id_enabled) {
+ if (verbose)
+ printf("Setting device enable/disable\n");
+ buf.id_enabled = buf1.id_enabled;
+ modified = TRUE;
+ }
+ if (verbose)
+ printf("----------------------------------------------------\n");
+ if (modified && !testonly) {
+
+ res = lseek(f, -(off_t) sizeof(struct isa_device),
+ SEEK_CUR);
+ if (write(f, &buf, sizeof(struct isa_device)) <= 0)
+ fatal("write", NULL);
+
+ }
+ } while (buf.id_id != 0 && buf1.id_id != 0);
+ }
+
+ if (kvm_nlist(kd, nlaux) != 0) {
+ /* num_eisa_conf need not exist, only handle it if found */
+ if (verbose)
+ printf("num_eisa_slots not found, ignoring.\n");
+ } else {
+ if (nlaux[0].n_type == 0)
+ fatal("kvm_nlist", "bad symbol type");
+ pos1 = nlaux[0].n_value;
+ if (kvm_read(kd, pos1, &s, sizeof(int)) < 0)
+ fatal("kvmread", NULL);
+
+ if (nlist(kernel, nlaux) != 0)
+ fatal("nlist", NULL);
+ if (nlaux[0].n_type == 0)
+ fatal("nlist", "bad symbol type");
+ pos = nlaux[0].n_value + getpagesize() - entry;
+ if (lseek(f, pos, SEEK_SET) != pos)
+ fatal("seek", NULL);
+ if ((res = read(f, (char *) &i, sizeof(int)))
+ <= 0)
+ fatal("read", NULL);
+
+ if (i != s) {
+ if (verbose)
+ printf("\nChanging num_eisa_slots from %d to %d.\n",
+ i, s);
+ if (!testonly) {
+ res = lseek(f, -(off_t) sizeof(int),
+ SEEK_CUR);
+ if (write(f, &s, sizeof(int)) <= 0)
+ fatal("write", NULL);
+ }
+ }
+ }
+
+ if (kvm_nlist(kd, nlpnp) != 0) {
+ /* pnp_ldn_overrides need not exist, only handle it if found */
+ if (verbose)
+ printf("pnp_ldn_overrides not found, ignoring.\n");
+ } else {
+ if (nlpnp[0].n_type == 0)
+ fatal("kvm_nlist", "bad symbol type");
+ /* must handle it, read and write... */
+ pos1 = nlpnp[0].n_value ;
+ if (kvm_read(kd, pos1, &new_ov, sizeof(new_ov) ) < 0 )
+ fatal("kvmread", NULL);
+ if (nlist(kernel, nlpnp) != 0)
+ fatal("nlist", NULL);
+ if (nlpnp[0].n_type == 0)
+ fatal("nlist", "bad symbol type");
+ pos = nlpnp[0].n_value + getpagesize() - entry;
+ if (lseek(f, pos, SEEK_SET) != pos)
+ fatal("seek", NULL);
+ if ((res = read(f, (char *) &old_ov, sizeof(old_ov))) <= 0 )
+ fatal("read", NULL);
+ if (testonly || bcmp(&old_ov, &new_ov, sizeof(old_ov)) ) {
+ if (verbose) {
+ int i;
+ printf("CSN LDN conf en irq drq vendor_id. ....\n");
+ for (i=0; i < MAX_PNP_LDN ; i++) {
+ if (new_ov[i].csn>0 && new_ov[i].csn<255) {
+ int maxp, maxm;
+ for (maxp=7; maxp>=0 ; maxp--)
+ if (new_ov[i].port[maxp] !=0) break;
+ for (maxm=3; maxm>=0 ; maxm--)
+ if (new_ov[i].mem[maxm].base !=0) break;
+ printf("%3d %3d %-4s %c ",
+ new_ov[i].csn,
+ new_ov[i].ldn,
+ new_ov[i].override ? "OS":"BIOS",
+ new_ov[i].enable ? 'y':'n');
+ printf(new_ov[i].irq[0] == 0 ? " -":" %2d",
+ new_ov[i].irq[0]);
+ printf(new_ov[i].irq[1] == 0 ? " - ":"%-2d",
+ new_ov[i].irq[1]);
+ printf(new_ov[i].drq[0] == 4 ? " -":" %d",
+ new_ov[i].drq[0]);
+ printf(new_ov[i].drq[1] == 4 ? " -":" %d",
+ new_ov[i].drq[1]);
+ if (new_ov[i].vendor_id > 0)
+ printf(" 0x%08x", new_ov[i].vendor_id);
+ if (new_ov[i].flags > 0)
+ printf(" flags 0x%08lx", new_ov[i].flags);
+ if (maxp >=0) {
+ int j;
+ printf(" port 0x%x", new_ov[i].port[0]);
+ for(j=1;j<=maxp;j++)
+ printf(" 0x%x", new_ov[i].port[j]);
+ }
+ if (maxm >=0) {
+ int j;
+ printf(" mem 0x%lx", new_ov[i].mem[0].base);
+ for(j=1;j<=maxm;j++)
+ printf(" 0x%lx", new_ov[i].mem[j].base);
+ }
+ printf("\n");
+ }
+ }
+ }
+ if (!testonly) {
+ res = lseek(f, -(off_t) sizeof(new_ov),
+ SEEK_CUR);
+ if (write(f,&new_ov, sizeof(new_ov)) <= 0)
+ fatal("write", NULL);
+ }
+ }
+ }
+ if (chflags(kernel, flags) < 0)
+ fatal("chflags restore", NULL);
+
+ kvm_close(kd);
+ close(f);
+ return(0);
+}
diff --git a/sbin/dump/traverse.c b/sbin/dump/traverse.c
index 555e948ceb7aa..952afc6a0bb38 100644
--- a/sbin/dump/traverse.c
+++ b/sbin/dump/traverse.c
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)traverse.c 8.7 (Berkeley) 6/15/95";
#endif
static const char rcsid[] =
- "$Id: traverse.c,v 1.7 1998/06/15 06:58:12 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include <sys/param.h>
@@ -501,14 +501,14 @@ void
writeheader(ino)
ino_t ino;
{
- register int32_t sum, cnt, *lp;
+ register long sum, cnt, *lp;
spcl.c_inumber = ino;
spcl.c_magic = NFS_MAGIC;
spcl.c_checksum = 0;
- lp = (int32_t *)&spcl;
+ lp = (long *)&spcl;
sum = 0;
- cnt = sizeof(union u_spcl) / (4 * sizeof(int32_t));
+ cnt = sizeof(union u_spcl) / (4 * sizeof(long));
while (--cnt >= 0) {
sum += *lp++;
sum += *lp++;
diff --git a/sbin/fsck/dir.c b/sbin/fsck/dir.c
index 71e8a05b9139b..91b507fa2b13a 100644
--- a/sbin/fsck/dir.c
+++ b/sbin/fsck/dir.c
@@ -36,11 +36,10 @@
static const char sccsid[] = "@(#)dir.c 8.8 (Berkeley) 4/28/95";
#endif
static const char rcsid[] =
- "$Id: dir.c,v 1.12 1998/09/23 05:37:35 nate Exp $";
+ "$Id: dir.c,v 1.11 1998/06/28 19:23:02 bde Exp $";
#endif /* not lint */
#include <sys/param.h>
-#include <sys/time.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ufs/dir.h>
@@ -89,9 +88,9 @@ propagate()
inp = *inpp;
if (inp->i_parent == 0)
continue;
- if (inoinfo(inp->i_parent)->ino_state == DFOUND &&
- inoinfo(inp->i_number)->ino_state == DSTATE) {
- inoinfo(inp->i_number)->ino_state = DFOUND;
+ if (statemap[inp->i_parent] == DFOUND &&
+ statemap[inp->i_number] == DSTATE) {
+ statemap[inp->i_number] = DFOUND;
change++;
}
}
@@ -124,8 +123,6 @@ dirscan(idesc)
idesc->id_loc = 0;
for (dp = fsck_readdir(idesc); dp != NULL; dp = fsck_readdir(idesc)) {
dsize = dp->d_reclen;
- if (dsize > sizeof(dbuf))
- dsize = sizeof(dbuf);
memmove(dbuf, dp, (size_t)dsize);
# if (BYTE_ORDER == LITTLE_ENDIAN)
if (!newinofmt) {
@@ -238,7 +235,8 @@ dircheck(idesc, dp)
int spaceleft;
spaceleft = DIRBLKSIZ - (idesc->id_loc % DIRBLKSIZ);
- if (dp->d_reclen == 0 ||
+ if (dp->d_ino >= maxino ||
+ dp->d_reclen == 0 ||
dp->d_reclen > spaceleft ||
(dp->d_reclen & 0x3) != 0)
return (0);
@@ -308,40 +306,13 @@ adjust(idesc, lcnt)
register struct inodesc *idesc;
int lcnt;
{
- struct dinode *dp;
- int saveresolved;
+ register struct dinode *dp;
dp = ginode(idesc->id_number);
if (dp->di_nlink == lcnt) {
- /*
- * If we have not hit any unresolved problems, are running
- * in preen mode, and are on a filesystem using soft updates,
- * then just toss any partially allocated files.
- */
- if (resolved && preen && usedsoftdep) {
- clri(idesc, "UNREF", 1);
- return;
- } else {
- /*
- * The filesystem can be marked clean even if
- * a file is not linked up, but is cleared.
- * Hence, resolved should not be cleared when
- * linkup is answered no, but clri is answered yes.
- */
- saveresolved = resolved;
- if (linkup(idesc->id_number, (ino_t)0, NULL) == 0) {
- resolved = saveresolved;
- clri(idesc, "UNREF", 0);
- return;
- }
- /*
- * Account for the new reference created by linkup().
- */
- dp = ginode(idesc->id_number);
- lcnt--;
- }
- }
- if (lcnt != 0) {
+ if (linkup(idesc->id_number, (ino_t)0) == 0)
+ clri(idesc, "UNREF", 0);
+ } else {
pwarn("LINK COUNT %s", (lfdir == idesc->id_number) ? lfname :
((dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE"));
pinode(idesc->id_number);
@@ -384,7 +355,7 @@ mkentry(idesc)
dirp->d_ino = idesc->id_parent; /* ino to be entered is in id_parent */
dirp->d_reclen = newent.d_reclen;
if (newinofmt)
- dirp->d_type = inoinfo(idesc->id_parent)->ino_type;
+ dirp->d_type = typemap[idesc->id_parent];
else
dirp->d_type = 0;
dirp->d_namlen = newent.d_namlen;
@@ -417,17 +388,16 @@ chgino(idesc)
return (KEEPON);
dirp->d_ino = idesc->id_parent;
if (newinofmt)
- dirp->d_type = inoinfo(idesc->id_parent)->ino_type;
+ dirp->d_type = typemap[idesc->id_parent];
else
dirp->d_type = 0;
return (ALTERED|STOP);
}
int
-linkup(orphan, parentdir, name)
+linkup(orphan, parentdir)
ino_t orphan;
ino_t parentdir;
- char *name;
{
register struct dinode *dp;
int lostdir;
@@ -440,7 +410,7 @@ linkup(orphan, parentdir, name)
lostdir = (dp->di_mode & IFMT) == IFDIR;
pwarn("UNREF %s ", lostdir ? "DIR" : "FILE");
pinode(orphan);
- if (preen && dp->di_size == 0)
+ if ((preen || usedsoftdep) && dp->di_size == 0)
return (0);
if (preen)
printf(" (RECONNECTED)\n");
@@ -461,7 +431,6 @@ linkup(orphan, parentdir, name)
lfdir = allocdir(ROOTINO, (ino_t)0, lfmode);
if (lfdir != 0) {
if (makeentry(ROOTINO, lfdir, lfname) != 0) {
- numdirs++;
if (preen)
printf(" (CREATED)\n");
} else {
@@ -497,21 +466,21 @@ linkup(orphan, parentdir, name)
idesc.id_type = ADDR;
idesc.id_func = pass4check;
idesc.id_number = oldlfdir;
- adjust(&idesc, inoinfo(oldlfdir)->ino_linkcnt + 1);
- inoinfo(oldlfdir)->ino_linkcnt = 0;
+ adjust(&idesc, lncntp[oldlfdir] + 1);
+ lncntp[oldlfdir] = 0;
dp = ginode(lfdir);
}
- if (inoinfo(lfdir)->ino_state != DFOUND) {
+ if (statemap[lfdir] != DFOUND) {
pfatal("SORRY. NO lost+found DIRECTORY\n\n");
return (0);
}
(void)lftempname(tempname, orphan);
- if (makeentry(lfdir, orphan, (name ? name : tempname)) == 0) {
+ if (makeentry(lfdir, orphan, tempname) == 0) {
pfatal("SORRY. NO SPACE IN lost+found DIRECTORY");
printf("\n\n");
return (0);
}
- inoinfo(orphan)->ino_linkcnt--;
+ lncntp[orphan]--;
if (lostdir) {
if ((changeino(orphan, "..", lfdir) & ALTERED) == 0 &&
parentdir != (ino_t)-1)
@@ -519,7 +488,7 @@ linkup(orphan, parentdir, name)
dp = ginode(lfdir);
dp->di_nlink++;
inodirty();
- inoinfo(lfdir)->ino_linkcnt++;
+ lncntp[lfdir]++;
pwarn("DIR I=%lu CONNECTED. ", orphan);
if (parentdir != (ino_t)-1) {
printf("PARENT WAS I=%lu\n", (u_long)parentdir);
@@ -530,7 +499,8 @@ linkup(orphan, parentdir, name)
* fixes the parent link count so that fsck does
* not need to be rerun.
*/
- inoinfo(parentdir)->ino_linkcnt++;
+ lncntp[parentdir]++;
+
}
if (preen == 0)
printf("\n");
@@ -688,20 +658,19 @@ allocdir(parent, request, mode)
dp->di_nlink = 2;
inodirty();
if (ino == ROOTINO) {
- inoinfo(ino)->ino_linkcnt = dp->di_nlink;
+ lncntp[ino] = dp->di_nlink;
cacheino(dp, ino);
return(ino);
}
- if (inoinfo(parent)->ino_state != DSTATE &&
- inoinfo(parent)->ino_state != DFOUND) {
+ if (statemap[parent] != DSTATE && statemap[parent] != DFOUND) {
freeino(ino);
return (0);
}
cacheino(dp, ino);
- inoinfo(ino)->ino_state = inoinfo(parent)->ino_state;
- if (inoinfo(ino)->ino_state == DSTATE) {
- inoinfo(ino)->ino_linkcnt = dp->di_nlink;
- inoinfo(parent)->ino_linkcnt++;
+ statemap[ino] = statemap[parent];
+ if (statemap[ino] == DSTATE) {
+ lncntp[ino] = dp->di_nlink;
+ lncntp[parent]++;
}
dp = ginode(parent);
dp->di_nlink++;
diff --git a/sbin/fsck/fsck.8 b/sbin/fsck/fsck.8
index 5ce5e0f681daf..51d1679f6d1d3 100644
--- a/sbin/fsck/fsck.8
+++ b/sbin/fsck/fsck.8
@@ -1,4 +1,3 @@
-.\"
.\" Copyright (c) 1980, 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -31,9 +30,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)fsck.8 8.4 (Berkeley) 5/9/95
-.\" $Id: fsck.8,v 1.11 1998/06/15 07:07:12 charnier Exp $
+.\" $Id: fsck.8,v 1.10 1997/03/12 16:35:26 bde Exp $
.\"
-.Dd November 15, 1996
+.Dd May 9, 1995
.Dt FSCK 8
.Os BSD 4
.Sh NAME
@@ -44,13 +43,12 @@
.Fl p
.Op Fl f
.Op Fl m Ar mode
-.Op Ar filesystem
-.Ar ...
.Nm fsck
-.Op Fl ny
.Op Fl b Ar block#
.Op Fl c Ar level
.Op Fl l Ar maxparallel
+.Op Fl y
+.Op Fl n
.Op Fl m Ar mode
.Op Ar filesystem
.Ar ...
@@ -76,8 +74,7 @@ The disk drive containing each filesystem is inferred from the longest prefix
of the device name that ends in a digit; the remaining characters are assumed
to be the partition designator.
.Pp
-In "preen" mode the clean flag of each filesystem's superblock is examined
-and only those filesystems that
+The clean flag of each filesystem's superblock is examined and only those filesystems that
are not marked clean are checked.
Filesystems are marked clean when they are unmounted,
when they have been mounted read-only, or when
@@ -91,8 +88,7 @@ will be checked regardless of the state of their clean flag.
The kernel takes care that only a restricted class of innocuous filesystem
inconsistencies can happen unless hardware or software failures intervene.
These are limited to the following:
-.Pp
-.Bl -item -compact -offset indent
+.Bl -item -compact
.It
Unreferenced inodes
.It
@@ -168,6 +164,32 @@ The following flags are interpreted by
Use the block specified immediately after the flag as
the super block for the filesystem. Block 32 is usually
an alternate super block.
+.It Fl l
+Limit the number of parallel checks to the number specified in the following
+argument.
+By default, the limit is the number of disks, running one process per disk.
+If a smaller limit is given, the disks are checked round-robin, one filesystem
+at a time.
+.It Fl m
+Use the mode specified in octal immediately after the flag as the
+permission bits to use when creating the
+.Pa lost+found
+directory rather than the default 1777.
+In particular, systems that do not wish to have lost files accessible
+by all users on the system should use a more restrictive
+set of permissions such as 700.
+.It Fl y
+Assume a yes response to all questions asked by
+.Nm Ns ;
+this should be used with great caution as this is a free license
+to continue after essentially unlimited trouble has been encountered.
+.It Fl n
+Assume a no response to all questions asked by
+.Nm
+except for
+.Ql CONTINUE? ,
+which is assumed to be affirmative;
+do not open the filesystem for writing.
.It Fl c
Convert the filesystem to the specified level.
Note that the level of a filesystem can only be raised.
@@ -201,40 +223,6 @@ are being converted at once.
The format of a filesystem can be determined from the
first line of output from
.Xr dumpfs 8 .
-.It Fl f
-Force
-.Nm fsck
-to check
-.Sq clean
-filesystems when preening.
-.It Fl l
-Limit the number of parallel checks to the number specified in the following
-argument.
-By default, the limit is the number of disks, running one process per disk.
-If a smaller limit is given, the disks are checked round-robin, one filesystem
-at a time.
-.It Fl m
-Use the mode specified in octal immediately after the flag as the
-permission bits to use when creating the
-.Pa lost+found
-directory rather than the default 1777.
-In particular, systems that do not wish to have lost files accessible
-by all users on the system should use a more restrictive
-set of permissions such as 700.
-.It Fl n
-Assume a no response to all questions asked by
-.Nm
-except for
-.Ql CONTINUE? ,
-which is assumed to be affirmative;
-do not open the filesystem for writing.
-.It Fl p
-Preen filesystems (see above).
-.It Fl y
-Assume a yes response to all questions asked by
-.Nm Ns ;
-this should be used with great caution as this is a free license
-to continue after essentially unlimited trouble has been encountered.
.El
.Pp
If no filesystems are given to
@@ -271,7 +259,7 @@ File pointing to unallocated inode.
.It
Inode number out of range.
.It
-Directories with unallocated blocks (holes).
+Holes in directories.
.It
Dot or dot-dot not the first two entries of a directory
or having the wrong inode number.
diff --git a/sbin/fsck/fsck.h b/sbin/fsck/fsck.h
index 81b2292688840..4e0271d815dd4 100644
--- a/sbin/fsck/fsck.h
+++ b/sbin/fsck/fsck.h
@@ -42,35 +42,16 @@
#define MAXBUFSPACE 40*1024 /* maximum space to allocate to buffers */
#define INOBUFSIZE 56*1024 /* size of buffer to read inodes in pass1 */
-/*
- * Each inode on the filesystem is described by the following structure.
- * The linkcnt is initially set to the value in the inode. Each time it
- * is found during the descent in passes 2, 3, and 4 the count is
- * decremented. Any inodes whose count is non-zero after pass 4 needs to
- * have its link count adjusted by the value remaining in ino_linkcnt.
- */
-struct inostat {
- char ino_state; /* state of inode, see below */
- char ino_type; /* type of inode */
- short ino_linkcnt; /* number of links not found */
-};
-/*
- * Inode states.
- */
+#ifndef BUFSIZ
+#define BUFSIZ 1024
+#endif
+
#define USTATE 01 /* inode not allocated */
#define FSTATE 02 /* inode is file */
#define DSTATE 03 /* inode is directory */
#define DFOUND 04 /* directory found during descent */
#define DCLEAR 05 /* directory is to be cleared */
#define FCLEAR 06 /* file is to be cleared */
-/*
- * Inode state information is contained on per cylinder group lists
- * which are described by the following structure.
- */
-struct inostatlist {
- long il_numalloced; /* number of inodes allocated in this cg */
- struct inostat *il_stat;/* inostat info for this cylinder group */
-} *inostathead;
/*
* buffer cache structure.
@@ -182,12 +163,11 @@ struct inoinfo {
ufs_daddr_t i_blks[1]; /* actually longer */
} **inphead, **inpsort;
long numdirs, listmax, inplast;
-long countdirs; /* number of directories we actually found */
char *cdevname; /* name of device being checked */
long dev_bsize; /* computed value of DEV_BSIZE */
long secsize; /* actual disk sector size */
-char fflag; /* force check, ignore clean flag */
+char fflag; /* force fs check (ignore clean flag) */
char nflag; /* assume a no response */
char yflag; /* assume a yes response */
int bflag; /* location of alternate super block */
@@ -197,19 +177,23 @@ int doinglevel1; /* converting to new cylinder group format */
int doinglevel2; /* converting to new inode format */
int newinofmt; /* filesystem has new inode format */
char usedsoftdep; /* just fix soft dependency inconsistencies */
-char preen; /* just fix normal inconsistencies */
-char rerun; /* rerun fsck. Only used in non-preen mode */
-int returntosingle; /* 1 => return to single user mode on exit */
char resolved; /* cleared if unresolved changes => not clean */
+char preen; /* just fix normal inconsistencies */
char hotroot; /* checking root device */
char havesb; /* superblock has been read */
int fsmodified; /* 1 => write done to file system */
int fsreadfd; /* file descriptor for reading file system */
int fswritefd; /* file descriptor for writing file system */
+int returntosingle; /* return to single user mode */
+int rerun; /* rerun fsck. Only used in non-preen mode */
ufs_daddr_t maxfsblock; /* number of blocks in the file system */
char *blockmap; /* ptr to primary blk allocation map */
ino_t maxino; /* number of inodes in file system */
+ino_t lastino; /* last inode in use */
+char *statemap; /* ptr to inode state table */
+u_char *typemap; /* ptr to inode type table */
+short *lncntp; /* ptr to link count table */
ino_t lfdir; /* lost & found directory inode number */
char *lfname; /* lost & found directory name */
@@ -235,7 +219,6 @@ struct dinode zino;
struct fstab;
-
void adjust __P((struct inodesc *, int lcnt));
ufs_daddr_t allocblk __P((long frags));
ino_t allocdir __P((ino_t parent, ino_t request, int mode));
@@ -256,7 +239,6 @@ int chkrange __P((ufs_daddr_t blk, int cnt));
void ckfini __P((int markclean));
int ckinode __P((struct dinode *dp, struct inodesc *));
void clri __P((struct inodesc *, char *type, int flag));
-int clearentry __P((struct inodesc *));
void direrror __P((ino_t ino, char *errmesg));
int dirscan __P((struct inodesc *));
int dofix __P((struct inodesc *, char *msg));
@@ -280,8 +262,7 @@ void getpathname __P((char *namebuf, ino_t curdir, ino_t ino));
struct dinode *ginode __P((ino_t inumber));
void inocleanup __P((void));
void inodirty __P((void));
-struct inostat *inoinfo __P((ino_t inum));
-int linkup __P((ino_t orphan, ino_t parentdir, char *name));
+int linkup __P((ino_t orphan, ino_t parentdir));
int makeentry __P((ino_t parent, ino_t ino, char *name));
void panic __P((const char *fmt, ...));
void pass1 __P((void));
@@ -297,6 +278,6 @@ void pinode __P((ino_t ino));
void propagate __P((void));
void pwarn __P((const char *fmt, ...));
int reply __P((char *question));
-void setinodebuf __P((ino_t));
+void resetinodebuf __P((void));
int setup __P((char *dev));
void voidquit __P((int));
diff --git a/sbin/fsck/inode.c b/sbin/fsck/inode.c
index 5a8acd289752f..b7e80cdffaa6d 100644
--- a/sbin/fsck/inode.c
+++ b/sbin/fsck/inode.c
@@ -36,7 +36,7 @@
static const char sccsid[] = "@(#)inode.c 8.8 (Berkeley) 4/28/95";
#endif
static const char rcsid[] =
- "$Id: inode.c,v 1.16 1998/08/01 18:03:28 dfr Exp $";
+ "$Id: inode.c,v 1.15 1998/06/28 19:23:02 bde Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -62,8 +62,7 @@ ckinode(dp, idesc)
register struct inodesc *idesc;
{
ufs_daddr_t *ap;
- int ret;
- long n, ndb, offset;
+ long ret, n, ndb, offset;
struct dinode dino;
quad_t remsize, sizepb;
mode_t mode;
@@ -75,7 +74,7 @@ ckinode(dp, idesc)
idesc->id_filesize = dp->di_size;
mode = dp->di_mode & IFMT;
if (mode == IFBLK || mode == IFCHR || (mode == IFLNK &&
- dp->di_size < (unsigned)sblock.fs_maxsymlinklen))
+ (dp->di_size < sblock.fs_maxsymlinklen || dp->di_blocks == 0)))
return (KEEPON);
dino = *dp;
ndb = howmany(dino.di_size, sblock.fs_bsize);
@@ -240,16 +239,8 @@ chkrange(blk, cnt)
{
register int c;
- if (cnt <= 0 || blk <= 0 || blk > maxfsblock ||
- cnt - 1 > maxfsblock - blk)
+ if (blk < 0 || blk >= maxfsblock || cnt < 0 || cnt > maxfsblock - blk)
return (1);
- if (cnt > sblock.fs_frag ||
- fragnum(&sblock, blk) + cnt > sblock.fs_frag) {
- if (debug)
- printf("bad size: blk %ld, offset %ld, size %ld\n",
- blk, fragnum(&sblock, blk), cnt);
- return (1);
- }
c = dtog(&sblock, blk);
if (blk < cgdmin(&sblock, c)) {
if ((blk + cnt) > cgsblock(&sblock, c)) {
@@ -326,29 +317,20 @@ getnextinode(inumber)
size = inobufsize;
lastinum += fullcnt;
}
- /*
- * If bread returns an error, it will already have zeroed
- * out the buffer, so we do not need to do so here.
- */
- (void)bread(fsreadfd, (char *)inodebuf, dblk, size);
+ (void)bread(fsreadfd, (char *)inodebuf, dblk, size); /* ??? */
dp = inodebuf;
}
return (dp++);
}
void
-setinodebuf(inum)
- ino_t inum;
+resetinodebuf()
{
- if (inum % sblock.fs_ipg != 0)
- errx(EEXIT, "bad inode number %d to setinodebuf", inum);
startinum = 0;
- nextino = inum;
- lastinum = inum;
+ nextino = 0;
+ lastinum = 0;
readcnt = 0;
- if (inodebuf != NULL)
- return;
inobufsize = blkroundup(&sblock, INOBUFSIZE);
fullcnt = inobufsize / sizeof(struct dinode);
readpercg = sblock.fs_ipg / fullcnt;
@@ -360,8 +342,11 @@ setinodebuf(inum)
partialcnt = fullcnt;
partialsize = inobufsize;
}
- if ((inodebuf = (struct dinode *)malloc((unsigned)inobufsize)) == NULL)
+ if (inodebuf == NULL &&
+ (inodebuf = (struct dinode *)malloc((unsigned)inobufsize)) == NULL)
errx(EEXIT, "cannot allocate space for inode buffer");
+ while (nextino < ROOTINO)
+ (void)getnextinode(nextino);
}
void
@@ -395,11 +380,14 @@ cacheino(dp, inumber)
inp = (struct inoinfo *)
malloc(sizeof(*inp) + (blks - 1) * sizeof(ufs_daddr_t));
if (inp == NULL)
- errx(EEXIT, "cannot increase directory list");
+ return;
inpp = &inphead[inumber % numdirs];
inp->i_nexthash = *inpp;
*inpp = inp;
- inp->i_parent = inumber == ROOTINO ? ROOTINO : (ino_t)0;
+ if (inumber == ROOTINO)
+ inp->i_parent = ROOTINO;
+ else
+ inp->i_parent = (ino_t)0;
inp->i_dotdot = (ino_t)0;
inp->i_number = inumber;
inp->i_isize = dp->di_size;
@@ -477,7 +465,7 @@ clri(idesc, type, flag)
n_files--;
(void)ckinode(dp, idesc);
clearinode(dp);
- inoinfo(idesc->id_number)->ino_state = USTATE;
+ statemap[idesc->id_number] = USTATE;
inodirty();
}
}
@@ -488,10 +476,8 @@ findname(idesc)
{
register struct direct *dirp = idesc->id_dirp;
- if (dirp->d_ino != idesc->id_parent || idesc->id_entryno < 2) {
- idesc->id_entryno++;
+ if (dirp->d_ino != idesc->id_parent)
return (KEEPON);
- }
memmove(idesc->id_name, dirp->d_name, (size_t)dirp->d_namlen + 1);
return (STOP|FOUND);
}
@@ -512,20 +498,6 @@ findino(idesc)
return (KEEPON);
}
-int
-clearentry(idesc)
- struct inodesc *idesc;
-{
- register struct direct *dirp = idesc->id_dirp;
-
- if (dirp->d_ino != idesc->id_parent || idesc->id_entryno < 2) {
- idesc->id_entryno++;
- return (KEEPON);
- }
- dirp->d_ino = 0;
- return (STOP|FOUND|ALTERED);
-}
-
void
pinode(ino)
ino_t ino;
@@ -562,14 +534,14 @@ blkerror(ino, type, blk)
pfatal("%ld %s I=%lu", blk, type, ino);
printf("\n");
- switch (inoinfo(ino)->ino_state) {
+ switch (statemap[ino]) {
case FSTATE:
- inoinfo(ino)->ino_state = FCLEAR;
+ statemap[ino] = FCLEAR;
return;
case DSTATE:
- inoinfo(ino)->ino_state = DCLEAR;
+ statemap[ino] = DCLEAR;
return;
case FCLEAR:
@@ -577,7 +549,7 @@ blkerror(ino, type, blk)
return;
default:
- errx(EEXIT, "BAD STATE %d TO BLKERR", inoinfo(ino)->ino_state);
+ errx(EEXIT, "BAD STATE %d TO BLKERR", statemap[ino]);
/* NOTREACHED */
}
}
@@ -597,10 +569,10 @@ allocino(request, type)
if (request == 0)
request = ROOTINO;
- else if (inoinfo(request)->ino_state != USTATE)
+ else if (statemap[request] != USTATE)
return (0);
for (ino = request; ino < maxino; ino++)
- if (inoinfo(ino)->ino_state == USTATE)
+ if (statemap[ino] == USTATE)
break;
if (ino == maxino)
return (0);
@@ -612,12 +584,12 @@ allocino(request, type)
cgp->cg_cs.cs_nifree--;
switch (type & IFMT) {
case IFDIR:
- inoinfo(ino)->ino_state = DSTATE;
+ statemap[ino] = DSTATE;
cgp->cg_cs.cs_ndir++;
break;
case IFREG:
case IFLNK:
- inoinfo(ino)->ino_state = FSTATE;
+ statemap[ino] = FSTATE;
break;
default:
return (0);
@@ -626,20 +598,19 @@ allocino(request, type)
dp = ginode(ino);
dp->di_db[0] = allocblk((long)1);
if (dp->di_db[0] == 0) {
- inoinfo(ino)->ino_state = USTATE;
+ statemap[ino] = USTATE;
return (0);
}
- dp->di_mode = type;
dp->di_flags = 0;
+ dp->di_mode = type;
dp->di_atime = time(NULL);
dp->di_mtime = dp->di_ctime = dp->di_atime;
- dp->di_mtimensec = dp->di_ctimensec = dp->di_atimensec = 0;
dp->di_size = sblock.fs_fsize;
dp->di_blocks = btodb(sblock.fs_fsize);
n_files++;
inodirty();
if (newinofmt)
- inoinfo(ino)->ino_type = IFTODT(type);
+ typemap[ino] = IFTODT(type);
return (ino);
}
@@ -661,6 +632,6 @@ freeino(ino)
(void)ckinode(dp, &idesc);
clearinode(dp);
inodirty();
- inoinfo(ino)->ino_state = USTATE;
+ statemap[ino] = USTATE;
n_files--;
}
diff --git a/sbin/fsck/main.c b/sbin/fsck/main.c
index bcf0021fd2a9f..9ff947c52f84d 100644
--- a/sbin/fsck/main.c
+++ b/sbin/fsck/main.c
@@ -42,13 +42,12 @@ static const char copyright[] =
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
#endif
static const char rcsid[] =
- "$Id: main.c,v 1.15 1998/11/05 03:26:36 mjacob Exp $";
+ "$Id: main.c,v 1.13 1998/03/08 09:55:26 julian Exp $";
#endif /* not lint */
#include <sys/param.h>
#include <sys/time.h>
#include <sys/mount.h>
-#include <sys/resource.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ufs/ufsmount.h>
@@ -59,6 +58,8 @@ static const char rcsid[] =
#include "fsck.h"
+int returntosingle;
+
static int argtoi __P((int flag, char *req, char *str, int base));
static int docheck __P((struct fstab *fsp));
static int checkfilesys __P((char *filesys, char *mntpt, long auxdata,
@@ -72,7 +73,6 @@ main(argc, argv)
{
int ch;
int ret, maxrun = 0;
- struct rlimit rlimit;
sync();
while ((ch = getopt(argc, argv, "dfpnNyYb:c:l:m:")) != -1) {
@@ -131,24 +131,9 @@ main(argc, argv)
(void)signal(SIGINT, catch);
if (preen)
(void)signal(SIGQUIT, catchquit);
- /*
- * Push up our allowed memory limit so we can cope
- * with huge filesystems.
- */
- if (getrlimit(RLIMIT_DATA, &rlimit) == 0) {
- rlimit.rlim_cur = rlimit.rlim_max;
- (void)setrlimit(RLIMIT_DATA, &rlimit);
- }
if (argc) {
- while (argc-- > 0) {
- char *path = blockcheck(*argv);
-
- if (path == NULL)
- pfatal("Can't check %s\n", *argv);
- else
- (void)checkfilesys(path, 0, 0L, 0);
- ++argv;
- }
+ while (argc-- > 0)
+ (void)checkfilesys(blockcheck(*argv++), 0, 0L, 0);
exit(0);
}
ret = checkfstab(preen, maxrun, docheck, checkfilesys);
@@ -313,7 +298,7 @@ checkfilesys(filesys, mntpt, auxdata, child)
muldup = (struct dups *)0;
inocleanup();
if (fsmodified) {
- sblock.fs_time = time(NULL);
+ (void)time(&sblock.fs_time);
sbdirty();
}
if (cvtlevel && sblk.b_dirty) {
@@ -338,13 +323,12 @@ checkfilesys(filesys, mntpt, auxdata, child)
resolved = 0;
}
ckfini(resolved);
-
- for (cylno = 0; cylno < sblock.fs_ncg; cylno++)
- if (inostathead[cylno].il_stat != NULL)
- free((char *)inostathead[cylno].il_stat);
- free((char *)inostathead);
- inostathead = NULL;
- if (fsmodified && !preen)
+ free(blockmap);
+ free(statemap);
+ free((char *)lncntp);
+ if (!fsmodified)
+ return (0);
+ if (!preen)
printf("\n***** FILE SYSTEM WAS MODIFIED *****\n");
if (rerun)
printf("\n***** PLEASE RERUN FSCK *****\n");
@@ -364,8 +348,6 @@ checkfilesys(filesys, mntpt, auxdata, child)
if (ret == 0)
return (0);
}
- if (!fsmodified)
- return (0);
if (!preen)
printf("\n***** REBOOT NOW *****\n");
sync();
diff --git a/sbin/fsck/pass1.c b/sbin/fsck/pass1.c
index 0d3fc478f37fe..30c0e7d5b5411 100644
--- a/sbin/fsck/pass1.c
+++ b/sbin/fsck/pass1.c
@@ -36,7 +36,7 @@
static const char sccsid[] = "@(#)pass1.c 8.6 (Berkeley) 4/28/95";
#endif
static const char rcsid[] =
- "$Id: pass1.c,v 1.13 1998/07/06 19:11:35 bde Exp $";
+ "$Id: pass1.c,v 1.11 1998/06/15 07:07:16 charnier Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -52,17 +52,14 @@ static const char rcsid[] =
static ufs_daddr_t badblk;
static ufs_daddr_t dupblk;
-static ino_t lastino; /* last inode in use */
static void checkinode __P((ino_t inumber, struct inodesc *));
void
pass1()
{
- u_int8_t *cp;
ino_t inumber;
- int c, i, cgd, inosused;
- struct inostat *info;
+ int c, i, cgd;
struct inodesc idesc;
/*
@@ -84,84 +81,15 @@ pass1()
memset(&idesc, 0, sizeof(struct inodesc));
idesc.id_type = ADDR;
idesc.id_func = pass1check;
+ inumber = 0;
n_files = n_blks = 0;
+ resetinodebuf();
for (c = 0; c < sblock.fs_ncg; c++) {
- inumber = c * sblock.fs_ipg;
- setinodebuf(inumber);
- inosused = sblock.fs_ipg;
- /*
- * If we are using soft updates, then we can trust the
- * cylinder group inode allocation maps to tell us which
- * inodes are allocated. We will scan the used inode map
- * to find the inodes that are really in use, and then
- * read only those inodes in from disk.
- */
- if (preen && usedsoftdep) {
- getblk(&cgblk, cgtod(&sblock, c), sblock.fs_cgsize);
- if (!cg_chkmagic(&cgrp))
- pfatal("CG %d: BAD MAGIC NUMBER\n", c);
- cp = &cg_inosused(&cgrp)[(sblock.fs_ipg - 1) / NBBY];
- for ( ; inosused > 0; inosused -= NBBY, cp--) {
- if (*cp == 0)
- continue;
- for (i = 1 << (NBBY - 1); i > 0; i >>= 1) {
- if (*cp & i)
- break;
- inosused--;
- }
- break;
- }
- if (inosused < 0)
- inosused = 0;
- }
- /*
- * Allocate inoinfo structures for the allocated inodes.
- */
- inostathead[c].il_numalloced = inosused;
- if (inosused == 0) {
- inostathead[c].il_stat = 0;
- continue;
- }
- info = calloc((unsigned)inosused, sizeof(struct inostat));
- if (info == NULL)
- pfatal("cannot alloc %u bytes for inoinfo\n",
- (unsigned)(sizeof(struct inostat) * inosused));
- inostathead[c].il_stat = info;
- /*
- * Scan the allocated inodes.
- */
- for (i = 0; i < inosused; i++, inumber++) {
- if (inumber < ROOTINO) {
- (void)getnextinode(inumber);
+ for (i = 0; i < sblock.fs_ipg; i++, inumber++) {
+ if (inumber < ROOTINO)
continue;
- }
checkinode(inumber, &idesc);
}
- lastino += 1;
- if (inosused < sblock.fs_ipg || inumber == lastino)
- continue;
- /*
- * If we were not able to determine in advance which inodes
- * were in use, then reduce the size of the inoinfo structure
- * to the size necessary to describe the inodes that we
- * really found.
- */
- inosused = lastino - (c * sblock.fs_ipg);
- if (inosused < 0)
- inosused = 0;
- inostathead[c].il_numalloced = inosused;
- if (inosused == 0) {
- free(inostathead[c].il_stat);
- inostathead[c].il_stat = 0;
- continue;
- }
- info = calloc((unsigned)inosused, sizeof(struct inostat));
- if (info == NULL)
- pfatal("cannot alloc %u bytes for inoinfo\n",
- (unsigned)(sizeof(struct inostat) * inosused));
- memmove(info, inostathead[c].il_stat, inosused * sizeof(*info));
- free(inostathead[c].il_stat);
- inostathead[c].il_stat = info;
}
freeinodebuf();
}
@@ -192,7 +120,7 @@ checkinode(inumber, idesc)
inodirty();
}
}
- inoinfo(inumber)->ino_state = USTATE;
+ statemap[inumber] = USTATE;
return;
}
lastino = inumber;
@@ -230,7 +158,8 @@ checkinode(inumber, idesc)
if (debug) {
symbuf[dp->di_size] = 0;
printf("convert symlink %lu(%s) of size %ld\n",
- (u_long)inumber, symbuf, (long)dp->di_size);
+ (u_long)inumber, symbuf,
+ (long)dp->di_size);
}
dp = ginode(inumber);
memmove(dp->di_shortlink, symbuf, (long)dp->di_size);
@@ -241,7 +170,8 @@ checkinode(inumber, idesc)
* Fake ndb value so direct/indirect block checks below
* will detect any garbage after symlink string.
*/
- if (dp->di_size < sblock.fs_maxsymlinklen) {
+ if (dp->di_size < sblock.fs_maxsymlinklen ||
+ dp->di_blocks == 0) {
ndb = howmany(dp->di_size, sizeof(ufs_daddr_t));
if (ndb > NDADDR) {
j = ndb - NDADDR;
@@ -270,7 +200,7 @@ checkinode(inumber, idesc)
if (ftypeok(dp) == 0)
goto unknown;
n_files++;
- inoinfo(inumber)->ino_linkcnt = dp->di_nlink;
+ lncntp[inumber] = dp->di_nlink;
if (dp->di_nlink <= 0) {
zlnp = (struct zlncnt *)malloc(sizeof *zlnp);
if (zlnp == NULL) {
@@ -287,14 +217,13 @@ checkinode(inumber, idesc)
}
if (mode == IFDIR) {
if (dp->di_size == 0)
- inoinfo(inumber)->ino_state = DCLEAR;
+ statemap[inumber] = DCLEAR;
else
- inoinfo(inumber)->ino_state = DSTATE;
+ statemap[inumber] = DSTATE;
cacheino(dp, inumber);
- countdirs++;
} else
- inoinfo(inumber)->ino_state = FSTATE;
- inoinfo(inumber)->ino_type = IFTODT(mode);
+ statemap[inumber] = FSTATE;
+ typemap[inumber] = IFTODT(mode);
if (doinglevel2 &&
(dp->di_ouid != (u_short)-1 || dp->di_ogid != (u_short)-1)) {
dp = ginode(inumber);
@@ -322,9 +251,9 @@ checkinode(inumber, idesc)
return;
unknown:
pfatal("UNKNOWN FILE TYPE I=%lu", inumber);
- inoinfo(inumber)->ino_state = FCLEAR;
+ statemap[inumber] = FCLEAR;
if (reply("CLEAR") == 1) {
- inoinfo(inumber)->ino_state = USTATE;
+ statemap[inumber] = USTATE;
dp = ginode(inumber);
clearinode(dp);
inodirty();
diff --git a/sbin/fsck/pass1b.c b/sbin/fsck/pass1b.c
index 9380382a91985..32a3be7723bd9 100644
--- a/sbin/fsck/pass1b.c
+++ b/sbin/fsck/pass1b.c
@@ -36,7 +36,7 @@
static const char sccsid[] = "@(#)pass1b.c 8.4 (Berkeley) 4/28/95";
#endif
static const char rcsid[] =
- "$Id: pass1b.c,v 1.4 1998/06/15 07:07:17 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include <sys/param.h>
@@ -72,7 +72,7 @@ pass1b()
if (dp == NULL)
continue;
idesc.id_number = inumber;
- if (inoinfo(inumber)->ino_state != USTATE &&
+ if (statemap[inumber] != USTATE &&
(ckinode(dp, &idesc) & STOP))
return;
}
diff --git a/sbin/fsck/pass2.c b/sbin/fsck/pass2.c
index 878bcbead4b75..4c24b23a9ca43 100644
--- a/sbin/fsck/pass2.c
+++ b/sbin/fsck/pass2.c
@@ -36,7 +36,7 @@
static const char sccsid[] = "@(#)pass2.c 8.9 (Berkeley) 4/28/95";
#endif
static const char rcsid[] =
- "$Id: pass2.c,v 1.7 1998/06/15 07:07:18 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include <sys/param.h>
@@ -64,7 +64,7 @@ pass2()
struct dinode dino;
char pathbuf[MAXPATHLEN + 1];
- switch (inoinfo(ROOTINO)->ino_state) {
+ switch (statemap[ROOTINO]) {
case USTATE:
pfatal("ROOT INODE UNALLOCATED");
@@ -113,13 +113,12 @@ pass2()
break;
default:
- errx(EEXIT, "BAD STATE %d FOR ROOT INODE",
- inoinfo(ROOTINO)->ino_state);
+ errx(EEXIT, "BAD STATE %d FOR ROOT INODE", statemap[ROOTINO]);
}
- inoinfo(ROOTINO)->ino_state = DFOUND;
+ statemap[ROOTINO] = DFOUND;
if (newinofmt) {
- inoinfo(WINO)->ino_state = FSTATE;
- inoinfo(WINO)->ino_type = DT_WHT;
+ statemap[WINO] = FSTATE;
+ typemap[WINO] = DT_WHT;
}
/*
* Sort the directory list into disk block order.
@@ -182,9 +181,9 @@ pass2()
inp = *inpp;
if (inp->i_parent == 0 || inp->i_isize == 0)
continue;
- if (inoinfo(inp->i_parent)->ino_state == DFOUND &&
- inoinfo(inp->i_number)->ino_state == DSTATE)
- inoinfo(inp->i_number)->ino_state = DFOUND;
+ if (statemap[inp->i_parent] == DFOUND &&
+ statemap[inp->i_number] == DSTATE)
+ statemap[inp->i_number] = DFOUND;
if (inp->i_dotdot == inp->i_parent ||
inp->i_dotdot == (ino_t)-1)
continue;
@@ -194,15 +193,15 @@ pass2()
if (reply("FIX") == 0)
continue;
(void)makeentry(inp->i_number, inp->i_parent, "..");
- inoinfo(inp->i_parent)->ino_linkcnt--;
+ lncntp[inp->i_parent]--;
continue;
}
fileerror(inp->i_parent, inp->i_number,
"BAD INODE NUMBER FOR '..'");
if (reply("FIX") == 0)
continue;
- inoinfo(inp->i_dotdot)->ino_linkcnt++;
- inoinfo(inp->i_parent)->ino_linkcnt--;
+ lncntp[inp->i_dotdot]++;
+ lncntp[inp->i_parent]--;
inp->i_dotdot = inp->i_parent;
(void)changeino(inp->i_number, "..", inp->i_parent);
}
@@ -229,7 +228,7 @@ pass2check(idesc)
* If converting, set directory entry type.
*/
if (doinglevel2 && dirp->d_ino > 0 && dirp->d_ino < maxino) {
- dirp->d_type = inoinfo(dirp->d_ino)->ino_type;
+ dirp->d_type = typemap[dirp->d_ino];
ret |= ALTERED;
}
/*
@@ -285,7 +284,7 @@ pass2check(idesc)
proto.d_reclen = entrysize;
memmove(dirp, &proto, (size_t)entrysize);
idesc->id_entryno++;
- inoinfo(dirp->d_ino)->ino_linkcnt--;
+ lncntp[dirp->d_ino]--;
dirp = (struct direct *)((char *)(dirp) + entrysize);
memset(dirp, 0, (size_t)n);
dirp->d_reclen = n;
@@ -320,7 +319,7 @@ chk1:
proto.d_reclen = dirp->d_reclen - n;
dirp->d_reclen = n;
idesc->id_entryno++;
- inoinfo(dirp->d_ino)->ino_linkcnt--;
+ lncntp[dirp->d_ino]--;
dirp = (struct direct *)((char *)(dirp) + n);
memset(dirp, 0, (size_t)proto.d_reclen);
dirp->d_reclen = proto.d_reclen;
@@ -357,7 +356,7 @@ chk1:
}
idesc->id_entryno++;
if (dirp->d_ino != 0)
- inoinfo(dirp->d_ino)->ino_linkcnt--;
+ lncntp[dirp->d_ino]--;
return (ret|KEEPON);
chk2:
if (dirp->d_ino == 0)
@@ -395,7 +394,7 @@ chk2:
ret |= ALTERED;
} else {
again:
- switch (inoinfo(dirp->d_ino)->ino_state) {
+ switch (statemap[dirp->d_ino]) {
case USTATE:
if (idesc->id_entryno <= 2)
break;
@@ -407,7 +406,7 @@ again:
case FCLEAR:
if (idesc->id_entryno <= 2)
break;
- if (inoinfo(dirp->d_ino)->ino_state == FCLEAR)
+ if (statemap[dirp->d_ino] == FCLEAR)
errmsg = "DUP/BAD";
else if (!preen && !usedsoftdep)
errmsg = "ZERO LENGTH DIRECTORY";
@@ -419,14 +418,14 @@ again:
if ((n = reply("REMOVE")) == 1)
break;
dp = ginode(dirp->d_ino);
- inoinfo(dirp->d_ino)->ino_state =
+ statemap[dirp->d_ino] =
(dp->di_mode & IFMT) == IFDIR ? DSTATE : FSTATE;
- inoinfo(dirp->d_ino)->ino_linkcnt = dp->di_nlink;
+ lncntp[dirp->d_ino] = dp->di_nlink;
goto again;
case DSTATE:
- if (inoinfo(idesc->id_number)->ino_state == DFOUND)
- inoinfo(dirp->d_ino)->ino_state = DFOUND;
+ if (statemap[idesc->id_number] == DFOUND)
+ statemap[dirp->d_ino] = DFOUND;
/* fall through */
case DFOUND:
@@ -440,10 +439,10 @@ again:
namebuf);
if (preen) {
printf(" (REMOVED)\n");
- n = 1;
- break;
+ n = 1;
+ break;
}
- if ((n = reply("REMOVE")) == 1)
+ else if ((n = reply("REMOVE")) == 1)
break;
}
if (idesc->id_entryno > 2)
@@ -451,20 +450,19 @@ again:
/* fall through */
case FSTATE:
- if (newinofmt &&
- dirp->d_type != inoinfo(dirp->d_ino)->ino_type) {
+ if (newinofmt && dirp->d_type != typemap[dirp->d_ino]) {
fileerror(idesc->id_number, dirp->d_ino,
"BAD TYPE VALUE");
- dirp->d_type = inoinfo(dirp->d_ino)->ino_type;
+ dirp->d_type = typemap[dirp->d_ino];
if (reply("FIX") == 1)
ret |= ALTERED;
}
- inoinfo(dirp->d_ino)->ino_linkcnt--;
+ lncntp[dirp->d_ino]--;
break;
default:
errx(EEXIT, "BAD STATE %d FOR INODE I=%d",
- inoinfo(dirp->d_ino)->ino_state, dirp->d_ino);
+ statemap[dirp->d_ino], dirp->d_ino);
}
}
if (n == 0)
diff --git a/sbin/fsck/pass3.c b/sbin/fsck/pass3.c
index f91f2c1df1eb7..6524a117e9a68 100644
--- a/sbin/fsck/pass3.c
+++ b/sbin/fsck/pass3.c
@@ -36,83 +36,41 @@
static const char sccsid[] = "@(#)pass3.c 8.2 (Berkeley) 4/27/95";
#endif
static const char rcsid[] =
- "$Id: pass3.c,v 1.4 1998/06/15 07:07:18 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include <sys/param.h>
#include <ufs/ufs/dinode.h>
-#include <ufs/ufs/dir.h>
-#include <ufs/ffs/fs.h>
-
-#include <string.h>
#include "fsck.h"
void
pass3()
{
- struct inoinfo *inp;
- int loopcnt, inpindex, state;
+ register struct inoinfo **inpp, *inp;
ino_t orphan;
- struct inodesc idesc;
- char namebuf[MAXNAMLEN+1];
+ int loopcnt;
- for (inpindex = inplast - 1; inpindex >= 0; inpindex--) {
- inp = inpsort[inpindex];
- state = inoinfo(inp->i_number)->ino_state;
+ for (inpp = &inpsort[inplast - 1]; inpp >= inpsort; inpp--) {
+ inp = *inpp;
if (inp->i_number == ROOTINO ||
- (inp->i_parent != 0 && state != DSTATE))
- continue;
- if (state == DCLEAR)
+ !(inp->i_parent == 0 || statemap[inp->i_number] == DSTATE))
continue;
- /*
- * If we are running with soft updates and we come
- * across unreferenced directories, we just leave
- * them in DSTATE which will cause them to be pitched
- * in pass 4.
- */
- if (preen && resolved && usedsoftdep && state == DSTATE) {
- if (inp->i_dotdot >= ROOTINO)
- inoinfo(inp->i_dotdot)->ino_linkcnt++;
+ if (statemap[inp->i_number] == DCLEAR)
continue;
- }
for (loopcnt = 0; ; loopcnt++) {
orphan = inp->i_number;
if (inp->i_parent == 0 ||
- inoinfo(inp->i_parent)->ino_state != DSTATE ||
- loopcnt > countdirs)
+ statemap[inp->i_parent] != DSTATE ||
+ loopcnt > numdirs)
break;
inp = getinoinfo(inp->i_parent);
}
- if (loopcnt <= countdirs) {
- if (linkup(orphan, inp->i_dotdot, NULL)) {
- inp->i_parent = inp->i_dotdot = lfdir;
- inoinfo(lfdir)->ino_linkcnt--;
- }
- inoinfo(orphan)->ino_state = DFOUND;
- propagate();
- continue;
- }
- pfatal("ORPHANED DIRECTORY LOOP DETECTED I=%lu", orphan);
- if (reply("RECONNECT") == 0)
- continue;
- memset(&idesc, 0, sizeof(struct inodesc));
- idesc.id_type = DATA;
- idesc.id_number = inp->i_parent;
- idesc.id_parent = orphan;
- idesc.id_func = findname;
- idesc.id_name = namebuf;
- if ((ckinode(ginode(inp->i_parent), &idesc) & FOUND) == 0)
- pfatal("COULD NOT FIND NAME IN PARENT DIRECTORY");
- if (linkup(orphan, inp->i_parent, namebuf)) {
- idesc.id_func = clearentry;
- if (ckinode(ginode(inp->i_parent), &idesc) & FOUND)
- inoinfo(orphan)->ino_linkcnt++;
- inp->i_parent = inp->i_dotdot = lfdir;
- inoinfo(lfdir)->ino_linkcnt--;
- }
- inoinfo(orphan)->ino_state = DFOUND;
+ (void)linkup(orphan, inp->i_dotdot);
+ inp->i_parent = inp->i_dotdot = lfdir;
+ lncntp[lfdir]--;
+ statemap[orphan] = DFOUND;
propagate();
}
}
diff --git a/sbin/fsck/pass4.c b/sbin/fsck/pass4.c
index 77b03ee0de81e..b2f1fe9ff00be 100644
--- a/sbin/fsck/pass4.c
+++ b/sbin/fsck/pass4.c
@@ -36,13 +36,12 @@
static const char sccsid[] = "@(#)pass4.c 8.4 (Berkeley) 4/28/95";
#endif
static const char rcsid[] =
- "$Id: pass4.c,v 1.4 1998/06/15 07:07:19 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include <sys/param.h>
#include <ufs/ufs/dinode.h>
-#include <ufs/ffs/fs.h>
#include <err.h>
#include <string.h>
@@ -56,27 +55,22 @@ pass4()
register struct zlncnt *zlnp;
struct dinode *dp;
struct inodesc idesc;
- int i, n, cg;
+ int n;
memset(&idesc, 0, sizeof(struct inodesc));
idesc.id_type = ADDR;
idesc.id_func = pass4check;
- for (cg = 0; cg < sblock.fs_ncg; cg++) {
- inumber = cg * sblock.fs_ipg;
- for (i = 0; i < inostathead[cg].il_numalloced; i++, inumber++) {
- if (inumber < ROOTINO)
- continue;
- idesc.id_number = inumber;
- switch (inoinfo(inumber)->ino_state) {
+ for (inumber = ROOTINO; inumber <= lastino; inumber++) {
+ idesc.id_number = inumber;
+ switch (statemap[inumber]) {
- case FSTATE:
- case DFOUND:
- n = inoinfo(inumber)->ino_linkcnt;
- if (n) {
- adjust(&idesc, (short)n);
- break;
- }
- for (zlnp = zlnhead; zlnp; zlnp = zlnp->next) {
+ case FSTATE:
+ case DFOUND:
+ n = lncntp[inumber];
+ if (n)
+ adjust(&idesc, (short)n);
+ else {
+ for (zlnp = zlnhead; zlnp; zlnp = zlnp->next)
if (zlnp->zlncnt == inumber) {
zlnp->zlncnt = zlnhead->zlncnt;
zlnp = zlnhead;
@@ -85,31 +79,30 @@ pass4()
clri(&idesc, "UNREF", 1);
break;
}
- }
- break;
+ }
+ break;
- case DSTATE:
- clri(&idesc, "UNREF", 1);
- break;
+ case DSTATE:
+ clri(&idesc, "UNREF", 1);
+ break;
- case DCLEAR:
- dp = ginode(inumber);
- if (dp->di_size == 0) {
- clri(&idesc, "ZERO LENGTH", 1);
- break;
- }
- /* fall through */
- case FCLEAR:
- clri(&idesc, "BAD/DUP", 1);
+ case DCLEAR:
+ dp = ginode(inumber);
+ if (dp->di_size == 0) {
+ clri(&idesc, "ZERO LENGTH", 1);
break;
+ }
+ /* fall through */
+ case FCLEAR:
+ clri(&idesc, "BAD/DUP", 1);
+ break;
- case USTATE:
- break;
+ case USTATE:
+ break;
- default:
- errx(EEXIT, "BAD STATE %d FOR INODE I=%d",
- inoinfo(inumber)->ino_state, inumber);
- }
+ default:
+ errx(EEXIT, "BAD STATE %d FOR INODE I=%d",
+ statemap[inumber], inumber);
}
}
}
diff --git a/sbin/fsck/pass5.c b/sbin/fsck/pass5.c
index d546e3fe3149b..f3994f84e2f85 100644
--- a/sbin/fsck/pass5.c
+++ b/sbin/fsck/pass5.c
@@ -36,7 +36,7 @@
static const char sccsid[] = "@(#)pass5.c 8.9 (Berkeley) 4/28/95";
#endif
static const char rcsid[] =
- "$Id: pass5.c,v 1.14 1998/08/15 10:07:33 dfr Exp $";
+ "$Id: pass5.c,v 1.13 1998/08/04 09:19:03 phk Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -52,7 +52,7 @@ static const char rcsid[] =
void
pass5()
{
- int c, blk, frags, basesize, sumsize, mapsize, savednrpos = 0;
+ int c, blk, frags, basesize, sumsize, mapsize, savednrpos;
int inomapsize, blkmapsize;
struct fs *fs = &sblock;
struct cg *cg = &cgrp;
@@ -66,7 +66,7 @@ pass5()
register struct cg *newcg = (struct cg *)buf;
struct ocg *ocg = (struct ocg *)buf;
- inoinfo(WINO)->ino_state = USTATE;
+ statemap[WINO] = USTATE;
memset(newcg, 0, (size_t)fs->fs_cgsize);
newcg->cg_niblk = fs->fs_ipg;
if (cvtlevel >= 3) {
@@ -207,8 +207,8 @@ pass5()
if (fs->fs_postblformat == FS_42POSTBLFMT)
ocg->cg_magic = CG_MAGIC;
j = fs->fs_ipg * c;
- for (i = 0; i < inostathead[c].il_numalloced; j++, i++) {
- switch (inoinfo(j)->ino_state) {
+ for (i = 0; i < fs->fs_ipg; j++, i++) {
+ switch (statemap[j]) {
case USTATE:
break;
@@ -229,7 +229,7 @@ pass5()
if (j < ROOTINO)
break;
errx(EEXIT, "BAD STATE %d FOR INODE I=%ld",
- inoinfo(j)->ino_state, j);
+ statemap[j], j);
}
}
if (c == 0)
@@ -325,7 +325,7 @@ pass5()
if (cg_inosused(cg)[i] & (1 << k))
continue;
pwarn("ALLOCATED INODE %d MARKED FREE\n",
- c * fs->fs_ipg + i * NBBY + k);
+ c * fs->fs_ipg + i * 8 + k);
}
}
for (i = 0; i < blkmapsize; i++) {
@@ -338,7 +338,7 @@ pass5()
if (cg_blksfree(newcg)[i] & (1 << k))
continue;
pwarn("ALLOCATED FRAG %d MARKED FREE\n",
- c * fs->fs_fpg + i * NBBY + k);
+ c * fs->fs_fpg + i * 8 + k);
}
}
}
@@ -355,7 +355,24 @@ pass5()
&& dofix(&idesc[0], "FREE BLK COUNT(S) WRONG IN SUPERBLK")) {
memmove(&fs->fs_cstotal, &cstotal, sizeof *cs);
fs->fs_ronly = 0;
- fs->fs_fmod = 0;
sbdirty();
}
+ if (fs->fs_fmod != 0) {
+ pwarn("MODIFIED FLAG SET IN SUPERBLOCK");
+ if (preen)
+ printf(" (FIXED)\n");
+ if (preen || reply("FIX") == 1) {
+ fs->fs_fmod = 0;
+ sbdirty();
+ }
+ }
+ if (fs->fs_clean == 0) {
+ pwarn("CLEAN FLAG NOT SET IN SUPERBLOCK");
+ if (preen)
+ printf(" (FIXED)\n");
+ if (preen || reply("FIX") == 1) {
+ fs->fs_clean = 1;
+ sbdirty();
+ }
+ }
}
diff --git a/sbin/fsck/preen.c b/sbin/fsck/preen.c
index cc8bba6e1e66d..9705aeea92807 100644
--- a/sbin/fsck/preen.c
+++ b/sbin/fsck/preen.c
@@ -36,7 +36,7 @@
static const char sccsid[] = "@(#)preen.c 8.5 (Berkeley) 4/28/95";
#endif
static const char rcsid[] =
- "$Id: preen.c,v 1.9 1998/06/15 07:07:20 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include <sys/param.h>
@@ -46,7 +46,7 @@ static const char rcsid[] =
#include <ufs/ufs/dinode.h>
#include <ctype.h>
-#include <errno.h>
+#include <err.h>
#include <fstab.h>
#include <string.h>
@@ -93,8 +93,7 @@ checkfstab(preen, maxrun, docheck, chkit)
sumstatus = 0;
for (passno = 1; passno <= 2; passno++) {
if (setfsent() == 0) {
- fprintf(stderr, "Can't open checklist file: %s\n",
- _PATH_FSTAB);
+ warnx("can't open checklist file: %s", _PATH_FSTAB);
return (8);
}
while ((fsp = getfsent()) != 0) {
@@ -223,15 +222,11 @@ finddisk(name)
dk->name[len] == 0)
return (dk);
}
- if ((*dkp = (struct disk *)malloc(sizeof(struct disk))) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
+ if ((*dkp = (struct disk *)malloc(sizeof(struct disk))) == NULL)
+ errx(8, "out of memory");
dk = *dkp;
- if ((dk->name = malloc(len + 1)) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
+ if ((dk->name = malloc(len + 1)) == NULL)
+ errx(8, "out of memory");
(void)strncpy(dk->name, name, len);
dk->name[len] = '\0';
dk->part = NULL;
@@ -254,20 +249,14 @@ addpart(name, fsname, auxdata)
printf("%s in fstab more than once!\n", name);
return;
}
- if ((*ppt = (struct part *)malloc(sizeof(struct part))) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
+ if ((*ppt = (struct part *)malloc(sizeof(struct part))) == NULL)
+ errx(8, "out of memory");
pt = *ppt;
- if ((pt->name = malloc(strlen(name) + 1)) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
+ if ((pt->name = malloc(strlen(name) + 1)) == NULL)
+ errx(8, "out of memory");
(void)strcpy(pt->name, name);
- if ((pt->fsname = malloc(strlen(fsname) + 1)) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
+ if ((pt->fsname = malloc(strlen(fsname) + 1)) == NULL)
+ errx(8, "out of memory");
(void)strcpy(pt->fsname, fsname);
pt->next = NULL;
pt->auxdata = auxdata;
@@ -282,7 +271,7 @@ startdisk(dk, checkit)
dk->pid = fork();
if (dk->pid < 0) {
- perror("fork");
+ warn("fork");
return (8);
}
if (dk->pid == 0)
@@ -298,17 +287,19 @@ blockcheck(origname)
struct stat stslash, stblock, stchar;
char *newname, *raw;
struct fstab *fsinfo;
- int retried = 0, len;
+ int retried = 0, l;
hotroot = 0;
if (stat("/", &stslash) < 0) {
- printf("Can't stat /: %s\n", strerror(errno));
+ warn("/");
+ printf("Can't stat root\n");
return (origname);
}
newname = origname;
retry:
if (stat(newname, &stblock) < 0) {
- printf("Can't stat %s: %s\n", newname, strerror(errno));
+ warn("%s", newname);
+ printf("Can't stat %s\n", newname);
return (origname);
}
if ((stblock.st_mode & S_IFMT) == S_IFBLK) {
@@ -316,7 +307,8 @@ retry:
hotroot++;
raw = rawname(newname);
if (stat(raw, &stchar) < 0) {
- printf("Can't stat %s: %s\n", raw, strerror(errno));
+ warn("%s", raw);
+ printf("Can't stat %s\n", raw);
return (origname);
}
if ((stchar.st_mode & S_IFMT) == S_IFCHR) {
@@ -326,15 +318,15 @@ retry:
return (origname);
}
} else if ((stblock.st_mode & S_IFMT) == S_IFCHR && !retried) {
- newname = unrawname(newname);
+ newname = unrawname(origname);
retried++;
goto retry;
} else if ((stblock.st_mode & S_IFMT) == S_IFDIR && !retried) {
- len = strlen(origname) - 1;
- if (len > 0 && origname[len] == '/')
+ l = strlen(origname) - 1;
+ if (l > 0 && origname[l] == '/')
/* remove trailing slash */
- origname[len] = '\0';
- if ((fsinfo = getfsfile(origname)) == NULL) {
+ origname[l] = '\0';
+ if(!(fsinfo=getfsfile(origname))) {
printf("Can't resolve %s to character special device",
origname);
return (0);
diff --git a/sbin/fsck/setup.c b/sbin/fsck/setup.c
index 88a7b6b1e3407..25dab92ad56d0 100644
--- a/sbin/fsck/setup.c
+++ b/sbin/fsck/setup.c
@@ -36,7 +36,7 @@
static const char sccsid[] = "@(#)setup.c 8.10 (Berkeley) 5/9/95";
#endif
static const char rcsid[] =
- "$Id: setup.c,v 1.12 1998/06/28 19:23:03 bde Exp $";
+ "$Id: setup.c,v 1.11 1998/06/15 07:07:21 charnier Exp $";
#endif /* not lint */
#define DKTYPENAMES
@@ -82,7 +82,7 @@ setup(dev)
havesb = 0;
fswritefd = -1;
- skipclean = fflag ? 0 : preen;
+ skipclean = preen;
if (stat(dev, &statb) < 0) {
printf("Can't stat %s: %s\n", dev, strerror(errno));
return (0);
@@ -114,7 +114,8 @@ setup(dev)
asblk.b_un.b_buf = malloc(SBSIZE);
if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL)
errx(EEXIT, "cannot allocate space for superblock");
- if ((lp = getdisklabel(NULL, fsreadfd)))
+ lp = getdisklabel((char *)NULL, fsreadfd);
+ if (lp)
dev_bsize = secsize = lp->d_secsize;
else
dev_bsize = secsize = DEV_BSIZE;
@@ -146,10 +147,6 @@ setup(dev)
pwarn("USING ALTERNATE SUPERBLOCK AT %d\n", bflag);
bflag = 0;
}
- if (skipclean && sblock.fs_clean) {
- pwarn("FILESYSTEM CLEAN; SKIPPING CHECKS\n");
- return (-1);
- }
maxfsblock = sblock.fs_size;
maxino = sblock.fs_ncg * sblock.fs_ipg;
/*
@@ -268,6 +265,12 @@ setup(dev)
}
}
/*
+ * If we survive the above basic checks and are preening,
+ * quit here unless forced.
+ */
+ if (skipclean && sblock.fs_clean && !fflag)
+ return (-1);
+ /*
* allocate and initialize the necessary maps
*/
bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(short));
@@ -277,11 +280,22 @@ setup(dev)
(unsigned)bmapsize);
goto badsb;
}
- inostathead = calloc((unsigned)(sblock.fs_ncg),
- sizeof(struct inostatlist));
- if (inostathead == NULL) {
- printf("cannot alloc %u bytes for inostathead\n",
- (unsigned)(sizeof(struct inostatlist) * (sblock.fs_ncg)));
+ statemap = calloc((unsigned)(maxino + 1), sizeof(char));
+ if (statemap == NULL) {
+ printf("cannot alloc %u bytes for statemap\n",
+ (unsigned)(maxino + 1));
+ goto badsb;
+ }
+ typemap = calloc((unsigned)(maxino + 1), sizeof(char));
+ if (typemap == NULL) {
+ printf("cannot alloc %u bytes for typemap\n",
+ (unsigned)(maxino + 1));
+ goto badsb;
+ }
+ lncntp = (short *)calloc((unsigned)(maxino + 1), sizeof(short));
+ if (lncntp == NULL) {
+ printf("cannot alloc %u bytes for lncntp\n",
+ (unsigned)(maxino + 1) * sizeof(short));
goto badsb;
}
numdirs = sblock.fs_cstotal.cs_ndir;
@@ -460,11 +474,9 @@ calcsb(dev, devfd, fs)
fstypenames[pp->p_fstype] : "unknown");
return (0);
}
- if (pp->p_fsize == 0 || pp->p_frag == 0 ||
- pp->p_cpg == 0 || pp->p_size == 0) {
- pfatal("%s: %s: type %s fsize %d, frag %d, cpg %d, size %d\n",
- dev, "INCOMPLETE LABEL", fstypenames[pp->p_fstype],
- pp->p_fsize, pp->p_frag, pp->p_cpg, pp->p_size);
+ if (pp->p_fsize == 0 || pp->p_frag == 0) {
+ pfatal("%s: LABELED AS A %s FILE SYSTEM, BUT BLOCK SIZE IS 0\n",
+ dev, fstypenames[pp->p_fstype]);
return (0);
}
memset(fs, 0, sizeof(struct fs));
diff --git a/sbin/fsck/utilities.c b/sbin/fsck/utilities.c
index b072964e8bf27..0d82d6ebbcf6b 100644
--- a/sbin/fsck/utilities.c
+++ b/sbin/fsck/utilities.c
@@ -36,7 +36,7 @@
static const char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95";
#endif
static const char rcsid[] =
- "$Id: utilities.c,v 1.8 1998/06/15 07:07:21 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include <sys/param.h>
@@ -45,6 +45,7 @@ static const char rcsid[] =
#include <ufs/ufs/dir.h>
#include <ufs/ffs/fs.h>
+#include <ctype.h>
#include <err.h>
#include <string.h>
@@ -115,26 +116,6 @@ reply(question)
}
/*
- * Look up state information for an inode.
- */
-struct inostat *
-inoinfo(inum)
- ino_t inum;
-{
- static struct inostat unallocated = { USTATE, 0, 0 };
- struct inostatlist *ilp;
- int iloff;
-
- if (inum > maxino)
- errx(EEXIT, "inoinfo: inumber %d out of range", inum);
- ilp = &inostathead[inum / sblock.fs_ipg];
- iloff = inum % sblock.fs_ipg;
- if (iloff >= ilp->il_numalloced)
- return (&unallocated);
- return (&ilp->il_stat[iloff]);
-}
-
-/*
* Malloc buffers and set up cache.
*/
void
@@ -291,21 +272,14 @@ ckfini(markclean)
if (bufhead.b_size != cnt)
errx(EEXIT, "panic: lost %d buffers", bufhead.b_size - cnt);
pbp = pdirbp = (struct bufarea *)0;
- if (sblock.fs_clean != markclean) {
- sblock.fs_clean = markclean;
+ if (markclean && sblock.fs_clean == 0) {
+ sblock.fs_clean = 1;
sbdirty();
ofsmodified = fsmodified;
flush(fswritefd, &sblk);
fsmodified = ofsmodified;
- if (!preen) {
- printf("\n***** FILE SYSTEM MARKED %s *****\n",
- markclean ? "CLEAN" : "DIRTY");
- if (!markclean)
- rerun = 1;
- }
- } else if (!preen && !markclean) {
- printf("\n***** FILE SYSTEM STILL DIRTY *****\n");
- rerun = 1;
+ if (!preen)
+ printf("\n***** FILE SYSTEM MARKED CLEAN *****\n");
}
if (debug)
printf("cache missed %ld of %ld (%d%%)\n", diskreads,
@@ -350,8 +324,6 @@ bread(fd, buf, blk, size)
}
}
printf("\n");
- if (errs)
- resolved = 0;
return (errs);
}
@@ -376,7 +348,6 @@ bwrite(fd, buf, blk, size)
fsmodified = 1;
return;
}
- resolved = 0;
rwerror("WRITE", blk);
if (lseek(fd, offset, 0) < 0)
rwerror("SEEK", blk);
@@ -467,8 +438,7 @@ getpathname(namebuf, curdir, ino)
return;
}
if (busy ||
- (inoinfo(curdir)->ino_state != DSTATE &&
- inoinfo(curdir)->ino_state != DFOUND)) {
+ (statemap[curdir] != DSTATE && statemap[curdir] != DFOUND)) {
(void)strcpy(namebuf, "?");
return;
}
@@ -619,16 +589,14 @@ pfatal(fmt, va_alist)
va_end(ap);
if (usedsoftdep)
(void)fprintf(stderr,
- "\nUNEXPECTED SOFT UPDATE INCONSISTENCY\n");
+ "\nUNEXPECTED SOFTDEP INCONSISTENCY\n");
return;
}
- if (cdevname == NULL)
- cdevname = "fsck";
(void)fprintf(stderr, "%s: ", cdevname);
(void)vfprintf(stderr, fmt, ap);
(void)fprintf(stderr,
"\n%s: UNEXPECTED%sINCONSISTENCY; RUN fsck MANUALLY.\n",
- cdevname, usedsoftdep ? " SOFT UPDATE " : " ");
+ cdevname, usedsoftdep ? " SOFTDEP " : " ");
ckfini(0);
exit(EEXIT);
}
diff --git a/sbin/fsdb/fsdb.c b/sbin/fsdb/fsdb.c
index 423a160bf424f..86a02cf25cad3 100644
--- a/sbin/fsdb/fsdb.c
+++ b/sbin/fsdb/fsdb.c
@@ -30,7 +30,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: fsdb.c,v 1.10 1998/06/15 07:12:19 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include <sys/types.h>
@@ -617,7 +617,7 @@ CMDFUNCSTART(newtype)
return 1;
type = curinode->di_mode & IFMT;
for (tp = typenamemap;
- tp < &typenamemap[sizeof(typenamemap)/sizeof(*typenamemap)];
+ tp < &typenamemap[sizeof(typemap)/sizeof(*typemap)];
tp++) {
if (!strcmp(argv[1], tp->typename)) {
printf("setting type to %s\n", tp->typename);
@@ -625,7 +625,7 @@ CMDFUNCSTART(newtype)
break;
}
}
- if (tp == &typenamemap[sizeof(typenamemap)/sizeof(*typenamemap)]) {
+ if (tp == &typenamemap[sizeof(typemap)/sizeof(*typemap)]) {
warnx("type `%s' not known", argv[1]);
warnx("try one of `file', `dir', `socket', `fifo'");
return 1;
diff --git a/sbin/i386/fdisk/fdisk.8 b/sbin/i386/fdisk/fdisk.8
index e4ce0a54720f3..2248b6a0c2a98 100644
--- a/sbin/i386/fdisk/fdisk.8
+++ b/sbin/i386/fdisk/fdisk.8
@@ -110,12 +110,12 @@ prints out the partition table that is written to the disk.
The final disk name can be provided as a
.Sq bare
disk name only, e.g.
-.Ql da0 ,
+.Ql sd0 ,
or as a fully qualified device node under
.Pa /dev .
If omitted, the disks
.Ql wd0 ,
-.Ql da0 ,
+.Ql sd0 ,
and
.Ql od0
are being searched in that order, until one is
diff --git a/sbin/i386/fdisk/fdisk.c b/sbin/i386/fdisk/fdisk.c
index 219a8b3dcff0d..ef274e118d309 100644
--- a/sbin/i386/fdisk/fdisk.c
+++ b/sbin/i386/fdisk/fdisk.c
@@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: fdisk.c,v 1.26 1998/11/06 03:43:21 alex Exp $";
+ "$Id: fdisk.c,v 1.23 1998/07/06 06:44:36 charnier Exp $";
#endif /* not lint */
#include <sys/disklabel.h>
@@ -67,7 +67,7 @@ int secsize = 0; /* the sensed sector size */
const char *disk;
const char *disks[] =
{
- "/dev/rwd0", "/dev/rda0", "/dev/rod0", 0
+ "/dev/rwd0", "/dev/rsd0", "/dev/rod0", 0
};
struct disklabel disklabel; /* disk parameters */
@@ -196,11 +196,9 @@ struct part_type
,{0x83, "Linux filesystem"}
,{0x93, "Amoeba filesystem"}
,{0x94, "Amoeba bad block table"}
- ,{0x9F, "BSD/OS"}
,{0xA5, "FreeBSD/NetBSD/386BSD"}
,{0xA6, "OpenBSD"}
,{0xA7, "NEXTSTEP"}
- ,{0xA9, "NetBSD"}
,{0xB7, "BSDI BSD/386 filesystem"}
,{0xB8, "BSDI BSD/386 swap"}
,{0xDB, "Concurrent CPM or C.DOS or CTOS"}
diff --git a/sbin/i386/mount_msdos/mount_msdos.8 b/sbin/i386/mount_msdos/mount_msdos.8
index 2088285cc68c5..46ca78bcff4c5 100644
--- a/sbin/i386/mount_msdos/mount_msdos.8
+++ b/sbin/i386/mount_msdos/mount_msdos.8
@@ -28,7 +28,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $Id: mount_msdos.8,v 1.14 1998/06/30 06:23:41 charnier Exp $
+.\" $Id: mount_msdos.8,v 1.13 1998/03/01 08:41:05 ache Exp $
.\"
.Dd April 7, 1994
.Dt MOUNT_MSDOS 8
@@ -119,7 +119,7 @@ are given,
.Nm
searches the root directory of the filesystem to
be mounted for any existing Win'95 long filenames.
-If no such entries are found, but short DOS filenames are found,
+If no such entries are found,
.Fl s
is the default. Otherwise
.Fl l
@@ -190,6 +190,15 @@ mounted file system.
Cluster sizes larger than 16K are unavoidable for file system sizes
larger than 1G, and also occur when filesystems larger than 1G are
shrunk to smaller than 1G using FIPS.
+.Pp
+The default handling for
+.Fl s
+and
+.Fl l
+will result in empty filesystems to be populated
+with short filenames only. To generate long filenames
+on empty DOS filesystems use
+.Fl l .
.Sh HISTORY
The
.Nm
diff --git a/sbin/init/init.8 b/sbin/init/init.8
index 38d46ac3d72de..7ce1cee83b4a6 100644
--- a/sbin/init/init.8
+++ b/sbin/init/init.8
@@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)init.8 8.3 (Berkeley) 4/18/94
-.\" $Id: init.8,v 1.12 1998/07/06 06:56:07 charnier Exp $
+.\" $Id: init.8,v 1.11 1998/06/19 08:34:52 jkoshy Exp $
.\"
.Dd April 18, 1994
.Dt INIT 8
@@ -113,13 +113,6 @@ This level precludes tampering with filesystems by unmounting them,
but also inhibits running
.Xr newfs 8
while the system is multi-user.
-.It Ic 3
-Network secure mode \- same as highly secure mode, plus
-IP packet filter rules (see
-.Xr ipfw 8
-and
-.Xr ipfirewall 4 )
-can not be changed and dummynet configuration can not be adjusted.
.El
.Pp
If the security level is initially -1, then
@@ -307,12 +300,10 @@ system shutdown commands
.Xr kill 1 ,
.Xr login 1 ,
.Xr sh 1 ,
-.Xr ipfirewall 4 ,
.Xr ttys 5 ,
.Xr crash 8 ,
.Xr getty 8 ,
.Xr halt 8 ,
-.Xr ipfw 8 ,
.Xr rc 8 ,
.Xr reboot 8 ,
.Xr shutdown 8 ,
@@ -327,7 +318,7 @@ Systems without
.Xr sysctl
behave as though they have security level \-1.
.Pp
-Setting the security level above 1 too early in the boot sequence can
+Setting the security level to 2 too early in the boot sequence can
prevent
.Xr fsck 8
from repairing inconsistent filesystems. The
diff --git a/sbin/ipfw/ipfw.8 b/sbin/ipfw/ipfw.8
index 40fb58277062a..bd70c5822db8f 100644
--- a/sbin/ipfw/ipfw.8
+++ b/sbin/ipfw/ipfw.8
@@ -6,11 +6,8 @@
.Nd controlling utility for IP firewall
.Sh SYNOPSIS
.Nm ipfw
-.Op Fl q
.Oo
-.Fl p Ar preproc
-.Op Fl D Ar macro Ns Op Ns =value
-.Op Fl U Ar macro
+.Fl q
.Oc
file
.Nm ipfw
@@ -61,32 +58,6 @@ will be read line by line and applied as arguments to the
.Nm
command.
.Pp
-Optionally, a preprocessor can be specified using
-.Fl p Ar preproc
-where
-.Ar file
-is to be piped through. Useful preprocessors include
-.Xr cpp 1
-and
-.Xr m4 1 .
-If
-.Ar preproc
-doesn't start with a slash as its first character, the usual
-.Ev PATH
-name search is performed. Care should be taken with this in environments
-where not all filesystems are mounted (yet) by the time
-.Nm
-is being run (e. g. since they are mounted over NFS). Once
-.Fl p
-has been specified, optional
-.Fl D
-and
-.Fl U
-specifcations can follow and will be passed on to the preprocessor.
-This allows for flexible configuration files (like conditionalizing
-them on the local hostname) and the use of macros to centralize
-frequently required arguments like IP addresses.
-.Pp
The
.Nm
code works by going through the rule-list for each packet,
@@ -511,11 +482,6 @@ ipfw flush
.Ed
.Pp
in similar surroundings is also a bad idea.
-.Pp
-The IP filter list may not be modified if the system security level
-is set to 3 or higher (see
-.Xr init 8
-for information on system security levels).
.Sh PACKET DIVERSION
A divert socket bound to the specified port will receive all packets diverted
to that port; see
@@ -549,14 +515,11 @@ This rule diverts all incoming packets from 192.168.2.0/24 to divert port 5000:
.Pp
.Dl ipfw divert 5000 all from 192.168.2.0/24 to any in
.Sh SEE ALSO
-.Xr cpp 1 ,
-.Xr m4 1 ,
.Xr divert 4 ,
.Xr ip 4 ,
.Xr ipfirewall 4 ,
.Xr protocols 5 ,
.Xr services 5 ,
-.Xr init 8 ,
.Xr reboot 8 ,
.Xr sysctl 8 ,
.Xr syslogd 8
@@ -580,8 +543,6 @@ are reassembled before delivery to the socket, whereas fragments diverted via
are not.
.Pp
Port aliases containing dashes cannot be first in a list.
-.Pp
-The ``tee'' action is unimplemented.
.Sh AUTHORS
.An Ugen J. S. Antsilevich ,
.An Poul-Henning Kamp ,
diff --git a/sbin/ipfw/ipfw.c b/sbin/ipfw/ipfw.c
index 22e794d6a81ab..3f6807b11dc05 100644
--- a/sbin/ipfw/ipfw.c
+++ b/sbin/ipfw/ipfw.c
@@ -16,7 +16,7 @@
*
* NEW command line interface for IP firewall facility
*
- * $Id: ipfw.c,v 1.63 1998/12/14 18:43:03 luigi Exp $
+ * $Id: ipfw.c,v 1.59 1998/08/04 14:41:37 thepish Exp $
*
*/
@@ -25,21 +25,18 @@
#include <sys/socket.h>
#include <sys/sockio.h>
#include <sys/time.h>
-#include <sys/wait.h>
#include <ctype.h>
#include <err.h>
-#include <errno.h>
#include <limits.h>
#include <netdb.h>
-#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
-#include <sysexits.h>
#include <time.h>
#include <unistd.h>
+#include <sysexits.h>
#include <net/if.h>
#include <netinet/in.h>
@@ -48,22 +45,17 @@
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/ip_fw.h>
-#include <net/route.h> /* def. of struct route */
-#include <sys/param.h>
-#include <sys/mbuf.h>
-#include <netinet/ip_dummynet.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
int lineno = -1;
int s; /* main RAW socket */
-int do_resolv=0; /* Would try to resolve all */
+int do_resolv=0; /* Would try to resolv all */
int do_acct=0; /* Show packet/byte count */
int do_time=0; /* Show time stamps */
int do_quiet=0; /* Be quiet in add and flush */
int do_force=0; /* Don't ask for confirmation */
-int do_pipe=0; /* this cmd refers to a pipe */
struct icmpcode {
int code;
@@ -224,9 +216,6 @@ show_ipfw(struct ip_fw *chain, int pcwidth, int bcwidth)
case IP_FW_F_SKIPTO:
printf("skipto %u", chain->fw_skipto_rule);
break;
- case IP_FW_F_PIPE:
- printf("pipe %u", chain->fw_skipto_rule);
- break ;
case IP_FW_F_REJECT:
if (chain->fw_reject_code == IP_FW_REJECT_RST)
printf("reset");
@@ -422,64 +411,12 @@ list(ac, av)
{
struct ip_fw *r;
struct ip_fw rules[1024];
- struct dn_pipe *p;
- struct dn_pipe pipes[1024];
int l,i,bytes;
unsigned long rulenum;
int pcwidth = 0;
int bcwidth = 0;
/* extract rules from kernel */
- if (do_pipe) {
- memset(rules,0,sizeof pipes);
- bytes = sizeof pipes;
- i = getsockopt(s, IPPROTO_IP, IP_DUMMYNET_GET, pipes, &bytes);
- if (i < 0)
- err(2,"getsockopt(IP_DUMMYNET_GET)");
- /* display requested pipes */
- if (ac > 0)
- rulenum = strtoul(*av++, NULL, 10);
- else
- rulenum = 0 ;
- for (p = pipes, l = bytes; l >= sizeof pipes[0];
- p++, l-=sizeof pipes[0]) {
- if (rulenum == 0 || rulenum == p->pipe_nr) {
- double b = p->bandwidth ;
- int l ;
- char buf[30] ;
- char qs[30] ;
- char plr[30] ;
-
- if (b == 0)
- sprintf(buf, "unlimited");
- else if (b >= 1000000)
- sprintf(buf, "%7.3f Mbit/s", b/1000000 );
- else if (b >= 1000)
- sprintf(buf, "%7.3f Kbit/s", b/1000 );
- else
- sprintf(buf, "%7.3f bit/s ", b );
-
- if ( (l = p->queue_size_bytes) ) {
- if (l >= 8192)
- sprintf(qs,"%d KB", l / 1024);
- else
- sprintf(qs,"%d B", l);
- } else
- sprintf(qs,"%3d sl.", p->queue_size);
- if (p->plr)
- sprintf(plr,"plr %f", 1.0*p->plr/(double)(0x7fffffff));
- else
- plr[0]='\0';
-
- printf("%05d: %s %4d ms %s %s -- %d pkts (%d B) %d drops\n",
- p->pipe_nr, buf, p->delay, qs, plr,
- p->r_len, p->r_len_bytes, p->r_drops);
- }
- }
-
- return ;
- }
-
memset(rules,0,sizeof rules);
bytes = sizeof rules;
i = getsockopt(s, IPPROTO_IP, IP_FW_GET, rules, &bytes);
@@ -841,26 +778,15 @@ delete(ac,av)
char **av;
{
struct ip_fw rule;
- struct dn_pipe pipe;
int i;
int exitval = EX_OK;
memset(&rule, 0, sizeof rule);
- memset(&pipe, 0, sizeof pipe);
av++; ac--;
/* Rule number */
while (ac && isdigit(**av)) {
- if (do_pipe) {
- pipe.pipe_nr = atoi(*av); av++; ac--;
- i = setsockopt(s, IPPROTO_IP, IP_DUMMYNET_DEL,
- &pipe, sizeof pipe);
- if (i) {
- exitval = 1;
- warn("rule %u: setsockopt(%s)", pipe.pipe_nr, "IP_DUMMYNET_DEL");
- }
- } else {
rule.fw_number = atoi(*av); av++; ac--;
i = setsockopt(s, IPPROTO_IP, IP_FW_DEL, &rule, sizeof rule);
if (i) {
@@ -868,7 +794,6 @@ delete(ac,av)
warn("rule %u: setsockopt(%s)", rule.fw_number, "IP_FW_DEL");
}
}
- }
if (exitval != EX_OK)
exit(exitval);
}
@@ -919,69 +844,6 @@ fill_iface(char *which, union ip_fw_if *ifu, int *byname, int ac, char *arg)
}
static void
-config_pipe(int ac, char **av)
-{
- struct dn_pipe pipe;
- int i ;
- char *end ;
-
- memset(&pipe, 0, sizeof pipe);
-
- av++; ac--;
- /* Pipe number */
- if (ac && isdigit(**av)) {
- pipe.pipe_nr = atoi(*av); av++; ac--;
- }
- while (ac > 1) {
- if (!strncmp(*av,"bw",strlen(*av)) ||
- ! strncmp(*av,"bandwidth",strlen(*av))) {
- pipe.bandwidth = strtoul(av[1], &end, 0);
- if (*end == 'K')
- end++, pipe.bandwidth *= 1000 ;
- else if (*end == 'M')
- end++, pipe.bandwidth *= 1000000 ;
- if (*end == 'B')
- pipe.bandwidth *= 8 ;
- av+=2; ac-=2;
- } else if (!strncmp(*av,"delay",strlen(*av)) ) {
- pipe.delay = strtoul(av[1], NULL, 0);
- av+=2; ac-=2;
- } else if (!strncmp(*av,"plr",strlen(*av)) ) {
-
- double d = strtod(av[1], NULL);
- pipe.plr = (int)(d*0x7fffffff) ;
- av+=2; ac-=2;
- } else if (!strncmp(*av,"queue",strlen(*av)) ) {
- end = NULL ;
- pipe.queue_size = strtoul(av[1], &end, 0);
- if (*end == 'K') {
- pipe.queue_size_bytes = pipe.queue_size*1024 ;
- pipe.queue_size = 0 ;
- } else if (*end == 'B') {
- pipe.queue_size_bytes = pipe.queue_size ;
- pipe.queue_size = 0 ;
- }
- av+=2; ac-=2;
- } else
- show_usage("unrecognised option ``%s''", *av);
- }
- if (pipe.pipe_nr == 0 )
- show_usage("pipe_nr %d be > 0", pipe.pipe_nr);
- if (pipe.queue_size > 100 )
- show_usage("queue size %d must be 2 <= x <= 100", pipe.queue_size);
- if (pipe.delay > 10000 )
- show_usage("delay %d must be < 10000", pipe.delay);
-#if 0
- printf("configuring pipe %d bw %d delay %d size %d\n",
- pipe.pipe_nr, pipe.bandwidth, pipe.delay, pipe.queue_size);
-#endif
- i = setsockopt(s,IPPROTO_IP, IP_DUMMYNET_CONFIGURE, &pipe,sizeof pipe);
- if (i)
- err(1, "setsockopt(%s)", "IP_DUMMYNET_CONFIGURE");
-
-}
-
-static void
add(ac,av)
int ac;
char **av;
@@ -1011,15 +873,10 @@ add(ac,av)
rule.fw_flg |= IP_FW_F_ACCEPT; av++; ac--;
} else if (!strncmp(*av,"count",strlen(*av))) {
rule.fw_flg |= IP_FW_F_COUNT; av++; ac--;
- } else if (!strncmp(*av,"pipe",strlen(*av))) {
- rule.fw_flg |= IP_FW_F_PIPE; av++; ac--;
- if (!ac)
- show_usage("missing pipe number");
- rule.fw_divert_port = strtoul(*av, NULL, 0); av++; ac--;
} else if (!strncmp(*av,"divert",strlen(*av))) {
rule.fw_flg |= IP_FW_F_DIVERT; av++; ac--;
if (!ac)
- show_usage("missing %s port", "divert");
+ show_usage("missing divert port");
rule.fw_divert_port = strtoul(*av, NULL, 0); av++; ac--;
if (rule.fw_divert_port == 0) {
struct servent *s;
@@ -1028,12 +885,12 @@ add(ac,av)
if (s != NULL)
rule.fw_divert_port = ntohs(s->s_port);
else
- show_usage("illegal %s port", "divert");
+ show_usage("illegal divert port");
}
} else if (!strncmp(*av,"tee",strlen(*av))) {
rule.fw_flg |= IP_FW_F_TEE; av++; ac--;
if (!ac)
- show_usage("missing %s port", "tee divert");
+ show_usage("missing divert port");
rule.fw_divert_port = strtoul(*av, NULL, 0); av++; ac--;
if (rule.fw_divert_port == 0) {
struct servent *s;
@@ -1042,11 +899,8 @@ add(ac,av)
if (s != NULL)
rule.fw_divert_port = ntohs(s->s_port);
else
- show_usage("illegal %s port", "tee divert");
+ show_usage("illegal divert port");
}
-#ifndef IPFW_TEE_IS_FINALLY_IMPLEMENTED
- err(EX_USAGE, "the ``tee'' action is not implemented");
-#endif
} else if (!strncmp(*av,"fwd",strlen(*av)) ||
!strncmp(*av,"forward",strlen(*av))) {
struct in_addr dummyip;
@@ -1345,7 +1199,7 @@ ipfw_main(ac,av)
{
int ch;
- extern int optreset; /* XXX should be declared in <unistd.h> */
+ extern int optind;
if ( ac == 1 ) {
show_usage(NULL);
@@ -1354,7 +1208,7 @@ ipfw_main(ac,av)
/* Set the force flag for non-interactive processes */
do_force = !isatty(STDIN_FILENO);
- optind = optreset = 1;
+ optind = 1;
while ((ch = getopt(ac, av, "afqtN")) != -1)
switch(ch) {
case 'a':
@@ -1381,24 +1235,8 @@ ipfw_main(ac,av)
show_usage("Bad arguments");
}
- if (!strncmp(*av, "pipe", strlen(*av))) {
- do_pipe = 1 ;
- ac-- ;
- av++ ;
- }
- if (!ac) {
- show_usage("pipe requires arguments");
- }
- /* allow argument swapping */
- if (ac > 1 && *av[0]>='0' && *av[0]<='9') {
- char *p = av[0] ;
- av[0] = av[1] ;
- av[1] = p ;
- }
if (!strncmp(*av, "add", strlen(*av))) {
add(ac,av);
- } else if (do_pipe && !strncmp(*av, "config", strlen(*av))) {
- config_pipe(ac,av);
} else if (!strncmp(*av, "delete", strlen(*av))) {
delete(ac,av);
} else if (!strncmp(*av, "flush", strlen(*av))) {
@@ -1451,11 +1289,10 @@ main(ac, av)
#define MAX_ARGS 32
#define WHITESP " \t\f\v\n\r"
char buf[BUFSIZ];
- char *a, *p, *args[MAX_ARGS], *cmd = NULL;
+ char *a, *args[MAX_ARGS];
char linename[10];
- int i, c, qflag, pflag, status;
- FILE *f = NULL;
- pid_t preproc = 0;
+ int i, qflag=0;
+ FILE *f;
s = socket( AF_INET, SOCK_RAW, IPPROTO_RAW );
if ( s < 0 )
@@ -1463,94 +1300,14 @@ main(ac, av)
setbuf(stdout,0);
- if (ac > 1 && access(av[ac - 1], R_OK) == 0) {
- qflag = pflag = i = 0;
+ if (av[1] && (!access(av[1], R_OK) ||
+ (av[2] && (qflag=!strcmp(av[1],"-q")) && !access(av[2], R_OK)))){
lineno = 0;
-
- while ((c = getopt(ac, av, "D:U:p:q")) != -1)
- switch(c) {
- case 'D':
- if (!pflag)
- errx(EX_USAGE, "-D requires -p");
- if (i > MAX_ARGS - 2)
- errx(EX_USAGE,
- "too many -D or -U options");
- args[i++] = "-D";
- args[i++] = optarg;
- break;
-
- case 'U':
- if (!pflag)
- errx(EX_USAGE, "-U requires -p");
- if (i > MAX_ARGS - 2)
- errx(EX_USAGE,
- "too many -D or -U options");
- args[i++] = "-U";
- args[i++] = optarg;
- break;
-
- case 'p':
- pflag = 1;
- cmd = optarg;
- args[0] = cmd;
- i = 1;
- break;
-
- case 'q':
- qflag = 1;
- break;
-
- default:
- show_usage(NULL);
- }
-
- av += optind;
- ac -= optind;
- if (ac != 1)
- show_usage("extraneous filename arguments");
-
- if ((f = fopen(av[0], "r")) == NULL)
- err(EX_UNAVAILABLE, "fopen: %s", av[0]);
-
- if (pflag) {
- /* pipe through preprocessor (cpp or m4) */
- int pipedes[2];
-
- args[i] = 0;
-
- if (pipe(pipedes) == -1)
- err(EX_OSERR, "cannot create pipe");
-
- switch((preproc = fork())) {
- case -1:
- err(EX_OSERR, "cannot fork");
-
- case 0:
- /* child */
- if (dup2(fileno(f), 0) == -1 ||
- dup2(pipedes[1], 1) == -1)
- err(EX_OSERR, "dup2()");
- fclose(f);
- close(pipedes[1]);
- close(pipedes[0]);
- execvp(cmd, args);
- err(EX_OSERR, "execvp(%s) failed", cmd);
-
- default:
- /* parent */
- fclose(f);
- close(pipedes[1]);
- if ((f = fdopen(pipedes[0], "r")) == NULL) {
- int savederrno = errno;
-
- (void)kill(preproc, SIGTERM);
- errno = savederrno;
- err(EX_OSERR, "fdopen()");
- }
- }
- }
-
+ if ((f = fopen(av[ac-1], "r")) == NULL)
+ err(EX_UNAVAILABLE, "fopen: %s", av[ac-1]);
while (fgets(buf, BUFSIZ, f)) {
+ char *p;
+
lineno++;
sprintf(linename, "Line %d", lineno);
args[0] = linename;
@@ -1564,7 +1321,7 @@ main(ac, av)
for (a = strtok(buf, WHITESP);
a && i < MAX_ARGS; a = strtok(NULL, WHITESP), i++)
args[i] = a;
- if (i == (qflag? 2: 1))
+ if (i == 1)
continue;
if (i == MAX_ARGS)
errx(EX_USAGE, "%s: too many arguments", linename);
@@ -1573,21 +1330,6 @@ main(ac, av)
ipfw_main(i, args);
}
fclose(f);
- if (pflag) {
- if (waitpid(preproc, &status, 0) != -1) {
- if (WIFEXITED(status)) {
- if (WEXITSTATUS(status) != EX_OK)
- errx(EX_UNAVAILABLE,
- "preprocessor exited with status %d",
- WEXITSTATUS(status));
- } else if (WIFSIGNALED(status)) {
- errx(EX_UNAVAILABLE,
- "preprocessor exited with signal %d",
- WTERMSIG(status));
- }
- }
- }
-
} else
ipfw_main(ac,av);
return EX_OK;
diff --git a/sbin/kldload/kldload.8 b/sbin/kldload/kldload.8
index 64d10cb32441d..8201f7f18c9bb 100644
--- a/sbin/kldload/kldload.8
+++ b/sbin/kldload/kldload.8
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: kldload.8,v 1.4 1998/03/19 07:45:17 charnier Exp $
+.\" $Id: kldload.8,v 1.3 1998/01/05 07:07:44 charnier Exp $
.\"
.Dd April 25, 1997
.Dt KLDLOAD 8
@@ -38,24 +38,13 @@
.Sh DESCRIPTION
The
.Nm
-loads the file
-.Ar filename.ko
-into the kernel using the kernel linker.
+loads a file into the kernel using the kernel linker.
.Pp
The following option is available:
.Bl -tag -width indent
.It Fl v
Be more verbose.
.El
-.Sh FILES
-.Bl -tag -width /modules -compact
-.It Pa /modules
-directory containing loadable modules. Modules must be have an extention of .ko
-.Sh DIAGNOSTICS
-The
-.Nm
-utility exits with a status of 0 on success
-and with a nonzero status if an error occurs.
.Sh SEE ALSO
.Xr kldstat 8 ,
.Xr kldunload 8
@@ -63,9 +52,6 @@ and with a nonzero status if an error occurs.
The
.Nm
command first appeared in
-.Fx 3.0 ,
-replacing the
-.Xr lkm 4
-interface.
+.Fx 3.0 .
.Sh AUTHORS
.An Doug Rabson Aq dfr@FreeBSD.org
diff --git a/sbin/kldstat/kldstat.8 b/sbin/kldstat/kldstat.8
index 943f5446c61b9..cd1d6a7dc23c4 100644
--- a/sbin/kldstat/kldstat.8
+++ b/sbin/kldstat/kldstat.8
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: kldstat.8,v 1.4 1998/03/19 07:45:28 charnier Exp $
+.\" $Id: kldstat.8,v 1.3 1998/01/05 07:09:28 charnier Exp $
.\"
.Dd April 25, 1997
.Dt KLDSTAT 8
@@ -43,7 +43,7 @@ utility displays the status of any files dynamically linked into the
kernel.
.Pp
The following options are available:
-.Bl -tag -width indentXX
+.Bl -tag -width indent
.It Fl v
Be more verbose.
.It Fl i Ar id
@@ -51,11 +51,6 @@ Display the status of only the file with this ID.
.It Fl n Ar name
Display the status of only the file with this name.
.El
-.Sh DIAGNOSTICS
-The
-.Nm
-utility exits with a status of 0 on success
-and with a nonzero status if an error occurs.
.Sh SEE ALSO
.Xr kldload 8 ,
.Xr kldunload 8
@@ -63,9 +58,6 @@ and with a nonzero status if an error occurs.
The
.Nm
command first appeared in
-.Fx 3.0 ,
-replacing the
-.Xr lkm 4
-interface.
+.Fx 3.0 .
.Sh AUTHORS
.An Doug Rabson Aq dfr@FreeBSD.org
diff --git a/sbin/kldstat/kldstat.c b/sbin/kldstat/kldstat.c
index 8df5cece0d51a..49cdd7a3cde9f 100644
--- a/sbin/kldstat/kldstat.c
+++ b/sbin/kldstat/kldstat.c
@@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: kldstat.c,v 1.4 1998/01/05 07:09:28 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include <err.h>
@@ -111,7 +111,7 @@ main(int argc, char** argv)
err(1, "can't find file %s", filename);
}
- printf("Id Refs Address Size Name\n");
+ printf("Id Refs Address Size Name\n");
if (fileid)
printfile(fileid, verbose);
else
diff --git a/sbin/kldunload/kldunload.8 b/sbin/kldunload/kldunload.8
index 8fd216d330902..15bbfa2573635 100644
--- a/sbin/kldunload/kldunload.8
+++ b/sbin/kldunload/kldunload.8
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: kldunload.8,v 1.5 1998/11/07 00:42:52 des Exp $
+.\" $Id: kldunload.8,v 1.3 1998/01/05 07:10:41 charnier Exp $
.\"
.Dd April 25, 1997
.Dt KLDUNLOAD 8
@@ -34,10 +34,8 @@
.Sh SYNOPSIS
.Nm kldunload
.Op Fl v
-.Fl i Ar id
-.Nm kldunload
-.Op Fl v
-.Fl n Ar name
+.Op Fl i Ar id
+.Op Fl n Ar name
.Sh DESCRIPTION
The
.Nm
@@ -45,7 +43,7 @@ utility unloads a file which was previously loaded with
.Xr kldload 8 .
.Pp
The following options are available:
-.Bl -tag -width indentXX
+.Bl -tag -width indent
.It Fl v
Be more verbose.
.It Fl i Ar id
@@ -53,11 +51,6 @@ Unload the file with this ID.
.It Fl n Ar name
Unload the file with this name.
.El
-.Sh DIAGNOSTICS
-The
-.Nm
-utility exits with a status of 0 on success
-and with a nonzero status if an error occurs.
.Sh SEE ALSO
.Xr kldload 8 ,
.Xr kldstat 8
@@ -65,9 +58,6 @@ and with a nonzero status if an error occurs.
The
.Nm
command first appeared in
-.Fx 3.0 ,
-replacing the
-.Xr lkm 4
-interface.
+.Fx 3.0 .
.Sh AUTHORS
.An Doug Rabson Aq dfr@FreeBSD.org
diff --git a/sbin/kldunload/kldunload.c b/sbin/kldunload/kldunload.c
index 1d4fb52f5a512..4a942ed1b4908 100644
--- a/sbin/kldunload/kldunload.c
+++ b/sbin/kldunload/kldunload.c
@@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: kldunload.c,v 1.6 1998/07/06 06:59:52 charnier Exp $";
+ "$Id: kldunload.c,v 1.5 1998/01/05 07:10:42 charnier Exp $";
#endif /* not lint */
#include <err.h>
@@ -39,8 +39,7 @@ static const char rcsid[] =
static void
usage(void)
{
- fprintf(stderr, "usage: kldunload [-v] -i id\n");
- fprintf(stderr, " kldunload [-v] -n name\n");
+ fprintf(stderr, "usage: kldunload [-v] [-i id] [-n name]\n");
exit(1);
}
@@ -69,12 +68,7 @@ main(int argc, char** argv)
argc -= optind;
argv += optind;
- if (!fileid && !filename && (argc == 1)) {
- filename = *argv;
- argc--;
- }
-
- if (argc != 0 || fileid && filename)
+ if (argc != 0)
usage();
if (fileid == 0 && filename == 0)
diff --git a/sbin/mount/Makefile b/sbin/mount/Makefile
index f4e95245514f1..e899d4ed6f75f 100644
--- a/sbin/mount/Makefile
+++ b/sbin/mount/Makefile
@@ -1,9 +1,12 @@
# @(#)Makefile 8.6 (Berkeley) 5/8/95
-# $Id: Makefile,v 1.7 1998/03/08 14:50:00 msmith Exp $
+# $Id: Makefile,v 1.6 1998/01/20 10:39:57 bde Exp $
PROG= mount
SRCS= mount.c mount_ufs.c getmntopts.c vfslist.c
MAN8= mount.8
# We do NOT install the getmntopts.3 man page.
+# We support the ROOTSLICE_HUNT hack
+CFLAGS+=-DROOTSLICE_HUNT
+
.include <bsd.prog.mk>
diff --git a/sbin/mount/mount_ufs.c b/sbin/mount/mount_ufs.c
index c6abfee22b705..00c2e72f0230f 100644
--- a/sbin/mount/mount_ufs.c
+++ b/sbin/mount/mount_ufs.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)mount_ufs.c 8.4 (Berkeley) 4/26/95";
#endif
static const char rcsid[] =
- "$Id: mount_ufs.c,v 1.14 1998/07/06 07:12:38 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include <sys/param.h>
@@ -80,6 +80,10 @@ mount_ufs(argc, argv)
char *fs_name;
struct vfsconf vfc;
int error = 0;
+#ifdef ROOTSLICE_HUNT
+ int slice, result, unit;
+ char part, devbuf[MAXPATHLEN], devpfx[MAXPATHLEN];
+#endif
mntflags = 0;
optind = optreset = 1; /* Reset for parse of new argv. */
@@ -121,8 +125,36 @@ mount_ufs(argc, argv)
warnx("ufs filesystem is not available");
return (1);
}
-
+#ifdef ROOTSLICE_HUNT
+ result = -1;
+ /*
+ * If we are mounting root, and we have a mount of something that
+ * might be the compatibility slice, try mounting other slices
+ * first. If the kernel has done the right thing and mounted
+ * the slice because the disk is really sliced, this will find
+ * the real root filesystem. If not, we'll try what was supplied.
+ */
+ if (!strcmp(fs_name, "/") &&
+ (sscanf(args.fspec, "%[^0-9]%d%c", devpfx, &unit, &part) == 3) &&
+ (part >= 'a') &&
+ (part <= 'h')) {
+ for (slice = 1; (slice < 32) && (result < 0); slice++) {
+ sprintf(devbuf, "%s%ds%d%c",
+ devpfx, unit, slice, part);
+ args.fspec = devbuf;
+ result = mount(vfc.vfc_name, fs_name, mntflags, &args);
+ }
+ args.fspec = argv[0];
+ }
+ if (result == 0)
+ warnx("*** update /etc/fstab entry for %s to use %s ***",
+ fs_name, devbuf);
+ /* Try the mount as originally requested */
+ if ((result < 0) &&
+ (mount(vfc.vfc_name, fs_name, mntflags, &args) < 0)) {
+#else
if (mount(vfc.vfc_name, fs_name, mntflags, &args) < 0) {
+#endif
switch (errno) {
case EMFILE:
warnx("%s on %s: mount table full",
diff --git a/sbin/mount_null/mount_null.8 b/sbin/mount_null/mount_null.8
index 16635371ec2f2..9ed773ebdfa99 100644
--- a/sbin/mount_null/mount_null.8
+++ b/sbin/mount_null/mount_null.8
@@ -35,7 +35,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)mount_null.8 8.6 (Berkeley) 5/1/95
-.\" $Id: mount_null.8,v 1.9 1998/07/06 07:17:26 charnier Exp $
+.\" $Id: mount_null.8,v 1.8 1997/03/11 12:33:34 peter Exp $
.\"
.Dd May 1, 1995
.Dt MOUNT_NULL 8
@@ -228,16 +228,6 @@ is that vnodes arguments must be manually mapped.
.sp
UCLA Technical Report CSD-910056,
.Em "Stackable Layers: an Architecture for File System Development" .
-.Sh BUGS
-
-THIS FILESYSTEM TYPE IS NOT YET FULLY SUPPORTED (READ: IT DOESN'T WORK)
-AND USING IT MAY, IN FACT, DESTROY DATA ON YOUR SYSTEM. USE AT YOUR
-OWN RISK. BEWARE OF DOG. SLIPPERY WHEN WET.
-
-This code also needs an owner in order to be less dangerous - serious
-hackers can apply by sending mail to hackers@freebsd.org and announcing
-their intent to take it over.
-
.Sh HISTORY
The
.Nm
diff --git a/sbin/mount_portal/Makefile b/sbin/mount_portal/Makefile
index 7734df49eee64..af7d5367e9431 100644
--- a/sbin/mount_portal/Makefile
+++ b/sbin/mount_portal/Makefile
@@ -1,9 +1,9 @@
# From: @(#)Makefile 8.3 (Berkeley) 3/27/94
-# $Id: Makefile,v 1.8 1998/01/20 10:40:04 bde Exp $
+# $Id: Makefile,v 1.7 1997/03/11 12:34:55 peter Exp $
PROG= mount_portal
SRCS= mount_portal.c activate.c conf.c getmntopts.c pt_conf.c \
- pt_exec.c pt_file.c pt_tcp.c pt_tcplisten.c
+ pt_exec.c pt_file.c pt_tcp.c
MAN8= mount_portal.8
MOUNT= ${.CURDIR}/../mount
diff --git a/sbin/mount_portal/activate.c b/sbin/mount_portal/activate.c
index 6eb0c582753ac..5bbd3b5a71065 100644
--- a/sbin/mount_portal/activate.c
+++ b/sbin/mount_portal/activate.c
@@ -39,7 +39,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: activate.c,v 1.5 1998/07/06 07:19:23 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include <errno.h>
@@ -148,7 +148,7 @@ int error;
/*
* Send to kernel...
*/
- if ((n = sendmsg(so, &msg, 0)) < 0)
+ if ((n = sendmsg(so, &msg, MSG_EOR)) < 0)
syslog(LOG_ERR, "send: %s", strerror(errno));
#ifdef DEBUG
fprintf(stderr, "sent %d bytes\n", n);
diff --git a/sbin/mount_portal/mount_portal.8 b/sbin/mount_portal/mount_portal.8
index 5a5750faf19f9..ed9434e557fe0 100644
--- a/sbin/mount_portal/mount_portal.8
+++ b/sbin/mount_portal/mount_portal.8
@@ -35,7 +35,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)mount_portal.8 8.3 (Berkeley) 3/27/94
-.\" $Id: mount_portal.8,v 1.3 1998/07/06 07:19:25 charnier Exp $
+.\" $Id$
.\"
.Dd March 27, 1994
.Dt MOUNT_PORTAL 8
@@ -89,22 +89,11 @@ to the calling process as the result of the open system call.
By convention, the portal daemon divides the namespace into sub-namespaces,
each of which handles objects of a particular type.
.Pp
-The following sub-namespaces are currently implemented:
-.Pa tcplisten ,
+Currently, two sub-namespaces are implemented:
.Pa tcp
and
.Pa fs .
The
-.Pa tcplisten
-namespace takes a slash separated hostname and port and creates a TCP/IP
-socket bound to the given hostname-port pair. The hostname may be
-specified as "ANY" to allow any other host to connect to the socket. A
-port number of 0 will dynamically allocate a port, this can be
-discovered by calling
-.Xr getsockname 8
-with the returned file descriptor. Privilaged ports can only be bound to
-by the super-user.
-The
.Pa tcp
namespace takes a hostname and a port (slash separated) and
creates an open TCP/IP connection.
@@ -127,7 +116,6 @@ tells the daemon what type of object to create.
Subsequent fields are passed to the creation function.
.Bd -literal
# @(#)portal.conf 5.1 (Berkeley) 7/13/92
-tcplisten/ tcplisten tcplisten/
tcp/ tcp tcp/
fs/ file fs/
.Ed
diff --git a/sbin/mount_portal/mount_portal.c b/sbin/mount_portal/mount_portal.c
index 6de71ea947e7b..d3fa3c3a0dce2 100644
--- a/sbin/mount_portal/mount_portal.c
+++ b/sbin/mount_portal/mount_portal.c
@@ -45,7 +45,7 @@ char copyright[] =
static char sccsid[] = "@(#)mount_portal.c 8.6 (Berkeley) 4/26/95";
#endif
static const char rcsid[] =
- "$Id: mount_portal.c,v 1.13 1998/07/06 07:19:25 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include <sys/param.h>
@@ -190,9 +190,7 @@ main(argc, argv)
/*
* Everything is ready to go - now is a good time to fork
*/
-#ifndef DEBUG
daemon(0, 0);
-#endif
/*
* Start logging (and change name)
diff --git a/sbin/mount_portal/portald.h b/sbin/mount_portal/portald.h
index f01e8a88ca788..23fce24198fa4 100644
--- a/sbin/mount_portal/portald.h
+++ b/sbin/mount_portal/portald.h
@@ -36,7 +36,7 @@
*
* @(#)portald.h 8.1 (Berkeley) 6/5/93
*
- * $Id: portald.h,v 1.3 1997/02/22 14:32:55 peter Exp $
+ * $Id$
*/
#include <sys/cdefs.h>
@@ -73,8 +73,6 @@ extern int portal_file __P((struct portal_cred *,
char *key, char **v, int so, int *fdp));
extern int portal_tcp __P((struct portal_cred *,
char *key, char **v, int so, int *fdp));
-extern int portal_tcplisten __P((struct portal_cred *,
- char *key, char **v, int so, int *fdp));
/*
* Global functions
diff --git a/sbin/mount_portal/pt_conf.c b/sbin/mount_portal/pt_conf.c
index 11088ea2934d8..2f9ab9772a819 100644
--- a/sbin/mount_portal/pt_conf.c
+++ b/sbin/mount_portal/pt_conf.c
@@ -39,7 +39,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: pt_conf.c,v 1.4 1998/07/06 07:19:25 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include <sys/types.h>
@@ -50,6 +50,5 @@ provider providers[] = {
{ "exec", portal_exec },
{ "file", portal_file },
{ "tcp", portal_tcp },
- { "tcplisten", portal_tcplisten },
{ 0, 0 }
};
diff --git a/sbin/mount_portal/pt_tcp.c b/sbin/mount_portal/pt_tcp.c
index 954388ee03fd2..d62ca3eb31a7f 100644
--- a/sbin/mount_portal/pt_tcp.c
+++ b/sbin/mount_portal/pt_tcp.c
@@ -39,7 +39,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: pt_tcp.c,v 1.7 1998/07/06 07:19:27 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include <errno.h>
@@ -124,16 +124,16 @@ int portal_tcp(pcr, key, v, kso, fdp)
#endif
sp = getservbyname(port, "tcp");
- if (sp != NULL) {
+ if (sp != NULL)
s_port = (u_short)sp->s_port;
- } else {
+ else {
s_port = strtoul(port, &p, 0);
if (s_port == 0 || *p != '\0')
return (EINVAL);
s_port = htons(s_port);
}
#ifdef DEBUG
- printf ("port number for %s is %d\n", port, (int)ntohs(s_port));
+ printf ("port number for %s is %d\n", port, ntohs(s_port));
#endif
memset(&sain, 0, sizeof(sain));
diff --git a/sbin/mount_portal/pt_tcplisten.c b/sbin/mount_portal/pt_tcplisten.c
deleted file mode 100644
index 43a20c5aa92cb..0000000000000
--- a/sbin/mount_portal/pt_tcplisten.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * Modified by Duncan Barclay.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)pt_tcp.c 8.3 (Berkeley) 3/27/94
- *
- * pt_tcp.c,v 1.1.1.1 1994/05/26 06:34:34 rgrimes Exp
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <strings.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/syslog.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-
-#include "portald.h"
-
-/*
- * Key will be tcplisten/host/port
- *
- * Create a TCP socket bound to the requested host and port.
- * If the host is "ANY" the receving address will be set to INADDR_ANY.
- * If the port is 0 the caller must find out the returned port number
- * using a call to getsockname.
- *
- * XXX! The owner of the socket will be root rather then the user. This
- * may cause remote auth (identd) to return unexpected results.
- *
- */
-int portal_tcplisten(pcr, key, v, kso, fdp)
- struct portal_cred *pcr;
- char *key;
- char **v;
- int kso;
- int *fdp;
-{
- char host[MAXHOSTNAMELEN];
- char port[MAXHOSTNAMELEN];
- char *p = key + (v[1] ? strlen(v[1]) : 0);
- char *q;
- struct hostent *hp;
- struct servent *sp;
- struct in_addr **ipp;
- struct in_addr *ip[2];
- struct in_addr ina;
- u_short s_port;
- int any = 0;
- struct sockaddr_in sain;
-
- q = strchr(p, '/');
- if (q == 0 || q - p >= sizeof(host))
- return (EINVAL);
- *q = '\0';
- snprintf(host, sizeof(host), "%s", p);
- p = q + 1;
-
- q = strchr(p, '/');
- if (q)
- *q = '\0';
- if (strlen(p) >= sizeof(port))
- return (EINVAL);
- snprintf(port, sizeof(port), "%s", p);
-
- if (strcmp(host, "ANY") == 0) {
- any = 1;
- } else {
- hp = gethostbyname(host);
- if (hp != 0) {
- ipp = (struct in_addr **) hp->h_addr_list;
- } else {
- ina.s_addr = inet_addr(host);
- if (ina.s_addr == INADDR_NONE)
- return (EINVAL);
- ip[0] = &ina;
- ip[1] = 0;
- ipp = ip;
- }
- }
-#ifdef DEBUG
- if (any)
- printf("INADDR_ANY to be used for hostname\n");
- else
- printf("inet address for %s is %s\n", host, inet_ntoa(*ipp[0]));
-#endif
-
- sp = getservbyname(port, "tcp");
- if (sp != NULL) {
- s_port = (u_short) sp->s_port;
- } else {
- s_port = strtoul(port, &p, 0);
- if (*p != '\0')
- return (EINVAL);
- s_port = htons(s_port);
- }
- if ((ntohs(s_port) != 0) &&
- (ntohs(s_port) <= IPPORT_RESERVED) &&
- (pcr->pcr_uid != 0))
- return (EPERM);
-#ifdef DEBUG
- printf("port number for %s is %d\n", port, ntohs(s_port));
-#endif
-
- memset(&sain, 0, sizeof(sain));
- sain.sin_len = sizeof(sain);
- sain.sin_family = AF_INET;
- sain.sin_port = s_port;
-
- if (any) {
- int so;
- int sock;
-
- so = socket(AF_INET, SOCK_STREAM, 0);
- if (so < 0) {
- syslog(LOG_ERR, "socket: %m");
- return (errno);
- }
-
- sain.sin_addr.s_addr = INADDR_ANY;
- if (bind(so, (struct sockaddr *) &sain, sizeof(sain)) == 0) {
- listen(so, 1);
- if ((sock = accept(so, (struct sockaddr *)0, (int *)0)) == -1) {
- syslog(LOG_ERR, "accept: %m");
- (void) close(so);
- return (errno);
- }
- *fdp = sock;
- (void) close(so);
- return (0);
- }
- syslog(LOG_ERR, "bind: %m");
- (void) close(so);
- return (errno);
- }
-
- while (ipp[0]) {
- int so;
- int sock;
-
- so = socket(AF_INET, SOCK_STREAM, 0);
- if (so < 0) {
- syslog(LOG_ERR, "socket: %m");
- return (errno);
- }
-
- sain.sin_addr = *ipp[0];
- if (bind(so, (struct sockaddr *) &sain, sizeof(sain)) == 0) {
- listen(so, 1);
- if ((sock = accept(so, (struct sockaddr *)0, (int *)0)) == -1) {
- syslog(LOG_ERR, "accept: %m");
- (void) close(so);
- return (errno);
- }
- *fdp = sock;
- (void) close(so);
- return (0);
- }
- (void) close(so);
-
- ipp++;
- }
-
- syslog(LOG_ERR, "bind: %m");
- return (errno);
-
-}
diff --git a/sbin/mount_umap/mount_umap.8 b/sbin/mount_umap/mount_umap.8
index 1407305aed317..4b9bd0016be51 100644
--- a/sbin/mount_umap/mount_umap.8
+++ b/sbin/mount_umap/mount_umap.8
@@ -34,7 +34,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)mount_umap.8 8.4 (Berkeley) 5/1/95
-.\" $Id: mount_umap.8,v 1.8 1998/07/15 06:12:31 charnier Exp $
+.\" $Id$
.\"
.Dd May 1, 1995
.Dt MOUNT_UMAP 8
@@ -123,16 +123,6 @@ sophisticated.
.Sh SEE ALSO
.Xr mount 8 ,
.Xr mount_null 8
-.Sh BUGS
-
-THIS FILESYSTEM TYPE IS NOT YET FULLY SUPPORTED (READ: IT DOESN'T WORK)
-AND USING IT MAY, IN FACT, DESTROY DATA ON YOUR SYSTEM. USE AT YOUR
-OWN RISK. BEWARE OF DOG. SLIPPERY WHEN WET.
-
-This code also needs an owner in order to be less dangerous - serious
-hackers can apply by sending mail to hackers@freebsd.org and announcing
-their intent to take it over.
-
.Sh HISTORY
The
.Nm
diff --git a/sbin/mount_union/mount_union.8 b/sbin/mount_union/mount_union.8
index eada8bf8c3f67..60800f1f165f1 100644
--- a/sbin/mount_union/mount_union.8
+++ b/sbin/mount_union/mount_union.8
@@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)mount_union.8 8.6 (Berkeley) 3/27/94
-.\" $Id: mount_union.8,v 1.4 1998/07/15 06:13:45 charnier Exp $
+.\" $Id$
.\"
.Dd March 27, 1994
.Dt MOUNT_UNION 8
@@ -183,15 +183,6 @@ accessible via
.Xr mount 8 ,
.Xr mount_null 8
.Sh BUGS
-
-THIS FILESYSTEM TYPE IS NOT YET FULLY SUPPORTED (READ: IT DOESN'T WORK)
-AND USING IT MAY, IN FACT, DESTROY DATA ON YOUR SYSTEM. USE AT YOUR
-OWN RISK. BEWARE OF DOG. SLIPPERY WHEN WET.
-
-This code also needs an owner in order to be less dangerous - serious
-hackers can apply by sending mail to hackers@freebsd.org and announcing
-their intent to take it over.
-
Without whiteout support from the filesystem backing the upper layer,
there is no way that delete and rename operations on lower layer
objects can be done.
@@ -209,4 +200,3 @@ The
.Nm
command first appeared in
.Bx 4.4 .
-It first worked in FreeBSD-(fill this in).
diff --git a/sbin/mountd/mountd.c b/sbin/mountd/mountd.c
index ab9fdc7c83630..fe556db9cc331 100644
--- a/sbin/mountd/mountd.c
+++ b/sbin/mountd/mountd.c
@@ -45,7 +45,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95";
#endif
static const char rcsid[] =
- "$Id: mountd.c,v 1.33 1998/08/02 16:06:34 bde Exp $";
+ "$Id: mountd.c,v 1.32 1998/07/15 06:21:40 charnier Exp $";
#endif /*not lint*/
#include <sys/param.h>
@@ -119,9 +119,9 @@ struct exportlist {
#define EX_LINKED 0x1
struct netmsk {
- u_int32_t nt_net;
- u_int32_t nt_mask;
- char *nt_name;
+ u_long nt_net;
+ u_long nt_mask;
+ char *nt_name;
};
union grouptypes {
@@ -163,7 +163,7 @@ void add_dlist __P((struct dirlist **, struct dirlist *,
void add_mlist __P((char *, char *));
int check_dirpath __P((char *));
int check_options __P((struct dirlist *));
-int chk_host __P((struct dirlist *, u_int32_t, int *, int *));
+int chk_host __P((struct dirlist *, u_long, int *, int *));
void del_mlist __P((char *, char *));
struct dirlist *dirp_search __P((struct dirlist *, char *));
int do_mount __P((struct exportlist *, struct grouplist *, int,
@@ -192,7 +192,7 @@ void nextfield __P((char **, char **));
void out_of_mem __P((void));
void parsecred __P((char *, struct ucred *));
int put_exlist __P((struct dirlist *, XDR *, struct dirlist *, int *));
-int scan_tree __P((struct dirlist *, u_int32_t));
+int scan_tree __P((struct dirlist *, u_long));
void send_umntall __P((void));
int umntall_each __P((caddr_t, struct sockaddr_in *));
static void usage __P((void));
@@ -376,7 +376,7 @@ mntsrv(rqstp, transp)
struct statfs fsb;
struct hostent *hp;
struct in_addr saddrin;
- u_int32_t saddr;
+ u_long saddr;
u_short sport;
char rpcpath[RPCMNT_PATHLEN + 1], dirpath[MAXPATHLEN];
int bad = 0, defset, hostset;
@@ -952,7 +952,7 @@ get_exportlist()
out_of_mem();
hpe->h_name = strdup("Default");
hpe->h_addrtype = AF_INET;
- hpe->h_length = sizeof (u_int32_t);
+ hpe->h_length = sizeof (u_long);
hpe->h_addr_list = (char **)NULL;
grp->gr_ptr.gt_hostent = hpe;
@@ -1247,13 +1247,13 @@ dirp_search(dp, dirpath)
int
chk_host(dp, saddr, defsetp, hostsetp)
struct dirlist *dp;
- u_int32_t saddr;
+ u_long saddr;
int *defsetp;
int *hostsetp;
{
struct hostlist *hp;
struct grouplist *grp;
- u_int32_t **addrp;
+ u_long **addrp;
if (dp) {
if (dp->dp_flag & DP_DEFSET)
@@ -1263,7 +1263,7 @@ chk_host(dp, saddr, defsetp, hostsetp)
grp = hp->ht_grp;
switch (grp->gr_type) {
case GT_HOST:
- addrp = (u_int32_t **)
+ addrp = (u_long **)
grp->gr_ptr.gt_hostent->h_addr_list;
while (*addrp) {
if (**addrp == saddr) {
@@ -1293,7 +1293,7 @@ chk_host(dp, saddr, defsetp, hostsetp)
int
scan_tree(dp, saddr)
struct dirlist *dp;
- u_int32_t saddr;
+ u_long saddr;
{
int defset, hostset;
@@ -1458,7 +1458,7 @@ get_host(cp, grp, tgrp)
char **addrp, **naddrp;
struct hostent t_host;
int i;
- u_int32_t saddr;
+ u_long saddr;
char *aptr[2];
if (grp->gr_type != GT_NULL)
@@ -1475,7 +1475,7 @@ get_host(cp, grp, tgrp)
hp = &t_host;
hp->h_name = cp;
hp->h_addrtype = AF_INET;
- hp->h_length = sizeof (u_int32_t);
+ hp->h_length = sizeof (u_long);
hp->h_addr_list = aptr;
aptr[0] = (char *)&saddr;
aptr[1] = (char *)NULL;
@@ -1494,8 +1494,8 @@ get_host(cp, grp, tgrp)
if (checkgrp->gr_type == GT_HOST &&
checkgrp->gr_ptr.gt_hostent != NULL &&
(!strcmp(checkgrp->gr_ptr.gt_hostent->h_name, hp->h_name)
- || *(u_int32_t *)checkgrp->gr_ptr.gt_hostent->h_addr ==
- *(u_int32_t *)hp->h_addr)) {
+ || *(unsigned long *)checkgrp->gr_ptr.gt_hostent->h_addr ==
+ *(unsigned long *)hp->h_addr)) {
grp->gr_type = GT_IGNORE;
return(0);
}
@@ -1640,7 +1640,7 @@ do_mount(ep, grp, exflags, anoncrp, dirp, dirplen, fsb)
struct statfs *fsb;
{
char *cp = (char *)NULL;
- u_int32_t **addrp;
+ u_long **addrp;
int done;
char savedc = '\0';
struct sockaddr_in sin, imask;
@@ -1652,7 +1652,7 @@ do_mount(ep, grp, exflags, anoncrp, dirp, dirplen, fsb)
struct msdosfs_args da;
#endif
} args;
- u_int32_t net;
+ u_long net;
args.ua.fspec = 0;
args.ua.export.ex_flags = exflags;
@@ -1665,9 +1665,9 @@ do_mount(ep, grp, exflags, anoncrp, dirp, dirplen, fsb)
imask.sin_family = AF_INET;
imask.sin_len = sizeof(sin);
if (grp->gr_type == GT_HOST)
- addrp = (u_int32_t **)grp->gr_ptr.gt_hostent->h_addr_list;
+ addrp = (u_long **)grp->gr_ptr.gt_hostent->h_addr_list;
else
- addrp = (u_int32_t **)NULL;
+ addrp = (u_long **)NULL;
done = FALSE;
while (!done) {
switch (grp->gr_type) {
@@ -1759,7 +1759,7 @@ do_mount(ep, grp, exflags, anoncrp, dirp, dirplen, fsb)
}
if (addrp) {
++addrp;
- if (*addrp == (u_int32_t *)NULL)
+ if (*addrp == (u_long *)NULL)
done = TRUE;
} else
done = TRUE;
diff --git a/sbin/natd/README b/sbin/natd/README
deleted file mode 100644
index 6c158d5e4ca15..0000000000000
--- a/sbin/natd/README
+++ /dev/null
@@ -1,53 +0,0 @@
-
- A Network Address Translation Daemon for FreeBSD
-
-
-1. WHAT IS NATD ?
-
- This is a simple daemon based on FreeBSD divert sockets
- which performs network address translation (or masquerading)
- for IP packets (see related RFCs 1631 and 1918).
- It is based on packet aliasing package (see README.alias)
- written by Charles Mott (cmott@srv.net).
-
- This package works with any network interface (doesn't have
- to be ppp). I run it on a computer having two ethernet cards,
- one connected to internet and the other one to local network.
-
-2. GETTING IT RUNNING
-
- 1) Get FreeBSD 2.2 - I think the divert sockets are
- not available on earlier versions,
-
- 2) Compile this software by executing "make".
-
- 3) Install the software by executing "make install".
-
- 4) See man natd for further instructions.
-
-3. FTP SITES FOR NATD
-
- This package is available at ftp://ftp.suutari.iki.fi/pub/natd.
-
-4. AUTHORS
-
- This program is the result of the efforts of many people
- at different times:
-
- Archie Cobbs <archie@whistle.com> Divert sockets
- Charles Mott <cmott@srv.net> Packet aliasing engine
- Eivind Eklund <eivind@dimaga.com> Packet aliasing engine
- Ari Suutari <suutari@iki.fi> Natd
- Brian Somers <brian@awfulhak.org> Manual page, glue and
- bunch of good ideas.
-
- The original package written by Charles Mott
- is available at http://www.srv.net/~cmott.
- It is described in README.alias.
-
- Happy Networking - comments and fixes are welcome!
-
- Ari S. (suutari@iki.fi)
-
-
-
diff --git a/sbin/natd/samples/natd.cf.sample b/sbin/natd/samples/natd.cf.sample
deleted file mode 100644
index df1018b7e2d34..0000000000000
--- a/sbin/natd/samples/natd.cf.sample
+++ /dev/null
@@ -1,94 +0,0 @@
-#
-# $Id:$
-#
-#
-# Configuration file for natd.
-#
-#
-# Enable logging to file /var/log/alias.log
-#
-log no
-#
-# Incoming connections. Should NEVER be set to "yes" if redirect_port,
-# redirect_address, or permanent_link statements are activated in this file!
-#
-# Setting to yes provides additional anti-crack protection
-#
-deny_incoming no
-#
-# Use sockets to avoid port clashes. Uses additional system resources, but
-# guarantees successful connections when port numbers conflict
-#
-use_sockets no
-#
-# Avoid port changes if possible when altering outbound packets. Makes rlogin
-# work in most cases.
-#
-same_port yes
-#
-# Verbose mode. Enables dumping of packets and disables
-# forking to background. Only set to yes for debugging.
-#
-verbose no
-#
-# Divert port. Can be a name in /etc/services or numeric value.
-#
-port 32000
-#
-# Interface name or address being aliased. Either one,
-# not both is required.
-#
-# Obtain interface name from the command output of "ifconfig -a"
-#
-# alias_address 192.168.0.1
-interface ep0
-#
-# Alias unregistered addresses or all addresses. Set this to yes if
-# the inside network is all RFC1918 addresses.
-#
-unregistered_only no
-#
-# Configure permanent links. If you use host names instead
-# of addresses here, be sure that name server works BEFORE
-# natd is up - this is usually not the case. So either use
-# numeric addresses or hosts that are in /etc/hosts.
-#
-# Note: Current versions of FreeBSD all call /etc/rc.firewall
-# BEFORE running named, so if the DNS server and NAT are on the same
-# machine, the nameserver won't be up if natd is called from /etc/rc.firewall
-#
-# Map connections coming to port 30000 to telnet in my_private_host.
-# Remember to allow the connection /etc/rc.firewall also.
-#
-# The following permanent_link and redirect_port statements are equivalent
-#permanent_link tcp my_private_host:telnet 0.0.0.0:0 30000
-#redirect_port tcp my_private_host:telnet 30000
-#
-# Map connections coming from host.xyz.com to port 30001 to
-# telnet in another_host.
-#permanent_link tcp another_host:telnet host.xyz.com:0 30001
-#
-# Static NAT address mapping:
-#
-# ipconfig must apply any legal IP numbers that inside hosts
-# will be known by to the outside interface. These are sometimes known as
-# virtual IP numbers. It's suggested to use the "interface" directive
-# instead of the "alias_address" directive to make it more clear what is
-# going on. (although both will work)
-#
-# DNS in this situation can get hairy. For example, an inside host
-# named aweb.company.com is located at 192.168.1.56, and needs to be
-# accessible through a legal IP number like 198.105.232.1. If both
-# 192.168.1.56 and 198.105.232.1 are set up as address records in the DNS
-# for aweb.company.com, then external hosts attempting to access
-# aweb.company.com may use address 192.168.1.56 which is inaccessible to them.
-#
-# The obvious solution is to use only a single address for the name, the
-# outside address. However, this creates needless traffic through the
-# NAT, because inside hosts will go through the NAT to get to the legal
-# number, even when the inside number is on the same subnet as they are!
-#
-# It's probably not a good idea to use DNS names in redirect_address statements
-#
-#The following mapping points outside address 198.105.232.1 to 192.168.1.56
-#redirect_address 192.168.1.56 198.105.232.1
diff --git a/sbin/natd/samples/natd.test b/sbin/natd/samples/natd.test
deleted file mode 100644
index cfdbd15aa6e28..0000000000000
--- a/sbin/natd/samples/natd.test
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-
- if [ $# != 1 ]
- then
- echo "usage: natd.test ifname"
- exit 1
- fi
-
- ipfw flush
- ipfw add divert 32000 ip from any to any via $1
- ipfw add pass ip from any to any
-
- ./natd -port 32000 -interface $1 -verbose
-
diff --git a/sbin/newfs/newfs.8 b/sbin/newfs/newfs.8
index 4eba3c7fa1bd0..afb46a55267e4 100644
--- a/sbin/newfs/newfs.8
+++ b/sbin/newfs/newfs.8
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)newfs.8 8.6 (Berkeley) 5/3/95
-.\" $Id: newfs.8,v 1.19 1998/11/28 09:59:40 rnordier Exp $
+.\" $Id: newfs.8,v 1.17 1998/09/11 07:08:49 grog Exp $
.\"
.Dd May 3, 1995
.Dt NEWFS 8
@@ -92,13 +92,12 @@ or
the disk must be labeled using
.Xr disklabel 8 .
.Nm Newfs
-builds a file system on the specified special file.
-(We often refer to the
+builds a file system on the specified special file. (We often refer to the
.Dq special file
as the
.Dq disk ,
-although the special file need not be a physical disk.
-In fact, it need not even be special.)
+although the special file need not be a physical disk. In fact, it need not
+even be special.)
Typically the defaults are reasonable, however
.Nm
has numerous options to allow the defaults to be selectively overridden.
@@ -220,10 +219,10 @@ for more details on how to set this option.
.It Fl s Ar size
The size of the file system in sectors.
.It Fl v
-Specify that the disk does not contain any partitions, and that
+Specify that the special device does not contain any partitions, and that
.Nm
-should build a file system on the whole disk.
-This option is useful for synthetic disks such as
+should treat the whole slice as the file system. This option is useful for
+synthetic disks such as
.Nm vinum.
.El
.Pp
@@ -306,7 +305,7 @@ man page for possible options and their meanings.
.El
.Sh EXAMPLES
.Pp
-.Dl mount_mfs -s 131072 -o nosuid,nodev /dev/da0s1b /tmp
+.Dl mount_mfs -s 131072 -o nosuid,nodev /dev/sd0s1b /tmp
.Pp
Mount a 64 MB large memory file system on /tmp, with
.Xr mount 8
diff --git a/sbin/newfs_msdos/newfs_msdos.c b/sbin/newfs_msdos/newfs_msdos.c
index dbcb4d10b7da9..c4d4703a605a8 100644
--- a/sbin/newfs_msdos/newfs_msdos.c
+++ b/sbin/newfs_msdos/newfs_msdos.c
@@ -27,7 +27,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: newfs_msdos.c,v 1.6 1998/12/07 14:09:17 rnordier Exp $";
+ "$Id: newfs_msdos.c,v 1.3 1998/07/16 12:24:51 rnordier Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -243,7 +243,6 @@ main(int argc, char *argv[])
u_int8_t *img;
const char *fname, *dtype, *bname;
ssize_t n;
- time_t now;
u_int fat, bss, rds, cls, dir, lsn, x, x1, x2;
int ch, fd, fd1;
@@ -412,7 +411,7 @@ main(int argc, char *argv[])
bpb.rde = opt_e;
if (mflag) {
if (opt_m < 0xf0)
- errx(1, "illegal media descriptor (%#x)", opt_m);
+ errx(1, "illegal media descriptor (0x%x)", opt_m);
bpb.mid = opt_m;
}
if (opt_a)
@@ -427,7 +426,7 @@ main(int argc, char *argv[])
if (opt_B) {
bname = opt_B;
if (!strchr(bname, '/')) {
- snprintf(buf, sizeof(buf), "/boot/%s", bname);
+ snprintf(buf, sizeof(buf), "/usr/mdec/%s", bname);
if (!(bname = strdup(buf)))
err(1, NULL);
}
@@ -542,8 +541,7 @@ main(int argc, char *argv[])
print_bpb(&bpb);
if (!opt_N) {
gettimeofday(&tv, NULL);
- now = tv.tv_sec;
- tm = localtime(&now);
+ tm = localtime(&tv.tv_sec);
if (!(img = malloc(bpb.bps)))
err(1, NULL);
dir = bpb.res + (bpb.spf ? bpb.spf : bpb.bspf) * bpb.nft;
@@ -804,7 +802,7 @@ print_bpb(struct bpb *bpb)
printf(" rde=%u", bpb->rde);
if (bpb->sec)
printf(" sec=%u", bpb->sec);
- printf(" mid=%#x", bpb->mid);
+ printf(" mid=0x%x", bpb->mid);
if (bpb->spf)
printf(" spf=%u", bpb->spf);
printf(" spt=%u hds=%u hid=%u", bpb->spt, bpb->hds, bpb->hid);
@@ -813,9 +811,9 @@ print_bpb(struct bpb *bpb)
if (!bpb->spf) {
printf(" bspf=%u rdcl=%u", bpb->bspf, bpb->rdcl);
printf(" infs=");
- printf(bpb->infs == MAXU16 ? "%#x" : "%u", bpb->infs);
+ printf(bpb->infs == MAXU16 ? "0x%x" : "%u", bpb->infs);
printf(" bkbs=");
- printf(bpb->bkbs == MAXU16 ? "%#x" : "%u", bpb->bkbs);
+ printf(bpb->bkbs == MAXU16 ? "0x%x" : "%u", bpb->bkbs);
}
printf("\n");
}
diff --git a/sbin/nologin/nologin.5 b/sbin/nologin/nologin.5
index 19a070df3eedf..d84c56604419e 100644
--- a/sbin/nologin/nologin.5
+++ b/sbin/nologin/nologin.5
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)nologin.8 8.1 (Berkeley) 6/19/93
-.\" $Id: nologin.5,v 1.4 1998/07/15 06:37:06 charnier Exp $
+.\" $Id$
.\"
.Dd June 19, 1993
.Dt NOLOGIN 5
@@ -41,22 +41,22 @@
.Sh DESCRIPTION
.Nm Nologin
disallows logins if the file
-.Pa /var/run/nologin
+.Pa /etc/nologin
exists.
Programs display the contents of
-.Pa /var/run/nologin
+.Pa /etc/nologin
to the user and exit.
.Sh SECURITY
Ignored by
.Xr login 1
for user root.
.Sh FILES
-.Bl -tag -width /var/run/nologinxxx -compact
-.It Pa /var/run/nologin
+.Bl -tag -width /etc/nologinxxx -compact
+.It Pa /etc/nologin
The
.Nm
file resides in
-.Pa /var/run .
+.Pa /etc .
.El
.Sh SEE ALSO
.Xr login 1 ,
diff --git a/sbin/ping/ping.8 b/sbin/ping/ping.8
index 50aeb0886be22..db82d5a4b8ba0 100644
--- a/sbin/ping/ping.8
+++ b/sbin/ping/ping.8
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)ping.8 8.2 (Berkeley) 12/11/93
-.\" $Id: ping.8,v 1.18 1998/11/29 13:20:04 bde Exp $
+.\" $Id: ping.8,v 1.16 1998/08/26 01:58:39 dillon Exp $
.\"
.Dd March 1, 1997
.Dt PING 8
@@ -48,7 +48,6 @@ packets to network hosts
.Op Fl l Ar preload
.Op Fl p Ar pattern
.Op Fl s Ar packetsize
-.Op Fl S Ar src_addr
.Bo
.Ar host |
.Op Fl L
@@ -86,10 +85,7 @@ Stop after sending
.Pq and receiving
.Ar count
.Tn ECHO_RESPONSE
-packets.
-If this option is not specified,
-.Nm
-will operate until interrupted.
+packets. If this option is not specified, ping will operate until interrupted.
.It Fl d
Set the
.Dv SO_DEBUG
@@ -104,7 +100,7 @@ sent a period
.Dq \&.
is printed, while for every
.Tn ECHO_REPLY
-received a backspace is printed.
+received a backspace is printed. Only root may specify this option.
This provides a rapid display of how many packets are being dropped.
Only the super-user may use this option.
.Bf -emphasis
@@ -115,10 +111,9 @@ Wait
.Ar wait
seconds
.Em between sending each packet .
-The default is to wait for one second between each packet.
-The wait time may be fractional, but only the super-user may specify
-values less then 1 second.
-This option is incompatible with the
+The default is to wait for one second between each packet. The
+wait time may be fractional, but only root may specify values
+less then 1 second. This option is incompatible with the
.Fl f
option.
.It Fl I Ar interface
@@ -202,8 +197,7 @@ The default is 56, which translates into 64
data bytes when combined
with the 8 bytes of
.Tn ICMP
-header data.
-Only the super-user may use this option.
+header data. Only root may use this option.
.It Fl T Ar ttl
Set the IP Time To Live for multicasted packets.
This flag only applies if the ping destination is a multicast address.
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c
index b1e20e8dec805..4db695bb0ec36 100644
--- a/sbin/ping/ping.c
+++ b/sbin/ping/ping.c
@@ -45,7 +45,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93";
#endif
static const char rcsid[] =
- "$Id: ping.c,v 1.41 1998/08/26 18:51:37 des Exp $";
+ "$Id: ping.c,v 1.40 1998/08/26 01:58:39 dillon Exp $";
#endif /* not lint */
/*
@@ -141,7 +141,6 @@ u_char outpack[MAXPACKET];
char BSPACE = '\b'; /* characters written for flood */
char DOT = '.';
char *hostname;
-char *shostname;
int ident; /* process id to identify our packets */
int uid; /* cached uid for micro-optimization */
@@ -185,15 +184,14 @@ main(argc, argv)
{
struct timeval last, intvl;
struct hostent *hp;
- struct sockaddr_in *to, sin;
+ struct sockaddr_in *to;
struct termios ts;
register int i;
int ch, hold, packlen, preload, sockerrno, almost_done = 0;
struct in_addr ifaddr;
unsigned char ttl, loop;
u_char *datap, *packet;
- char *source = NULL, *target, hnamebuf[MAXHOSTNAMELEN];
- char snamebuf[MAXHOSTNAMELEN];
+ char *target, hnamebuf[MAXHOSTNAMELEN];
char *ep;
u_long ultmp;
#ifdef IP_OPTIONS
@@ -219,7 +217,7 @@ main(argc, argv)
preload = 0;
datap = &outpack[8 + PHDR_LEN];
- while ((ch = getopt(argc, argv, "I:LQRS:T:c:adfi:l:np:qrs:v")) != -1) {
+ while ((ch = getopt(argc, argv, "I:LQRT:c:adfi:l:np:qrs:v")) != -1) {
switch(ch) {
case 'a':
options |= F_AUDIBLE;
@@ -318,9 +316,6 @@ main(argc, argv)
optarg);
datalen = ultmp;
break;
- case 'S':
- source = optarg;
- break;
case 'T': /* multicast TTL */
ultmp = strtoul(optarg, &ep, 0);
if (*ep || ep == optarg || ultmp > 255)
@@ -341,31 +336,6 @@ main(argc, argv)
usage();
target = argv[optind];
- if (source) {
- bzero((char *)&sin, sizeof(sin));
- sin.sin_family = AF_INET;
- if (inet_aton(source, &sin.sin_addr) != 0) {
- shostname = source;
- } else {
- hp = gethostbyname2(source, AF_INET);
- if (!hp)
- errx(EX_NOHOST, "cannot resolve %s: %s",
- source, hstrerror(h_errno));
-
- sin.sin_len = sizeof sin;
- if (hp->h_length > sizeof(sin.sin_addr))
- errx(1,"gethostbyname2: illegal address");
- memcpy(&sin.sin_addr, hp->h_addr_list[0],
- sizeof (sin.sin_addr));
- (void)strncpy(snamebuf, hp->h_name,
- sizeof(snamebuf) - 1);
- snamebuf[sizeof(snamebuf) - 1] = '\0';
- shostname = snamebuf;
- }
- if (bind(s, (struct sockaddr *)&sin, sizeof sin) == -1)
- err(1, "bind");
- }
-
bzero((char *)&whereto, sizeof(struct sockaddr));
to = (struct sockaddr_in *)&whereto;
to->sin_family = AF_INET;
@@ -474,13 +444,11 @@ main(argc, argv)
(void)setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&hold,
sizeof(hold));
- if (to->sin_family == AF_INET) {
- (void)printf("PING %s (%s)", hostname,
- inet_ntoa(to->sin_addr));
- if (source)
- (void)printf(" from %s", shostname);
- (void)printf(": %d data bytes\n", datalen);
- } else
+ if (to->sin_family == AF_INET)
+ (void)printf("PING %s (%s): %d data bytes\n", hostname,
+ inet_ntoa(to->sin_addr),
+ datalen);
+ else
(void)printf("PING %s: %d data bytes\n", hostname, datalen);
/*
@@ -1316,9 +1284,8 @@ fill(bp, patp)
static void
usage()
{
- fprintf(stderr, "%s\n%s\n%s\n",
+ fprintf(stderr, "%s\n%s\n",
"usage: ping [-QRadfnqrv] [-c count] [-i wait] [-l preload] [-p pattern]",
-" [-s packetsize] [-S src_addr]",
-" [host | [-L] [-I iface] [-T ttl] mcast-group]");
+" [-s packetsize] [host | [-L] [-I iface] [-T ttl] mcast-group]");
exit(EX_USAGE);
}
diff --git a/sbin/reboot/boot_i386.8 b/sbin/reboot/boot_i386.8
index ea2d9978ca91f..321fe8f5746c4 100644
--- a/sbin/reboot/boot_i386.8
+++ b/sbin/reboot/boot_i386.8
@@ -36,7 +36,7 @@
.\"
.\" @(#)boot_i386.8 8.2 (Berkeley) 4/19/94
.\"
-.\" $Id: boot_i386.8,v 1.15 1999/01/06 14:19:09 rnordier Exp $
+.\" $Id: boot_i386.8,v 1.13 1998/07/15 06:51:35 charnier Exp $
.\"
.Dd April 19, 1994
.Dt BOOT 8 i386
@@ -52,49 +52,25 @@ An automatic consistency check of the file systems will be performed,
and unless this fails, the system will resume multi-user operations.
.Pp
.Sy Cold starts.
-Most i386 PCs attempt to boot first from floppy disk drive 0 (sometimes
-known as drive A:) and, failing that, from hard disk drive 0 (sometimes
-known as drive C:, or as drive 0x80 to the BIOS). Some BIOSes allow
-you to change this default sequence, and may also include a CD-ROM
+Most 386
+.Tn "PC AT"
+clones attempt to boot the floppy disk drive 0 (otherwise known as
+drive A:) first, and failing that, attempt to boot the hard disk
+drive 0 (otherwise known as drive C:,
+or (confusingly) hard disk drive 1, or drive 0x80 in the BIOS).
+Some BIOSes let you change this default sequence or may include a CD-ROM
drive as a boot device.
-.Pp
-By default, a three-stage bootstrap is employed, and control is
-automatically passed from the boot blocks (bootstrap stages one and
-two) to a separate third-stage bootstrap program,
-.Pa /boot/loader .
-This third stage provides more sophisticated control over the booting
-process than it is possible to achieve in the boot blocks, which are
-constrained by occupying limited fixed space on a given disk or slice.
-.Pp
-However, it is possible to dispense with the third stage altogether,
-either by specifying a kernel name in the boot block parameter
-file,
-.Pa /boot.config ,
-or by hitting a key during a brief pause (while one of the characters
-.Dv - ,
-.Dv \e ,
-.Dv \&| ,
-or
-.Dv /
-is displayed) before
-.Pa /boot/loader
-is invoked. Booting will also be attempted at stage two, if the
-third stage cannot be loaded.
-.Pp
-The remainder of this subsection deals only with the boot blocks.
-At present, documentation of the third stage is chiefly
-available through online help in the
-.Pa /boot/loader
-program itself.
-.Pp
After the boot blocks have been loaded,
you should see a prompt similar to the following:
.Bd -literal
->> FreeBSD/i386 BOOT
-Default: 0:wd(0,a)/kernel
+>> FreeBSD BOOT @ 0x10000: 640/7168 k of memory, internal console
+Boot default: 0:wd(0,a)kernel
+
boot:
.Ed
.Pp
+(You may see some tips printed on the screen too.)
+.Pp
The automatic boot will attempt to load
.Pa /kernel
from partition
@@ -107,12 +83,8 @@ prompt. At this time, the following input will be accepted:
.Bl -tag -width 10x
.It \&?
Give a short listing of the files in the root directory of the default
-boot device, as a hint about available boot files. (A
-.Dv \&?
-may also be specified as the last segment of a path, in which case
-the listing will be of the relevant subdirectory.)
-.Pp
-.It bios_drive:interface(unit,part) filename Op Fl aCcDdghPrsv
+boot device, as a hint about available boot files.
+.It Op bios_drive:interface(unit,part) Op filename Op Fl aCcDdghPrsv
Specify boot file and flags.
.Bl -tag -width 10x -compact
.It bios_drive
@@ -145,12 +117,12 @@ By convention, only partition
.Ql a
contains a bootable image. If sliced disks are used
.Pq Dq fdisk partitions ,
-any slice can be booted from, with the default being the active slice
-or, otherwise, the first FreeBSD slice.
+only the first BSD slice can be used to boot from. The partition
+letter always refers to the first slice.
.It filename
The pathname of the file to boot (relative to the root directory
on the specified partition). Defaults to
-.Pa /kernel .
+.Pa kernel .
Symbolic links are not supported (hard links are).
.It Fl acCdDghPrsv
Boot flags:
@@ -221,26 +193,36 @@ be verbose during device probing (and later).
.El
.Pp
You may put a BIOS drive number, a controller type, a unit number,
-a partition, a kernel file name, and any valid option in
+a partition, a kernel file name and the
+.Fl D,
+.Fl h
+or
+.Fl P
+options in
.Pa /boot.config
-to set defaults. Enter them in one line just as you type at the
+to set defaults. Write them in one line just as you type at the
.Ql boot:
prompt.
.Sh FILES
.Bl -tag -width /kernel.old.config -compact
.It Pa /boot.config
-parameters for the boot blocks (optional)
-.It Pa /boot/loader
-third-stage bootstrap
+parameters for the boot loader (optional)
+.It Pa /boot.help
+help messages
.It Pa /kernel
default kernel
+.It Pa /kernel.config
+parameters for default kernel (optional)
.It Pa /kernel.old
typical non-default kernel (optional)
+.It Pa /kernel.old.config
+parameters for non-default kernel (optional)
+.\" .It Pa /boot
+.\" system bootstrap
.El
.Sh SEE ALSO
.Xr ddb 4 ,
.Xr ttys 5 ,
-.Xr btxld 8 ,
.Xr config 8 ,
.Xr disklabel 8 ,
.Xr halt 8 ,
@@ -252,4 +234,5 @@ The disklabel format used by this version of
is quite
different from that of other architectures.
.Pp
-Some features are not yet documented.
+The boot flags are not very self-explanatory, and the alphabet has
+too few characters to implement every potentially useful boot option.
diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c
index db68d66a470d3..15d7b067909e8 100644
--- a/sbin/restore/dirs.c
+++ b/sbin/restore/dirs.c
@@ -41,7 +41,7 @@
static char sccsid[] = "@(#)dirs.c 8.7 (Berkeley) 5/1/95";
#endif
static const char rcsid[] =
- "$Id: dirs.c,v 1.12 1998/07/28 06:20:05 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include <sys/param.h>
@@ -71,8 +71,8 @@ static const char rcsid[] =
struct inotab {
struct inotab *t_next;
ino_t t_ino;
- int32_t t_seekpt;
- int32_t t_size;
+ long t_seekpt;
+ long t_size;
};
static struct inotab *inotab[HASHSIZE];
@@ -95,8 +95,8 @@ struct modeinfo {
#define DIRBLKSIZ 1024
struct rstdirdesc {
int dd_fd;
- int32_t dd_loc;
- int32_t dd_size;
+ long dd_loc;
+ long dd_size;
char dd_buf[DIRBLKSIZ];
};
diff --git a/sbin/restore/interactive.c b/sbin/restore/interactive.c
index 1d6424db239a3..763ca13a3fee2 100644
--- a/sbin/restore/interactive.c
+++ b/sbin/restore/interactive.c
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)interactive.c 8.5 (Berkeley) 5/1/95";
#endif
static const char rcsid[] =
- "$Id: interactive.c,v 1.6 1998/09/17 20:18:11 imp Exp $";
+ "$Id: interactive.c,v 1.5 1998/07/28 06:20:08 charnier Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -343,8 +343,7 @@ getcmd(curdir, cmd, name, size, ap)
* If no argument, use curdir as the default.
*/
if (*cp == '\0') {
- (void) strncpy(name, curdir, size);
- name[size - 1] = '\0';
+ (void) strcpy(name, curdir);
return;
}
nextarg = cp;
@@ -378,8 +377,7 @@ getnext:
ap->argcnt = ap->glob.gl_pathc;
retnext:
- strncpy(name, ap->glob.gl_pathv[ap->glob.gl_pathc - ap->argcnt], size);
- name[size - 1] = '\0';
+ strcpy(name, ap->glob.gl_pathv[ap->glob.gl_pathc - ap->argcnt]);
if (--ap->argcnt == 0) {
ap->freeglob = 0;
globfree(&ap->glob);
diff --git a/sbin/restore/restore.8 b/sbin/restore/restore.8
index 9c9159614227f..2bf0722058623 100644
--- a/sbin/restore/restore.8
+++ b/sbin/restore/restore.8
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)restore.8 8.4 (Berkeley) 5/1/95
-.\" $Id: restore.8,v 1.14 1998/09/22 10:05:27 roberto Exp $
+.\" $Id: restore.8,v 1.13 1998/07/28 06:20:11 charnier Exp $
.\"
.Dd May 1, 1995
.Dt RESTORE 8
@@ -281,7 +281,7 @@ may be a special device file
like
.Pa /dev/rmt12
(a tape drive),
-.Pa /dev/rda1c
+.Pa /dev/rsd1c
(a disk drive),
an ordinary file,
or
diff --git a/sbin/restore/symtab.c b/sbin/restore/symtab.c
index 795669ca74e6d..f9a5422ab85b3 100644
--- a/sbin/restore/symtab.c
+++ b/sbin/restore/symtab.c
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)symtab.c 8.3 (Berkeley) 4/28/95";
#endif
static const char rcsid[] =
- "$Id: symtab.c,v 1.5 1998/07/28 06:20:13 charnier Exp $";
+ "$Id$";
#endif /* not lint */
/*
@@ -440,13 +440,13 @@ freename(name)
* Useful quantities placed at the end of a dumped symbol table.
*/
struct symtableheader {
- int32_t volno;
- int32_t stringsize;
- int32_t entrytblsize;
+ long volno;
+ long stringsize;
+ long entrytblsize;
time_t dumptime;
time_t dumpdate;
ino_t maxino;
- int32_t ntrec;
+ long ntrec;
};
/*
diff --git a/sbin/restore/tape.c b/sbin/restore/tape.c
index 80a14a864e1a1..03ddd15aa2bc0 100644
--- a/sbin/restore/tape.c
+++ b/sbin/restore/tape.c
@@ -41,7 +41,7 @@
static char sccsid[] = "@(#)tape.c 8.9 (Berkeley) 5/1/95";
#endif
static const char rcsid[] =
- "$Id: tape.c,v 1.14 1998/07/28 18:50:01 imp Exp $";
+ "$Id: tape.c,v 1.13 1998/07/28 06:20:15 charnier Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -1009,32 +1009,32 @@ gethead(buf)
long i;
union {
quad_t qval;
- int32_t val[2];
+ long val[2];
} qcvt;
union u_ospcl {
char dummy[TP_BSIZE];
struct s_ospcl {
- int32_t c_type;
- int32_t c_date;
- int32_t c_ddate;
- int32_t c_volume;
- int32_t c_tapea;
+ long c_type;
+ long c_date;
+ long c_ddate;
+ long c_volume;
+ long c_tapea;
u_short c_inumber;
- int32_t c_magic;
- int32_t c_checksum;
+ long c_magic;
+ long c_checksum;
struct odinode {
unsigned short odi_mode;
u_short odi_nlink;
u_short odi_uid;
u_short odi_gid;
- int32_t odi_size;
- int32_t odi_rdev;
+ long odi_size;
+ long odi_rdev;
char odi_addr[36];
- int32_t odi_atime;
- int32_t odi_mtime;
- int32_t odi_ctime;
+ long odi_atime;
+ long odi_mtime;
+ long odi_ctime;
} c_dinode;
- int32_t c_count;
+ long c_count;
char c_addr[256];
} s_ospcl;
} u_ospcl;
diff --git a/sbin/shutdown/shutdown.8 b/sbin/shutdown/shutdown.8
index 70d6044c8ae16..0d40c1cddbcc0 100644
--- a/sbin/shutdown/shutdown.8
+++ b/sbin/shutdown/shutdown.8
@@ -29,10 +29,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)shutdown.8 8.2 (Berkeley) 4/27/95
-.\" $Id: shutdown.8,v 1.8 1998/12/11 10:35:38 bde Exp $
+.\" @(#)shutdown.8 8.1 (Berkeley) 6/5/93
+.\" $Id$
.\"
-.Dd Dec 11, 1998
+.Dd June 5, 1993
.Dt SHUTDOWN 8
.Os BSD 4
.Sh NAME
@@ -41,7 +41,7 @@
.Sh SYNOPSIS
.Nm shutdown
.Op Fl
-.Op Fl hknpr
+.Op Fl hkrn
.Ar time
.Op Ar warning-message ...
.Sh DESCRIPTION
@@ -61,7 +61,7 @@ when
executes
.Xr halt 8 .
.It Fl k
-Kick everybody off.
+Kick every body off.
The
.Fl k
option
@@ -71,8 +71,6 @@ system multi-user with logins disabled (for all but super-user).
Prevent the normal
.Xr sync 2
before stopping.
-.It Fl p
-The system will turn the power off after shutdown if it can.
.It Fl r
.Nm Shutdown
executes
@@ -110,7 +108,7 @@ and starting at ten hours before shutdown, warning messages are displayed
on the terminals of all users logged in. Five minutes before
shutdown, or immediately if shutdown is in less than 5 minutes,
logins are disabled by creating
-.Pa /var/run/nologin
+.Pa /etc/nologin
and copying the
warning message there. If this file exists when a user attempts to
log in,
@@ -129,13 +127,13 @@ to bring the system down to single-user state (depending on above
options).
The time of the shutdown and the warning message
are placed in
-.Pa /var/run/nologin
+.Pa /etc/nologin
and should be used to
inform the users about when the system will be back up
and why it is going down (or anything else).
.Sh FILES
-.Bl -tag -width /var/run/nologin -compact
-.It Pa /var/run/nologin
+.Bl -tag -width /etc/nologin -compact
+.It Pa /etc/nologin
tells login not to let anyone log in
.El
.Sh SEE ALSO
diff --git a/sbin/shutdown/shutdown.c b/sbin/shutdown/shutdown.c
index 680925fc970af..025a1c68b4232 100644
--- a/sbin/shutdown/shutdown.c
+++ b/sbin/shutdown/shutdown.c
@@ -39,10 +39,10 @@ static const char copyright[] =
#ifndef lint
#if 0
-static char sccsid[] = "@(#)shutdown.c 8.4 (Berkeley) 4/28/95";
+static char sccsid[] = "@(#)shutdown.c 8.2 (Berkeley) 2/16/94";
#endif
static const char rcsid[] =
- "$Id: shutdown.c,v 1.15 1998/12/11 11:04:19 bde Exp $";
+ "$Id$";
#endif /* not lint */
#include <sys/param.h>
@@ -93,7 +93,7 @@ struct interval {
#undef S
static time_t offset, shuttime;
-static int dohalt, dopower, doreboot, killflg, mbuflen;
+static int dohalt, doreboot, killflg, mbuflen;
static char *nosync, *whom, mbuf[BUFSIZ];
void badtime __P((void));
@@ -121,7 +121,7 @@ main(argc, argv)
#endif
nosync = NULL;
readstdin = 0;
- while ((ch = getopt(argc, argv, "-hknpr")) != -1)
+ while ((ch = getopt(argc, argv, "-hknr")) != -1)
switch (ch) {
case '-':
readstdin = 1;
@@ -135,9 +135,6 @@ main(argc, argv)
case 'n':
nosync = "-n";
break;
- case 'p':
- dopower = 1;
- break;
case 'r':
doreboot = 1;
break;
@@ -151,8 +148,8 @@ main(argc, argv)
if (argc < 1)
usage();
- if (doreboot + dohalt + dopower > 1) {
- warnx("incompatible switches -h, -p and -r");
+ if (doreboot && dohalt) {
+ warnx("incompatible switches -h and -r");
usage();
}
getoffset(*argv++);
@@ -164,7 +161,7 @@ main(argc, argv)
break;
if (p != mbuf)
*p++ = ' ';
- memmove(p, *argv, arglen);
+ bcopy(*argv, p, arglen);
p += arglen;
}
*p = '\n';
@@ -329,8 +326,7 @@ die_you_gravy_sucking_pig_dog()
char *empty_environ[] = { NULL };
syslog(LOG_NOTICE, "%s by %s: %s",
- doreboot ? "reboot" : dohalt ? "halt" : dopower ? "power-down" :
- "shutdown", whom, mbuf);
+ doreboot ? "reboot" : dohalt ? "halt" : "shutdown", whom, mbuf);
(void)sleep(2);
(void)printf("\r\nSystem shutdown time has arrived\007\007\r\n");
@@ -343,8 +339,6 @@ die_you_gravy_sucking_pig_dog()
(void)printf("reboot");
else if (dohalt)
(void)printf("halt");
- else if (dopower)
- (void)printf("power-down");
if (nosync)
(void)printf(" no sync");
(void)printf("\nkill -HUP 1\n");
@@ -361,12 +355,6 @@ die_you_gravy_sucking_pig_dog()
syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_HALT);
warn(_PATH_HALT);
}
- else if (dopower) {
- execle(_PATH_HALT, "halt", "-l", "-p", nosync,
- (char *)NULL, empty_environ);
- syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_HALT);
- warn(_PATH_HALT);
- }
(void)kill(1, SIGTERM); /* to single user */
#endif
finish(0);
@@ -480,8 +468,7 @@ void
finish(signo)
int signo;
{
- if (!killflg)
- (void)unlink(_PATH_NOLOGIN);
+ (void)unlink(_PATH_NOLOGIN);
exit(0);
}
@@ -494,7 +481,6 @@ badtime()
void
usage()
{
- fprintf(stderr,
- "usage: shutdown [-] [-hknpr] time [warning-message ...]\n");
+ fprintf(stderr, "usage: shutdown [-hknr] shutdowntime [ message ]\n");
exit(1);
}
diff --git a/sbin/sysctl/Makefile b/sbin/sysctl/Makefile
deleted file mode 100644
index e0c6a2238d457..0000000000000
--- a/sbin/sysctl/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $Id$
-
-PROG= sysctl
-MAN8= sysctl.8
-
-BINDIR= /sbin
-NOSHARED?= yes
-
-.include <bsd.prog.mk>
diff --git a/sbin/sysctl/pathconf.c b/sbin/sysctl/pathconf.c
deleted file mode 100644
index 07f786d820863..0000000000000
--- a/sbin/sysctl/pathconf.c
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)pathconf.c 8.1 (Berkeley) 6/6/93";
-#endif
-static const char rcsid[] =
- "$Id$";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <sys/unistd.h>
-
-#include <err.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#define PC_NAMES { \
- { 0, 0 }, \
- { "link_max", CTLTYPE_INT }, \
- { "max_canon", CTLTYPE_INT }, \
- { "max_input", CTLTYPE_INT }, \
- { "name_max", CTLTYPE_INT }, \
- { "path_max", CTLTYPE_INT }, \
- { "pipe_buf", CTLTYPE_INT }, \
- { "chown_restricted", CTLTYPE_INT }, \
- { "no_trunc", CTLTYPE_INT }, \
- { "vdisable", CTLTYPE_INT }, \
-}
-#define PC_MAXID 10
-
-struct ctlname pcnames[] = PC_NAMES;
-char names[BUFSIZ];
-
-struct list {
- struct ctlname *list;
- int size;
-};
-struct list pclist = { pcnames, PC_MAXID };
-
-int Aflag, aflag, nflag, wflag, stdinflag;
-
-int findname __P((char *, char *, char**, struct list *));
-void listall __P((char *, struct list *));
-void parse __P((char *, char *, int));
-static void usage __P((void));
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- char *path;
- int ch;
-
- while ((ch = getopt(argc, argv, "Aan")) != -1) {
- switch (ch) {
-
- case 'A':
- Aflag = 1;
- break;
-
- case 'a':
- aflag = 1;
- break;
-
- case 'n':
- nflag = 1;
- break;
-
- default:
- usage();
- }
- }
- argc -= optind;
- argv += optind;
-
- if (argc == 0)
- usage();
- path = *argv++;
- if (strcmp(path, "-") == 0)
- stdinflag = 1;
- argc--;
- if (Aflag || aflag) {
- listall(path, &pclist);
- exit(0);
- }
- if (argc == 0)
- usage();
- while (argc-- > 0)
- parse(path, *argv, 1);
- exit(0);
-}
-
-/*
- * List all variables known to the system.
- */
-void
-listall(path, lp)
- char *path;
- struct list *lp;
-{
- int lvl2;
-
- if (lp->list == 0)
- return;
- for (lvl2 = 0; lvl2 < lp->size; lvl2++) {
- if (lp->list[lvl2].ctl_name == 0)
- continue;
- parse(path, lp->list[lvl2].ctl_name, Aflag);
- }
-}
-
-/*
- * Parse a name into an index.
- * Lookup and print out the attribute if it exists.
- */
-void
-parse(pathname, string, flags)
- char *pathname;
- char *string;
- int flags;
-{
- int indx, value;
- char *bufp, buf[BUFSIZ];
-
- bufp = buf;
- snprintf(buf, BUFSIZ, "%s", string);
- if ((indx = findname(string, "top", &bufp, &pclist)) == -1)
- return;
- if (bufp) {
- warnx("name %s in %s is unknown", *bufp, string);
- return;
- }
- if (stdinflag)
- value = fpathconf(0, indx);
- else
- value = pathconf(pathname, indx);
- if (value == -1) {
- if (flags == 0)
- return;
- switch (errno) {
- case EOPNOTSUPP:
- warnx("%s: value is not available", string);
- return;
- case ENOTDIR:
- warnx("%s: specification is incomplete", string);
- return;
- case ENOMEM:
- warnx("%s: type is unknown to this program", string);
- return;
- default:
- warn("%s", string);
- return;
- }
- }
- if (!nflag)
- fprintf(stdout, "%s = ", string);
- fprintf(stdout, "%d\n", value);
-}
-
-/*
- * Scan a list of names searching for a particular name.
- */
-int
-findname(string, level, bufp, namelist)
- char *string;
- char *level;
- char **bufp;
- struct list *namelist;
-{
- char *name;
- int i;
-
- if (namelist->list == 0 || (name = strsep(bufp, ".")) == NULL) {
- warnx("%s: incomplete specification", string);
- return (-1);
- }
- for (i = 0; i < namelist->size; i++)
- if (namelist->list[i].ctl_name != NULL &&
- strcmp(name, namelist->list[i].ctl_name) == 0)
- break;
- if (i == namelist->size) {
- warnx("%s level name %s in %s is invalid", level, name, string);
- return (-1);
- }
- return (i);
-}
-
-static void
-usage()
-{
-
- (void)fprintf(stderr, "%s\n%s\n%s\n",
- "usage: pathname [-n] variable ...",
- " pathname [-n] -a",
- " pathname [-n] -A");
- exit(1);
-}
diff --git a/sbin/sysctl/sysctl.8 b/sbin/sysctl/sysctl.8
deleted file mode 100644
index e959ecd77aff2..0000000000000
--- a/sbin/sysctl/sysctl.8
+++ /dev/null
@@ -1,243 +0,0 @@
-.\" Copyright (c) 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" From: @(#)sysctl.8 8.1 (Berkeley) 6/6/93
-.\" $Id: sysctl.8,v 1.17 1998/09/29 02:01:06 jkoshy Exp $
-.\"
-.Dd September 23, 1994
-.Dt SYSCTL 8
-.Os
-.Sh NAME
-.Nm sysctl
-.Nd get or set kernel state
-.Sh SYNOPSIS
-.Nm sysctl
-.Op Fl bdn
-.Ar name ...
-.Nm sysctl
-.Op Fl bn
-.Fl w
-.Ar name=value ...
-.Nm sysctl
-.Op Fl bdn
-.Fl aAX
-.Sh DESCRIPTION
-The
-.Nm
-utility retrieves kernel state and allows processes with
-appropriate privilege to set kernel state.
-The state to be retrieved or set is described using a
-``Management Information Base'' (``MIB'') style name,
-described as a dotted set of components.
-.Pp
-The following options are available:
-.Bl -tag -width indent
-.It Fl a
-List all the currently available string or integer values.
-.It Fl A
-List all the known MIB names including opaques.
-Those with string or integer values will be printed as with the
-.Fl a
-flag; for the opaque values,
-information about the format and the length is printed in addition the first
-few bytes is dumped in hex.
-.It Fl X
-Same as
-.Fl A
-except the entire value of opaque variables is hexdumped.
-.It Fl n
-Specify that the printing of the field name should be
-suppressed and that only its value should be output.
-This flag is useful for setting shell variables.
-For example, to save the pagesize in variable psize, use:
-.Bd -literal -offset indent -compact
-set psize=`sysctl -n hw.pagesize`
-.Ed
-.It Fl b
-Force the value of the variable(s) to be output in raw, binary
-format. No names are printed and no terminating newlines are output.
-This is mostly useful with a single variable.
-.It Fl d
-Display the description rather than the value of the requested
-variable(s).
-.It Fl w Ar name=value ...
-Set the MIB
-.Ar name
-to the new
-.Ar value .
-If just a MIB style
-.Ar name
-is given,
-the corresponding value is retrieved.
-.El
-.Pp
-The information available from
-.Nm
-consists of integers, strings, and opaques.
-.Nm Sysctl
-only knows about a couple of opaque types, and will resort to hexdumps
-for the rest.
-The opaque information is much more useful if retrieved by special
-purpose programs such as
-.Nm ps ,
-.Nm systat ,
-and
-.Nm netstat .
-.Pp
-The string and integer information is summarized below.
-For a detailed description of these variable see
-.Xr sysctl 3 .
-.Pp
-The changeable column indicates whether a process with appropriate
-privilege can change the value.
-.Bl -column net.inet.ip.forwardingxxxxxx integerxxx
-.It Sy Name Type Changeable
-.It kern.ostype string no
-.It kern.osrelease string no
-.It kern.osrevision integer no
-.It kern.version string no
-.It kern.maxvnodes integer yes
-.It kern.maxproc integer no
-.It kern.maxprocperuid integer yes
-.It kern.maxfiles integer yes
-.It kern.maxfilesperproc integer yes
-.It kern.argmax integer no
-.It kern.securelevel integer raise only
-.It kern.hostname string yes
-.It kern.hostid integer yes
-.It kern.clockrate struct no
-.It kern.posix1version integer no
-.It kern.ngroups integer no
-.It kern.job_control integer no
-.It kern.saved_ids integer no
-.It kern.boottime struct no
-.It kern.domainname string yes
-.It kern.update integer yes
-.It kern.osreldate string no
-.It kern.bootfile string yes
-.It kern.corefile string yes
-.It kern.logsigexit integer yes
-.It vm.loadavg struct no
-.It hw.machine string no
-.It hw.model string no
-.It hw.ncpu integer no
-.It hw.byteorder integer no
-.It hw.physmem integer no
-.It hw.usermem integer no
-.It hw.pagesize integer no
-.It hw.floatingpoint integer no
-.It hw.machine_arch string no
-.It machdep.console_device dev_t no
-.It machdep.adjkerntz integer yes
-.It machdep.disable_rtc_set integer yes
-.It user.cs_path string no
-.It user.bc_base_max integer no
-.It user.bc_dim_max integer no
-.It user.bc_scale_max integer no
-.It user.bc_string_max integer no
-.It user.coll_weights_max integer no
-.It user.expr_nest_max integer no
-.It user.line_max integer no
-.It user.re_dup_max integer no
-.It user.posix2_version integer no
-.It user.posix2_c_bind integer no
-.It user.posix2_c_dev integer no
-.It user.posix2_char_term integer no
-.It user.posix2_fort_dev integer no
-.It user.posix2_fort_run integer no
-.It user.posix2_localedef integer no
-.It user.posix2_sw_dev integer no
-.It user.posix2_upe integer no
-.It user.stream_max integer no
-.It user.tzname_max integer no
-.El
-.Sh EXAMPLES
-For example, to retrieve the maximum number of processes allowed
-in the system, one would use the follow request:
-.Bd -literal -offset indent -compact
-sysctl kern.maxproc
-.Ed
-.Pp
-To set the maximum number of processes allowed
-per uid to 1000, one would use the follow request:
-.Bd -literal -offset indent -compact
-sysctl -w kern.maxprocperuid=1000
-.Ed
-.Pp
-Information about the system clock rate may be obtained with:
-.Bd -literal -offset indent -compact
-sysctl kern.clockrate
-.Ed
-.Pp
-Information about the load average history may be obtained with:
-.Bd -literal -offset indent -compact
-sysctl vm.loadavg
-.Ed
-.Pp
-More variables than these exist, and the best and likely only place
-to search for their deeper meaning is undoubtedly the source where
-they are defined.
-.Sh FILES
-.Bl -tag -width <netinet/icmpXvar.h> -compact
-.It Pa <sys/sysctl.h>
-definitions for top level identifiers, second level kernel and hardware
-identifiers, and user level identifiers
-.It Pa <sys/socket.h>
-definitions for second level network identifiers
-.It Pa <sys/gmon.h>
-definitions for third level profiling identifiers
-.It Pa <vm/vm_param.h>
-definitions for second level virtual memory identifiers
-.It Pa <netinet/in.h>
-definitions for third level Internet identifiers and
-fourth level IP identifiers
-.It Pa <netinet/icmp_var.h>
-definitions for fourth level ICMP identifiers
-.It Pa <netinet/udp_var.h>
-definitions for fourth level UDP identifiers
-.El
-.Sh SEE ALSO
-.Xr sysctl 3
-.Sh BUGS
-.Nm Sysctl
-presently exploits an undocumented interface to the kernel
-sysctl facility to traverse the sysctl tree and to retrieve format
-and name information.
-This correct interface is being thought about for the time being.
-.Sh HISTORY
-.Nm Sysctl
-first appeared in
-.Bx 4.4 .
-.Pp
-In
-.Fx 2.2 ,
-.Nm
-was significantly remodeled.
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
deleted file mode 100644
index f264409d6b3d1..0000000000000
--- a/sbin/sysctl/sysctl.c
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)from: sysctl.c 8.1 (Berkeley) 6/6/93";
-#endif
-static const char rcsid[] =
- "$Id: sysctl.c,v 1.19 1998/11/08 19:27:43 phk Exp $";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/sysctl.h>
-#include <sys/resource.h>
-
-#include <ctype.h>
-#include <err.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-static int Aflag, aflag, bflag, dflag, nflag, wflag, Xflag;
-
-static int oidfmt(int *, int, char *, u_int *);
-static void parse(char *);
-static int show_var(int *, int);
-static int sysctl_all (int *oid, int len);
-static int name2oid(char *, int *);
-
-static void
-usage(void)
-{
-
- (void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n",
- "usage: sysctl [-bdn] variable ...",
- " sysctl [-bn] -w variable=value ...",
- " sysctl [-bdn] -a",
- " sysctl [-bdn] -A",
- " sysctl [-bdn] -X");
- exit(1);
-}
-
-int
-main(int argc, char **argv)
-{
- int ch;
- setbuf(stdout,0);
- setbuf(stderr,0);
-
- while ((ch = getopt(argc, argv, "AabdnwX")) != -1) {
- switch (ch) {
- case 'A': Aflag = 1; break;
- case 'a': aflag = 1; break;
- case 'b': bflag = 1; break;
- case 'd': dflag = 1; break;
- case 'n': nflag = 1; break;
- case 'w': wflag = 1; break;
- case 'X': Xflag = Aflag = 1; break;
- default: usage();
- }
- }
- argc -= optind;
- argv += optind;
-
- if (wflag && (Aflag || aflag || dflag))
- usage();
- if (Aflag || aflag)
- exit (sysctl_all(0, 0));
- if (argc == 0)
- usage();
- while (argc-- > 0)
- parse(*argv++);
- exit(0);
-}
-
-/*
- * Parse a name into a MIB entry.
- * Lookup and print out the MIB entry if it exists.
- * Set a new value if requested.
- */
-static void
-parse(char *string)
-{
- int len, i, j;
- void *newval = 0;
- int intval, newsize = 0;
- quad_t quadval;
- int mib[CTL_MAXNAME];
- char *cp, *bufp, buf[BUFSIZ];
- u_int kind;
-
- bufp = buf;
- snprintf(buf, BUFSIZ, "%s", string);
- if ((cp = strchr(string, '=')) != NULL) {
- if (!wflag)
- errx(2, "must specify -w to set variables");
- *strchr(buf, '=') = '\0';
- *cp++ = '\0';
- while (isspace(*cp))
- cp++;
- newval = cp;
- newsize = strlen(cp);
- } else {
- if (wflag)
- usage();
- }
- len = name2oid(bufp, mib);
-
- if (len < 0)
- errx(1, "unknown oid '%s'", bufp);
-
- if (oidfmt(mib, len, 0, &kind))
- err(1, "couldn't find format of oid '%s'", bufp);
-
- if (!wflag) {
- if ((kind & CTLTYPE) == CTLTYPE_NODE) {
- sysctl_all(mib, len);
- } else {
- i = show_var(mib, len);
- if (!i && !bflag)
- putchar('\n');
- }
- } else {
- if ((kind & CTLTYPE) == CTLTYPE_NODE)
- errx(1, "oid '%s' isn't a leaf node", bufp);
-
- if (!(kind&CTLFLAG_WR))
- errx(1, "oid '%s' is read only", bufp);
-
- switch (kind & CTLTYPE) {
- case CTLTYPE_INT:
- intval = atoi(newval);
- newval = &intval;
- newsize = sizeof intval;
- break;
- break;
- case CTLTYPE_STRING:
- break;
- case CTLTYPE_QUAD:
- break;
- sscanf(newval, "%qd", &quadval);
- newval = &quadval;
- newsize = sizeof quadval;
- break;
- default:
- errx(1, "oid '%s' is type %d,"
- " cannot set that", bufp,
- kind & CTLTYPE);
- }
-
- i = show_var(mib, len);
- if (sysctl(mib, len, 0, 0, newval, newsize) == -1) {
- if (!i && !bflag)
- putchar('\n');
- switch (errno) {
- case EOPNOTSUPP:
- errx(1, "%s: value is not available",
- string);
- case ENOTDIR:
- errx(1, "%s: specification is incomplete",
- string);
- case ENOMEM:
- errx(1, "%s: type is unknown to this program",
- string);
- default:
- warn("%s", string);
- return;
- }
- }
- if (!bflag)
- printf(" -> ");
- i = nflag;
- nflag = 1;
- j = show_var(mib, len);
- if (!j && !bflag)
- putchar('\n');
- nflag = i;
- }
-}
-
-/* These functions will dump out various interesting structures. */
-
-static int
-S_clockinfo(int l2, void *p)
-{
- struct clockinfo *ci = (struct clockinfo*)p;
- if (l2 != sizeof *ci)
- err(1, "S_clockinfo %d != %d", l2, sizeof *ci);
- printf("{ hz = %d, tick = %d, tickadj = %d, profhz = %d, stathz = %d }",
- ci->hz, ci->tick, ci->tickadj, ci->profhz, ci->stathz);
- return (0);
-}
-
-static int
-S_loadavg(int l2, void *p)
-{
- struct loadavg *tv = (struct loadavg*)p;
-
- if (l2 != sizeof *tv)
- err(1, "S_loadavg %d != %d", l2, sizeof *tv);
-
- printf("{ %.2f %.2f %.2f }",
- (double)tv->ldavg[0]/(double)tv->fscale,
- (double)tv->ldavg[1]/(double)tv->fscale,
- (double)tv->ldavg[2]/(double)tv->fscale);
- return (0);
-}
-
-static int
-S_timeval(int l2, void *p)
-{
- struct timeval *tv = (struct timeval*)p;
- time_t tv_sec;
- char *p1, *p2;
-
- if (l2 != sizeof *tv)
- err(1, "S_timeval %d != %d", l2, sizeof *tv);
- printf("{ sec = %ld, usec = %ld } ",
- tv->tv_sec, tv->tv_usec);
- tv_sec = tv->tv_sec;
- p1 = strdup(ctime(&tv_sec));
- for (p2=p1; *p2 ; p2++)
- if (*p2 == '\n')
- *p2 = '\0';
- fputs(p1, stdout);
- return (0);
-}
-
-static int
-T_dev_t(int l2, void *p)
-{
- dev_t *d = (dev_t *)p;
- if (l2 != sizeof *d)
- err(1, "T_dev_T %d != %d", l2, sizeof *d);
- printf("{ major = %d, minor = %d }",
- major(*d), minor(*d));
- return (0);
-}
-
-/*
- * These functions uses a presently undocumented interface to the kernel
- * to walk the tree and get the type so it can print the value.
- * This interface is under work and consideration, and should probably
- * be killed with a big axe by the first person who can find the time.
- * (be aware though, that the proper interface isn't as obvious as it
- * may seem, there are various conflicting requirements.
- */
-
-static int
-name2oid(char *name, int *oidp)
-{
- int oid[2];
- int i;
- size_t j;
-
- oid[0] = 0;
- oid[1] = 3;
-
- j = CTL_MAXNAME * sizeof (int);
- i = sysctl(oid, 2, oidp, &j, name, strlen(name));
- if (i < 0)
- return i;
- j /= sizeof (int);
- return (j);
-}
-
-static int
-oidfmt(int *oid, int len, char *fmt, u_int *kind)
-{
- int qoid[CTL_MAXNAME+2];
- u_char buf[BUFSIZ];
- int i;
- size_t j;
-
- qoid[0] = 0;
- qoid[1] = 4;
- memcpy(qoid + 2, oid, len * sizeof(int));
-
- j = sizeof buf;
- i = sysctl(qoid, len + 2, buf, &j, 0, 0);
- if (i)
- err(1, "sysctl fmt %d %d %d", i, j, errno);
-
- if (kind)
- *kind = *(u_int *)buf;
-
- if (fmt)
- strcpy(fmt, (char *)(buf + sizeof(u_int)));
- return 0;
-}
-
-/*
- * This formats and outputs the value of one variable
- *
- * Returns zero if anything was actually output.
- * Returns one if didn't know what to do with this.
- * Return minus one if we had errors.
- */
-
-static int
-show_var(int *oid, int nlen)
-{
- u_char buf[BUFSIZ], *val, *p;
- char name[BUFSIZ], descr[BUFSIZ], *fmt;
- int qoid[CTL_MAXNAME+2];
- int i;
- size_t j, len;
- u_int kind;
- int (*func)(int, void *) = 0;
-
- qoid[0] = 0;
- memcpy(qoid + 2, oid, nlen * sizeof(int));
-
- qoid[1] = 1;
- j = sizeof name;
- i = sysctl(qoid, nlen + 2, name, &j, 0, 0);
- if (i || !j)
- err(1, "sysctl name %d %d %d", i, j, errno);
-
- if (dflag) {
- qoid[1] = 5;
- j = sizeof descr;
- i = sysctl(qoid, nlen + 2, descr, &j, 0, 0);
- if (i || !j)
- err(1, "sysctl name %d %d %d", i, j, errno);
- if (!nflag)
- printf("%s: ", name);
- printf("%s", descr[0] ? descr : "[no description]");
- return (0);
- }
-
- /* find an estimate of how much we need for this var */
- j = 0;
- i = sysctl(oid, nlen, 0, &j, 0, 0);
- j += j; /* we want to be sure :-) */
-
- val = alloca(j);
- len = j;
- i = sysctl(oid, nlen, val, &len, 0, 0);
- if (i || !len)
- return (1);
-
- if (bflag) {
- fwrite(val, 1, len, stdout);
- return (0);
- }
-
- qoid[1] = 4;
- j = sizeof buf;
- i = sysctl(qoid, nlen + 2, buf, &j, 0, 0);
- if (i || !j)
- err(1, "sysctl fmt %d %d %d", i, j, errno);
-
- kind = *(u_int *)buf;
-
- fmt = (char *)(buf + sizeof(u_int));
-
- p = val;
- switch (*fmt) {
- case 'A':
- if (!nflag)
- printf("%s: ", name);
- printf("%s", p);
- return (0);
-
- case 'I':
- if (!nflag)
- printf("%s: ", name);
- val = "";
- while (len >= sizeof(int)) {
- printf("%s%d", val, *(int *)p);
- val = " ";
- len -= sizeof (int);
- p += sizeof (int);
- }
- return (0);
-
- case 'L':
- if (!nflag)
- printf("%s: ", name);
- printf("%ld", *(long *)p);
- return (0);
-
- case 'P':
- if (!nflag)
- printf("%s: ", name);
- printf("%p", *(void **)p);
- return (0);
-
- case 'T':
- case 'S':
- i = 0;
- if (!strcmp(fmt, "S,clockinfo")) func = S_clockinfo;
- else if (!strcmp(fmt, "S,timeval")) func = S_timeval;
- else if (!strcmp(fmt, "S,loadavg")) func = S_loadavg;
- else if (!strcmp(fmt, "T,dev_t")) func = T_dev_t;
- if (func) {
- if (!nflag)
- printf("%s: ", name);
- return ((*func)(len, p));
- }
- /* FALL THROUGH */
- default:
- if (!Aflag)
- return (1);
- if (!nflag)
- printf("%s: ", name);
- printf("Format:%s Length:%d Dump:0x", fmt, len);
- while (len--) {
- printf("%02x", *p++);
- if (Xflag || p < val+16)
- continue;
- printf("...");
- break;
- }
- return (0);
- }
- return (1);
-}
-
-static int
-sysctl_all (int *oid, int len)
-{
- int name1[22], name2[22];
- int i, j;
- size_t l1, l2;
-
- name1[0] = 0;
- name1[1] = 2;
- l1 = 2;
- if (len) {
- memcpy(name1+2, oid, len*sizeof (int));
- l1 += len;
- } else {
- name1[2] = 1;
- l1++;
- }
- while (1) {
- l2 = sizeof name2;
- j = sysctl(name1, l1, name2, &l2, 0, 0);
- if (j < 0)
- if (errno == ENOENT)
- return 0;
- else
- err(1, "sysctl(getnext) %d %d", j, l2);
-
- l2 /= sizeof (int);
-
- if (l2 < len)
- return 0;
-
- for (i = 0; i < len; i++)
- if (name2[i] != oid[i])
- return 0;
-
- i = show_var(name2, l2);
- if (!i && !bflag)
- putchar('\n');
-
- memcpy(name1+2, name2, l2*sizeof (int));
- l1 = 2 + l2;
- }
-}
diff --git a/sbin/tunefs/tunefs.8 b/sbin/tunefs/tunefs.8
index 9706d4323324b..42ca903df9b95 100644
--- a/sbin/tunefs/tunefs.8
+++ b/sbin/tunefs/tunefs.8
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)tunefs.8 8.2 (Berkeley) 12/11/93
-.\" $Id: tunefs.8,v 1.7 1998/08/03 06:41:20 charnier Exp $
+.\" $Id$
.\"
.Dd December 11, 1993
.Dt TUNEFS 8
@@ -45,10 +45,10 @@
.Op Fl d Ar rotdelay
.Op Fl e Ar maxbpg
.Op Fl m Ar minfree
+.Op Fl p
.Bk -words
.Op Fl n Ar enable | disable
.Op Fl o Ar optimize_preference
-.Op Fl p
.Ek
.Op Ar special | Ar filesystem
.Sh DESCRIPTION
diff --git a/sbin/tunefs/tunefs.c b/sbin/tunefs/tunefs.c
index 8a32cb189d057..682c6e2fc4f32 100644
--- a/sbin/tunefs/tunefs.c
+++ b/sbin/tunefs/tunefs.c
@@ -42,18 +42,16 @@ static const char copyright[] =
static char sccsid[] = "@(#)tunefs.c 8.2 (Berkeley) 4/19/94";
#endif
static const char rcsid[] =
- "$Id: tunefs.c,v 1.6 1998/08/03 06:41:20 charnier Exp $";
+ "$Id$";
#endif /* not lint */
/*
* tunefs: change layout parameters to an existing file system.
*/
#include <sys/param.h>
-#include <sys/mount.h>
#include <sys/stat.h>
#include <ufs/ffs/fs.h>
-#include <ufs/ufs/ufsmount.h>
#include <err.h>
#include <fcntl.h>
@@ -61,7 +59,6 @@ static const char rcsid[] =
#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <unistd.h>
/* the optimization warning string template */
@@ -81,7 +78,6 @@ int bread(daddr_t, char *, int);
void getsb(struct fs *, char *);
void usage __P((void));
void printfs __P((void));
-char *rawname __P((char *, char *));
int
main(argc, argv)
@@ -91,27 +87,17 @@ main(argc, argv)
char *cp, *special, *name, *action;
struct stat st;
int i;
- int Aflag = 0, active = 0;
+ int Aflag = 0;
struct fstab *fs;
char *chg[2], device[MAXPATHLEN];
- struct ufs_args args;
- struct statfs stfs;
argc--, argv++;
if (argc < 2)
usage();
special = argv[argc - 1];
fs = getfsfile(special);
- if (fs) {
- if (statfs(special, &stfs) == 0) {
- if ((stfs.f_flags & MNT_RDONLY) == 0) {
- errx(1, "cannot work on read-write mounted file system");
- }
- active = 1;
- special = rawname(fs->fs_spec, device);
- } else
- special = fs->fs_spec;
- }
+ if (fs)
+ special = fs->fs_spec;
again:
if (stat(special, &st) < 0) {
if (*special != '/') {
@@ -259,13 +245,6 @@ again:
bwrite(fsbtodb(&sblock, cgsblock(&sblock, i)),
(char *)&sblock, SBSIZE);
close(fi);
- if (active) {
- bzero(&args, sizeof(args));
- if (mount("ufs", fs->fs_file,
- stfs.f_flags | MNT_UPDATE | MNT_RELOAD, &args) < 0)
- err(9, "%s: reload", special);
- warnx("file system reloaded");
- }
exit(0);
}
@@ -348,25 +327,3 @@ bread(bno, buf, cnt)
}
return (0);
}
-
-char *
-rawname(special, pathbuf)
- char *special;
- char *pathbuf;
-{
- char *p;
- int n;
-
- p = strrchr(special, '/');
- if (p) {
- n = ++p - special;
- bcopy(special, pathbuf, n);
- } else {
- strcpy(pathbuf, _PATH_DEV);
- n = strlen(pathbuf);
- p = special;
- }
- pathbuf[n++] = 'r';
- strcpy(pathbuf + n, p);
- return pathbuf;
-}
diff --git a/sbin/vinum/Makefile b/sbin/vinum/Makefile
index 1c3e2edbdd823..7d0a0c285c932 100644
--- a/sbin/vinum/Makefile
+++ b/sbin/vinum/Makefile
@@ -1,15 +1,23 @@
-# $Id: Makefile,v 1.5 1999/01/13 23:05:26 grog Exp $
-
PROG= vinum
-SRCS= v.c list.c vinumparser.c vinumutil.c vext.h commands.c
+SRCS= v.c list.c parser.c util.c vext.h commands.c
MAN8= vinum.8
-CFLAGS+= -I${.CURDIR}/../../sys -g -Wall -DVINUMDEBUG
-DPADD= ${LIBUTIL} ${LIBREADLINE} ${LIBTERMCAP}
-LDADD= -lutil -lreadline -ltermcap
+CFLAGS= -I${.CURDIR}/../../lkm/vinum -g -Wall -DDEBUG -DRAID5
+
+LDADD+= -lutil -lreadline -ltermcap
+# DPADD+= ${LIBKVM}
BINGRP= kmem
-BINMODE= 555
+BINMODE= 2555
+
+parser.c:
+ rm -f $@
+ ln -s ${.CURDIR}/../../lkm/vinum/$@ .
+
+util.c: statetexts.h
+ rm -f $@
+ ln -s ${.CURDIR}/../../lkm/vinum/$@ .
-.PATH: ${.CURDIR}/../../sys/dev/vinum
+statetexts.h:
+ (cd ${.CURDIR}/../../lkm/vinum; make $@)
.include <bsd.prog.mk>
diff --git a/sbin/vinum/commands.c b/sbin/vinum/commands.c
index 6d6dcacedfc9c..6554d3307a851 100644
--- a/sbin/vinum/commands.c
+++ b/sbin/vinum/commands.c
@@ -36,7 +36,7 @@
*
*/
-/* $Id: commands.c,v 1.5 1999/01/18 03:36:32 grog Exp grog $ */
+/* $Id: commands.c,v 1.1 1998/08/19 08:06:57 grog Exp grog $ */
#include <ctype.h>
#include <errno.h>
@@ -51,7 +51,7 @@
#include <syslog.h>
#include <unistd.h>
#include <sys/ioctl.h>
-#include <dev/vinum/vinumhdr.h>
+#include "vinumhdr.h"
#include "vext.h"
#include <sys/types.h>
#include <sys/wait.h>
@@ -122,21 +122,16 @@ vinum_read(int argc, char *argv[], char *arg0[])
int error;
char buffer[BUFSIZE]; /* read config file in here */
struct _ioctl_reply *reply;
- int i;
-
reply = (struct _ioctl_reply *) &buffer;
- if (argc < 1) { /* wrong arg count */
- fprintf(stderr, "Usage: read drive [drive ...]\n");
+
+ if (argc != 1) { /* wrong arg count */
+ fprintf(stderr, "Expecting 1 parameter, not %d\n", argc);
return;
}
strcpy(buffer, "read ");
- for (i = 0; i < argc; i++) { /* each drive name */
- strcat(buffer, argv[i]);
- strcat(buffer, " ");
- }
-
+ strcat(buffer, argv[0]);
if (ioctl(superdev, VINUM_STARTCONFIG, NULL)) { /* can't get config? */
- fprintf(stderr, "Can't configure: %s (%d)\n", strerror(errno), errno);
+ printf("Can't configure: %s (%d)\n", strerror(errno), errno);
return;
}
ioctl(superdev, VINUM_CREATE, &buffer);
@@ -217,7 +212,7 @@ vinum_drive(int argc, char *argv[], char *arg0[])
fprintf(stdout, "** %d %s: %s\n", file_line, reply->msg, strerror(reply->error));
}
-#ifdef VINUMDEBUG
+#ifdef DEBUG
void
vinum_debug(int argc, char *argv[], char *arg0[])
{
@@ -254,7 +249,7 @@ vinum_rm(int argc, char *argv[], char *arg0[])
struct vinum_ioctl_msg *message = (struct vinum_ioctl_msg *) &reply;
if (argc == 0) /* start everything */
- fprintf(stderr, "Usage: rm object [object...]\n");
+ fprintf(stderr, "what do you want to remove?\n");
else { /* start specified objects */
int index;
enum objecttype type;
@@ -306,12 +301,10 @@ vinum_resetconfig(int argc, char *argv[], char *arg0[])
printf("\b Vinum configuration obliterated\n");
system("rm -rf " VINUM_DIR "/" "*"); /* remove the old /dev/vinum */
syslog(LOG_NOTICE | LOG_KERN, "configuration obliterated");
- start_daemon(); /* then restart the daemon */
}
}
}
-/* Initialize a plex */
void
vinum_init(int argc, char *argv[], char *arg0[])
{
@@ -348,77 +341,89 @@ vinum_init(int argc, char *argv[], char *arg0[])
return;
}
}
- pid = fork();
- if (pid == 0) { /* we're the child */
- int failed = 0; /* set if a child dies badly */
- int sdfh; /* and for subdisk */
- char zeros[PLEXINITSIZE];
- int count; /* write count */
- long long offset; /* offset in subdisk */
- long long sdsize; /* size of subdisk */
-
- bzero(zeros, sizeof(zeros));
- openlog("vinum", LOG_CONS | LOG_PERROR | LOG_PID, LOG_KERN);
- for (sdno = 0; sdno < plex.subdisks; sdno++) { /* initialize each subdisk */
+ message->index = plexno; /* pass object number */
+ message->type = plex_object; /* and type of object */
+ message->state = object_initializing;
+ message->force = 1; /* insist */
+ ioctl(superdev, VINUM_SETSTATE, message);
+ if (reply.error) {
+ syslog(LOG_ERR | LOG_KERN,
+ "can't initialize %s: %s",
+ plex.name,
+ reply.msg[0] ? reply.msg : strerror(reply.error));
+ } else {
+ pid = fork();
+ if (pid == 0) { /* we're the child */
+ int failed = 0; /* set if a child dies badly */
+ int sdfh; /* and for subdisk */
+ char zeros[PLEXINITSIZE];
+ int count; /* write count */
+ long long offset; /* offset in subdisk */
+ long long sdsize; /* size of subdisk */
+
+ bzero(zeros, sizeof(zeros));
+ openlog("vinum", LOG_CONS | LOG_PERROR | LOG_PID, LOG_KERN);
+ for (sdno = 0; sdno < plex.subdisks; sdno++) { /* initialize each subdisk */
/* We already have the plex data in global
- * plex from the call to find_object */
- pid = fork(); /* into the background with you */
- if (pid == 0) { /* I'm the child */
- get_plex_sd_info(&sd, plexno, sdno);
- sdsize = sd.sectors * DEV_BSIZE; /* size of subdisk in bytes */
- sprintf(filename, VINUM_DIR "/rsd/%s", sd.name);
- setproctitle("initializing %s", filename); /* show what we're doing */
- syslog(LOG_INFO | LOG_KERN, "initializing subdisk %s", filename);
- if ((sdfh = open(filename, O_RDWR, S_IRWXU)) < 0) { /* no go */
- syslog(LOG_ERR | LOG_KERN,
- "can't open subdisk %s: %s",
- filename,
- strerror(errno));
- exit(1);
- }
- for (offset = 0; offset < sdsize; offset += count) {
- count = write(sdfh, zeros, PLEXINITSIZE); /* write a block */
- if (count < 0) {
+ * plex from the call to find_object */
+ pid = fork(); /* into the background with you */
+ if (pid == 0) { /* I'm the child */
+ get_plex_sd_info(&sd, plexno, sdno);
+ sdsize = sd.sectors * DEV_BSIZE; /* size of subdisk in bytes */
+ sprintf(filename, VINUM_DIR "/sd/%s", sd.name);
+ setproctitle("initializing %s", filename); /* show what we're doing */
+ syslog(LOG_INFO | LOG_KERN, "initializing subdisk %s\n", filename);
+ if ((sdfh = open(filename, O_RDWR, S_IRWXU)) < 0) { /* no go */
syslog(LOG_ERR | LOG_KERN,
- "can't write subdisk %s: %s",
+ "can't open subdisk %s: %s\n",
filename,
strerror(errno));
exit(1);
}
+ for (offset = 0; offset < sdsize; offset += count) {
+ count = write(sdfh, zeros, PLEXINITSIZE); /* write a block */
+ if (count < 0) {
+ syslog(LOG_ERR | LOG_KERN,
+ "can't write subdisk %s: %s\n",
+ filename,
+ strerror(errno));
+ exit(1);
+ }
/* XXX Grrrr why doesn't this thing recognize EOF? */
- else if (count == 0)
- break;
+ else if (count == 0)
+ break;
+ }
+ syslog(LOG_INFO | LOG_KERN, "subdisk %s initialized\n", filename);
+ exit(0);
+ } else if (pid < 0) /* failure */
+ printf("couldn't fork for subdisk %d: %s", sdno, strerror(errno));
+ }
+ /* Now wait for them to complete */
+ for (sdno = 0; sdno < plex.subdisks; sdno++) {
+ int status;
+ pid = wait(&status);
+ if (WEXITSTATUS(status) != 0) { /* oh, oh */
+ printf("child %d exited with status 0x%x\n", pid, WEXITSTATUS(status));
+ failed++;
}
- syslog(LOG_INFO | LOG_KERN, "subdisk %s initialized", filename);
- /* Bring the subdisk up */
- message->index = sd.sdno; /* pass object number */
- message->type = sd_object; /* and type of object */
- message->state = object_up;
- message->force = 1; /* insist */
- ioctl(superdev, VINUM_SETSTATE, message);
- exit(0);
- } else if (pid < 0) /* failure */
- printf("couldn't fork for subdisk %d: %s", sdno, strerror(errno));
- }
- /* Now wait for them to complete */
- for (sdno = 0; sdno < plex.subdisks; sdno++) {
- int status;
- pid = wait(&status);
- if (WEXITSTATUS(status) != 0) { /* oh, oh */
- printf("child %d exited with status 0x%x\n", pid, WEXITSTATUS(status));
- failed++;
}
- }
- if (failed == 0) {
- syslog(LOG_INFO | LOG_KERN, "plex %s initialized", plex.name);
+ if (failed == 0) {
+ for (sdno = 0; sdno < plex.subdisks; sdno++) { /* bring the subdisks up */
+ get_plex_sd_info(&sd, plexno, sdno); /* get the SD info again */
+ message->index = sd.sdno; /* pass object number */
+ message->type = sd_object; /* and type of object */
+ message->state = object_up;
+ message->force = 1; /* insist */
+ ioctl(superdev, VINUM_SETSTATE, message);
+ }
+ syslog(LOG_INFO | LOG_KERN, "plex %s initialized\n", plex.name);
+ } else
+ syslog(LOG_ERR | LOG_KERN, "couldn't initialize plex %s, %d processes died\n",
+ plex.name,
+ failed);
+ exit(0);
} else
- syslog(LOG_ERR | LOG_KERN, "couldn't initialize plex %s, %d processes died",
- plex.name,
- failed);
- exit(0);
- } else {
- close(plexfh); /* we don't need this any more */
- sleep(1); /* give them a chance to print */
+ close(plexfh); /* we don't need this any more */
}
}
}
@@ -445,11 +450,59 @@ vinum_start(int argc, char *argv[], char *arg0[])
message->index = object; /* pass object number */
message->type = type; /* and type of object */
message->state = object_up;
- message->force = 0; /* don't force it, use a larger hammer */
+ /* XXX Kludge until we get the kernelland
+ * config stuff rewritten:
+ * Take all subdisks down, then up. */
+ if (message->type == plex_object) { /* it's a plex */
+ struct plex plex;
+ struct sd sd;
+ int sdno;
+ struct _ioctl_reply sreply;
+ struct vinum_ioctl_msg *smessage = (struct vinum_ioctl_msg *) &sreply;
+
+ get_plex_info(&plex, message->index);
+ if (plex.state != plex_up) {
+ /* And when they were down, they were down */
+ for (sdno = 0; sdno < plex.subdisks; sdno++) {
+ get_plex_sd_info(&sd, plex.plexno, sdno);
+ smessage->type = sd_object;
+ smessage->state = object_down;
+ smessage->force = 1;
+ smessage->index = sd.sdno;
+ ioctl(superdev, VINUM_SETSTATE, smessage);
+ if (sreply.error != 0) {
+ fprintf(stderr,
+ "Can't stop %s: %s (%d)\n",
+ sd.name,
+ sreply.msg[0] ? sreply.msg : strerror(sreply.error),
+ sreply.error);
+ }
+ }
+
+ /* And when they were up, they were up */
+ for (sdno = 0; sdno < plex.subdisks; sdno++) {
+ get_plex_sd_info(&sd, plex.plexno, sdno);
+ smessage->type = sd_object;
+ smessage->state = object_up;
+ smessage->force = 1;
+ smessage->index = sd.sdno;
+ ioctl(superdev, VINUM_SETSTATE, smessage);
+ if (sreply.error != 0) {
+ fprintf(stderr,
+ "Can't stop %s: %s (%d)\n",
+ sd.name,
+ sreply.msg[0] ? sreply.msg : strerror(sreply.error),
+ sreply.error);
+ }
+ }
+ }
+ }
+ /* XXX End kludge until we get the kernelland
+ * config stuff rewritten */
ioctl(superdev, VINUM_SETSTATE, message);
if (reply.error != 0) {
if ((reply.error == EAGAIN) /* we're reviving */
- &&(type == sd_object))
+ &&(type == plex_object))
continue_revive(object);
else
fprintf(stderr,
@@ -674,7 +727,7 @@ vinum_attach(int argc, char *argv[], char *argv0[])
struct _ioctl_reply *reply = (struct _ioctl_reply *) &msg;
const char *objname = argv[0];
const char *supername = argv[1];
- int sdno = -1;
+ int sdno;
int plexno = -1;
char newname[MAXNAME + 8];
int rename = 0; /* set if we want to rename the object */
@@ -718,7 +771,6 @@ vinum_attach(int argc, char *argv[], char *argv0[])
fprintf(stderr, "Can't attach subdisks to a %s plex\n", plex_org(plex.organization));
return;
}
- sdno = msg.index; /* note the subdisk number for later */
break;
case plex_object:
@@ -726,6 +778,7 @@ vinum_attach(int argc, char *argv[], char *argv0[])
fprintf(stderr, "%s can only be attached to a volume\n", objname);
return;
}
+ plexno = msg.index; /* note the plex number, we'll need it again */
break;
case volume_object:
@@ -741,7 +794,7 @@ vinum_attach(int argc, char *argv[], char *argv0[])
ioctl(superdev, VINUM_ATTACH, &msg);
if (reply->error != 0) {
if (reply->error == EAGAIN) /* reviving */
- continue_revive(sdno); /* continue the revive */
+ continue_revive(plexno); /* continue the revive */
else
fprintf(stderr,
"Can't attach %s to %s: %s (%d)\n",
@@ -975,92 +1028,3 @@ vinum_replace(int argc, char *argv[], char *argv0[])
{
fprintf(stderr, "replace function not implemented yet\n");
}
-
-/* Primitive help function */
-void
-vinum_help(int argc, char *argv[], char *argv0[])
-{
- char commands[] =
- {
- "COMMANDS\n"
- " create description-file\n"
- " Create a volume as described in description-file\n"
- " attach plex volume [rename]\n"
- " attach subdisk plex [offset] [rename]\n"
- " Attach a plex to a volume, or a subdisk to a plex.\n"
- " debug\n"
- " Cause the volume manager to enter the kernel debugger.\n"
- " detach [plex | subdisk]\n"
- " Detach a plex or subdisk from the volume or plex to which it is at-\n"
- " tached.\n"
- " info [-v]\n"
- " List information about volume manager state.\n"
- " init [-v]\n"
- " Initialize a plex by writing zeroes to all its subdisks.\n"
- " label volume\n"
- " Create a volume label\n"
- " list [-r] [-s] [-v] [-V] [volume | plex | subdisk]\n"
- " List information about specified objects\n"
- " l [-r] [-s] [-v] [-V] [volume | plex | subdisk]\n"
- " List information about specified objects (alternative to\n"
- " list command)\n"
- " ld [-r] [-s] [-v] [-V] [volume]\n"
- " List information about drives\n"
- " ls [-r] [-s] [-v] [-V] [subdisk]\n"
- " List information about subdisks\n"
- " lp [-r] [-s] [-v] [-V] [plex]\n"
- " List information about plexes\n"
- " lv [-r] [-s] [-v] [-V] [volume]\n"
- " List information about volumes\n"
- " makedev\n"
- " Remake the device nodes in /dev/vinum.\n"
- " read disk-partition\n"
- " Read the vinum configuration from the specified disk partition.\n"
- " rename [-r] [drive | subdisk | plex | volume] newname\n"
- " Change the name of the specified object.\n"
- " replace [subdisk | plex] newobject\n"
- " Replace the object with an identical other object. XXX not im-\n"
- " plemented yet.\n"
- " resetconfig\n"
- " Reset the complete vinum configuration.\n"
- " resetstats [-r] [volume | plex | subdisk]\n"
- " Reset statistisc counters for the specified objects, or for all\n"
- " objects if none are specified.\n"
- " rm [-f] [-r] volume | plex | subdisk\n"
- " Remove an object\n"
- " setdaemon options\n"
- " set the daemon options\n"
- " start [volume | plex | subdisk]\n"
- " Allow the system to access the objects\n"
- " stop [-f] [volume | plex | subdisk]\n"
- " Terminate access the objects\n"
- };
- puts(commands);
-}
-
-/* Set daemon options.
- * XXX quick and dirty: use a bitmap, which requires
- * knowing which bit does what. FIXME */
-void
-vinum_setdaemon(int argc, char *argv[], char *argv0[])
-{
- int options;
-
- switch (argc) {
- case 0:
- if (ioctl(superdev, VINUM_GETDAEMON, &options) < 0)
- fprintf(stderr, "Can't set daemon options: %s (%d)\n", strerror(errno), errno);
- else
- printf("Options mask: %d\n", options);
- break;
-
- case 1:
- options = atoi(argv[0]);
- if (ioctl(superdev, VINUM_SETDAEMON, &options) < 0)
- fprintf(stderr, "Can't set daemon options: %s (%d)\n", strerror(errno), errno);
- break;
-
- default:
- fprintf(stderr, "Usage: \tsetdaemon [<bitmask>]\n");
- }
-}
diff --git a/sbin/vinum/list.c b/sbin/vinum/list.c
index 94f117cfbf605..40807480fff75 100644
--- a/sbin/vinum/list.c
+++ b/sbin/vinum/list.c
@@ -35,7 +35,7 @@
* otherwise) arising in any way out of the use of this software, even if
* advised of the possibility of such damage.
*
- * $Id: list.c,v 1.17 1999/01/17 02:58:44 grog Exp grog $
+ * $Id: list.c,v 1.12 1998/08/10 05:15:06 grog Exp grog $
*/
#include <ctype.h>
@@ -50,9 +50,9 @@
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/utsname.h>
-#include <dev/vinum/vinumhdr.h>
+#include "vinumhdr.h"
#include "vext.h"
-#include <dev/vinum/request.h>
+
/* Take a size in sectors and return a pointer to a
* string which represents the size best.
* If lj is != 0, return left justified, otherwise
@@ -124,21 +124,17 @@ vinum_li(int object, enum objecttype type)
void
vinum_ldi(int driveno, int recurse)
{
- time_t t; /* because Bruce says so */
-
get_drive_info(&drive, driveno);
if (drive.state != drive_unallocated) {
if (verbose) {
printf("Drive %s:\tDevice %s\n",
drive.label.name,
drive.devicename);
- t = drive.label.date_of_birth.tv_sec;
printf("\t\tCreated on %s at %s",
drive.label.sysname,
- ctime(&t));
- t = drive.label.last_update.tv_sec;
+ ctime(&drive.label.date_of_birth.tv_sec));
printf("\t\tConfig last updated %s", /* care: \n at end */
- ctime(&t));
+ ctime(&drive.label.last_update.tv_sec));
printf("\t\tSize: %16qd bytes (%qd MB)\n\t\tUsed: %16qd bytes (%qd MB)\n"
"\t\tAvailable: %11qd bytes (%d MB)\n",
drive.label.drive_size, /* bytes used */
@@ -350,6 +346,55 @@ vinum_lpi(int plexno, int recurse)
get_volume_info(&vol, plex.volno);
printf("\t\tPart of volume %s\n", vol.name);
}
+ if (plex.state == plex_reviving) {
+ printf("\t\tRevive pointer:\t\t%s\n",
+ roughlength(plex.revived << DEV_BSHIFT, 0));
+ printf("\t\tRevive blocksize:\t%s\n"
+ "\t\tRevive interval:\t%10d seconds\n",
+ roughlength(plex.revive_blocksize << DEV_BSHIFT, 0),
+ plex.revive_interval);
+ }
+ if (Verbose) { /* show the unmapped and defective parts */
+ int re; /* freelist entry */
+ struct plexregion region;
+ struct rerq { /* request to pass to ioctl */
+ int plexno; /* plex for the request */
+ int re; /* region */
+ } *rerq = (struct rerq *) &region;
+
+ if (plex.unmapped_regions) {
+ printf("\t\tPlex contains %d unmapped regions:\n\t\t Offset\t Size\n",
+ plex.unmapped_regions);
+ for (re = 0; re < plex.unmapped_regions; re++) {
+ rerq->plexno = plex.plexno;
+ rerq->re = re;
+ if (ioctl(superdev, VINUM_GETUNMAPPED, &region) < 0) {
+ fprintf(stderr,
+ "Can't get unmapped region %d: %s\n",
+ re,
+ strerror(errno));
+ longjmp(command_fail, -1);
+ }
+ printf("\t\t%9qd\t%9qd\n", region.offset, region.length);
+ }
+ }
+ if (plex.defective_regions) {
+ printf("\t\tPlex contains %d defective regions:\n\t\t Offset\t Size\n",
+ plex.defective_regions);
+ for (re = 0; re < plex.defective_regions; re++) {
+ rerq->plexno = plex.plexno;
+ rerq->re = re;
+ if (ioctl(superdev, VINUM_GETDEFECTIVE, &region) < 0) {
+ fprintf(stderr,
+ "Can't get defective region %d: %s\n",
+ re,
+ strerror(errno));
+ longjmp(command_fail, -1);
+ }
+ printf("\t\t%9qd\t%9qd\n", region.offset, region.length);
+ }
+ }
+ }
} else {
char *org = ""; /* organization */
@@ -388,15 +433,12 @@ vinum_lpi(int plexno, int recurse)
if (plex.writes != 0)
printf("\t\tAverage write:\t%16qd bytes\n",
plex.bytes_written / plex.writes);
- if (((plex.reads + plex.writes) > 0)
- && ((plex.organization == plex_striped)
- || (plex.organization == plex_raid5)))
- printf("\t\tMultiblock:\t%16qd (%d%%)\n"
- "\t\tMultistripe:\t%16qd (%d%%)\n",
+ if ((plex.organization == plex_striped)
+ || (plex.organization == plex_raid5))
+ printf("\t\tMultiblock:\t%16qd\n"
+ "\t\tMultistripe:\t%16qd\n",
plex.multiblock,
- (int) (plex.multiblock * 100 / (plex.reads + plex.writes)),
- plex.multistripe,
- (int) (plex.multistripe * 100 / (plex.reads + plex.writes)));
+ plex.multistripe);
}
if (plex.subdisks > 0) {
int sdno;
@@ -465,16 +507,10 @@ vinum_lsi(int sdno, int recurse)
if (sd.plexno >= 0) {
get_plex_info(&plex, sd.plexno);
printf("\t\tPlex %s", plex.name);
- printf(" at offset %qd\n", (long long) sd.plexoffset * DEV_BSIZE);
- }
- if (sd.state == sd_reviving) {
- printf("\t\tRevive pointer:\t\t%s (%d%%)\n",
- roughlength(sd.revived << DEV_BSHIFT, 0),
- (int) (((u_int64_t) (sd.revived * 100)) / sd.sectors));
- printf("\t\tRevive blocksize:\t%s\n"
- "\t\tRevive interval:\t%10d seconds\n",
- roughlength(sd.revive_blocksize, 0),
- sd.revive_interval);
+ if (plex.organization == plex_concat)
+ printf(" at offset %qd\n", (long long) sd.plexoffset * DEV_BSIZE);
+ else
+ printf("\n");
}
} else {
printf("S %-21s State: %s\tPO: %s ",
@@ -569,29 +605,12 @@ listconfig()
vinum_ls(0, NULL, NULL);
}
-/* Convert a timeval to Tue Oct 13 13:54:14.0434324
- * Return pointer to text */
-char *
-timetext(struct timeval *time)
-{
- static char text[30];
- time_t t; /* to keep Bruce happy */
-
- t = time->tv_sec;
- strcpy(text, ctime(&t)); /* to the second */
- sprintf(&text[19], ".%06ld", time->tv_usec); /* and the microseconds */
- return &text[11];
-}
-
void
vinum_info(int argc, char *argv[], char *argv0[])
{
struct meminfo meminfo;
struct mc malloced;
int i;
-#if VINUMDEBUG
- struct rqinfo rq;
-#endif
if (ioctl(superdev, VINUM_GETCONFIG, &vinum_conf) < 0) {
perror("Can't get vinum config");
@@ -608,7 +627,7 @@ vinum_info(int argc, char *argv[], char *argv0[])
meminfo.highwater,
(int) meminfo.malloced);
- if (verbose && (!Verbose))
+ if (Verbose)
for (i = 0; i < meminfo.mallocs; i++) {
malloced.seq = i;
if (ioctl(superdev, VINUM_MALLOCINFO, &malloced) < 0) {
@@ -625,97 +644,6 @@ vinum_info(int argc, char *argv[], char *argv0[])
malloced.line,
(char *) &malloced.file);
}
-#if VINUMDEBUG
- if (Verbose) {
- printf("\nTime\t\t Event\t Buf\tDev\tOffset\t\tBytes\tSD\tSDoff\tDoffset\tGoffset\n\n");
- for (i = RQINFO_SIZE - 1; i >= 0; i--) { /* go through the request list in order */
- *((int *) &rq) = i;
- if (ioctl(superdev, VINUM_RQINFO, &rq) < 0) {
- perror("Can't get information");
- return;
- }
- switch (rq.type) {
- case loginfo_unused: /* never been used */
- break;
-
- case loginfo_user_bp: /* this is the bp when strategy is called */
- printf("%s 1VS %s %p\t0x%x\t0x%-9x\t%ld\n",
- timetext(&rq.timestamp),
- rq.info.b.b_flags & B_READ ? "Read " : "Write",
- rq.bp,
- rq.info.b.b_dev,
- rq.info.b.b_blkno,
- rq.info.b.b_bcount);
- break;
-
- case loginfo_user_bpl: /* and this is the bp at launch time */
- printf("%s 2LR %s %p\t0x%x\t0x%-9x\t%ld\n",
- timetext(&rq.timestamp),
- rq.info.b.b_flags & B_READ ? "Read " : "Write",
- rq.bp,
- rq.info.b.b_dev,
- rq.info.b.b_blkno,
- rq.info.b.b_bcount);
- break;
-
- case loginfo_rqe: /* user RQE */
- printf("%s 3RQ %s %p\t0x%x\t0x%-9x\t%ld\t%d\t%x\t%x\t%x\n",
- timetext(&rq.timestamp),
- rq.info.rqe.b.b_flags & B_READ ? "Read " : "Write",
- rq.bp,
- rq.info.rqe.b.b_dev,
- rq.info.rqe.b.b_blkno,
- rq.info.rqe.b.b_bcount,
- rq.info.rqe.sdno,
- rq.info.rqe.sdoffset,
- rq.info.rqe.dataoffset,
- rq.info.rqe.groupoffset);
- break;
-
- case loginfo_iodone: /* iodone called */
- printf("%s 4DN %s %p\t0x%x\t0x%-9x\t%ld\t%d\t%x\t%x\t%x\n",
- timetext(&rq.timestamp),
- rq.info.rqe.b.b_flags & B_READ ? "Read " : "Write",
- rq.bp,
- rq.info.rqe.b.b_dev,
- rq.info.rqe.b.b_blkno,
- rq.info.rqe.b.b_bcount,
- rq.info.rqe.sdno,
- rq.info.rqe.sdoffset,
- rq.info.rqe.dataoffset,
- rq.info.rqe.groupoffset);
- break;
-
- case loginfo_raid5_data: /* RAID-5 write data block */
- printf("%s 5RD %s %p\t0x%x\t0x%-9x\t%ld\t%d\t%x\t%x\t%x\n",
- timetext(&rq.timestamp),
- rq.info.rqe.b.b_flags & B_READ ? "Read " : "Write",
- rq.bp,
- rq.info.rqe.b.b_dev,
- rq.info.rqe.b.b_blkno,
- rq.info.rqe.b.b_bcount,
- rq.info.rqe.sdno,
- rq.info.rqe.sdoffset,
- rq.info.rqe.dataoffset,
- rq.info.rqe.groupoffset);
- break;
-
- case loginfo_raid5_parity: /* RAID-5 write parity block */
- printf("%s 6RP %s %p\t0x%x\t0x%-9x\t%ld\t%d\t%x\t%x\t%x\n",
- timetext(&rq.timestamp),
- rq.info.rqe.b.b_flags & B_READ ? "Read " : "Write",
- rq.bp,
- rq.info.rqe.b.b_dev,
- rq.info.rqe.b.b_blkno,
- rq.info.rqe.b.b_bcount,
- rq.info.rqe.sdno,
- rq.info.rqe.sdoffset,
- rq.info.rqe.dataoffset,
- rq.info.rqe.groupoffset);
- }
- }
- }
-#endif
}
/* Print config file to a file. This is a userland version
@@ -781,7 +709,7 @@ vinum_printconfig(int argc, char *argv[], char *argv0[])
plex_state(plex.state),
plex_org(plex.organization));
if ((plex.organization == plex_striped)
- || (plex.organization == plex_raid5)) {
+ ) {
fprintf(of, "%db ", (int) plex.stripesize);
}
if (plex.volno >= 0) { /* we have a volume */
diff --git a/sbin/vinum/v.c b/sbin/vinum/v.c
index d9a11f24f90d6..8ae420d784daf 100644
--- a/sbin/vinum/v.c
+++ b/sbin/vinum/v.c
@@ -36,7 +36,7 @@
*
*/
-/* $Id: v.c,v 1.24 1999/01/17 02:53:38 grog Exp grog $ */
+/* $Id: v.c,v 1.22 1998/08/11 07:44:54 grog Exp grog $ */
#include <ctype.h>
#include <errno.h>
@@ -51,15 +51,12 @@
#include <syslog.h>
#include <unistd.h>
#include <sys/ioctl.h>
-#include <dev/vinum/vinumhdr.h>
+#include "vinumhdr.h"
#include "vext.h"
#include <sys/types.h>
#include <sys/wait.h>
#include <readline/history.h>
#include <readline/readline.h>
-#include <sys/linker.h>
-#include <sys/module.h>
-#include <sys/resource.h>
FILE *cf; /* config file handle */
@@ -71,7 +68,7 @@ int inerror; /* set to 1 to exit after end of config file */
/* flags */
-#if VINUMDEBUG
+#if DEBUG
int debug = 0; /* debug flag, usage varies */
#endif
int force = 0; /* set to 1 to force some dangerous ops */
@@ -91,8 +88,6 @@ struct drive drive;
jmp_buf command_fail; /* return on a failed command */
int superdev; /* vinum super device */
-void start_daemon(void);
-
#define ofs(x) ((void *) (& ((struct confdata *) 0)->x)) /* offset of x in struct confdata */
/* create description-file
@@ -117,20 +112,6 @@ int tokens; /* number of tokens */
int
main(int argc, char *argv[])
{
-#if RAID5
-#define VINUMMOD "Vinum"
-#else
-#define VINUMMOD "vinum"
-#endif
-
- if (modfind(VINUMMOD) < 0) {
- /* need to load the vinum module */
- if (kldload(VINUMMOD) < 0 || modfind(VINUMMOD) < 0) {
- perror("vinum kernel module not available");
- return 1;
- }
- }
-
superdev = open(VINUM_SUPERDEV_NAME, O_RDWR); /* open it */
if (superdev < 0) { /* no go */
@@ -141,10 +122,6 @@ main(int argc, char *argv[])
return 1;
}
}
- /* Check if the dæmon is running. If not, start it in the
- * background */
- start_daemon();
-
if (argc > 1) { /* we have a command on the line */
if (setjmp(command_fail) != 0) /* long jumped out */
return -1;
@@ -179,13 +156,6 @@ main(int argc, char *argv[])
return 0; /* normal completion */
}
-/* stop the hard way */
-void
-vinum_quit(int argc, char *argv[], char *argv0[])
-{
- exit(0);
-}
-
#define FUNKEY(x) { kw_##x, &vinum_##x } /* create pair "kw_foo", vinum_foo */
struct funkey {
@@ -195,7 +165,7 @@ struct funkey {
FUNKEY(create),
FUNKEY(read),
-#ifdef VINUMDEBUG
+#ifdef DEBUG
FUNKEY(debug),
#endif
FUNKEY(volume),
@@ -221,10 +191,6 @@ struct funkey {
FUNKEY(printconfig),
FUNKEY(start),
FUNKEY(stop),
- FUNKEY(makedev),
- FUNKEY(help),
- FUNKEY(quit),
- FUNKEY(setdaemon),
FUNKEY(resetstats)
};
@@ -253,7 +219,7 @@ parseline(int args, char *argv[])
for (i = 1; (i < args) && (argv[i][0] == '-'); i++) { /* while we have flags */
for (j = 1; j < strlen(argv[i]); j++)
switch (argv[i][j]) {
-#if VINUMDEBUG
+#if DEBUG
case 'd': /* -d: debug */
debug = 1;
break;
@@ -382,7 +348,6 @@ make_devices(void)
system("mkdir -p " VINUM_DIR "/drive " /* and make them again */
VINUM_DIR "/plex "
VINUM_DIR "/sd "
- VINUM_DIR "/rsd "
VINUM_DIR "/vol "
VINUM_DIR "/rvol "
VINUM_RDIR);
@@ -475,16 +440,10 @@ make_devices(void)
if (mknod(filename, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IFBLK, sddev) < 0)
fprintf(stderr, "Can't create %s: %s\n", filename, strerror(errno));
- /* /dev/vinum/sd/<sd> */
+ /* And /dev/vinum/sd/<sd> */
sprintf(filename, VINUM_DIR "/sd/%s", sd.name);
if (mknod(filename, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IFBLK, sddev) < 0)
fprintf(stderr, "Can't create %s: %s\n", filename, strerror(errno));
-
- /* And /dev/vinum/rsd/<sd> */
- sprintf(filename, VINUM_DIR "/rsd/%s", sd.name);
- sddev = VINUMCDEV(volno, plexno, sdno, VINUM_SD_TYPE);
- if (mknod(filename, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IFCHR, sddev) < 0)
- fprintf(stderr, "Can't create %s: %s\n", filename, strerror(errno));
}
}
}
@@ -502,13 +461,6 @@ make_devices(void)
}
}
-/* command line interface for the 'makedev' command */
-void
-vinum_makedev(int argc, char *argv[], char *arg0[])
-{
- make_devices();
-}
-
/* Find the object "name". Return object type at type,
* and the index as the return value.
* If not found, return -1 and invalid_object.
@@ -564,80 +516,46 @@ find_object(const char *name, enum objecttype *type)
return -1;
}
-/* Continue reviving a subdisk in the background */
+/* Continue reviving a plex in the background */
void
-continue_revive(int sdno)
+continue_revive(int plexno)
{
- struct sd sd;
+ struct plex plex;
pid_t pid;
- get_sd_info(&sd, sdno);
+ get_plex_info(&plex, plexno);
-#if VINUMDEBUG
+#if DEBUG
if (debug)
pid = 0; /* wander through into the "child" process */
else
pid = fork(); /* do this in the background */
-#else
- pid = fork(); /* do this in the background */
#endif
if (pid == 0) { /* we're the child */
struct _ioctl_reply reply;
struct vinum_ioctl_msg *message = (struct vinum_ioctl_msg *) &reply;
openlog("vinum", LOG_CONS | LOG_PERROR | LOG_PID, LOG_KERN);
- syslog(LOG_INFO | LOG_KERN, "reviving %s", sd.name);
+ syslog(LOG_INFO | LOG_KERN, "reviving plex %s", plex.name);
for (reply.error = EAGAIN; reply.error == EAGAIN;) {
- message->index = sdno; /* pass sd number */
- message->type = sd_object; /* and type of object */
+ message->index = plexno; /* pass plex number */
+ message->type = plex_object; /* and type of object */
message->state = object_up;
ioctl(superdev, VINUM_SETSTATE, message);
}
if (reply.error) {
syslog(LOG_ERR | LOG_KERN,
- "can't revive %s: %s",
- sd.name,
+ "can't revive plex %s: %s",
+ plex.name,
reply.msg[0] ? reply.msg : strerror(reply.error));
exit(1);
} else {
- get_sd_info(&sd, sdno); /* update the info */
- syslog(LOG_INFO | LOG_KERN, "%s is %s", sd.name, sd_state(sd.state));
+ get_plex_info(&plex, plexno); /* update the info */
+ syslog(LOG_INFO | LOG_KERN, "plex %s is %s", plex.name, plex_state(plex.state));
exit(0);
}
} else if (pid < 0) /* couldn't fork? */
- fprintf(stderr, "Can't continue reviving %s: %s\n", sd.name, strerror(errno));
+ fprintf(stderr, "Can't continue reviving %s: %s\n", plex.name, strerror(errno));
else
- printf("Reviving %s in the background\n", sd.name);
-}
-
-/* Check if the daemon is running,
- * start it if it isn't. The check itself
- * could take a while, so we do it as a separate
- * process, which will become the daemon if one isn't
- * running already */
-void
-start_daemon(void)
-{
- int pid;
- int status;
- int error;
-
- pid = (int) fork();
-
- if (pid == 0) { /* We're the child, do the work */
- error = daemon(0, 0); /* this will fork again, but who's counting? */
- if (error != 0) {
- fprintf(stderr, "Can't start daemon: %s (%d)\n", strerror(errno), errno);
- exit(1);
- }
- setproctitle("Vinum daemon"); /* show what we're doing */
- status = ioctl(superdev, VINUM_FINDDAEMON, NULL);
- if (status != 0) { /* no daemon, */
- ioctl(superdev, VINUM_DAEMON, &verbose); /* we should hang here */
- syslog(LOG_ERR | LOG_KERN, "%s", strerror(errno));
- exit(1);
- }
- exit(0); /* when told to die */
- } else if (pid < 0) /* couldn't fork */
- printf("Can't fork to check daemon\n");
+ printf("Reviving %s in the background\n", plex.name);
}
diff --git a/sbin/vinum/vext.h b/sbin/vinum/vext.h
index a446f8466900b..5b1678f6c920c 100644
--- a/sbin/vinum/vext.h
+++ b/sbin/vinum/vext.h
@@ -1,9 +1,6 @@
-/*-
- * Copyright (c) 1997, 1998
- * Nan Yang Computer Services Limited. All rights reserved.
- *
- * This software is distributed under the so-called ``Berkeley
- * License'':
+/*
+ * Copyright (c) 1997 Nan Yang Computer Services Limited
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -15,30 +12,28 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by Nan Yang Computer
- * Services Limited.
- * 4. Neither the name of the Company nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * This software is provided ``as is'', and any express or implied
- * warranties, including, but not limited to, the implied warranties of
- * merchantability and fitness for a particular purpose are disclaimed.
- * In no event shall the company or contributors be liable for any
- * direct, indirect, incidental, special, exemplary, or consequential
- * damages (including, but not limited to, procurement of substitute
- * goods or services; loss of use, data, or profits; or business
- * interruption) however caused and on any theory of liability, whether
- * in contract, strict liability, or tort (including negligence or
- * otherwise) arising in any way out of the use of this software, even if
- * advised of the possibility of such damage.
+ * This product includes software developed for the NetBSD Project
+ * by Jason R. Thorpe.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
*
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
*/
-/* $Id: vext.h,v 1.10 1999/01/12 04:31:45 grog Exp grog $ */
+/* $Id: vext.h,v 1.9 1998/08/11 03:06:02 grog Exp grog $ */
#define MAXARGS 64 /* maximum number of args on a line */
-#define PLEXINITSIZE 61440 /* this is what the system does somewhere */
+#define PLEXINITSIZE MAXPHYS /* block size to write when initializing */
enum {
KILOBYTE = 1024,
@@ -66,10 +61,6 @@ void vinum_resetconfig(int argc, char *argv[], char *arg0[]);
void vinum_start(int argc, char *argv[], char *arg0[]);
void continue_revive(int plexno);
void vinum_stop(int argc, char *argv[], char *arg0[]);
-void vinum_makedev(int argc, char *argv[], char *arg0[]);
-void vinum_help(int argc, char *argv[], char *arg0[]);
-void vinum_quit(int argc, char *argv[], char *arg0[]);
-void vinum_setdaemon(int argc, char *argv[], char *arg0[]);
void reset_volume_stats(int volno, int recurse);
void reset_plex_stats(int plexno, int recurse);
void reset_sd_stats(int sdno, int recurse);
@@ -86,8 +77,7 @@ void vinum_ld(int argc, char *argv[], char *arg0[]);
void vinum_ls(int argc, char *argv[], char *arg0[]);
void vinum_lp(int argc, char *argv[], char *arg0[]);
void vinum_lv(int argc, char *argv[], char *arg0[]);
-void start_daemon(void);
-#ifdef VINUMDEBUG
+#ifdef DEBUG
void vinum_debug(int argc, char *argv[], char *arg0[]);
#endif
void make_devices(void);
diff --git a/sbin/vinum/vinum.8 b/sbin/vinum/vinum.8
index d2dfdb6abcb04..8f6c65542295b 100644
--- a/sbin/vinum/vinum.8
+++ b/sbin/vinum/vinum.8
@@ -1,6 +1,6 @@
.\" Hey, Emacs, edit this file in -*- nroff-fill -*- mode
.\"
-.Dd 15 January 1999
+.Dd 11 July 1998
.Dt vinum 8
.Os FreeBSD
.Sh NAME
@@ -30,14 +30,9 @@ Attach a plex to a volume, or a subdisk to a plex.
.in +1i
Cause the volume manager to enter the kernel debugger.
.in
-.Cd debug
-.Ar flags
-.in +1i
-Set debugging flags.
-.in
.Cd detach
.Op Ar plex | subdisk
-.in +1i
+.in +1
Detach a plex or subdisk from the volume or plex to which it is attached.
.in
.Cd info
@@ -51,12 +46,7 @@ List information about volume manager state.
.\" XXX
Initialize a plex by writing zeroes to all its subdisks.
.in
-.Cd label
-.Ar volume
-.in +1i
-Create a volume label
-.in
-.Cd list
+.Cd l
.Op Fl r
.Op Fl s
.Op Fl v
@@ -65,16 +55,14 @@ Create a volume label
.in +1i
List information about specified objects
.in
-.Cd l
+.Cd list
.Op Fl r
.Op Fl s
.Op Fl v
.Op Fl V
.Op volume | plex | subdisk
.in +1i
-List information about specified objects (alternative to
-.Cd list
-command)
+List information about specified objects
.in
.Cd ld
.Op Fl r
@@ -112,41 +100,29 @@ List information about plexes
.in +1i
List information about volumes
.in
-.Cd makedev
-.in +1i
-Remake the device nodes in
-.Ar /dev/vinum .
-.in
-.Cd quit
+.Cd label
+.Ar volume
.in +1i
-Exit the
-.Nm
-program when running in interactive mode. Normally this would be done by
-entering the
-.Ar EOF
-character.
+Create a volume label
.in
.Cd read
-.Ar disk Op disk...
+.Ar disk-partition
.in +1i
Read the
.Nm
-configuration from the specified disks.
+configuration from the specified disk partition.
.in
.Cd rename Op Fl r
.Ar [ drive | subdisk | plex | volume ]
.Ar newname
.in +1i
Change the name of the specified object.
-.ig
-XXX
.in
.Cd replace
.Ar [ subdisk | plex ]
.Ar newobject
.in +1i
Replace the object with an identical other object. XXX not implemented yet.
-..
.in
.Cd resetconfig
.in +1i
@@ -178,11 +154,6 @@ XXX
Set the state of the object to \fIstate\fP\|
.in
..
-.Cd setdaemon
-.Op value
-.in +1i
-Set dæmon configuration.
-.in
.Cd start
.Op volume | plex | subdisk
.in +1i
@@ -203,10 +174,7 @@ for more information about the volume manager.
.Xr vinum 8
is designed either for interactive use, when started without a command, or to
execute a single command if the command is supplied as arguments to
-.Nm vinum .
-In interactive mode,
-.Nm
-maintains a command line history.
+.Nm vinum.
.Ss OPTIONS
.Nm
commands may optionally be followed by an option. Any of the following options
@@ -267,8 +235,7 @@ commands perform the following functions:
.Bl -hang
.It Nm attach Ar plex Ar volume
.Op Nm rename
-.if n .sp -1v
-.if t .sp -.6v
+.sp -1v
.It Nm attach Ar subdisk Ar plex Ar [offset]
.Op Nm rename
.sp
@@ -289,25 +256,6 @@ renames the object (and in the case of a plex, any subordinate subdisks) to fit
in with the default
.Nm
naming convention.
-.Pp
-A number of considerations apply to attaching subdisks:
-.Bl -bullet
-.It
-Subdisks can normally only be attached to concatenated plexes.
-.It
-If a striped or RAID-5 plex is missing a subdisk (for example after drive
-failure), it may be replaced by a subdisk of the same size only. No other
-attachment of subdisks is currently allowed.
-.It
-For concatenated plexes, the
-.Ar offset
-parameter specifies the offset in blocks from the beginning of the plex. For
-striped and RAID-5 plexes, it specifies the offset of the first block of the
-subdisk: in other words, the offset is the numerical position of the subdisk
-multiplied by the stripe size. For example, in a plex of block size 256k, the
-first subdisk will have offset 0, the second offset 256k, the third 512k, etc.
-This calculation ignores parity blocks in RAID-5 plexes.
-.El
.It Nm create Ar description-file
.sp
.Nm
@@ -323,49 +271,13 @@ CONFIGURATION FILE below for more information.
.Ar debug
is used to enter the remote kernel debugger. It is only activated if
.Nm
-is built with the
-.Ar VINUMDEBUG
-option. This option will stop the execution of the operating system until the
-kernel debugger is exited. If remote debugging is set and there is no remote
+is built with the DEBUG option. This option will stop the execution of the
+operating system until the kernel debugger is exited. If there is no remote
connection for a kernel debugger, it will be necessary to reset the system and
reboot in order to leave the debugger.
-.It Nm debug
-.Ar flags
-.Pp
-Set a bit mask of internal debugging flags. These will change without warning
-as the product matures; to be certain, read the header file
-.Pa sys/dev/vinumvar.h .
-The bit mask is composed of the following values:
-.Bl -hang
-.It DEBUG_ADDRESSES (1)
-.br
-Show buffer information during requests
-.It DEBUG_NUMOUTPUT (2)
-.br
-Show the value of
-.Dv vp->v_numoutput.
-.It DEBUG_RESID (4)
-.br
-Go into debugger in
-.Fd complete_rqe.
-.It DEBUG_LASTREQS (8)
-.br
-Keep a circular buffer of last requests.
-.It DEBUG_REVIVECONFLICT (16)
-.br
-Print info about revive conflicts.
-.It DEBUG_REMOTEGDB (256)
-.br
-Go into remote
-.Ic gdb
-when the
-.Nm debug
-command is issued.
-.El
.It Nm detach Op Fl f
.Ar plex
-.if n .sp -1v
-.if t .sp -.6v
+.sp -1v
.It Nm detach Op Fl f
.Ar subdisk
.sp
@@ -379,14 +291,8 @@ option is specified. If the object is named after the object above it (for
example, subdisk vol1.p7.s0 attached to plex vol1.p7), the name will be changed
by prepending the text ``ex-'' (for example, ex-vol1.p7.s0). If necessary, the
name will be truncated in the process.
-.Pp
-.Nm detach
-does not reduce the number of subdisks in a striped or RAID-5 plex. Instead,
-the subdisk is marked absent, and can later be replaced with the
-.Nm attach
-command.
.It Nm info
-.br
+.Pp
.Nm
.Ar info
displays information about
@@ -394,117 +300,6 @@ displays information about
memory usage. This is intended primarily for debugging. With the
.Fl v
option, it will give detailed information about the memory areas in use.
-.Pp
-With the
-.Fl V
-option,
-.Ar info
-displays information about the last up to 64 I/O requests handled by the
-.Nm
-driver. This information is only collected if debug flag 8 is set. The format
-looks like:
-.Pp
-.Bd -literal
-vinum -> info -V
-Flags: 0x200 1 opens
-Total of 38 blocks malloced, total memory: 16460
-Maximum allocs: 56, malloc table at 0xf0f72dbc
-
-Time Event Buf Dev Offset Bytes SD SDoff Doffset Goffset
-
-14:40:00.637758 1VS Write 0xf2361f40 0x5b03 0x10 16384
-14:40:00.639280 2LR Write 0xf2361f40 0x5b03 0x10 16384
-14:40:00.639294 3RQ Read 0xf2361f40 0x427 0x104109 8192 19 0 0 0
-14:40:00.639455 3RQ Read 0xf2361f40 0x417 0xd2109 8192 17 0 0 0
-14:40:00.639529 3RQ Read 0xf2361f40 0x40f 0x6e109 8192 16 0 0 0
-14:40:00.652978 4DN Read 0xf2361f40 0x427 0x104109 8192 19 0 0 0
-14:40:00.667040 4DN Read 0xf2361f40 0x40f 0x6e109 8192 16 0 0 0
-14:40:00.668556 4DN Read 0xf2361f40 0x417 0xd2109 8192 17 0 0 0
-14:40:00.669777 6RP Write 0xf2361f40 0x427 0x104109 8192 19 0 0 0
-14:40:00.685547 4DN Write 0xf2361f40 0x427 0x104109 8192 19 0 0 0
-.Ed
-.Pp
-The
-.Ar Buf
-field always contains the address of the user buffer header. This can be used
-to identify the requests associated with a user request, though this is not 100%
-reliable: theoretically two requests in sequence could use the same buffer
-header, though this is not common. The beginning of a request can be identified
-by the event
-.Ar 1VS .
-The example above shows the requests involved in a single user request.
-.Pp
-The
-.Ar Event
-field contains information related to the sequence of events in the request
-chain. The digit
-.Ar 1
-to
-.Ar 6
-indicates the approximate sequence of events, and the two-letter abbreviation is
-a mnemonic for the location
-.Bl -hang
-.It 1VS
-(vinumstrategy) shows information about the user request on entry to
-.Fd vinumstrategy .
-The device number is the
-.Nm
-device, and offset and length are the user parameters. This is always the
-beginning of a request sequence.
-.It 2LR
-(launch_requests) shows the user request just prior to launching the low-level
-.Nm
-requests in the function
-.Fd launch_requests.
-The parameters should be the same as in the
-.Ar 1VS
-information.
-.Pp
-In the following requests,
-.Ar Dev
-is the device number of the associated disk partition,
-.Ar Offset
-is the offset from the beginning of the partition,
-.Ar SD
-is the subdisk index in
-.Dv vinum_conf ,
-.Ar SDoff
-is the offset from the beginning of the subdisk,
-.Ar Doffset
-is the offset of the associated data request, and
-.Ar Goffset
-is the offset of the associated group request, where applicable.
-.It 3RQ
-(request) shows one of possibly several low-level
-.Nm
-requests which are launched to satisfy the high-level request. This information
-is also logged in
-.Fd launch_requests.
-.It 4DN
-(done) is called from
-.Fd complete_rqe,
-showing the completion of a request. This completion should match a request
-launched either at stage
-.Ar 4DN
-from
-.Fd launch_requests,
-or from
-.Fd complete_raid5_write
-at stage
-.Ar 5RD
-or
-.Ar 6RP .
-.It 5RD
-(RAID-5 data) is called from
-.Fd complete_raid5_write
-and represents the data written to a RAID-5 data stripe after calculating
-parity.
-.It 6RP
-(RAID-5 parity) is called from
-.Fd complete_raid5_write
-and represents the data written to a RAID-5 parity stripe after calculating
-parity.
-.El
.\" XXX
.It Nm init Ar plex
.Pp
@@ -519,63 +314,37 @@ initializes all subdisks of a plex in parallel. Since this operation can take a
long time, it is performed in the background.
.Nm
prints a console message when the initialization is complete.
-.It Nm label
-.Ar volume
-.Pp
-The
-.Nm label
-command writes a
-.Ar ufs
-style volume label on a volume. It is a simple alternative to an appropriate
-call to
-.Ar disklabel .
-This is needed because some
-.Ar ufs
-commands still read the disk to find the label instead of using the correct
-.Ar ioctl
-call to access it.
-.Nm
-maintains a volume label separately from the volume data, so this command is not
-needed for
-.Ar newfs .
-This command is deprecated.
-.Pp
.It Nm list
.Op Fl r
.Op Fl V
.Op volume | plex | subdisk
-.if n .sp -1v
-.if t .sp -.6v
+.sp -1
.It Nm l
.Op Fl r
.Op Fl V
.Op volume | plex | subdisk
-.if n .sp -1v
-.if t .sp -.6v
+.sp -1
.It Nm ld
.Op Fl r
.Op Fl s
.Op Fl v
.Op Fl V
.Op volume
-.if n .sp -1v
-.if t .sp -.6v
+.sp -1
.It Nm ls
.Op Fl r
.Op Fl s
.Op Fl v
.Op Fl V
.Op subdisk
-.if n .sp -1v
-.if t .sp -.6v
+.sp -1
.It Nm lp
.Op Fl r
.Op Fl s
.Op Fl v
.Op Fl V
.Op plex
-.if n .sp -1v
-.if t .sp -.6v
+.sp -1
.It Nm lv
.Op Fl r
.Op Fl s
@@ -614,42 +383,39 @@ to output device statistics, the
(verbose) option causes some additional information to be output, and the
.Op Fl V
causes considerable additional information to be output.
-.It Nm makedev
-.br
-The
-.Nm makedev
-command removes the directory /dev/vinum and recreates it with device nodes
-which reflect the current configuration. This command is not intended for
-general use, and is provided for emergency use only.
+.It Nm label
+.Ar volume
.Pp
-.It Nm quit
-Exit the
+The
+.Nm label
+command writes a
+.Ar ufs
+style volume label on a volume. It is a simple alternative to an appropriate
+call to
+.Ar disklabel .
+This is needed because some
+.Ar ufs
+commands still read the disk to find the label instead of using the correct
+.Ar ioctl
+call to access it.
.Nm
-program when running in interactive mode. Normally this would be done by
-entering the
-.Ar EOF
-character.
+maintains a volume label separately from the volume data, so this command is not
+needed for
+.Ar newfs .
+This command is deprecated.
+.Pp
.It Nm read
-.Ar disk Op disk...
+.Ar disk-partition
.Pp
The
.Nm read
-command scans the specified disks for
-.Nm
-partitions containing previously created configuration information. It reads
-the configuration in order from the most recently updated to least recently
-updated configuration. This is the normal method used to start
-.Nm vinum .
+command reads a previously created
.Nm
-maintains an up-to-date copy of all configuration information on each disk
-partition. You must specify all of the partitions in a configuration as the
-parameter to this command.
+configuration from the specified disk partition.
.Nm
-.Nm read
-will accept the names of non-Vinum partitions, so you can specify all partitions
-upon which a
-.Nm
-partition might be resident to this command.
+maintains an up-to-date copy of all configuration information on each of the
+disk slices. You can specify any of the partitions in a configuration as the
+parameter to this command.
.It Nm rename
.Op Fl r
.Ar [ drive | subdisk | plex | volume ]
@@ -689,9 +455,6 @@ Enter text -> \f(BINO FUTURE\fP
Vinum configuration obliterated
.Ed
.ft R
-.Pp
-As the message suggests, this is a last-ditch command. Don't use it unless you
-have an existing configuration which you never want to see again.
.It Nm resetstats
.Op Fl r
.Op volume | plex | subdisk
@@ -759,29 +522,22 @@ care: it can result in total loss of data on a volume.
.\"XXX
.Nm This command has not yet been implemented.
..
-.It Nm setdaemon
-.Op value
-.Pp
-.Nm setdaemon
-sets a variable bitmask for the
-.Nm
-dæmon. This command is temporary and will be replaced. Currently, the bit mask
-may contain the bits 1 (log every action to syslog) and 4 (don't update
-configuration). Option bit 4 can be useful for error recovery.
.It Nm start
.Op volume | plex | subdisk
.Pp
.Nm start
-starts one or more
+starts the
.Nm
-objects. To start a plex in a multi-plex volume, the data must be copied from
-another plex in the volume. This frequently takes a long time and is done in
-the background.
+subsystem or one of its components. To start a plex in a multi-plex volume, the
+data must be copied from another plex in the volume. This frequently takes a
+long time and is done in the background.
.ig
-XXX When invoked without arguments, it checks all disks connected to the system
-for BSD partitions (type 165) and scans the partitions for a
+XXX
+When invoked without arguments, it checks
+all disks connected to the system for BSD partitions (type 165) and scans the
+slices for a
.Nm
-partition, which it calls a \fIdrive\fR\|. The
+slice, which it calls a \fIdrive\fR\|. The
.Nm
drive contains a header with all information about the data stored on the drive,
including the names of the other drives which are required in order to represent
@@ -843,6 +599,7 @@ Options are:
tab(#) ;
l lw50 .
Option#Meaning
+.TH N
T{
.Nm plex
.Ar plexname
@@ -887,9 +644,7 @@ command to first bring them to a consistent state. In the case of striped and
concatenated plexes, however, it does not normally cause problems to leave them
inconsistent: when using a volume for a file system or a swap partition, the
previous contents of the disks are not of interest, so they may be ignored.
-If you want to take this risk, use this keyword. It will only apply to the
-plexes defined immediately after the volume in the configuration file. If you
-add plexes to a volume at a later time, you must integrate them.
+If you want to take this risk, use this keyword.
.Pp
Note that you \fImust\fP\| use the
.Nm init
@@ -907,6 +662,7 @@ Define a plex. Unlike a volume, a plex does not need a name.
tab(#) ;
l lw50 .
Option#Meaning
+.TH N
T{
.Nm name
.Ar plexname
@@ -944,12 +700,6 @@ it specifies the size of a group. A group is a portion of a plex which
stores the parity bits all in the same subdisk. It must be a factor of the plex size (in
other words, the result of dividing the plex size by the stripe size must be an
integer), and it must be a multiple of a disk sector (512 bytes).
-.sp
-For optimum performance, stripes should be at least 128 kB in size: anything
-smaller will result in a significant increase in I/O activity due to mapping of
-individual requests over multiple disks. The increase in concurrency due to
-this mapping will not make up for the increase in latency. A good guideline for
-stripe size is between 256 kB and 512 kB.
T}
.Pp
#T{
@@ -1074,7 +824,7 @@ T}
.TE
.El
.Sh EXAMPLE CONFIGURATION FILE
-.Bd -literal
+.nf
# Sample vinum configuration file
#
# Our drives
@@ -1099,14 +849,14 @@ volume concat
sd length 100m drive drive2
sd length 50m drive drive4
plex org concat
- sd length 150m drive drive4
+ sd length 100m drive drive4
# A volume with one striped plex and one concatenated plex
volume strcon
plex org striped 32b
sd length 100m drive drive2
sd length 100m drive drive4
plex org concat
- sd length 150m drive drive2
+ sd length 100m drive drive2
sd length 50m drive drive4
# a volume with a RAID-5 and a striped plex
# note that the RAID-5 volume is longer by
@@ -1121,7 +871,7 @@ volume vol5
sd length 500m drive drive3
sd length 500m drive drive4
sd length 500m drive drive5
-.Ed
+.fi
.Ss DRIVE LAYOUT CONSIDERATIONS
.Nm
drives are currently BSD disk partitions. They must be of type
@@ -1130,162 +880,13 @@ in order to avoid overwriting file systems. In later versions of
.Nm
this requirement will change to type
.Ar vinum .
-Use
-.Nm disklabel
-.Ar -e
-to edit a partition type definition. The following display shows a typical
-partition layout as shown by
-.Nm disklabel:
-.Bd -literal
-8 partitions:
-# size offset fstype [fsize bsize bps/cpg]
- a: 81920 344064 4.2BSD 0 0 0 # (Cyl. 240*- 297*)
- b: 262144 81920 swap # (Cyl. 57*- 240*)
- c: 4226725 0 unused 0 0 # (Cyl. 0 - 2955*)
- e: 81920 0 4.2BSD 0 0 0 # (Cyl. 0 - 57*)
- f: 1900000 425984 4.2BSD 0 0 0 # (Cyl. 297*- 1626*)
- g: 1900741 2325984 unused 0 0 0 # (Cyl. 1626*- 2955*)
-.Ed
-.sp
-In this example, partition
-.Nm g
-may be used as a
-.Nm
-partition. Partitions
-.Nm a ,
-.Nm e
-and
-.Nm f
-may be used as
-.Nm UFS
-file systems or
-.Nm ccd
-partitions. Partition
-.Nm b
-is a swap partition, and partition
-.Nm c
-represents the whole disk and should not be used for any other purpose.
-.Pp
.Nm
uses the first 265 sectors on each partition for configuration information, so
the maximum size of a subdisk is 265 sectors smaller than the drive.
-.Sh GOTCHAS
-The following points are not bugs, and they have good reasons for existing, but
-they have shown to cause confusion. Each is discussed in the appropriate
-section above.
-.Bl -enum
-.It
-.Nm
-will not create a device on UFS partitions. Instead, it will return an error
-message ``wrong partition type''. The partition type must currently be
-``unused''.
-.It
-When you create a volume with multiple plexes,
-.Nm
-does not automatically initialize the plexes. This means that the contents are
-not known, but they are certainly not consistent. As a result, by default
-.Nm
-sets the state of all newly-created plexes except the first to
-.Ar stale .
-.Pp
-In practice, people aren't too interested in what was in the plex when it was
-created, and other volume managers cheat by setting them
-.Ar up
-anyway.
-.Nm
-provides two ways to ensure that newly created plexes are
-.Ar up :
-.Bl -bullet
-.It
-Create the plexes and then initialize them with
-.Nm vinum init .
-.It
-Create the volume (not the plex) with the keyword
-.Ar setupstate ,
-which tells
-.Nm
-to ignore any possible inconsistency and set the plexes to be
-.Ar up .
-.El
-.It
-Some of the commands currently supported by
-.Nm
-are not really needed. For reasons which I don't understand, however, I find
-that users frequently try the
-.Nm label
-and
-.Nm resetconfig
-commands, though especially
-.Nm resetconfig
-outputs all sort of dire warnings. Don't use these commands unless you have a
-good reason to do so.
-.It
-Some state transitions are not very intuitive. In fact, it's not clear whether
-this is a bug or a feature. If you find that you can't start an object in some
-strange state, such as a
-.Ar reborn
-subdisk, try first to get it into
-.Ar stopped
-state, with the
-.Nm stop
-or
-.Nm stop Ar -f
-commands. If that works, you should then be able to start it. If you find
-that this is the only way to get out of a position where easier methods fail,
-please report the situation.
-.It
-If you build the kernel module with the
-.Ar -DVINUMDEBUG
-option, you must also build
-.Nm vinum(8)
-with the
-.Ar -DVINUMDEBUG
-option, since the size of some data objects used by both components depends on
-this option. If you don't do so, commands will fail with the message
-.Ar Invalid argument ,
-and a console message will be logged such as
-.Pp
-.Bd -literal
-vinumioctl: invalid ioctl from process 247 (vinum): c0e44642
-.Ed
-.Pp
-This error may also occur if you use old versions of kld or userland program.
-.El
.Sh BUGS
-.Bl -enum
-.It
.Nm
is currently in beta test. Many bugs can be expected. The configuration
-mechanism is not yet fully functional. If you have difficulties, please look at
-http://www.lemis.com/vinum_beta.html and
-http://www.lemis.com/vinum_debugging.html before reporting problems.
-.It
-It is possible to unload
-.Nm
-with the
-.Nm kldunload
-command. This is buggy, and the only reason it is present at all is to make it
-easier for people testing the system: the alternative is a reboot. It works
-about 80% of the time: expect about one panic every five unloads.
-.It
-It is possible to configure
-.Nm
-statically, but it has never been tested in this form. Don't even bother to
-report the problem if you have trouble with a static
-.Nm
-pseudo-device.
-.It
-This man page tickles a bug in the
-.Ar doc
-man page macros: depending on your screen size, you may get the error message
-.Bd -literal -offset indent
-warning: page 6: table text block will not fit on one page
-.Ed
-.Pp
-This will be fixed in a later rewrite of the page, when the
-.Nm tbl
-macros will be removed.
-.El
+mechanism is not yet fully functional.
.Sh FILES
.Ar /dev/vinum
- directory with device nodes for
@@ -1306,10 +907,7 @@ plexes.
.Nm
subdisks.
.Sh SEE ALSO
-.Xr vinum 4 ,
-.Xr disklabel 8 ,
-.Nm http://www.lemis.com/vinum.html ,
-.Nm http://www.lemis.com/vinum-debugging.html .
+.Xr vinum 4
.Sh AUTHOR
Greg Lehey
.Pa <grog@lemis.com> .