Add '-f disktab' option to disklabel, via lib/6623 from
Greg A. Woods <woods@most.weird.com>. (Very) slightly tweaked disklabel.8
This commit is contained in:
parent
df91e2ba06
commit
593d6c65b9
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disktab.h,v 1.6 1998/07/27 09:09:24 mycroft Exp $ */
|
||||
/* $NetBSD: disktab.h,v 1.7 1999/01/19 06:24:09 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
|
@ -43,25 +43,11 @@
|
|||
/*
|
||||
* Disk description table, see disktab(5)
|
||||
*/
|
||||
#define DISKTAB "/etc/disktab"
|
||||
#define _PATH_DISKTAB "/etc/disktab"
|
||||
|
||||
struct partition {
|
||||
int p_size; /* #sectors in partition */
|
||||
short p_bsize; /* block size in bytes */
|
||||
short p_fsize; /* frag size in bytes */
|
||||
};
|
||||
|
||||
struct disktab {
|
||||
__aconst char *d_name; /* drive name */
|
||||
__aconst char *d_type; /* drive type */
|
||||
int d_secsize; /* sector size in bytes */
|
||||
int d_ntracks; /* # tracks/cylinder */
|
||||
int d_nsectors; /* # sectors/track */
|
||||
int d_ncylinders; /* # cylinders */
|
||||
int d_rpm; /* revolutions/minute */
|
||||
int d_badsectforw; /* supports DEC bad144 std */
|
||||
int d_sectoffset; /* use sect rather than cyl offsets */
|
||||
struct partition d_partitions[8];
|
||||
};
|
||||
__BEGIN_DECLS
|
||||
int setdisktab __P((char *));
|
||||
struct disklabel *getdiskbyname __P((const char *));
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_DISKTAB_H_ */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile.inc,v 1.95 1999/01/15 13:31:22 bouyer Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.96 1999/01/19 06:24:08 abs Exp $
|
||||
# from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95
|
||||
|
||||
# gen sources
|
||||
|
@ -71,6 +71,7 @@ MLINKS+=getcap.3 cgetcap.3 getcap.3 cgetclose.3 getcap.3 cgetent.3 \
|
|||
getcap.3 cgetnum.3 getcap.3 cgetset.3 getcap.3 cgetstr.3 \
|
||||
getcap.3 cgetustr.3
|
||||
MLINKS+=getcwd.3 getwd.3
|
||||
MLINKS+=getdiskbyname.3 setdisktab.3
|
||||
MLINKS+=getdomainname.3 setdomainname.3
|
||||
MLINKS+=getfsent.3 endfsent.3 getfsent.3 getfsfile.3 getfsent.3 getfsspec.3 \
|
||||
getfsent.3 getfstype.3 getfsent.3 setfsent.3
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.c,v 1.22 1998/11/12 15:51:44 christos Exp $ */
|
||||
/* $NetBSD: disklabel.c,v 1.23 1999/01/19 06:24:08 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1987, 1993
|
||||
|
@ -38,7 +38,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)disklabel.c 8.2 (Berkeley) 5/3/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: disklabel.c,v 1.22 1998/11/12 15:51:44 christos Exp $");
|
||||
__RCSID("$NetBSD: disklabel.c,v 1.23 1999/01/19 06:24:08 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -58,6 +58,8 @@ __RCSID("$NetBSD: disklabel.c,v 1.22 1998/11/12 15:51:44 christos Exp $");
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <disktab.h>
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(getdiskbyname,_getdiskbyname);
|
||||
#endif
|
||||
|
@ -67,6 +69,20 @@ static void error __P((int));
|
|||
#endif
|
||||
static int gettype __P((char *, const char *const *));
|
||||
|
||||
static char *db_array[2] = { _PATH_DISKTAB, 0 };
|
||||
|
||||
int
|
||||
setdisktab(name)
|
||||
char *name;
|
||||
{
|
||||
if (!name || !*name)
|
||||
return -1;
|
||||
|
||||
db_array[0] = name;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
struct disklabel *
|
||||
getdiskbyname(name)
|
||||
const char *name;
|
||||
|
@ -75,7 +91,6 @@ getdiskbyname(name)
|
|||
struct disklabel *dp = &disk;
|
||||
struct partition *pp;
|
||||
char *buf;
|
||||
char *db_array[2] = { _PATH_DISKTAB, 0 };
|
||||
char *cp, *cq; /* can't be */
|
||||
char p, max, psize[3], pbsize[3],
|
||||
pfsize[3], poffset[3], ptype[3];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: getdiskbyname.3,v 1.4 1998/02/05 18:46:30 perry Exp $
|
||||
.\" $NetBSD: getdiskbyname.3,v 1.5 1999/01/19 06:24:08 abs Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1983, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -37,12 +37,17 @@
|
|||
.Dt GETDISKBYNAME 3
|
||||
.Os BSD 4.2
|
||||
.Sh NAME
|
||||
.Nm getdiskbyname
|
||||
.Nm getdiskbyname ,
|
||||
.Nm setdisktab
|
||||
.Nd get generic disk description by its name
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <sys/types.h>
|
||||
.Fd #include <sys/disklabel.h>
|
||||
.Fd #include <disktab.h>
|
||||
.Ft int
|
||||
.Fn setdisktab "char *name"
|
||||
.Ft struct disklabel *
|
||||
.Fn getdiskbyname "const char *name"
|
||||
.Sh DESCRIPTION
|
||||
|
@ -57,6 +62,31 @@ disk partition tables. All information is obtained from
|
|||
the
|
||||
.Xr disktab 5
|
||||
file.
|
||||
.Pp
|
||||
The
|
||||
.Fn setdisktab
|
||||
function changes the default
|
||||
.Pn disktab
|
||||
file name from
|
||||
.Pa /etc/disktab
|
||||
.Pq aka Dv _PATH_DISKTAB
|
||||
to
|
||||
.Fa name .
|
||||
.Sh RETURN VALUES
|
||||
.Fn getdiskbyname
|
||||
returns a null pointer if the entry is not found in the current
|
||||
.Pa disktab
|
||||
file.
|
||||
.Pp
|
||||
.Fn setdisktab
|
||||
returns 0 on success and -1 if
|
||||
.Fa name
|
||||
is a null pointer or points to an empty string.
|
||||
.Sh FILES
|
||||
.Bl -tag -width /etc/disktab -compact
|
||||
.It Pa /etc/disktab
|
||||
the default database of disk types.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr disklabel 5 ,
|
||||
.Xr disktab 5 ,
|
||||
|
@ -66,3 +96,13 @@ The
|
|||
.Fn getdiskbyname
|
||||
function appeared in
|
||||
.Bx 4.3 .
|
||||
.Pp
|
||||
The
|
||||
.Fn setdisktab
|
||||
function appeared in
|
||||
.Nx 1.4 .
|
||||
.Sh BUGS
|
||||
The
|
||||
.Fn getdiskbyname
|
||||
function leaves its results in an internal static object and returns a
|
||||
pointer to that object. Subsequent calls will modify the same object.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: disklabel.8,v 1.23 1998/04/27 21:03:08 fair Exp $
|
||||
.\" $NetBSD: disklabel.8,v 1.24 1999/01/19 06:24:09 abs Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1987, 1988, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -50,6 +50,7 @@
|
|||
.Nm ""
|
||||
.Fl w
|
||||
.Op Fl r
|
||||
.Op Fl f Ar disktab
|
||||
.Ar disk Ar disktype
|
||||
.Oo Ar packid Oc
|
||||
.Nm ""
|
||||
|
@ -71,6 +72,7 @@
|
|||
.sp
|
||||
.Nm ""
|
||||
.Fl B
|
||||
.Op Fl f Ar disktab
|
||||
.Oo
|
||||
.Fl b Ar boot1
|
||||
.Op Fl s Ar boot2
|
||||
|
@ -80,6 +82,7 @@
|
|||
.Nm ""
|
||||
.Fl w
|
||||
.Fl B
|
||||
.Op Fl f Ar disktab
|
||||
.Oo
|
||||
.Fl b Ar boot1
|
||||
.Op Fl s Ar boot2
|
||||
|
@ -89,6 +92,7 @@
|
|||
.Nm ""
|
||||
.Fl R
|
||||
.Fl B
|
||||
.Op Fl f Ar disktab
|
||||
.Oo
|
||||
.Fl b Ar boot1
|
||||
.Op Fl s Ar boot2
|
||||
|
@ -180,6 +184,12 @@ If the disk does not already have a label, the
|
|||
flag must be used.
|
||||
In either case, the kernel's in-core label is replaced.
|
||||
.Pp
|
||||
An alternate
|
||||
.Xr disktab 5
|
||||
file may be specified with the
|
||||
.Fl f Ar disktab
|
||||
option.
|
||||
.Pp
|
||||
An existing disk label may be edited by using the
|
||||
.Fl e
|
||||
flag.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.c,v 1.60 1998/11/12 16:19:48 christos Exp $ */
|
||||
/* $NetBSD: disklabel.c,v 1.61 1999/01/19 06:24:09 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1993
|
||||
|
@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993\n\
|
|||
static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95";
|
||||
/* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */
|
||||
#else
|
||||
__RCSID("$NetBSD: disklabel.c,v 1.60 1998/11/12 16:19:48 christos Exp $");
|
||||
__RCSID("$NetBSD: disklabel.c,v 1.61 1999/01/19 06:24:09 abs Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -74,6 +74,8 @@ __RCSID("$NetBSD: disklabel.c,v 1.60 1998/11/12 16:19:48 christos Exp $");
|
|||
#include <unistd.h>
|
||||
#include <util.h>
|
||||
|
||||
#include <disktab.h>
|
||||
|
||||
#include "pathnames.h"
|
||||
#include "extern.h"
|
||||
#include "dkcksum.h"
|
||||
|
@ -130,9 +132,9 @@ static int Cflag;
|
|||
|
||||
#ifdef DEBUG
|
||||
static int debug;
|
||||
#define OPTIONS "BCNRWb:deirs:tw"
|
||||
#define OPTIONS "BCNRWb:def:irs:tw"
|
||||
#else
|
||||
#define OPTIONS "BCNRWb:eirs:tw"
|
||||
#define OPTIONS "BCNRWb:ef:irs:tw"
|
||||
#endif
|
||||
|
||||
#ifdef __i386__
|
||||
|
@ -217,6 +219,10 @@ main(argc, argv)
|
|||
usage();
|
||||
op = EDIT;
|
||||
break;
|
||||
case 'f':
|
||||
if (setdisktab(optarg) == -1)
|
||||
usage();
|
||||
break;
|
||||
case 'i':
|
||||
if (op != UNSPEC)
|
||||
usage();
|
||||
|
@ -1806,7 +1812,7 @@ usage()
|
|||
} usages[] = {
|
||||
{ "%s [-rt] [-C] disk",
|
||||
"(to read label)" },
|
||||
{ "%s -w [-r] disk type [ packid ]",
|
||||
{ "%s -w [-r] [-f disktab] disk type [ packid ]",
|
||||
#if NUMBOOT > 0
|
||||
"(to write label with existing boot program)"
|
||||
#else
|
||||
|
@ -1826,18 +1832,18 @@ usage()
|
|||
},
|
||||
#if NUMBOOT > 0
|
||||
# if NUMBOOT > 1
|
||||
{ "%s -B [ -b xxboot [ -s bootxx ] ] disk [ type ]",
|
||||
{ "%s -B [-f disktab] [ -b xxboot [ -s bootxx ] ] disk [ type ]",
|
||||
"(to install boot program with existing label)" },
|
||||
{ "%s -w -B [ -b xxboot [ -s bootxx ] ] disk type [ packid ]",
|
||||
{ "%s -w -B [-f disktab] [ -b xxboot [ -s bootxx ] ] disk type [ packid ]",
|
||||
"(to write label and boot program)" },
|
||||
{ "%s -R -B [ -b xxboot [ -s bootxx ] ] disk protofile [ type ]",
|
||||
{ "%s -R -B [-f disktab] [ -b xxboot [ -s bootxx ] ] disk protofile [ type ]",
|
||||
"(to restore label and boot program)" },
|
||||
# else
|
||||
{ "%s -B [ -b bootprog ] disk [ type ]",
|
||||
{ "%s -B [-f disktab] [ -b bootprog ] disk [ type ]",
|
||||
"(to install boot program with existing on-disk label)" },
|
||||
{ "%s -w -B [ -b bootprog ] disk type [ packid ]",
|
||||
{ "%s -w -B [-f disktab] [ -b bootprog ] disk type [ packid ]",
|
||||
"(to write label and install boot program)" },
|
||||
{ "%s -R -B [ -b bootprog ] disk protofile [ type ]",
|
||||
{ "%s -R -B [-f disktab] [ -b bootprog ] disk protofile [ type ]",
|
||||
"(to restore label and install boot program)" },
|
||||
# endif
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.h,v 1.50 1998/11/13 01:05:51 thorpej Exp $ */
|
||||
/* $NetBSD: disklabel.h,v 1.51 1999/01/19 06:24:09 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1993
|
||||
|
@ -38,12 +38,6 @@
|
|||
#ifndef _SYS_DISKLABEL_H_
|
||||
#define _SYS_DISKLABEL_H_
|
||||
|
||||
/*
|
||||
* Disk description table, see disktab(5)
|
||||
*/
|
||||
#define _PATH_DISKTAB "/etc/disktab"
|
||||
#define DISKTAB "/etc/disktab" /* deprecated */
|
||||
|
||||
/*
|
||||
* Each disk has a label which includes information about the hardware
|
||||
* disk geometry, filesystem partitions, and drive specific information.
|
||||
|
@ -366,10 +360,6 @@ int bounds_check_with_label __P((struct buf *, struct disklabel *, int));
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
struct disklabel *getdiskbyname __P((const char *));
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* !_SYS_DISKLABEL_H_ */
|
||||
|
|
Loading…
Reference in New Issue