add a new fstab type "dp" for the user-specified dump device.

change swapctl -A to see this and add it via swapctl(2).  also
add a new swapctl -D <device> to change the dump device on the
fly.
This commit is contained in:
mrg 1999-02-23 17:00:53 +00:00
parent cd577c539a
commit bdadd56346
5 changed files with 126 additions and 37 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: fstab.h,v 1.8 1998/07/27 11:14:34 mycroft Exp $ */
/* $NetBSD: fstab.h,v 1.9 1999/02/23 17:00:53 mrg Exp $ */
/*
* Copyright (c) 1980, 1993
@ -58,6 +58,7 @@
#define FSTAB_RQ "rq" /* read/write with quotas */
#define FSTAB_RO "ro" /* read-only device */
#define FSTAB_SW "sw" /* swap device */
#define FSTAB_DP "dp" /* dump device */
#define FSTAB_XX "xx" /* ignore totally */
struct fstab {

View File

@ -1,4 +1,4 @@
/* $NetBSD: fstab.c,v 1.18 1999/01/26 02:23:34 thorpej Exp $ */
/* $NetBSD: fstab.c,v 1.19 1999/02/23 17:00:53 mrg Exp $ */
/*
* Copyright (c) 1980, 1988, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)fstab.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: fstab.c,v 1.18 1999/01/26 02:23:34 thorpej Exp $");
__RCSID("$NetBSD: fstab.c,v 1.19 1999/02/23 17:00:53 mrg Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -92,7 +92,7 @@ fstabscan()
static const char sep[] = ":\n";
static const char ws[] = " \t\n";
static char *fstab_type[] = {
FSTAB_RW, FSTAB_RQ, FSTAB_RO, FSTAB_SW, FSTAB_XX, NULL
FSTAB_RW, FSTAB_RQ, FSTAB_RO, FSTAB_SW, FSTAB_DP, FSTAB_XX, NULL
};
for (;;) {

View File

@ -1,4 +1,4 @@
.\" $NetBSD: swapctl.8,v 1.14 1998/05/22 18:27:52 msaitoh Exp $
.\" $NetBSD: swapctl.8,v 1.15 1999/02/23 17:00:53 mrg Exp $
.\"
.\" Copyright (c) 1997 Matthew R. Green
.\" All rights reserved.
@ -36,6 +36,7 @@
.Sh SYNOPSIS
.Nm
.Fl A
.Op Fl D Ar dumpdev
.Op Fl p Ar priority
.Op Fl t Ar blk|noblk
.Nm ""
@ -86,10 +87,29 @@ This option causes
.Nm
to read the
.Pa /etc/fstab
file for devices and files with a ``sw'' type, and adds all these entries
as swap devices. If no swap devices are configured,
file for devices and files with a
.Dq sw
and
.Dq dp
type, and adds all these entries
as swap devices, or for a dump device in the case of a
.Dq dp
type. If no swap devices are configured,
.Nm
will exit with an error code.
.It Fl D
The
.Fl D
option requires that a
.Ar dumpdev
also be in the argument list. The kernel dump device is set to
.Ar dumpdev .
This changed is made via the
.Xr swapctl 2
system call. The dump device is used when the system crashes
to write a current snapshot of real memory, to be saved later with
.Xr savecore 8
at system reboot, and analyzed to determine the problem.
.It Fl a
The
.Fl a

View File

@ -1,4 +1,4 @@
/* $NetBSD: swapctl.c,v 1.9 1998/07/26 20:23:15 mycroft Exp $ */
/* $NetBSD: swapctl.c,v 1.10 1999/02/23 17:00:53 mrg Exp $ */
/*
* Copyright (c) 1996, 1997 Matthew R. Green
@ -30,7 +30,9 @@
/*
* swapctl command:
* -A add all devices listed as `sw' in /etc/fstab
* -A add all devices listed as `sw' in /etc/fstab (also
* (sets the the dump device, if listed in fstab)
* -D <dev> set dumpdev to <dev>
* -t [blk|noblk] if -A, add either all block device or all non-block
* devices
* -a <dev> add this device
@ -70,11 +72,12 @@ int command;
* Commands for swapctl(8). These are mutually exclusive.
*/
#define CMD_A 0x01 /* process /etc/fstab */
#define CMD_a 0x02 /* add a swap file/device */
#define CMD_c 0x04 /* change priority of a swap file/device */
#define CMD_d 0x08 /* delete a swap file/device */
#define CMD_l 0x10 /* list swap files/devices */
#define CMD_s 0x20 /* summary of swap files/devices */
#define CMD_D 0x02 /* set dumpdev */
#define CMD_a 0x04 /* add a swap file/device */
#define CMD_c 0x08 /* change priority of a swap file/device */
#define CMD_d 0x10 /* delete a swap file/device */
#define CMD_l 0x20 /* list swap files/devices */
#define CMD_s 0x40 /* summary of swap files/devices */
#define SET_COMMAND(cmd) \
do { \
@ -87,7 +90,7 @@ do { \
* Commands that require a "path" argument at the end of the command
* line, and the ones which require that none exist.
*/
#define REQUIRE_PATH (CMD_a | CMD_c | CMD_d)
#define REQUIRE_PATH (CMD_D | CMD_a | CMD_c | CMD_d)
#define REQUIRE_NOPATH (CMD_A | CMD_l | CMD_s)
/*
@ -104,9 +107,10 @@ char *tflag; /* swap device type (blk or noblk) */
int pri; /* uses 0 as default pri */
static void change_priority __P((char *));
static void add_swap __P((char *));
static void del_swap __P((char *));
static void change_priority __P((const char *));
static void add_swap __P((const char *));
static void del_swap __P((const char *));
static void set_dumpdev __P((const char *));
int main __P((int, char *[]));
static void do_fstab __P((void));
static void usage __P((void));
@ -136,12 +140,16 @@ main(argc, argv)
}
#endif
while ((c = getopt(argc, argv, "Aacdlkp:st:")) != -1) {
while ((c = getopt(argc, argv, "ADacdlkp:st:")) != -1) {
switch (c) {
case 'A':
SET_COMMAND(CMD_A);
break;
case 'D':
SET_COMMAND(CMD_D);
break;
case 'a':
SET_COMMAND(CMD_a);
break;
@ -244,6 +252,10 @@ main(argc, argv)
case CMD_A:
do_fstab();
break;
case CMD_D:
set_dumpdev(argv[0]);
break;
}
exit(0);
@ -309,7 +321,7 @@ swapon_command(argc, argv)
*/
void
change_priority(path)
char *path;
const char *path;
{
if (swapctl(SWAP_CTL, path, pri) < 0)
@ -321,10 +333,20 @@ change_priority(path)
*/
void
add_swap(path)
char *path;
const char *path;
{
struct stat sb;
if (stat(path, &sb) < 0)
goto oops;
if (sb.st_mode & S_IROTH)
warnx("%s is readable by the world", path);
if (sb.st_mode & S_IWOTH)
warnx("%s is writable by the world", path);
if (swapctl(SWAP_ON, path, pri) < 0)
oops:
err(1, "%s", path);
}
@ -333,13 +355,24 @@ add_swap(path)
*/
void
del_swap(path)
char *path;
const char *path;
{
if (swapctl(SWAP_OFF, path, pri) < 0)
err(1, "%s", path);
}
void
set_dumpdev(path)
const char *path;
{
if (swapctl(SWAP_DUMPDEV, path, NULL) == -1)
warn("could not set dump device to %s", path);
else
printf("%s: setting dump device to %s\n", __progname, path);
}
void
do_fstab()
{
@ -356,10 +389,15 @@ do_fstab()
while ((fp = getfsent()) != NULL) {
const char *spec;
spec = fp->fs_spec;
if (strcmp(fp->fs_type, "dp") == 0) {
set_dumpdev(spec);
continue;
}
if (strcmp(fp->fs_type, "sw") != 0)
continue;
spec = fp->fs_spec;
isblk = 0;
if ((s = strstr(fp->fs_mntops, PRIORITYEQ)) != NULL) {

View File

@ -1,4 +1,4 @@
.\" $NetBSD: fstab.5,v 1.14 1999/01/01 19:05:23 msaitoh Exp $
.\" $NetBSD: fstab.5,v 1.15 1999/02/23 17:00:53 mrg Exp $
.\"
.\" Copyright (c) 1980, 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -51,7 +51,9 @@ it is the duty of the system administrator to properly create
and maintain this file.
Each filesystem is described on a separate line;
fields on each line are separated by tabs or spaces. Lines beginning
with ``#'' are comments.
with
.Dq #
are comments.
The order of records in
.Nm
is important because
@ -72,13 +74,18 @@ For filesystems of type
the special file name is the block special file name,
and not the character special file name.
If a program needs the character special file name,
the program must create it by appending a ``r'' after the
last ``/'' in the special file name.
the program must create it by appending a
.Dq r
after the
last
.Dq /
in the special file name.
.Pp
The second field,
.Pq Fa fs_file ,
describes the mount point for the filesystem.
For swap partitions, this field should be specified as ``none''.
For swap and dump partitions, this field should be specified as
.Dq none .
.Pp
The third field,
.Pq Fa fs_vfstype ,
@ -115,7 +122,8 @@ an
.Tn MS-DOS
.Dq FAT filesystem
.It Em nfs
a Sun Microsystems compatible ``Network File System''
a Sun Microsystems compatible
.Dq Network File System
.It Em nullfs
a loop-back filesystem, allowing parts of the system to be viewed
elsewhere.
@ -140,11 +148,21 @@ It contains at least the type of mount (see
below) plus any additional options
appropriate to the filesystem type.
.Pp
The option ``auto'' can be used in the ``noauto'' form to cause
a file system not to be mounted automatically (with ``mount -a'',
The option
.Dq auto
can be used in the
.Dq noauto
form to cause
a file system not to be mounted automatically (with
.Dq mount -a
,
or system boot time).
.Pp
If the options ``userquota'' and/or ``groupquota'' are specified,
If the options
.Dq userquota
and/or
.Dq groupquota
are specified,
the filesystem is automatically processed by the
.Xr quotacheck 8
command, and user and/or group disk quotas are enabled with
@ -175,19 +193,28 @@ field (it is not deleted from the
field).
If
.Fa fs_type
is ``rw'' or ``ro'' then the filesystem whose name is given in the
is
.Dq rw
or
.Dq ro
then the filesystem whose name is given in the
.Fa fs_file
field is normally mounted read-write or read-only on the
specified special file.
If
.Fa fs_type
is ``sw'' then the special file is made available as a piece of swap
is
.Dq sw
or
.Dq dp
then the special file is made available as a piece of swap
or dump
space by the
.Xr swapctl 8
command towards the beginning of the system reboot procedure.
See
.Xr swapctl 8
for more information on configuring swap devices.
for more information on configuring swap and dump devices.
The fields other than
.Fa fs_spec
and
@ -195,7 +222,9 @@ and
are unused.
If
.Fa fs_type
is specified as ``xx'' the entry is ignored.
is specified as
.Dq xx
the entry is ignored.
This is useful to show disk partitions which are currently unused.
.Pp
The fifth field,
@ -229,6 +258,7 @@ will assume that the filesystem does not need to be checked.
#define FSTAB_RW "rw" /* read-write device */
#define FSTAB_RO "ro" /* read-only device */
#define FSTAB_SW "sw" /* swap device */
#define FSTAB_DP "dp" /* dump device */
#define FSTAB_XX "xx" /* ignore totally */
struct fstab {