Add Id. Use err(3). Costmetic in usage string.
This commit is contained in:
parent
86d025a068
commit
bef2080a01
@ -32,6 +32,8 @@
|
|||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* 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
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
@ -62,6 +64,7 @@ static char sccsid[] = "@(#)disklabel.c 8.2 (Berkeley) 1/7/94";
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <err.h>
|
||||||
#include "pathnames.h"
|
#include "pathnames.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -107,7 +110,6 @@ int getasciilabel __P((FILE *, struct disklabel *));
|
|||||||
int checklabel __P((struct disklabel *));
|
int checklabel __P((struct disklabel *));
|
||||||
void setbootflag __P((struct disklabel *));
|
void setbootflag __P((struct disklabel *));
|
||||||
void Warning (char *, ...);
|
void Warning (char *, ...);
|
||||||
void Perror __P((char *));
|
|
||||||
void usage __P((void));
|
void usage __P((void));
|
||||||
extern u_short dkcksum __P((struct disklabel *));
|
extern u_short dkcksum __P((struct disklabel *));
|
||||||
struct disklabel * getvirginlabel __P((void));
|
struct disklabel * getvirginlabel __P((void));
|
||||||
@ -245,7 +247,7 @@ main(argc, argv)
|
|||||||
f = open(specname, op == READ ? O_RDONLY : O_RDWR);
|
f = open(specname, op == READ ? O_RDONLY : O_RDWR);
|
||||||
}
|
}
|
||||||
if (f < 0)
|
if (f < 0)
|
||||||
Perror(specname);
|
err(4, "%s", specname);
|
||||||
|
|
||||||
switch(op) {
|
switch(op) {
|
||||||
|
|
||||||
@ -259,7 +261,7 @@ main(argc, argv)
|
|||||||
case NOWRITE:
|
case NOWRITE:
|
||||||
flag = 0;
|
flag = 0;
|
||||||
if (ioctl(f, DIOCWLABEL, (char *)&flag) < 0)
|
if (ioctl(f, DIOCWLABEL, (char *)&flag) < 0)
|
||||||
Perror("ioctl DIOCWLABEL");
|
err(4, "ioctl DIOCWLABEL");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case READ:
|
case READ:
|
||||||
@ -281,7 +283,7 @@ main(argc, argv)
|
|||||||
usage();
|
usage();
|
||||||
lp = makebootarea(bootarea, &lab, f);
|
lp = makebootarea(bootarea, &lab, f);
|
||||||
if (!(t = fopen(argv[1], "r")))
|
if (!(t = fopen(argv[1], "r")))
|
||||||
Perror(argv[1]);
|
err(4, "%s", argv[1]);
|
||||||
if (getasciilabel(t, lp))
|
if (getasciilabel(t, lp))
|
||||||
error = writelabel(f, bootarea, lp);
|
error = writelabel(f, bootarea, lp);
|
||||||
break;
|
break;
|
||||||
@ -303,7 +305,7 @@ main(argc, argv)
|
|||||||
case WRITEABLE:
|
case WRITEABLE:
|
||||||
flag = 1;
|
flag = 1;
|
||||||
if (ioctl(f, DIOCWLABEL, (char *)&flag) < 0)
|
if (ioctl(f, DIOCWLABEL, (char *)&flag) < 0)
|
||||||
Perror("ioctl DIOCWLABEL");
|
err(4, "ioctl DIOCWLABEL");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if NUMBOOT > 0
|
#if NUMBOOT > 0
|
||||||
@ -506,7 +508,7 @@ readlabel(f)
|
|||||||
|
|
||||||
if (rflag) {
|
if (rflag) {
|
||||||
if (read(f, bootarea, BBSIZE) < BBSIZE)
|
if (read(f, bootarea, BBSIZE) < BBSIZE)
|
||||||
Perror(specname);
|
err(4, "%s", specname);
|
||||||
for (lp = (struct disklabel *)bootarea;
|
for (lp = (struct disklabel *)bootarea;
|
||||||
lp <= (struct disklabel *)(bootarea + BBSIZE - sizeof(*lp));
|
lp <= (struct disklabel *)(bootarea + BBSIZE - sizeof(*lp));
|
||||||
lp = (struct disklabel *)((char *)lp + 16))
|
lp = (struct disklabel *)((char *)lp + 16))
|
||||||
@ -524,7 +526,7 @@ readlabel(f)
|
|||||||
} else {
|
} else {
|
||||||
lp = &lab;
|
lp = &lab;
|
||||||
if (ioctl(f, DIOCGDINFO, lp) < 0)
|
if (ioctl(f, DIOCGDINFO, lp) < 0)
|
||||||
Perror("ioctl DIOCGDINFO");
|
err(4, "ioctl DIOCGDINFO");
|
||||||
}
|
}
|
||||||
return (lp);
|
return (lp);
|
||||||
}
|
}
|
||||||
@ -570,7 +572,7 @@ makebootarea(boot, dp, f)
|
|||||||
if (!installboot) {
|
if (!installboot) {
|
||||||
if (rflag) {
|
if (rflag) {
|
||||||
if (read(f, boot, BBSIZE) < BBSIZE)
|
if (read(f, boot, BBSIZE) < BBSIZE)
|
||||||
Perror(specname);
|
err(4, "%s", specname);
|
||||||
bzero((char *)lp, sizeof *lp);
|
bzero((char *)lp, sizeof *lp);
|
||||||
}
|
}
|
||||||
return (lp);
|
return (lp);
|
||||||
@ -630,7 +632,7 @@ makebootarea(boot, dp, f)
|
|||||||
*/
|
*/
|
||||||
b = open(xxboot, O_RDONLY);
|
b = open(xxboot, O_RDONLY);
|
||||||
if (b < 0)
|
if (b < 0)
|
||||||
Perror(xxboot);
|
err(4, "%s", xxboot);
|
||||||
#if NUMBOOT > 1
|
#if NUMBOOT > 1
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
/*
|
/*
|
||||||
@ -641,11 +643,11 @@ makebootarea(boot, dp, f)
|
|||||||
* the xxboot provides a template.)
|
* the xxboot provides a template.)
|
||||||
*/
|
*/
|
||||||
if ((tmpbuf = (char *)malloc((int)dp->d_secsize)) == 0)
|
if ((tmpbuf = (char *)malloc((int)dp->d_secsize)) == 0)
|
||||||
Perror(xxboot);
|
err(4, "%s", xxboot);
|
||||||
memcpy((void *)tmpbuf, (void *)boot, (int)dp->d_secsize);
|
memcpy((void *)tmpbuf, (void *)boot, (int)dp->d_secsize);
|
||||||
#endif /* i386 */
|
#endif /* i386 */
|
||||||
if (read(b, boot, (int)dp->d_secsize) < 0)
|
if (read(b, boot, (int)dp->d_secsize) < 0)
|
||||||
Perror(xxboot);
|
err(4, "%s", xxboot);
|
||||||
(void)close(b);
|
(void)close(b);
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
for (i = DOSPARTOFF, found = 0;
|
for (i = DOSPARTOFF, found = 0;
|
||||||
@ -660,13 +662,13 @@ makebootarea(boot, dp, f)
|
|||||||
#endif /* i386 */
|
#endif /* i386 */
|
||||||
b = open(bootxx, O_RDONLY);
|
b = open(bootxx, O_RDONLY);
|
||||||
if (b < 0)
|
if (b < 0)
|
||||||
Perror(bootxx);
|
err(4, "%s", bootxx);
|
||||||
if (read(b, &boot[dp->d_secsize],
|
if (read(b, &boot[dp->d_secsize],
|
||||||
(int)(dp->d_bbsize-dp->d_secsize)) < 0)
|
(int)(dp->d_bbsize-dp->d_secsize)) < 0)
|
||||||
Perror(bootxx);
|
err(4, "%s", bootxx);
|
||||||
#else
|
#else
|
||||||
if (read(b, boot, (int)dp->d_bbsize) < 0)
|
if (read(b, boot, (int)dp->d_bbsize) < 0)
|
||||||
Perror(xxboot);
|
err(4, "%s", xxboot);
|
||||||
(void)fstat(b, &sb);
|
(void)fstat(b, &sb);
|
||||||
bootsize = (int)sb.st_size - dp->d_bbsize;
|
bootsize = (int)sb.st_size - dp->d_bbsize;
|
||||||
if (bootsize > 0) {
|
if (bootsize > 0) {
|
||||||
@ -674,10 +676,10 @@ makebootarea(boot, dp, f)
|
|||||||
bootsize = (bootsize + dp->d_secsize-1) & ~(dp->d_secsize-1);
|
bootsize = (bootsize + dp->d_secsize-1) & ~(dp->d_secsize-1);
|
||||||
bootbuf = (char *)malloc((size_t)bootsize);
|
bootbuf = (char *)malloc((size_t)bootsize);
|
||||||
if (bootbuf == 0)
|
if (bootbuf == 0)
|
||||||
Perror(xxboot);
|
err(4, "%s", xxboot);
|
||||||
if (read(b, bootbuf, bootsize) < 0) {
|
if (read(b, bootbuf, bootsize) < 0) {
|
||||||
free(bootbuf);
|
free(bootbuf);
|
||||||
Perror(xxboot);
|
err(4, "%s", xxboot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1333,11 +1335,11 @@ getvirginlabel(void)
|
|||||||
}
|
}
|
||||||
(void)snprintf(namebuf, BBSIZE, "%sr%s", _PATH_DEV, dkname);
|
(void)snprintf(namebuf, BBSIZE, "%sr%s", _PATH_DEV, dkname);
|
||||||
if ((f = open(namebuf, O_RDONLY, 0)) == -1) {
|
if ((f = open(namebuf, O_RDONLY, 0)) == -1) {
|
||||||
Perror("open()");
|
err(4, "open()");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (ioctl(f, DIOCGDINFO, &lab) < 0) {
|
if (ioctl(f, DIOCGDINFO, &lab) < 0) {
|
||||||
Perror("ioctl DIOCGDINFO");
|
err(4, "ioctl DIOCGDINFO");
|
||||||
close(f);
|
close(f);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -1404,52 +1406,47 @@ Warning(char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
Perror(str)
|
|
||||||
char *str;
|
|
||||||
{
|
|
||||||
fputs("disklabel: ", stderr); perror(str);
|
|
||||||
exit(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
#if NUMBOOT > 0
|
#if NUMBOOT > 0
|
||||||
fprintf(stderr,
|
fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
|
||||||
"%s\n\t%s\n%s\n\t%s\n%s\n\t%s\n%s\n\t%s\n%s\n\t%s\n%s\n\t%s\n%s\n\t%s\n%s\n\t%s\n",
|
"usage: disklabel [-r] disk",
|
||||||
"usage: disklabel [-r] disk",
|
"\t\t(to read label)",
|
||||||
"(to read label)",
|
" disklabel -w [-r] disk type [ packid ]",
|
||||||
"or disklabel -w [-r] disk type [ packid ]",
|
"\t\t(to write label with existing boot program)",
|
||||||
"(to write label with existing boot program)",
|
" disklabel -e [-r] disk",
|
||||||
"or disklabel -e [-r] disk",
|
"\t\t(to edit label)",
|
||||||
"(to edit label)",
|
" disklabel -R [-r] disk protofile",
|
||||||
"or disklabel -R [-r] disk protofile",
|
"\t\t(to restore label with existing boot program)",
|
||||||
"(to restore label with existing boot program)",
|
|
||||||
#if NUMBOOT > 1
|
#if NUMBOOT > 1
|
||||||
"or disklabel -B [ -b boot1 [ -s boot2 ] ] disk [ type ]",
|
" disklabel -B [ -b boot1 [ -s boot2 ] ] disk [ type ]",
|
||||||
"(to install boot program with existing label)",
|
"\t\t(to install boot program with existing label)",
|
||||||
"or disklabel -w -B [ -b boot1 [ -s boot2 ] ] disk type [ packid ]",
|
" disklabel -w -B [ -b boot1 [ -s boot2 ] ] disk type [ packid ]",
|
||||||
"(to write label and boot program)",
|
"\t\t(to write label and boot program)",
|
||||||
"or disklabel -R -B [ -b boot1 [ -s boot2 ] ] disk protofile [ type ]",
|
" disklabel -R -B [ -b boot1 [ -s boot2 ] ] disk protofile [ type ]",
|
||||||
"(to restore label and boot program)",
|
"\t\t(to restore label and boot program)",
|
||||||
#else
|
#else
|
||||||
"or disklabel -B [ -b bootprog ] disk [ type ]",
|
" disklabel -B [ -b bootprog ] disk [ type ]",
|
||||||
"(to install boot program with existing on-disk label)",
|
"\t\t(to install boot program with existing on-disk label)",
|
||||||
"or disklabel -w -B [ -b bootprog ] disk type [ packid ]",
|
" disklabel -w -B [ -b bootprog ] disk type [ packid ]",
|
||||||
"(to write label and install boot program)",
|
"\t\t(to write label and install boot program)",
|
||||||
"or disklabel -R -B [ -b bootprog ] disk protofile [ type ]",
|
" disklabel -R -B [ -b bootprog ] disk protofile [ type ]",
|
||||||
"(to restore label and install boot program)",
|
"\t\t(to restore label and install boot program)",
|
||||||
#endif
|
#endif
|
||||||
"or disklabel [-NW] disk",
|
" disklabel [-NW] disk",
|
||||||
"(to write disable/enable label)");
|
"\t\t(to write disable/enable label)");
|
||||||
#else
|
#else
|
||||||
fprintf(stderr, "%-43s%s\n%-43s%s\n%-43s%s\n%-43s%s\n%-43s%s\n",
|
fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
|
||||||
"usage: disklabel [-r] disk", "(to read label)",
|
"usage: disklabel [-r] disk", "(to read label)",
|
||||||
"or disklabel -w [-r] disk type [ packid ]", "(to write label)",
|
" disklabel -w [-r] disk type [ packid ]",
|
||||||
"or disklabel -e [-r] disk", "(to edit label)",
|
"\t\t(to write label)",
|
||||||
"or disklabel -R [-r] disk protofile", "(to restore label)",
|
" disklabel -e [-r] disk",
|
||||||
"or disklabel [-NW] disk", "(to write disable/enable label)");
|
"\t\t(to edit label)",
|
||||||
|
" disklabel -R [-r] disk protofile",
|
||||||
|
"\t\t(to restore label)",
|
||||||
|
" disklabel [-NW] disk",
|
||||||
|
"\t\t(to write disable/enable label)");
|
||||||
#endif
|
#endif
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* 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
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* 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
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
@ -62,6 +64,7 @@ static char sccsid[] = "@(#)disklabel.c 8.2 (Berkeley) 1/7/94";
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <err.h>
|
||||||
#include "pathnames.h"
|
#include "pathnames.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -107,7 +110,6 @@ int getasciilabel __P((FILE *, struct disklabel *));
|
|||||||
int checklabel __P((struct disklabel *));
|
int checklabel __P((struct disklabel *));
|
||||||
void setbootflag __P((struct disklabel *));
|
void setbootflag __P((struct disklabel *));
|
||||||
void Warning (char *, ...);
|
void Warning (char *, ...);
|
||||||
void Perror __P((char *));
|
|
||||||
void usage __P((void));
|
void usage __P((void));
|
||||||
extern u_short dkcksum __P((struct disklabel *));
|
extern u_short dkcksum __P((struct disklabel *));
|
||||||
struct disklabel * getvirginlabel __P((void));
|
struct disklabel * getvirginlabel __P((void));
|
||||||
@ -245,7 +247,7 @@ main(argc, argv)
|
|||||||
f = open(specname, op == READ ? O_RDONLY : O_RDWR);
|
f = open(specname, op == READ ? O_RDONLY : O_RDWR);
|
||||||
}
|
}
|
||||||
if (f < 0)
|
if (f < 0)
|
||||||
Perror(specname);
|
err(4, "%s", specname);
|
||||||
|
|
||||||
switch(op) {
|
switch(op) {
|
||||||
|
|
||||||
@ -259,7 +261,7 @@ main(argc, argv)
|
|||||||
case NOWRITE:
|
case NOWRITE:
|
||||||
flag = 0;
|
flag = 0;
|
||||||
if (ioctl(f, DIOCWLABEL, (char *)&flag) < 0)
|
if (ioctl(f, DIOCWLABEL, (char *)&flag) < 0)
|
||||||
Perror("ioctl DIOCWLABEL");
|
err(4, "ioctl DIOCWLABEL");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case READ:
|
case READ:
|
||||||
@ -281,7 +283,7 @@ main(argc, argv)
|
|||||||
usage();
|
usage();
|
||||||
lp = makebootarea(bootarea, &lab, f);
|
lp = makebootarea(bootarea, &lab, f);
|
||||||
if (!(t = fopen(argv[1], "r")))
|
if (!(t = fopen(argv[1], "r")))
|
||||||
Perror(argv[1]);
|
err(4, "%s", argv[1]);
|
||||||
if (getasciilabel(t, lp))
|
if (getasciilabel(t, lp))
|
||||||
error = writelabel(f, bootarea, lp);
|
error = writelabel(f, bootarea, lp);
|
||||||
break;
|
break;
|
||||||
@ -303,7 +305,7 @@ main(argc, argv)
|
|||||||
case WRITEABLE:
|
case WRITEABLE:
|
||||||
flag = 1;
|
flag = 1;
|
||||||
if (ioctl(f, DIOCWLABEL, (char *)&flag) < 0)
|
if (ioctl(f, DIOCWLABEL, (char *)&flag) < 0)
|
||||||
Perror("ioctl DIOCWLABEL");
|
err(4, "ioctl DIOCWLABEL");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if NUMBOOT > 0
|
#if NUMBOOT > 0
|
||||||
@ -506,7 +508,7 @@ readlabel(f)
|
|||||||
|
|
||||||
if (rflag) {
|
if (rflag) {
|
||||||
if (read(f, bootarea, BBSIZE) < BBSIZE)
|
if (read(f, bootarea, BBSIZE) < BBSIZE)
|
||||||
Perror(specname);
|
err(4, "%s", specname);
|
||||||
for (lp = (struct disklabel *)bootarea;
|
for (lp = (struct disklabel *)bootarea;
|
||||||
lp <= (struct disklabel *)(bootarea + BBSIZE - sizeof(*lp));
|
lp <= (struct disklabel *)(bootarea + BBSIZE - sizeof(*lp));
|
||||||
lp = (struct disklabel *)((char *)lp + 16))
|
lp = (struct disklabel *)((char *)lp + 16))
|
||||||
@ -524,7 +526,7 @@ readlabel(f)
|
|||||||
} else {
|
} else {
|
||||||
lp = &lab;
|
lp = &lab;
|
||||||
if (ioctl(f, DIOCGDINFO, lp) < 0)
|
if (ioctl(f, DIOCGDINFO, lp) < 0)
|
||||||
Perror("ioctl DIOCGDINFO");
|
err(4, "ioctl DIOCGDINFO");
|
||||||
}
|
}
|
||||||
return (lp);
|
return (lp);
|
||||||
}
|
}
|
||||||
@ -570,7 +572,7 @@ makebootarea(boot, dp, f)
|
|||||||
if (!installboot) {
|
if (!installboot) {
|
||||||
if (rflag) {
|
if (rflag) {
|
||||||
if (read(f, boot, BBSIZE) < BBSIZE)
|
if (read(f, boot, BBSIZE) < BBSIZE)
|
||||||
Perror(specname);
|
err(4, "%s", specname);
|
||||||
bzero((char *)lp, sizeof *lp);
|
bzero((char *)lp, sizeof *lp);
|
||||||
}
|
}
|
||||||
return (lp);
|
return (lp);
|
||||||
@ -630,7 +632,7 @@ makebootarea(boot, dp, f)
|
|||||||
*/
|
*/
|
||||||
b = open(xxboot, O_RDONLY);
|
b = open(xxboot, O_RDONLY);
|
||||||
if (b < 0)
|
if (b < 0)
|
||||||
Perror(xxboot);
|
err(4, "%s", xxboot);
|
||||||
#if NUMBOOT > 1
|
#if NUMBOOT > 1
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
/*
|
/*
|
||||||
@ -641,11 +643,11 @@ makebootarea(boot, dp, f)
|
|||||||
* the xxboot provides a template.)
|
* the xxboot provides a template.)
|
||||||
*/
|
*/
|
||||||
if ((tmpbuf = (char *)malloc((int)dp->d_secsize)) == 0)
|
if ((tmpbuf = (char *)malloc((int)dp->d_secsize)) == 0)
|
||||||
Perror(xxboot);
|
err(4, "%s", xxboot);
|
||||||
memcpy((void *)tmpbuf, (void *)boot, (int)dp->d_secsize);
|
memcpy((void *)tmpbuf, (void *)boot, (int)dp->d_secsize);
|
||||||
#endif /* i386 */
|
#endif /* i386 */
|
||||||
if (read(b, boot, (int)dp->d_secsize) < 0)
|
if (read(b, boot, (int)dp->d_secsize) < 0)
|
||||||
Perror(xxboot);
|
err(4, "%s", xxboot);
|
||||||
(void)close(b);
|
(void)close(b);
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
for (i = DOSPARTOFF, found = 0;
|
for (i = DOSPARTOFF, found = 0;
|
||||||
@ -660,13 +662,13 @@ makebootarea(boot, dp, f)
|
|||||||
#endif /* i386 */
|
#endif /* i386 */
|
||||||
b = open(bootxx, O_RDONLY);
|
b = open(bootxx, O_RDONLY);
|
||||||
if (b < 0)
|
if (b < 0)
|
||||||
Perror(bootxx);
|
err(4, "%s", bootxx);
|
||||||
if (read(b, &boot[dp->d_secsize],
|
if (read(b, &boot[dp->d_secsize],
|
||||||
(int)(dp->d_bbsize-dp->d_secsize)) < 0)
|
(int)(dp->d_bbsize-dp->d_secsize)) < 0)
|
||||||
Perror(bootxx);
|
err(4, "%s", bootxx);
|
||||||
#else
|
#else
|
||||||
if (read(b, boot, (int)dp->d_bbsize) < 0)
|
if (read(b, boot, (int)dp->d_bbsize) < 0)
|
||||||
Perror(xxboot);
|
err(4, "%s", xxboot);
|
||||||
(void)fstat(b, &sb);
|
(void)fstat(b, &sb);
|
||||||
bootsize = (int)sb.st_size - dp->d_bbsize;
|
bootsize = (int)sb.st_size - dp->d_bbsize;
|
||||||
if (bootsize > 0) {
|
if (bootsize > 0) {
|
||||||
@ -674,10 +676,10 @@ makebootarea(boot, dp, f)
|
|||||||
bootsize = (bootsize + dp->d_secsize-1) & ~(dp->d_secsize-1);
|
bootsize = (bootsize + dp->d_secsize-1) & ~(dp->d_secsize-1);
|
||||||
bootbuf = (char *)malloc((size_t)bootsize);
|
bootbuf = (char *)malloc((size_t)bootsize);
|
||||||
if (bootbuf == 0)
|
if (bootbuf == 0)
|
||||||
Perror(xxboot);
|
err(4, "%s", xxboot);
|
||||||
if (read(b, bootbuf, bootsize) < 0) {
|
if (read(b, bootbuf, bootsize) < 0) {
|
||||||
free(bootbuf);
|
free(bootbuf);
|
||||||
Perror(xxboot);
|
err(4, "%s", xxboot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1333,11 +1335,11 @@ getvirginlabel(void)
|
|||||||
}
|
}
|
||||||
(void)snprintf(namebuf, BBSIZE, "%sr%s", _PATH_DEV, dkname);
|
(void)snprintf(namebuf, BBSIZE, "%sr%s", _PATH_DEV, dkname);
|
||||||
if ((f = open(namebuf, O_RDONLY, 0)) == -1) {
|
if ((f = open(namebuf, O_RDONLY, 0)) == -1) {
|
||||||
Perror("open()");
|
err(4, "open()");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (ioctl(f, DIOCGDINFO, &lab) < 0) {
|
if (ioctl(f, DIOCGDINFO, &lab) < 0) {
|
||||||
Perror("ioctl DIOCGDINFO");
|
err(4, "ioctl DIOCGDINFO");
|
||||||
close(f);
|
close(f);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -1404,52 +1406,47 @@ Warning(char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
Perror(str)
|
|
||||||
char *str;
|
|
||||||
{
|
|
||||||
fputs("disklabel: ", stderr); perror(str);
|
|
||||||
exit(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
#if NUMBOOT > 0
|
#if NUMBOOT > 0
|
||||||
fprintf(stderr,
|
fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
|
||||||
"%s\n\t%s\n%s\n\t%s\n%s\n\t%s\n%s\n\t%s\n%s\n\t%s\n%s\n\t%s\n%s\n\t%s\n%s\n\t%s\n",
|
"usage: disklabel [-r] disk",
|
||||||
"usage: disklabel [-r] disk",
|
"\t\t(to read label)",
|
||||||
"(to read label)",
|
" disklabel -w [-r] disk type [ packid ]",
|
||||||
"or disklabel -w [-r] disk type [ packid ]",
|
"\t\t(to write label with existing boot program)",
|
||||||
"(to write label with existing boot program)",
|
" disklabel -e [-r] disk",
|
||||||
"or disklabel -e [-r] disk",
|
"\t\t(to edit label)",
|
||||||
"(to edit label)",
|
" disklabel -R [-r] disk protofile",
|
||||||
"or disklabel -R [-r] disk protofile",
|
"\t\t(to restore label with existing boot program)",
|
||||||
"(to restore label with existing boot program)",
|
|
||||||
#if NUMBOOT > 1
|
#if NUMBOOT > 1
|
||||||
"or disklabel -B [ -b boot1 [ -s boot2 ] ] disk [ type ]",
|
" disklabel -B [ -b boot1 [ -s boot2 ] ] disk [ type ]",
|
||||||
"(to install boot program with existing label)",
|
"\t\t(to install boot program with existing label)",
|
||||||
"or disklabel -w -B [ -b boot1 [ -s boot2 ] ] disk type [ packid ]",
|
" disklabel -w -B [ -b boot1 [ -s boot2 ] ] disk type [ packid ]",
|
||||||
"(to write label and boot program)",
|
"\t\t(to write label and boot program)",
|
||||||
"or disklabel -R -B [ -b boot1 [ -s boot2 ] ] disk protofile [ type ]",
|
" disklabel -R -B [ -b boot1 [ -s boot2 ] ] disk protofile [ type ]",
|
||||||
"(to restore label and boot program)",
|
"\t\t(to restore label and boot program)",
|
||||||
#else
|
#else
|
||||||
"or disklabel -B [ -b bootprog ] disk [ type ]",
|
" disklabel -B [ -b bootprog ] disk [ type ]",
|
||||||
"(to install boot program with existing on-disk label)",
|
"\t\t(to install boot program with existing on-disk label)",
|
||||||
"or disklabel -w -B [ -b bootprog ] disk type [ packid ]",
|
" disklabel -w -B [ -b bootprog ] disk type [ packid ]",
|
||||||
"(to write label and install boot program)",
|
"\t\t(to write label and install boot program)",
|
||||||
"or disklabel -R -B [ -b bootprog ] disk protofile [ type ]",
|
" disklabel -R -B [ -b bootprog ] disk protofile [ type ]",
|
||||||
"(to restore label and install boot program)",
|
"\t\t(to restore label and install boot program)",
|
||||||
#endif
|
#endif
|
||||||
"or disklabel [-NW] disk",
|
" disklabel [-NW] disk",
|
||||||
"(to write disable/enable label)");
|
"\t\t(to write disable/enable label)");
|
||||||
#else
|
#else
|
||||||
fprintf(stderr, "%-43s%s\n%-43s%s\n%-43s%s\n%-43s%s\n%-43s%s\n",
|
fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
|
||||||
"usage: disklabel [-r] disk", "(to read label)",
|
"usage: disklabel [-r] disk", "(to read label)",
|
||||||
"or disklabel -w [-r] disk type [ packid ]", "(to write label)",
|
" disklabel -w [-r] disk type [ packid ]",
|
||||||
"or disklabel -e [-r] disk", "(to edit label)",
|
"\t\t(to write label)",
|
||||||
"or disklabel -R [-r] disk protofile", "(to restore label)",
|
" disklabel -e [-r] disk",
|
||||||
"or disklabel [-NW] disk", "(to write disable/enable label)");
|
"\t\t(to edit label)",
|
||||||
|
" disklabel -R [-r] disk protofile",
|
||||||
|
"\t\t(to restore label)",
|
||||||
|
" disklabel [-NW] disk",
|
||||||
|
"\t\t(to write disable/enable label)");
|
||||||
#endif
|
#endif
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* 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
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
|
Loading…
Reference in New Issue
Block a user