Module Name: src
Committed By: christos
Date: Mon Sep 29 21:04:34 UTC 2014
Modified Files:
src/sbin/gpt: Makefile backup.c biosboot.c destroy.c gpt.c migrate.c
Log Message:
more toolification
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sbin/gpt/Makefile src/sbin/gpt/biosboot.c
cvs rdiff -u -r1.4 -r1.5 src/sbin/gpt/backup.c
cvs rdiff -u -r1.5 -r1.6 src/sbin/gpt/destroy.c
cvs rdiff -u -r1.31 -r1.32 src/sbin/gpt/gpt.c
cvs rdiff -u -r1.15 -r1.16 src/sbin/gpt/migrate.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/gpt/Makefile
diff -u src/sbin/gpt/Makefile:1.10 src/sbin/gpt/Makefile:1.11
--- src/sbin/gpt/Makefile:1.10 Sun Sep 28 04:14:51 2014
+++ src/sbin/gpt/Makefile Mon Sep 29 17:04:34 2014
@@ -1,13 +1,16 @@
-# $NetBSD: Makefile,v 1.10 2014/09/28 08:14:51 jnemeth Exp $
+# $NetBSD: Makefile,v 1.11 2014/09/29 21:04:34 christos Exp $
# $FreeBSD: src/sbin/gpt/Makefile,v 1.7 2005/09/01 02:49:20 marcel Exp $
PROG= gpt
-SRCS= add.c backup.c biosboot.c create.c destroy.c gpt.c label.c map.c \
- migrate.c recover.c remove.c resize.c resizedisk.c restore.c \
+SRCS= add.c biosboot.c create.c destroy.c gpt.c label.c map.c \
+ migrate.c recover.c remove.c resize.c resizedisk.c \
set.c show.c type.c unset.c
MAN= gpt.8
+.if (${HOSTPROG:U} == "")
+SRCS+= backup.c restore.c
LDADD+= -lprop -lutil
DPADD+= ${LIBPROP} ${LIBUTIL}
+.endif
.include <bsd.prog.mk>
Index: src/sbin/gpt/biosboot.c
diff -u src/sbin/gpt/biosboot.c:1.10 src/sbin/gpt/biosboot.c:1.11
--- src/sbin/gpt/biosboot.c:1.10 Mon Sep 29 16:28:57 2014
+++ src/sbin/gpt/biosboot.c Mon Sep 29 17:04:34 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: biosboot.c,v 1.10 2014/09/29 20:28:57 christos Exp $ */
+/* $NetBSD: biosboot.c,v 1.11 2014/09/29 21:04:34 christos Exp $ */
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#ifdef __RCSID
-__RCSID("$NetBSD: biosboot.c,v 1.10 2014/09/29 20:28:57 christos Exp $");
+__RCSID("$NetBSD: biosboot.c,v 1.11 2014/09/29 21:04:34 christos Exp $");
#endif
#include <sys/stat.h>
@@ -56,7 +56,11 @@ __RCSID("$NetBSD: biosboot.c,v 1.10 2014
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#ifndef NBTOOL_CONFIG_H
#include <util.h>
+#else
+#include "opendisk.h"
+#endif
#include "map.h"
#include "gpt.h"
Index: src/sbin/gpt/backup.c
diff -u src/sbin/gpt/backup.c:1.4 src/sbin/gpt/backup.c:1.5
--- src/sbin/gpt/backup.c:1.4 Mon Sep 29 16:28:57 2014
+++ src/sbin/gpt/backup.c Mon Sep 29 17:04:34 2014
@@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/show.c,v 1.14 2006/06/22 22:22:32 marcel Exp $");
#endif
#ifdef __RCSID
-__RCSID("$NetBSD: backup.c,v 1.4 2014/09/29 20:28:57 christos Exp $");
+__RCSID("$NetBSD: backup.c,v 1.5 2014/09/29 21:04:34 christos Exp $");
#endif
#include <sys/bootblock.h>
@@ -46,6 +46,7 @@ __RCSID("$NetBSD: backup.c,v 1.4 2014/09
#include <string.h>
#include <unistd.h>
#include <prop/proplib.h>
+#endif
#include "map.h"
#include "gpt.h"
@@ -305,7 +306,6 @@ cmd_backup(int argc, char *argv[])
warn("unable to open device '%s'", device_name);
continue;
}
-
backup();
gpt_close(fd);
Index: src/sbin/gpt/destroy.c
diff -u src/sbin/gpt/destroy.c:1.5 src/sbin/gpt/destroy.c:1.6
--- src/sbin/gpt/destroy.c:1.5 Mon Sep 29 16:28:57 2014
+++ src/sbin/gpt/destroy.c Mon Sep 29 17:04:34 2014
@@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/destroy.c,v 1.6 2005/08/31 01:47:19 marcel Exp $");
#endif
#ifdef __RCSID
-__RCSID("$NetBSD: destroy.c,v 1.5 2014/09/29 20:28:57 christos Exp $");
+__RCSID("$NetBSD: destroy.c,v 1.6 2014/09/29 21:04:34 christos Exp $");
#endif
#include <sys/types.h>
@@ -80,12 +80,12 @@ destroy(int fd)
}
if (pri_hdr != NULL) {
- bzero(pri_hdr->map_data, secsz);
+ memset(pri_hdr->map_data, 0, secsz);
gpt_write(fd, pri_hdr);
}
if (!recoverable && sec_hdr != NULL) {
- bzero(sec_hdr->map_data, secsz);
+ memset(sec_hdr->map_data, 0, secsz);
gpt_write(fd, sec_hdr);
}
}
Index: src/sbin/gpt/gpt.c
diff -u src/sbin/gpt/gpt.c:1.31 src/sbin/gpt/gpt.c:1.32
--- src/sbin/gpt/gpt.c:1.31 Mon Sep 29 16:28:57 2014
+++ src/sbin/gpt/gpt.c Mon Sep 29 17:04:34 2014
@@ -35,7 +35,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/gpt.c,v 1.16 2006/07/07 02:44:23 marcel Exp $");
#endif
#ifdef __RCSID
-__RCSID("$NetBSD: gpt.c,v 1.31 2014/09/29 20:28:57 christos Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.32 2014/09/29 21:04:34 christos Exp $");
#endif
#include <sys/param.h>
@@ -54,10 +54,14 @@ __RCSID("$NetBSD: gpt.c,v 1.31 2014/09/2
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <util.h>
#include <ctype.h>
+#ifndef HAVE_NBTOOL_CONFIG_H
+#include <util.h>
#include <prop/proplib.h>
#include <sys/drvctlio.h>
+#else
+#include "opendisk.h"
+#endif
#include "map.h"
#include "gpt.h"
@@ -455,6 +459,7 @@ gpt_mbr(int fd, off_t lba)
return (0);
}
+#ifndef HAVE_NBTOOL_CONFIG_H
static int
drvctl(const char *name, u_int *sector_size, off_t *media_size)
{
@@ -537,6 +542,7 @@ out:
errno = EINVAL;
return -1;
}
+#endif
int
gpt_gpt(int fd, off_t lba, int found)
@@ -666,8 +672,10 @@ gpt_open(const char *dev)
ioctl(fd, DIOCGMEDIASIZE, &mediasz) == -1)
goto close;
#endif
+#ifndef HAVE_NBTOOL_CONFIG_H
if (drvctl(device_name, &secsz, &mediasz) == -1)
goto close;
+#endif
} else {
secsz = 512; /* Fixed size for files. */
if (sb.st_size % secsz) {
@@ -721,7 +729,9 @@ static struct {
const char *name;
} cmdsw[] = {
{ cmd_add, "add" },
+#ifndef HAVE_NBTOOL_CONFIG_H
{ cmd_backup, "backup" },
+#endif
{ cmd_biosboot, "biosboot" },
{ cmd_create, "create" },
{ cmd_destroy, "destroy" },
@@ -733,7 +743,9 @@ static struct {
{ NULL, "rename" },
{ cmd_resize, "resize" },
{ cmd_resizedisk, "resizedisk" },
+#ifndef HAVE_NBTOOL_CONFIG_H
{ cmd_restore, "restore" },
+#endif
{ cmd_set, "set" },
{ cmd_show, "show" },
{ cmd_type, "type" },
@@ -745,17 +757,23 @@ static struct {
__dead static void
usage(void)
{
- extern const char addmsg1[], addmsg2[], backupmsg[], biosbootmsg[];
+ extern const char addmsg1[], addmsg2[], biosbootmsg[];
extern const char createmsg[], destroymsg[], labelmsg1[], labelmsg2[];
extern const char labelmsg3[], migratemsg[], recovermsg[], removemsg1[];
extern const char removemsg2[], resizemsg[], resizediskmsg[];
- extern const char restoremsg[], setmsg[], showmsg[], typemsg1[];
+ extern const char setmsg[], showmsg[], typemsg1[];
extern const char typemsg2[], typemsg3[], unsetmsg[];
+#ifndef HAVE_NBTOOL_CONFIG_H
+ extern const char backupmsg[], restoremsg[];
+#endif
+
fprintf(stderr,
"usage: %s %s\n"
" %s %s\n"
+#ifndef HAVE_NBTOOL_CONFIG_H
" %s %s\n"
+#endif
" %s %s\n"
" %s %s\n"
" %s %s\n"
@@ -769,7 +787,9 @@ usage(void)
" %s %s\n"
" %s %s\n"
" %s %s\n"
+#ifndef HAVE_NBTOOL_CONFIG_H
" %s %s\n"
+#endif
" %s %s\n"
" %s %s\n"
" %s %s\n"
@@ -777,7 +797,9 @@ usage(void)
" %s %s\n",
getprogname(), addmsg1,
getprogname(), addmsg2,
+#ifndef HAVE_NBTOOL_CONFIG_H
getprogname(), backupmsg,
+#endif
getprogname(), biosbootmsg,
getprogname(), createmsg,
getprogname(), destroymsg,
@@ -790,7 +812,9 @@ usage(void)
getprogname(), removemsg2,
getprogname(), resizemsg,
getprogname(), resizediskmsg,
+#ifndef HAVE_NBTOOL_CONFIG_H
getprogname(), restoremsg,
+#endif
getprogname(), setmsg,
getprogname(), showmsg,
getprogname(), typemsg1,
Index: src/sbin/gpt/migrate.c
diff -u src/sbin/gpt/migrate.c:1.15 src/sbin/gpt/migrate.c:1.16
--- src/sbin/gpt/migrate.c:1.15 Mon Sep 29 16:28:57 2014
+++ src/sbin/gpt/migrate.c Mon Sep 29 17:04:34 2014
@@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/migrate.c,v 1.16 2005/09/01 02:42:52 marcel Exp $");
#endif
#ifdef __RCSID
-__RCSID("$NetBSD: migrate.c,v 1.15 2014/09/29 20:28:57 christos Exp $");
+__RCSID("$NetBSD: migrate.c,v 1.16 2014/09/29 21:04:34 christos Exp $");
#endif
#include <sys/types.h>
@@ -437,7 +437,7 @@ migrate(int fd)
/*
* Turn the MBR into a Protective MBR.
*/
- bzero(mbr->mbr_part, sizeof(mbr->mbr_part));
+ memset(mbr->mbr_part, 0, sizeof(mbr->mbr_part));
mbr->mbr_part[0].part_shd = 0x00;
mbr->mbr_part[0].part_ssect = 0x02;
mbr->mbr_part[0].part_scyl = 0x00;