Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/gpt more toolification



details:   https://anonhg.NetBSD.org/src/rev/973c6821b401
branches:  trunk
changeset: 332582:973c6821b401
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Sep 29 21:04:34 2014 +0000

description:
more toolification

diffstat:

 sbin/gpt/Makefile   |   9 ++++++---
 sbin/gpt/backup.c   |   4 ++--
 sbin/gpt/biosboot.c |   8 ++++++--
 sbin/gpt/destroy.c  |   6 +++---
 sbin/gpt/gpt.c      |  32 ++++++++++++++++++++++++++++----
 sbin/gpt/migrate.c  |   4 ++--
 6 files changed, 47 insertions(+), 16 deletions(-)

diffs (260 lines):

diff -r 642939a61358 -r 973c6821b401 sbin/gpt/Makefile
--- a/sbin/gpt/Makefile Mon Sep 29 20:29:44 2014 +0000
+++ b/sbin/gpt/Makefile Mon Sep 29 21:04:34 2014 +0000
@@ -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>
diff -r 642939a61358 -r 973c6821b401 sbin/gpt/backup.c
--- a/sbin/gpt/backup.c Mon Sep 29 20:29:44 2014 +0000
+++ b/sbin/gpt/backup.c Mon Sep 29 21:04:34 2014 +0000
@@ -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 @@
 #include <string.h>
 #include <unistd.h>
 #include <prop/proplib.h>
+#endif
 
 #include "map.h"
 #include "gpt.h"
@@ -305,7 +306,6 @@
                        warn("unable to open device '%s'", device_name);
                        continue;
                }
-
                backup();
 
                gpt_close(fd);
diff -r 642939a61358 -r 973c6821b401 sbin/gpt/biosboot.c
--- a/sbin/gpt/biosboot.c       Mon Sep 29 20:29:44 2014 +0000
+++ b/sbin/gpt/biosboot.c       Mon Sep 29 21:04:34 2014 +0000
@@ -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 @@
 #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"
diff -r 642939a61358 -r 973c6821b401 sbin/gpt/destroy.c
--- a/sbin/gpt/destroy.c        Mon Sep 29 20:29:44 2014 +0000
+++ b/sbin/gpt/destroy.c        Mon Sep 29 21:04:34 2014 +0000
@@ -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 @@
        }
 
        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);
        }
 }
diff -r 642939a61358 -r 973c6821b401 sbin/gpt/gpt.c
--- a/sbin/gpt/gpt.c    Mon Sep 29 20:29:44 2014 +0000
+++ b/sbin/gpt/gpt.c    Mon Sep 29 21:04:34 2014 +0000
@@ -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 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <ctype.h>
+#ifndef HAVE_NBTOOL_CONFIG_H
 #include <util.h>
-#include <ctype.h>
 #include <prop/proplib.h>
 #include <sys/drvctlio.h>
+#else
+#include "opendisk.h"
+#endif
 
 #include "map.h"
 #include "gpt.h"
@@ -455,6 +459,7 @@
        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 @@
        errno = EINVAL;
        return -1;
 }
+#endif
 
 int
 gpt_gpt(int fd, off_t lba, int found)
@@ -666,8 +672,10 @@
                    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 @@
        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 @@
        { 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 @@
 __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 @@
            "       %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 @@
            "       %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 @@
            getprogname(), removemsg2,
            getprogname(), resizemsg,
            getprogname(), resizediskmsg,
+#ifndef HAVE_NBTOOL_CONFIG_H
            getprogname(), restoremsg,
+#endif
            getprogname(), setmsg,
            getprogname(), showmsg,
            getprogname(), typemsg1,
diff -r 642939a61358 -r 973c6821b401 sbin/gpt/migrate.c
--- a/sbin/gpt/migrate.c        Mon Sep 29 20:29:44 2014 +0000
+++ b/sbin/gpt/migrate.c        Mon Sep 29 21:04:34 2014 +0000
@@ -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 @@
        /*
         * 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;



Home | Main Index | Thread Index | Old Index