CVS commit: src/sbin/gpt

2024-02-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Feb  6 20:25:11 UTC 2024

Modified Files:
src/sbin/gpt: resizedisk.c

Log Message:
check the right variable


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sbin/gpt/resizedisk.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/resizedisk.c
diff -u src/sbin/gpt/resizedisk.c:1.20 src/sbin/gpt/resizedisk.c:1.21
--- src/sbin/gpt/resizedisk.c:1.20	Mon Nov 21 19:25:52 2022
+++ src/sbin/gpt/resizedisk.c	Tue Feb  6 15:25:11 2024
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: resizedisk.c,v 1.20 2022/11/22 00:25:52 mlelstv Exp $");
+__RCSID("$NetBSD: resizedisk.c,v 1.21 2024/02/06 20:25:11 christos Exp $");
 #endif
 
 #include 
@@ -107,7 +107,7 @@ resizedisk(gpt_t gpt, off_t sector, off_
 mbr = mbrmap->map_data;
 
 	gpt->gpt = map_find(gpt, MAP_TYPE_PRI_GPT_HDR);
-	if (gpt == NULL) {
+	if (gpt->gpt == NULL) {
 		gpt_warnx(gpt, "No primary GPT header; run create or recover");
 		return -1;
 	}



CVS commit: src/sbin/gpt

2024-02-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Feb  6 20:25:11 UTC 2024

Modified Files:
src/sbin/gpt: resizedisk.c

Log Message:
check the right variable


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sbin/gpt/resizedisk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2023-12-12 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Dec 13 06:51:57 UTC 2023

Modified Files:
src/sbin/gpt: gpt.c

Log Message:
avoid use after free.  skip the QUIET check already in gpt_warn().


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sbin/gpt/gpt.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/gpt.c
diff -u src/sbin/gpt/gpt.c:1.86 src/sbin/gpt/gpt.c:1.87
--- src/sbin/gpt/gpt.c:1.86	Mon Dec 11 12:45:22 2023
+++ src/sbin/gpt/gpt.c	Wed Dec 13 06:51:57 2023
@@ -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.86 2023/12/11 12:45:22 mlelstv Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.87 2023/12/13 06:51:57 mrg Exp $");
 #endif
 
 #include 
@@ -604,9 +604,8 @@ gpt_open(const char *dev, int flags, int
  close:
 	if (gpt->fd != -1)
 		close(gpt->fd);
+	gpt_warn(gpt, "No GPT found");
 	free(gpt);
-	if (!(flags & GPT_QUIET))
-		gpt_warn(gpt, "No GPT found");
 	return NULL;
 }
 



CVS commit: src/sbin/gpt

2023-12-12 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Dec 13 06:51:57 UTC 2023

Modified Files:
src/sbin/gpt: gpt.c

Log Message:
avoid use after free.  skip the QUIET check already in gpt_warn().


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sbin/gpt/gpt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2023-12-11 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Dec 11 12:45:22 UTC 2023

Modified Files:
src/sbin/gpt: gpt.c

Log Message:
Be verbose about errors.


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sbin/gpt/gpt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2023-12-11 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Dec 11 12:45:22 UTC 2023

Modified Files:
src/sbin/gpt: gpt.c

Log Message:
Be verbose about errors.


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sbin/gpt/gpt.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/gpt.c
diff -u src/sbin/gpt/gpt.c:1.85 src/sbin/gpt/gpt.c:1.86
--- src/sbin/gpt/gpt.c:1.85	Tue Sep 26 15:55:46 2023
+++ src/sbin/gpt/gpt.c	Mon Dec 11 12:45:22 2023
@@ -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.85 2023/09/26 15:55:46 kre Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.86 2023/12/11 12:45:22 mlelstv Exp $");
 #endif
 
 #include 
@@ -386,8 +386,10 @@ gpt_gpt(gpt_t gpt, off_t lba, int found)
 	uint32_t crc;
 
 	hdr = gpt_read(gpt, lba, 1);
-	if (hdr == NULL)
+	if (hdr == NULL) {
+		gpt_warn(gpt, "Read failed");
 		return -1;
+	}
 
 	if (memcmp(hdr->hdr_sig, GPT_HDR_SIG, sizeof(hdr->hdr_sig)))
 		goto fail_hdr;
@@ -540,6 +542,7 @@ gpt_open(const char *dev, int flags, int
 			gpt->secsz = 512;	/* Fixed size for files. */
 		if (gpt->mediasz == 0) {
 			if (gpt->sb.st_size % gpt->secsz) {
+gpt_warn(gpt, "Media size not a multiple of sector size (%u)\n", gpt->secsz);
 errno = EINVAL;
 goto close;
 			}
@@ -602,6 +605,8 @@ gpt_open(const char *dev, int flags, int
 	if (gpt->fd != -1)
 		close(gpt->fd);
 	free(gpt);
+	if (!(flags & GPT_QUIET))
+		gpt_warn(gpt, "No GPT found");
 	return NULL;
 }
 



CVS commit: src/sbin/gpt

2023-12-05 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Dec  5 17:23:20 UTC 2023

Modified Files:
src/sbin/gpt: map.c

Log Message:
Fix an incorrect comment.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sbin/gpt/map.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/map.c
diff -u src/sbin/gpt/map.c:1.15 src/sbin/gpt/map.c:1.16
--- src/sbin/gpt/map.c:1.15	Sun May 24 14:42:44 2020
+++ src/sbin/gpt/map.c	Tue Dec  5 17:23:19 2023
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/map.c,v 1.6 2005/08/31 01:47:19 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: map.c,v 1.15 2020/05/24 14:42:44 jmcneill Exp $");
+__RCSID("$NetBSD: map.c,v 1.16 2023/12/05 17:23:19 tsutsui Exp $");
 #endif
 
 #include 
@@ -257,7 +257,7 @@ map_resize(gpt_t gpt, map_t m, off_t siz
 		gpt_warnx(gpt, "negative size or alignment");
 		return -1;
 	}
-	/* Size == 0 means delete, if the next map is unused */
+	/* Size == 0 means to use whole region of the following unused map */
 	if (size == 0) { 
 		if (n == NULL) {
 			// XXX: we could just turn the map to UNUSED!



CVS commit: src/sbin/gpt

2023-12-05 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Dec  5 17:23:20 UTC 2023

Modified Files:
src/sbin/gpt: map.c

Log Message:
Fix an incorrect comment.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sbin/gpt/map.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2023-11-06 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Tue Nov  7 00:53:39 UTC 2023

Modified Files:
src/sbin/gpt: gpt.8

Log Message:
gpt.8: fix grammar in a sentence


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sbin/gpt/gpt.8

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/gpt.8
diff -u src/sbin/gpt/gpt.8:1.79 src/sbin/gpt/gpt.8:1.80
--- src/sbin/gpt/gpt.8:1.79	Tue Oct 31 12:09:48 2023
+++ src/sbin/gpt/gpt.8	Tue Nov  7 00:53:39 2023
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.79 2023/10/31 12:09:48 martin Exp $
+.\" $NetBSD: gpt.8,v 1.80 2023/11/07 00:53:39 gutteridge Exp $
 .\"
 .\" Copyright (c) 2002 Marcel Moolenaar
 .\" All rights reserved.
@@ -659,7 +659,7 @@ option, all information for all GPT part
 .Fl i Ar index )
 will be printed.
 None of the options have any effect on non-GPT partitions.
-The order of precedence for the options are:
+The order of precedence for the options is:
 .Fl a ,
 .Fl i ,
 .Fl l ,



CVS commit: src/sbin/gpt

2023-11-06 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Tue Nov  7 00:53:39 UTC 2023

Modified Files:
src/sbin/gpt: gpt.8

Log Message:
gpt.8: fix grammar in a sentence


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sbin/gpt/gpt.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2023-10-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 31 12:09:48 UTC 2023

Modified Files:
src/sbin/gpt: gpt.8

Log Message:
Apply patch from Thierry Laronde: add missing suffixes for size values
and clarify that they are case independant.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sbin/gpt/gpt.8

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/gpt.8
diff -u src/sbin/gpt/gpt.8:1.78 src/sbin/gpt/gpt.8:1.79
--- src/sbin/gpt/gpt.8:1.78	Sat Jul 15 21:18:06 2023
+++ src/sbin/gpt/gpt.8	Tue Oct 31 12:09:48 2023
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.78 2023/07/15 21:18:06 gutteridge Exp $
+.\" $NetBSD: gpt.8,v 1.79 2023/10/31 12:09:48 martin Exp $
 .\"
 .\" Copyright (c) 2002 Marcel Moolenaar
 .\" All rights reserved.
@@ -160,7 +160,7 @@ or
 .Sq S
 then size is in sectors, otherwise size is in bytes which must be
 a multiple of the device's sector size.
-Accepted suffix units are
+Accepted suffix units (case insensitive) are
 .Sq b
 to denote bytes,
 .Sq k
@@ -168,7 +168,13 @@ to denote kilobytes,
 .Sq m
 to denote megabytes and
 .Sq g
-to denote gigabytes.
+to denote gigabytes,
+.Sq t
+to denote terabytes,
+.Sq p
+to denote petabytes, and
+.Sq e
+to denote exabytes.
 The minimum size is 1 sector.
 .Pp
 The



CVS commit: src/sbin/gpt

2023-10-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 31 12:09:48 UTC 2023

Modified Files:
src/sbin/gpt: gpt.8

Log Message:
Apply patch from Thierry Laronde: add missing suffixes for size values
and clarify that they are case independant.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sbin/gpt/gpt.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/sbin/gpt

2023-09-27 Thread Robert Elz
Date:Wed, 27 Sep 2023 09:44:10 +
From:"Taylor R Campbell" 
Message-ID:  <20230927094410.b9257f...@cvs.netbsd.org>

  | gpt(8): Make gpt type array and enum match again.

Thanks, and apologies for not checking that better - I did test
that it recognised the new one properly...

kre




CVS commit: src/sbin/gpt

2023-09-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Sep 27 09:44:10 UTC 2023

Modified Files:
src/sbin/gpt: gpt_uuid.c gpt_uuid.h

Log Message:
gpt(8): Make gpt type array and enum match again.

Add cross-referencing comment to reduce the probability of these
getting out of sync again.

Should fix a slew of failing tests since kre's recent change to add
windows-recovery to the array but not to the enum:

sbin/gpt/t_gpt:create_2part
sbin/gpt/t_gpt:migrate_disklabel
sbin/gpt/t_gpt:recover_backup
sbin/gpt/t_gpt:recover_primary
sbin/gpt/t_gpt:remove_2part
sbin/gpt/t_gpt:resize_2part
sbin/gpt/t_gpt:restore_2part

Fail: stdout does not match golden output
--- /usr/tests/sbin/gpt/gpt.2part.show.normal   2023-09-26 15:48:30.0 
+
+++ /tmp/check.sc6ylB/stdout2023-09-26 23:30:42.388157924 
+
@@ -3,6 +3,6 @@
   1  1 Pri GPT header
   2 32 Pri GPT table
  34   1024  1  GPT part - EFI System
-   1058   9150  2  GPT part - NetBSD FFSv1/FFSv2
+   1058   9150  2  GPT part - NetBSD Cryptographic Disk
   10208 32 Sec GPT table
   10240  1 Sec GPT header

https://releng.netbsd.org/b5reports/i386/commits-2023.09.html#build-2023.09.26.15.47.11


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sbin/gpt/gpt_uuid.c
cvs rdiff -u -r1.9 -r1.10 src/sbin/gpt/gpt_uuid.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2023-09-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Sep 27 09:44:10 UTC 2023

Modified Files:
src/sbin/gpt: gpt_uuid.c gpt_uuid.h

Log Message:
gpt(8): Make gpt type array and enum match again.

Add cross-referencing comment to reduce the probability of these
getting out of sync again.

Should fix a slew of failing tests since kre's recent change to add
windows-recovery to the array but not to the enum:

sbin/gpt/t_gpt:create_2part
sbin/gpt/t_gpt:migrate_disklabel
sbin/gpt/t_gpt:recover_backup
sbin/gpt/t_gpt:recover_primary
sbin/gpt/t_gpt:remove_2part
sbin/gpt/t_gpt:resize_2part
sbin/gpt/t_gpt:restore_2part

Fail: stdout does not match golden output
--- /usr/tests/sbin/gpt/gpt.2part.show.normal   2023-09-26 15:48:30.0 
+
+++ /tmp/check.sc6ylB/stdout2023-09-26 23:30:42.388157924 
+
@@ -3,6 +3,6 @@
   1  1 Pri GPT header
   2 32 Pri GPT table
  34   1024  1  GPT part - EFI System
-   1058   9150  2  GPT part - NetBSD FFSv1/FFSv2
+   1058   9150  2  GPT part - NetBSD Cryptographic Disk
   10208 32 Sec GPT table
   10240  1 Sec GPT header

https://releng.netbsd.org/b5reports/i386/commits-2023.09.html#build-2023.09.26.15.47.11


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sbin/gpt/gpt_uuid.c
cvs rdiff -u -r1.9 -r1.10 src/sbin/gpt/gpt_uuid.h

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/gpt_uuid.c
diff -u src/sbin/gpt/gpt_uuid.c:1.20 src/sbin/gpt/gpt_uuid.c:1.21
--- src/sbin/gpt/gpt_uuid.c:1.20	Tue Sep 26 15:48:30 2023
+++ src/sbin/gpt/gpt_uuid.c	Wed Sep 27 09:44:10 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: gpt_uuid.c,v 1.20 2023/09/26 15:48:30 kre Exp $	*/
+/*	$NetBSD: gpt_uuid.c,v 1.21 2023/09/27 09:44:10 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: gpt_uuid.c,v 1.20 2023/09/26 15:48:30 kre Exp $");
+__RCSID("$NetBSD: gpt_uuid.c,v 1.21 2023/09/27 09:44:10 riastradh Exp $");
 #endif
 
 #include 
@@ -65,6 +65,7 @@ static const struct {
 	const char *n;
 	const char *d;
 } gpt_nv[] = {
+	/* Must match the gpt_type_t enum in gpt_uuid.h */
 	{ GPT_ENT_TYPE_APPLE_HFS, "apple", "Apple HFS" },
 	{ GPT_ENT_TYPE_APPLE_UFS, "apple-ufs", "Apple UFS" },
 	{ GPT_ENT_TYPE_BIOS, "bios", "BIOS Boot" },

Index: src/sbin/gpt/gpt_uuid.h
diff -u src/sbin/gpt/gpt_uuid.h:1.9 src/sbin/gpt/gpt_uuid.h:1.10
--- src/sbin/gpt/gpt_uuid.h:1.9	Sun Jun 30 11:38:16 2019
+++ src/sbin/gpt/gpt_uuid.h	Wed Sep 27 09:44:10 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: gpt_uuid.h,v 1.9 2019/06/30 11:38:16 sevan Exp $	*/
+/*	$NetBSD: gpt_uuid.h,v 1.10 2023/09/27 09:44:10 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -46,7 +46,7 @@
  * support anyway
  */
 
-// Must match the array in gpt_uuid.c
+/* Must match the gpt_nv array in gpt_uuid.c */
 typedef enum {
 	GPT_TYPE_INVALID = -1,
 	GPT_TYPE_APPLE_HFS = 0,
@@ -64,6 +64,7 @@ typedef enum {
 	GPT_TYPE_LINUX_LVM,
 	GPT_TYPE_MS_BASIC_DATA,
 	GPT_TYPE_MS_RESERVED,
+	GPT_TYPE_MS_RECOVERY,
 	GPT_TYPE_NETBSD_CCD,
 	GPT_TYPE_NETBSD_CGD,
 	GPT_TYPE_NETBSD_FFS,



CVS commit: src/sbin/gpt

2023-09-26 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Sep 26 15:55:46 UTC 2023

Modified Files:
src/sbin/gpt: gpt.c

Log Message:
When extracting the attributes (to printable form), avoid simply ignoring
any attribute bits which are unknown, print them as a hex value.  This
avoids "Attributes: " for most windows filesystem types, which all seem
to have but 63 set (which is supposed to mean "don't assign a drive letter"
which is akin to "noauto" in fstab - except it is set even on partitions
which do get mounted, so must mean something subtly different).

These upper 16 attribute bits are supposed to be file system type speficic
(in practice, they seem to be common to all filesystem types from one vendor)
but we don't have the info (yet anyway) to treat them like that.

ChromeOS seems to treat some of the bits as bit fields containing numeric
values - add #if 0'd (but compile tested) code to deal with those (maybe,
compile tested - but not execution tested) should someone ever get an
environment where these things occur, and could add the missing definitions
to actually test this.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sbin/gpt/gpt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2023-09-26 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Sep 26 15:55:46 UTC 2023

Modified Files:
src/sbin/gpt: gpt.c

Log Message:
When extracting the attributes (to printable form), avoid simply ignoring
any attribute bits which are unknown, print them as a hex value.  This
avoids "Attributes: " for most windows filesystem types, which all seem
to have but 63 set (which is supposed to mean "don't assign a drive letter"
which is akin to "noauto" in fstab - except it is set even on partitions
which do get mounted, so must mean something subtly different).

These upper 16 attribute bits are supposed to be file system type speficic
(in practice, they seem to be common to all filesystem types from one vendor)
but we don't have the info (yet anyway) to treat them like that.

ChromeOS seems to treat some of the bits as bit fields containing numeric
values - add #if 0'd (but compile tested) code to deal with those (maybe,
compile tested - but not execution tested) should someone ever get an
environment where these things occur, and could add the missing definitions
to actually test this.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sbin/gpt/gpt.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/gpt.c
diff -u src/sbin/gpt/gpt.c:1.84 src/sbin/gpt/gpt.c:1.85
--- src/sbin/gpt/gpt.c:1.84	Tue Nov 22 00:25:52 2022
+++ src/sbin/gpt/gpt.c	Tue Sep 26 15:55:46 2023
@@ -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.84 2022/11/22 00:25:52 mlelstv Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.85 2023/09/26 15:55:46 kre Exp $");
 #endif
 
 #include 
@@ -1239,13 +1239,62 @@ const char *
 gpt_attr_list(char *buf, size_t len, uint64_t attributes)
 {
 	size_t i;
+	/*
+	 * a uint64_t (attributes) has at most 16 hex digits
+	 * in its representation, add 2 for "0x", and 2 more
+	 * for surrounding [ ], plus one for a trailing \0,
+	 * and we need 21 bytes, round that up to 24
+	 */
+	char xbuf[24];
+
 	strlcpy(buf, "", len);	
 
-	for (i = 0; i < __arraycount(gpt_attr); i++)
+	for (i = 0; i < __arraycount(gpt_attr); i++) {
+		/*
+		 * if the attribute is specified in one of bits
+		 * 48..63, it should depend upon the defining
+		 * partition type for that attribute.   Currently
+		 * we have no idea what that is, so...
+		 *
+		 * Also note that for some partition types, these
+		 * fields are not a single bit boolean, but several
+		 * bits to form a numeric value.  That we could handle.
+		 */
+
 		if (attributes & gpt_attr[i].mask) {
 			strlcat(buf, buf[0] ? ", " : "", len); 
 			strlcat(buf, gpt_attr[i].name, len);
+#if 0
+	/*
+	 * there are none currently defined, so this is untestable
+	 * (it does build however).
+	 */
+			if (gpt_attr[i].mask & (gpt_attr[i].mask - 1)) {
+/* This only happens in bits 46..63 */
+
+/*
+ * xbuf is big enough for "=65535\0"
+ * which is the biggest possible value
+ */
+snprintf(xbuf, sizeof xbuf, "=%ju",
+(uintmax_t) (
+  (attributes & gpt_attr[i].mask) >>
+  (ffs((int)(gpt_attr[i].mask >> 48)) + 47)
+));
+
+strlcat(buf, xbuf, len);
+			}
+#endif
+			attributes &=~ gpt_attr[i].mask;
 		}
+	}
+
+	if (attributes != 0) {
+		snprintf(xbuf, sizeof xbuf, "[%#jx]", (uintmax_t)attributes);
+		strlcat(buf, buf[0] ? ", " : "", len);
+		strlcat(buf, xbuf, len);
+	}
+
 	return buf;
 }
 



CVS commit: src/sbin/gpt

2023-09-26 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Sep 26 15:48:31 UTC 2023

Modified Files:
src/sbin/gpt: gpt_uuid.c

Log Message:
Recognise Windows Recovery partitions.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sbin/gpt/gpt_uuid.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/gpt_uuid.c
diff -u src/sbin/gpt/gpt_uuid.c:1.19 src/sbin/gpt/gpt_uuid.c:1.20
--- src/sbin/gpt/gpt_uuid.c:1.19	Mon Mar 30 10:41:53 2020
+++ src/sbin/gpt/gpt_uuid.c	Tue Sep 26 15:48:30 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: gpt_uuid.c,v 1.19 2020/03/30 10:41:53 martin Exp $	*/
+/*	$NetBSD: gpt_uuid.c,v 1.20 2023/09/26 15:48:30 kre Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: gpt_uuid.c,v 1.19 2020/03/30 10:41:53 martin Exp $");
+__RCSID("$NetBSD: gpt_uuid.c,v 1.20 2023/09/26 15:48:30 kre Exp $");
 #endif
 
 #include 
@@ -80,6 +80,7 @@ static const struct {
 	{ GPT_ENT_TYPE_LINUX_LVM, "linux-lvm", "Linux LVM" },
 	{ GPT_ENT_TYPE_MS_BASIC_DATA, "windows", "Windows basic data" },
 	{ GPT_ENT_TYPE_MS_RESERVED, "windows-reserved", "Windows reserved" },
+	{ GPT_ENT_TYPE_MS_RECOVERY, "windows-recovery", "Windows recovery" },
 	{ GPT_ENT_TYPE_NETBSD_CCD, "ccd", "NetBSD ccd component" },
 	{ GPT_ENT_TYPE_NETBSD_CGD, "cgd", "NetBSD Cryptographic Disk" },
 	{ GPT_ENT_TYPE_NETBSD_FFS, "ffs", "NetBSD FFSv1/FFSv2" },



CVS commit: src/sbin/gpt

2023-09-26 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Sep 26 15:48:31 UTC 2023

Modified Files:
src/sbin/gpt: gpt_uuid.c

Log Message:
Recognise Windows Recovery partitions.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sbin/gpt/gpt_uuid.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2023-07-15 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sat Jul 15 21:18:07 UTC 2023

Modified Files:
src/sbin/gpt: gpt.8

Log Message:
gpt.8: fix some grammar

(The BUGS section seems perhaps a little outdated in its warnings of
potential incompatible changes.)


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sbin/gpt/gpt.8

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/gpt.8
diff -u src/sbin/gpt/gpt.8:1.77 src/sbin/gpt/gpt.8:1.78
--- src/sbin/gpt/gpt.8:1.77	Sat Jul 15 21:11:58 2023
+++ src/sbin/gpt/gpt.8	Sat Jul 15 21:18:06 2023
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.77 2023/07/15 21:11:58 gutteridge Exp $
+.\" $NetBSD: gpt.8,v 1.78 2023/07/15 21:18:06 gutteridge Exp $
 .\"
 .\" Copyright (c) 2002 Marcel Moolenaar
 .\" All rights reserved.
@@ -174,7 +174,7 @@ The minimum size is 1 sector.
 The
 .Fl t Ar type
 option allows the user to specify the partition type.
-The type is given as an UUID, but
+The type is given as a UUID, but
 .Nm
 accepts
 .Bl -tag -width "windows-reserved" -compact -offset indent
@@ -381,7 +381,7 @@ This can cause multiple partitions to be
 The
 .Fl t Ar type
 option selects all partitions that have the given type.
-The type is given as an UUID or by the aliases that the
+The type is given as a UUID or by the aliases that the
 .Ic add
 command accepts.
 This can cause multiple partitions to be labeled.
@@ -639,7 +639,7 @@ option the GPT partition label will be d
 type.
 With the
 .Fl u
-option the GPT partition type is displayed as an UUID instead of in a
+option the GPT partition type is displayed as a UUID instead of in a
 user friendly form.
 With the
 .Fl i
@@ -826,7 +826,7 @@ However, it is believed that the current
 and stable enough that this tool can be used without bullet-proof footware if
 one thinks one does not make mistakes.
 .Pp
-It is expected that the basic usage model does not change, but it is
+It is expected that the basic usage model will not change, but it is
 possible that future versions will not be compatible in the strictest sense
 of the word.
 Also, options primarily intended for diagnostic or debug purposes may be



CVS commit: src/sbin/gpt

2023-07-15 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sat Jul 15 21:18:07 UTC 2023

Modified Files:
src/sbin/gpt: gpt.8

Log Message:
gpt.8: fix some grammar

(The BUGS section seems perhaps a little outdated in its warnings of
potential incompatible changes.)


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sbin/gpt/gpt.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2023-07-15 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sat Jul 15 21:11:58 UTC 2023

Modified Files:
src/sbin/gpt: gpt.8

Log Message:
gpt.8: drop cross-reference to cvs(1)

It's no more useful to reference cvs(1) than, say, openssl(1), and
should be self-evident, anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sbin/gpt/gpt.8

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/gpt.8
diff -u src/sbin/gpt/gpt.8:1.76 src/sbin/gpt/gpt.8:1.77
--- src/sbin/gpt/gpt.8:1.76	Thu Apr  7 13:57:44 2022
+++ src/sbin/gpt/gpt.8	Sat Jul 15 21:11:58 2023
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.76 2022/04/07 13:57:44 kre Exp $
+.\" $NetBSD: gpt.8,v 1.77 2023/07/15 21:11:58 gutteridge Exp $
 .\"
 .\" Copyright (c) 2002 Marcel Moolenaar
 .\" All rights reserved.
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD: src/sbin/gpt/gpt.8,v 1.17 2006/06/22 22:22:32 marcel Exp $
 .\"
-.Dd April 7, 2022
+.Dd July 15, 2023
 .Dt GPT 8
 .Os
 .Sh NAME
@@ -59,11 +59,6 @@ tables
 but see
 .Sx BUGS
 below for how and where functionality is missing.
-The basic usage model of the
-.Nm
-tool follows that of the
-.Xr cvs 1
-tool.
 The general options are described in the following paragraph.
 The remaining paragraphs describe the individual commands with their options.
 Here we conclude by mentioning that a



CVS commit: src/sbin/gpt

2023-07-15 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sat Jul 15 21:11:58 UTC 2023

Modified Files:
src/sbin/gpt: gpt.8

Log Message:
gpt.8: drop cross-reference to cvs(1)

It's no more useful to reference cvs(1) than, say, openssl(1), and
should be self-evident, anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sbin/gpt/gpt.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2022-11-21 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Nov 22 00:25:52 UTC 2022

Modified Files:
src/sbin/gpt: gpt.c resizedisk.c

Log Message:
Big-Endian fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sbin/gpt/gpt.c
cvs rdiff -u -r1.19 -r1.20 src/sbin/gpt/resizedisk.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/gpt.c
diff -u src/sbin/gpt/gpt.c:1.83 src/sbin/gpt/gpt.c:1.84
--- src/sbin/gpt/gpt.c:1.83	Sun Nov 20 11:57:02 2022
+++ src/sbin/gpt/gpt.c	Tue Nov 22 00:25:52 2022
@@ -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.83 2022/11/20 11:57:02 mlelstv Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.84 2022/11/22 00:25:52 mlelstv Exp $");
 #endif
 
 #include 
@@ -578,6 +578,7 @@ gpt_open(const char *dev, int flags, int
 	if (found) {
 		struct map *map;
 		struct gpt_hdr *hdr;
+		uint64_t lba;
 
 		/*
 		 * read secondary GPT from position stored in primary header
@@ -585,8 +586,9 @@ gpt_open(const char *dev, int flags, int
 		 */
 		map = map_find(gpt, MAP_TYPE_PRI_GPT_HDR);
 		hdr = map ? map->map_data : NULL;
-		if (hdr && hdr->hdr_lba_alt > 0 && hdr->hdr_lba_alt < (uint64_t)devsz) {
-			if (gpt_gpt(gpt, (off_t)hdr->hdr_lba_alt, found) == -1)
+		lba = le64toh(hdr->hdr_lba_alt);
+		if (hdr && lba > 0 && lba < (uint64_t)devsz) {
+			if (gpt_gpt(gpt, (off_t)lba, found) == -1)
 goto close;
 		}
 	} else {

Index: src/sbin/gpt/resizedisk.c
diff -u src/sbin/gpt/resizedisk.c:1.19 src/sbin/gpt/resizedisk.c:1.20
--- src/sbin/gpt/resizedisk.c:1.19	Sun Nov 20 11:57:02 2022
+++ src/sbin/gpt/resizedisk.c	Tue Nov 22 00:25:52 2022
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: resizedisk.c,v 1.19 2022/11/20 11:57:02 mlelstv Exp $");
+__RCSID("$NetBSD: resizedisk.c,v 1.20 2022/11/22 00:25:52 mlelstv Exp $");
 #endif
 
 #include 
@@ -194,7 +194,7 @@ resizedisk(gpt_t gpt, off_t sector, off_
 	}
 
 	hdr = gpt->gpt->map_data;
-	hdr->hdr_lba_alt = (uint64_t)gpt->tpg->map_start;
+	hdr->hdr_lba_alt = htole64((uint64_t)gpt->tpg->map_start);
 	hdr->hdr_crc_self = 0;
 	hdr->hdr_lba_end = htole64((uint64_t)(gpt->lbt->map_start - 1));
 	hdr->hdr_crc_self =



CVS commit: src/sbin/gpt

2022-11-21 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Nov 22 00:25:52 UTC 2022

Modified Files:
src/sbin/gpt: gpt.c resizedisk.c

Log Message:
Big-Endian fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sbin/gpt/gpt.c
cvs rdiff -u -r1.19 -r1.20 src/sbin/gpt/resizedisk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2022-11-20 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Nov 20 11:57:02 UTC 2022

Modified Files:
src/sbin/gpt: destroy.c gpt.c gpt.h resizedisk.c

Log Message:
Fix destroying and moving GPT header also for truncated/extended
images.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sbin/gpt/destroy.c
cvs rdiff -u -r1.82 -r1.83 src/sbin/gpt/gpt.c
cvs rdiff -u -r1.43 -r1.44 src/sbin/gpt/gpt.h
cvs rdiff -u -r1.18 -r1.19 src/sbin/gpt/resizedisk.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/destroy.c
diff -u src/sbin/gpt/destroy.c:1.13 src/sbin/gpt/destroy.c:1.14
--- src/sbin/gpt/destroy.c:1.13	Wed Oct 16 19:03:53 2019
+++ src/sbin/gpt/destroy.c	Sun Nov 20 11:57:02 2022
@@ -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.13 2019/10/16 19:03:53 jnemeth Exp $");
+__RCSID("$NetBSD: destroy.c,v 1.14 2022/11/20 11:57:02 mlelstv Exp $");
 #endif
 
 #include 
@@ -59,7 +59,7 @@ struct gpt_cmd c_destroy = {
 	"destroy",
 	cmd_destroy,
 	destroyhelp, __arraycount(destroyhelp),
-	GPT_SYNC,
+	GPT_OPTGPT | GPT_SYNC,
 };
 
 #define usage() gpt_usage(NULL, _destroy)

Index: src/sbin/gpt/gpt.c
diff -u src/sbin/gpt/gpt.c:1.82 src/sbin/gpt/gpt.c:1.83
--- src/sbin/gpt/gpt.c:1.82	Sun May 24 18:42:20 2020
+++ src/sbin/gpt/gpt.c	Sun Nov 20 11:57:02 2022
@@ -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.82 2020/05/24 18:42:20 jmcneill Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.83 2022/11/20 11:57:02 mlelstv Exp $");
 #endif
 
 #include 
@@ -574,8 +574,25 @@ gpt_open(const char *dev, int flags, int
 		goto close;
 	if ((found = gpt_gpt(gpt, 1LL, 1)) == -1)
 		goto close;
-	if (gpt_gpt(gpt, devsz - 1LL, found) == -1)
-		goto close;
+
+	if (found) {
+		struct map *map;
+		struct gpt_hdr *hdr;
+
+		/*
+		 * read secondary GPT from position stored in primary header
+		 * when possible
+		 */
+		map = map_find(gpt, MAP_TYPE_PRI_GPT_HDR);
+		hdr = map ? map->map_data : NULL;
+		if (hdr && hdr->hdr_lba_alt > 0 && hdr->hdr_lba_alt < (uint64_t)devsz) {
+			if (gpt_gpt(gpt, (off_t)hdr->hdr_lba_alt, found) == -1)
+goto close;
+		}
+	} else {
+		if (gpt_gpt(gpt, devsz - 1LL, found) == -1)
+			goto close;
+	}
 
 	return gpt;
 

Index: src/sbin/gpt/gpt.h
diff -u src/sbin/gpt/gpt.h:1.43 src/sbin/gpt/gpt.h:1.44
--- src/sbin/gpt/gpt.h:1.43	Sat Jul 16 12:57:14 2022
+++ src/sbin/gpt/gpt.h	Sun Nov 20 11:57:02 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: gpt.h,v 1.43 2022/07/16 12:57:14 mlelstv Exp $	*/
+/*	$NetBSD: gpt.h,v 1.44 2022/11/20 11:57:02 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2002 Marcel Moolenaar
@@ -85,6 +85,7 @@ gpt_t	gpt_open(const char *, int, int, o
 #define GPT_TIMESTAMP	0x20
 #define GPT_SYNC	0x40
 #define GPT_HYBRID	0x80
+#define GPT_OPTGPT	0x4000
 #define GPT_OPTDEV	0x8000
 
 void*	gpt_read(gpt_t, off_t, size_t);

Index: src/sbin/gpt/resizedisk.c
diff -u src/sbin/gpt/resizedisk.c:1.18 src/sbin/gpt/resizedisk.c:1.19
--- src/sbin/gpt/resizedisk.c:1.18	Sun May 24 14:42:44 2020
+++ src/sbin/gpt/resizedisk.c	Sun Nov 20 11:57:02 2022
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: resizedisk.c,v 1.18 2020/05/24 14:42:44 jmcneill Exp $");
+__RCSID("$NetBSD: resizedisk.c,v 1.19 2022/11/20 11:57:02 mlelstv Exp $");
 #endif
 
 #include 
@@ -62,7 +62,7 @@ struct gpt_cmd c_resizedisk = {
 	"resizedisk",
 	cmd_resizedisk,
 	resizediskhelp, __arraycount(resizediskhelp),
-	0,
+	GPT_OPTGPT,
 };
 
 #define usage() gpt_usage(NULL, _resizedisk)
@@ -123,25 +123,9 @@ resizedisk(gpt_t gpt, off_t sector, off_
 
 	gpt->tpg = map_find(gpt, MAP_TYPE_SEC_GPT_HDR);
 	gpt->lbt = map_find(gpt, MAP_TYPE_SEC_GPT_TBL);
-	if (gpt->tpg == NULL || gpt->lbt == NULL) {
-		if (gpt_gpt(gpt, oldloc, 1) == -1) {
-			gpt_warnx(gpt,
-			"Error reading backup GPT information at %#jx",
-			oldloc);
-			return -1;
-		}
-	}
 
-	gpt->tpg = map_find(gpt, MAP_TYPE_SEC_GPT_HDR);
-	if (gpt->tpg == NULL) {
-		gpt_warnx(gpt, "No secondary GPT header; Run recover");
-		return -1;
-	}
-	gpt->lbt = map_find(gpt, MAP_TYPE_SEC_GPT_TBL);
-	if (gpt->lbt == NULL) {
-		gpt_warnx(gpt, "No secondary GPT table; Run recover");
-		return -1;
-	}
+	if (gpt->tpg == NULL || gpt->lbt == NULL)
+		gpt_warnx(gpt, "No secondary GPT table");
 
 	gpt_size = gpt->tbl->map_size;
 	if (sector == oldloc) {
@@ -153,7 +137,8 @@ resizedisk(gpt_t gpt, off_t sector, off_
 	if (sector == 0 && last == oldloc) {
 		if (!quiet)
 			gpt_warnx(gpt, "Device hasn't changed size");
-		return 0;
+		if (gpt->tpg != NULL && gpt->lbt != NULL)
+			return 0;
 	}
 
 	for (ent = gpt->tbl->map_data; ent <
@@ -183,18 +168,14 @@ resizedisk(gpt_t gpt, off_t sector, off_
 	if (sector == 0 && last > 

CVS commit: src/sbin/gpt

2022-11-20 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Nov 20 11:57:02 UTC 2022

Modified Files:
src/sbin/gpt: destroy.c gpt.c gpt.h resizedisk.c

Log Message:
Fix destroying and moving GPT header also for truncated/extended
images.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sbin/gpt/destroy.c
cvs rdiff -u -r1.82 -r1.83 src/sbin/gpt/gpt.c
cvs rdiff -u -r1.43 -r1.44 src/sbin/gpt/gpt.h
cvs rdiff -u -r1.18 -r1.19 src/sbin/gpt/resizedisk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2022-07-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Jul 16 12:57:14 UTC 2022

Modified Files:
src/sbin/gpt: gpt.h

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sbin/gpt/gpt.h

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/gpt.h
diff -u src/sbin/gpt/gpt.h:1.42 src/sbin/gpt/gpt.h:1.43
--- src/sbin/gpt/gpt.h:1.42	Sun May 24 18:42:20 2020
+++ src/sbin/gpt/gpt.h	Sat Jul 16 12:57:14 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: gpt.h,v 1.42 2020/05/24 18:42:20 jmcneill Exp $	*/
+/*	$NetBSD: gpt.h,v 1.43 2022/07/16 12:57:14 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2002 Marcel Moolenaar
@@ -85,7 +85,7 @@ gpt_t	gpt_open(const char *, int, int, o
 #define GPT_TIMESTAMP	0x20
 #define GPT_SYNC	0x40
 #define GPT_HYBRID	0x80
-#define GPT_OPTDEV  0x8000
+#define GPT_OPTDEV	0x8000
 
 void*	gpt_read(gpt_t, off_t, size_t);
 off_t	gpt_last(gpt_t);



CVS commit: src/sbin/gpt

2022-07-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Jul 16 12:57:14 UTC 2022

Modified Files:
src/sbin/gpt: gpt.h

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sbin/gpt/gpt.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2022-04-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Apr  7 13:57:44 UTC 2022

Modified Files:
src/sbin/gpt: gpt.8

Log Message:
Note that biosboot without -A clears the PMBR "active" flag.
While here, fix some grammar and make the selection options
for biosboot a little clearer.

Ride nia@'s Dd bump.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sbin/gpt/gpt.8

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/gpt.8
diff -u src/sbin/gpt/gpt.8:1.75 src/sbin/gpt/gpt.8:1.76
--- src/sbin/gpt/gpt.8:1.75	Thu Apr  7 09:06:01 2022
+++ src/sbin/gpt/gpt.8	Thu Apr  7 13:57:44 2022
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.75 2022/04/07 09:06:01 nia Exp $
+.\" $NetBSD: gpt.8,v 1.76 2022/04/07 13:57:44 kre Exp $
 .\"
 .\" Copyright (c) 2002 Marcel Moolenaar
 .\" All rights reserved.
@@ -263,28 +263,43 @@ primary bootstrap program, used during
 The
 .Fl A
 options sets the PMBR partition active.
+This should not normally be necessary,
+but some firmware might require it.
+If
+.Fl A
+is omitted, the active flag will be cleared from the PMBR label.
 .Pp
 The
 .Fl c
-option allows the user to specify the filename that
+option allows the user to specify the filename from which
 .Nm
-should read the bootcode from.
+should read the bootcode.
 The default is to read from
 .Pa /usr/mdec/gptmbr.bin .
 .Pp
+The partition that should contain the primary bootstrap code,
+.Pq similar to that installed via Xr installboot 8
+is selected using the
+.Fl i ,
+.Fl L
+and
+.Fl b
+options.
+One of these three options is required.
 The
 .Fl i
-option selects the partition that should contain the primary
-bootstrap code, as installed via
-.Xr installboot 8 .
+option selects the partition given by the
+.Ar index .
 The
 .Fl L
-option selects the partition by label.
-If there are multiple partitions with the same label, the
-first one found will be used.
+option selects the partition by
+.Ar label .
+If there are multiple partitions with the same label,
+the first one found will be used.
 The
 .Fl b
-options selects the partition by start block.
+option selects the partition starting at block
+.Ar startsec .
 .\"  create 
 .It Nm Ic create Oo Fl AfP Oc Oo Fl p Ar partitions Oc
 The



CVS commit: src/sbin/gpt

2022-04-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Apr  7 13:57:44 UTC 2022

Modified Files:
src/sbin/gpt: gpt.8

Log Message:
Note that biosboot without -A clears the PMBR "active" flag.
While here, fix some grammar and make the selection options
for biosboot a little clearer.

Ride nia@'s Dd bump.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sbin/gpt/gpt.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2022-04-07 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Thu Apr  7 09:06:01 UTC 2022

Modified Files:
src/sbin/gpt: gpt.8

Log Message:
gpt.8: Clarify that "windows" partition types are also used for FAT32
("msdos" in NetBSD terms), and UDF partitions. Use the same name as
Wikipedia, "Microsoft basic data".


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sbin/gpt/gpt.8

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/gpt.8
diff -u src/sbin/gpt/gpt.8:1.74 src/sbin/gpt/gpt.8:1.75
--- src/sbin/gpt/gpt.8:1.74	Mon Jul 27 20:54:18 2020
+++ src/sbin/gpt/gpt.8	Thu Apr  7 09:06:01 2022
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.74 2020/07/27 20:54:18 christos Exp $
+.\" $NetBSD: gpt.8,v 1.75 2022/04/07 09:06:01 nia Exp $
 .\"
 .\" Copyright (c) 2002 Marcel Moolenaar
 .\" All rights reserved.
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD: src/sbin/gpt/gpt.8,v 1.17 2006/06/22 22:22:32 marcel Exp $
 .\"
-.Dd July 27, 2020
+.Dd April 7, 2022
 .Dt GPT 8
 .Os
 .Sh NAME
@@ -216,9 +216,9 @@ Linux swap
 .It Cm linux-lvm
 Linux LVM
 .It Cm windows
-Windows basic data
+Microsoft basic data - NTFS, FAT32 ("msdos"), FAT16, also used for UDF
 .It Cm windows-reserved
-Windows reserved
+Microsoft reserved
 .It Cm ccd
 .Nx
 ccd component



CVS commit: src/sbin/gpt

2022-04-07 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Thu Apr  7 09:06:01 UTC 2022

Modified Files:
src/sbin/gpt: gpt.8

Log Message:
gpt.8: Clarify that "windows" partition types are also used for FAT32
("msdos" in NetBSD terms), and UDF partitions. Use the same name as
Wikipedia, "Microsoft basic data".


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sbin/gpt/gpt.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2019-10-16 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Wed Oct 16 19:03:53 UTC 2019

Modified Files:
src/sbin/gpt: destroy.c

Log Message:
Do the 'dkctl makewedges' dance to drop any wedges assoicated the
destroyed GPT.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sbin/gpt/destroy.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2019-10-16 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Wed Oct 16 19:03:53 UTC 2019

Modified Files:
src/sbin/gpt: destroy.c

Log Message:
Do the 'dkctl makewedges' dance to drop any wedges assoicated the
destroyed GPT.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sbin/gpt/destroy.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/destroy.c
diff -u src/sbin/gpt/destroy.c:1.12 src/sbin/gpt/destroy.c:1.13
--- src/sbin/gpt/destroy.c:1.12	Thu Apr  4 14:03:40 2019
+++ src/sbin/gpt/destroy.c	Wed Oct 16 19:03:53 2019
@@ -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.12 2019/04/04 14:03:40 martin Exp $");
+__RCSID("$NetBSD: destroy.c,v 1.13 2019/10/16 19:03:53 jnemeth Exp $");
 #endif
 
 #include 
@@ -59,7 +59,7 @@ struct gpt_cmd c_destroy = {
 	"destroy",
 	cmd_destroy,
 	destroyhelp, __arraycount(destroyhelp),
-	0,
+	GPT_SYNC,
 };
 
 #define usage() gpt_usage(NULL, _destroy)



CVS commit: src/sbin/gpt

2019-10-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct 11 23:04:52 UTC 2019

Modified Files:
src/sbin/gpt: gpt.c

Log Message:
gpt_uuid_parse does not set errno ...


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sbin/gpt/gpt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2019-10-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct 11 23:04:52 UTC 2019

Modified Files:
src/sbin/gpt: gpt.c

Log Message:
gpt_uuid_parse does not set errno ...


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sbin/gpt/gpt.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/gpt.c
diff -u src/sbin/gpt/gpt.c:1.80 src/sbin/gpt/gpt.c:1.81
--- src/sbin/gpt/gpt.c:1.80	Mon Jun 24 23:50:18 2019
+++ src/sbin/gpt/gpt.c	Fri Oct 11 19:04:52 2019
@@ -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.80 2019/06/25 03:50:18 jnemeth Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.81 2019/10/11 23:04:52 christos Exp $");
 #endif
 
 #include 
@@ -1293,7 +1293,7 @@ gpt_uuid_get(gpt_t gpt, gpt_uuid_t *uuid
 	if (!gpt_uuid_is_nil(*uuid))
 		return -1;
 	if (gpt_uuid_parse(optarg, *uuid) != 0) {
-		gpt_warn(gpt, "Can't parse uuid");
+		gpt_warnx(gpt, "Can't parse uuid/type `%s'", optarg);
 		return -1;
 	}
 	return 0;



CVS commit: src/sbin/gpt

2019-07-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jul 26 07:22:05 UTC 2019

Modified Files:
src/sbin/gpt: gpt.8

Log Message:
Remove outdated note about sysinst restrictions


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sbin/gpt/gpt.8

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/gpt.8
diff -u src/sbin/gpt/gpt.8:1.69 src/sbin/gpt/gpt.8:1.70
--- src/sbin/gpt/gpt.8:1.69	Tue Jun 25 04:53:40 2019
+++ src/sbin/gpt/gpt.8	Fri Jul 26 07:22:05 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.69 2019/06/25 04:53:40 jnemeth Exp $
+.\" $NetBSD: gpt.8,v 1.70 2019/07/26 07:22:05 martin Exp $
 .\"
 .\" Copyright (c) 2002 Marcel Moolenaar
 .\" All rights reserved.
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD: src/sbin/gpt/gpt.8,v 1.17 2006/06/22 22:22:32 marcel Exp $
 .\"
-.Dd June 22, 2019
+.Dd July 26, 2019
 .Dt GPT 8
 .Os
 .Sh NAME
@@ -758,11 +758,7 @@ nas# gpt show -l wd3
 nas#
 .Ed
 .Pp
-Booting from GPT on an BIOS system.
-This creates a bootable partition that can be manually installed to.
-Note that
-.Xr sysinst 8
-does not yet properly support this setup.
+Booting from GPT on a BIOS system: this creates a bootable partition.
 .Bd -literal
 xotica# gpt create wd1
 xotica# gpt add -b 1024 -l bootroot -t ffs -s 1g wd1
@@ -776,6 +772,10 @@ xotica# installboot /dev/rdk0 /usr/mdec/
 xotica# mount /dev/dk0 /mnt
 xotica# cp /usr/mdec/boot /mnt
 .Ed
+.Pp
+Note that
+.Ic biosboot
+is not needed for UEFI systems.
 .Sh SEE ALSO
 .Xr boot 8 ,
 .Xr dkctl 8 ,



CVS commit: src/sbin/gpt

2019-07-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jul 26 07:22:05 UTC 2019

Modified Files:
src/sbin/gpt: gpt.8

Log Message:
Remove outdated note about sysinst restrictions


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sbin/gpt/gpt.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/sbin/gpt

2019-06-25 Thread Christos Zoulas
In article <201906250354.x5p3suvz009...@server.cornerstoneservice.ca>,
John Nemeth   wrote:
>On Jun 25,  3:42am, "John Nemeth" wrote:
>} 
>} Module Name: src
>} Committed By:jnemeth
>} Date:Tue Jun 25 03:42:46 UTC 2019
>} 
>} Modified Files:
>}  src/sbin/gpt: gpt.h
>} 
>} Log Message:
>} gpt.c
>
> ARGH!  Message should have read:
>
>Add gpt_change_hdr() similar to gpt_change_ent() for changing
>arbitrary header fields.
>
>Updated in repository.

If you did, then the git sync is broken :-( I guess it is time to turn
off "cvs admin -m"...

christos



CVS commit: src/sbin/gpt

2019-06-24 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Tue Jun 25 04:53:41 UTC 2019

Modified Files:
src/sbin/gpt: Makefile gpt.8 main.c
Added Files:
src/sbin/gpt: uuid.c

Log Message:
Add an "uuid" command to generate a new UUID for a portion.  The
primary intention is for use for after cloning disks to prevent
collisions.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sbin/gpt/Makefile
cvs rdiff -u -r1.68 -r1.69 src/sbin/gpt/gpt.8
cvs rdiff -u -r1.12 -r1.13 src/sbin/gpt/main.c
cvs rdiff -u -r0 -r1.1 src/sbin/gpt/uuid.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.18 src/sbin/gpt/Makefile:1.19
--- src/sbin/gpt/Makefile:1.18	Thu Dec  3 02:02:43 2015
+++ src/sbin/gpt/Makefile	Tue Jun 25 04:53:40 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.18 2015/12/03 02:02:43 christos Exp $
+# $NetBSD: Makefile,v 1.19 2019/06/25 04:53:40 jnemeth Exp $
 # $FreeBSD: src/sbin/gpt/Makefile,v 1.7 2005/09/01 02:49:20 marcel Exp $
 
 .include 
@@ -7,7 +7,7 @@ WARNS=6
 PROG=	gpt
 SRCS=	add.c biosboot.c create.c destroy.c gpt.c header.c label.c map.c \
 	main.c migrate.c recover.c remove.c resize.c resizedisk.c \
-	set.c show.c type.c unset.c gpt_uuid.c
+	set.c show.c type.c unset.c gpt_uuid.c uuid.c
 MAN=	gpt.8
 
 #LINKS=  ${BINDIR}/gpt ${BINDIR}/gptlabel

Index: src/sbin/gpt/gpt.8
diff -u src/sbin/gpt/gpt.8:1.68 src/sbin/gpt/gpt.8:1.69
--- src/sbin/gpt/gpt.8:1.68	Thu Apr  4 13:55:40 2019
+++ src/sbin/gpt/gpt.8	Tue Jun 25 04:53:40 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.68 2019/04/04 13:55:40 martin Exp $
+.\" $NetBSD: gpt.8,v 1.69 2019/06/25 04:53:40 jnemeth Exp $
 .\"
 .\" Copyright (c) 2002 Marcel Moolenaar
 .\" All rights reserved.
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD: src/sbin/gpt/gpt.8,v 1.17 2006/06/22 22:22:32 marcel Exp $
 .\"
-.Dd April 4, 2019
+.Dd June 22, 2019
 .Dt GPT 8
 .Os
 .Sh NAME
@@ -693,6 +693,25 @@ code.
 They may be used by
 .Nx
 code in the future.
+.\"  uuid 
+.It Nm Ic uuid Oo Fl a Oc
+.It Nm Ic uuid Oo Fl b Ar blocknr Oc Oo Fl i Ar index Oc \
+Oo Fl L Ar label Oc Oo Fl s Ar sectors Oc Oo Fl t Ar type Oc
+The
+.Ic uuid
+command allows the user to change the UUID of any and all partitions
+that match the selection.
+It uses the same selection options as the
+.Ic label
+command.
+See above for a description of these options.
+If
+.Fl a
+is used, then the header UUID is changed as well.
+.Pp
+The primary purpose of this command is for use after cloning a disk to
+prevent collisions when both disks are used in the same system.
+.\"  end of commands 
 .El
 .Sh EXIT STATUS
 The

Index: src/sbin/gpt/main.c
diff -u src/sbin/gpt/main.c:1.12 src/sbin/gpt/main.c:1.13
--- src/sbin/gpt/main.c:1.12	Mon Aug 27 15:50:39 2018
+++ src/sbin/gpt/main.c	Tue Jun 25 04:53:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.12 2018/08/27 15:50:39 sevan Exp $	*/
+/*	$NetBSD: main.c,v 1.13 2019/06/25 04:53:40 jnemeth Exp $	*/
 
 /*-
  * Copyright (c) 2002 Marcel Moolenaar
@@ -34,7 +34,7 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: main.c,v 1.12 2018/08/27 15:50:39 sevan Exp $");
+__RCSID("$NetBSD: main.c,v 1.13 2019/06/25 04:53:40 jnemeth Exp $");
 #endif
 
 #include 
@@ -73,7 +73,8 @@ extern const struct gpt_cmd
 	c_set,
 	c_show,
 	c_type,
-	c_unset;
+	c_unset,
+	c_uuid;
 
 static const struct gpt_cmd *cmdsw[] = {
 	_add,
@@ -97,6 +98,7 @@ static const struct gpt_cmd *cmdsw[] = {
 	_show,
 	_type,
 	_unset,
+	_uuid,
 	_null,
 };
 

Added files:

Index: src/sbin/gpt/uuid.c
diff -u /dev/null src/sbin/gpt/uuid.c:1.1
--- /dev/null	Tue Jun 25 04:53:41 2019
+++ src/sbin/gpt/uuid.c	Tue Jun 25 04:53:40 2019
@@ -0,0 +1,114 @@
+/*-
+ * Copyright (c) 2004 Marcel Moolenaar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR 

CVS commit: src/sbin/gpt

2019-06-24 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Tue Jun 25 04:53:41 UTC 2019

Modified Files:
src/sbin/gpt: Makefile gpt.8 main.c
Added Files:
src/sbin/gpt: uuid.c

Log Message:
Add an "uuid" command to generate a new UUID for a portion.  The
primary intention is for use for after cloning disks to prevent
collisions.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sbin/gpt/Makefile
cvs rdiff -u -r1.68 -r1.69 src/sbin/gpt/gpt.8
cvs rdiff -u -r1.12 -r1.13 src/sbin/gpt/main.c
cvs rdiff -u -r0 -r1.1 src/sbin/gpt/uuid.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2019-06-24 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Tue Jun 25 04:25:12 UTC 2019

Modified Files:
src/sbin/gpt: gpt_uuid.c

Log Message:
adjust gpt_uuid_generate() to accept gpt==NULL


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sbin/gpt/gpt_uuid.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/gpt_uuid.c
diff -u src/sbin/gpt/gpt_uuid.c:1.17 src/sbin/gpt/gpt_uuid.c:1.18
--- src/sbin/gpt/gpt_uuid.c:1.17	Thu Dec 20 14:58:10 2018
+++ src/sbin/gpt/gpt_uuid.c	Tue Jun 25 04:25:11 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: gpt_uuid.c,v 1.17 2018/12/20 14:58:10 martin Exp $	*/
+/*	$NetBSD: gpt_uuid.c,v 1.18 2019/06/25 04:25:11 jnemeth Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: gpt_uuid.c,v 1.17 2018/12/20 14:58:10 martin Exp $");
+__RCSID("$NetBSD: gpt_uuid.c,v 1.18 2019/06/25 04:25:11 jnemeth Exp $");
 #endif
 
 #include 
@@ -321,7 +321,7 @@ gpt_uuid_generate(gpt_t gpt, gpt_uuid_t 
 {
 	int rv;
 	struct dce_uuid u;
-	if (gpt->flags & GPT_TIMESTAMP)
+	if (gpt && (gpt->flags & GPT_TIMESTAMP))
 		rv = gpt_uuid_tstamp(gpt, , sizeof(u));
 	else
 		rv = gpt_uuid_random(gpt, , sizeof(u));



CVS commit: src/sbin/gpt

2019-06-24 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Tue Jun 25 04:25:12 UTC 2019

Modified Files:
src/sbin/gpt: gpt_uuid.c

Log Message:
adjust gpt_uuid_generate() to accept gpt==NULL


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sbin/gpt/gpt_uuid.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/sbin/gpt

2019-06-24 Thread John Nemeth
On Jun 25,  3:42am, "John Nemeth" wrote:
} 
} Module Name:  src
} Committed By: jnemeth
} Date: Tue Jun 25 03:42:46 UTC 2019
} 
} Modified Files:
}   src/sbin/gpt: gpt.h
} 
} Log Message:
} gpt.c

 ARGH!  Message should have read:

Add gpt_change_hdr() similar to gpt_change_ent() for changing
arbitrary header fields.

Updated in repository.

}-- End of excerpt from "John Nemeth"


CVS commit: src/sbin/gpt

2019-06-24 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Tue Jun 25 03:50:18 UTC 2019

Modified Files:
src/sbin/gpt: gpt.c

Log Message:
Add gpt_change_hdr() similar to gpt_change_ent() for changing
arbitrary header fields.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sbin/gpt/gpt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2019-06-24 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Tue Jun 25 03:50:18 UTC 2019

Modified Files:
src/sbin/gpt: gpt.c

Log Message:
Add gpt_change_hdr() similar to gpt_change_ent() for changing
arbitrary header fields.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sbin/gpt/gpt.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/gpt.c
diff -u src/sbin/gpt/gpt.c:1.79 src/sbin/gpt/gpt.c:1.80
--- src/sbin/gpt/gpt.c:1.79	Fri Jun 21 02:14:59 2019
+++ src/sbin/gpt/gpt.c	Tue Jun 25 03:50:18 2019
@@ -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.79 2019/06/21 02:14:59 jnemeth Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.80 2019/06/25 03:50:18 jnemeth Exp $");
 #endif
 
 #include 
@@ -1076,6 +1076,33 @@ gpt_change_ent(gpt_t gpt, const struct g
 }
 
 int
+gpt_change_hdr(gpt_t gpt, const struct gpt_find *find,
+void (*cfn)(struct gpt_hdr *, void *, int), void *v)
+{
+	struct gpt_hdr *hdr;
+
+	if ((hdr = gpt_hdr(gpt)) == NULL)
+		return -1;
+
+	/* Change the primary header. */
+	(*cfn)(hdr, v, 0);
+
+	if (gpt_write_primary(gpt) == -1)
+		return -1;
+
+	hdr = gpt->tpg->map_data;
+	/* Change the secondary header. */
+	(*cfn)(hdr, v, 1);
+
+	if (gpt_write_backup(gpt) == -1)
+		return -1;
+
+	gpt_msg(gpt, "Header %s", find->msg);
+
+	return 0;
+}
+
+int
 gpt_add_ais(gpt_t gpt, off_t *alignment, u_int *entry, off_t *size, int ch)
 {
 	switch (ch) {



CVS commit: src/sbin/gpt

2019-06-24 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Tue Jun 25 03:42:46 UTC 2019

Modified Files:
src/sbin/gpt: gpt.h

Log Message:
gpt.c


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sbin/gpt/gpt.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2019-06-24 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Tue Jun 25 03:42:46 UTC 2019

Modified Files:
src/sbin/gpt: gpt.h

Log Message:
gpt.c


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sbin/gpt/gpt.h

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/gpt.h
diff -u src/sbin/gpt/gpt.h:1.39 src/sbin/gpt/gpt.h:1.40
--- src/sbin/gpt/gpt.h:1.39	Fri Jun 21 02:14:59 2019
+++ src/sbin/gpt/gpt.h	Tue Jun 25 03:42:45 2019
@@ -116,6 +116,8 @@ struct gpt_find {
 };
 int	gpt_change_ent(gpt_t, const struct gpt_find *,
 void (*)(struct gpt_ent *, void *, int), void *);
+int	gpt_change_hdr(gpt_t, const struct gpt_find *,
+void (*)(struct gpt_hdr *, void *, int), void *);
 int	gpt_add_find(gpt_t, struct gpt_find *, int);
 
 #define GPT_AIS "a:i:s:"



CVS commit: src/sbin/gpt

2019-06-20 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Fri Jun 21 02:14:59 UTC 2019

Modified Files:
src/sbin/gpt: gpt.c gpt.h label.c remove.c type.c

Log Message:
Add a third argument to the "cfn" function that is an argument to
gpt_change_ent().  The purpose of the third argument is to specify
whether the entry to be changed is a primary GPT entry or a secondary
GPT entry.  It is assumed that a secondary GPT entry will always
follow a corresponding primary entry.

This is in preparation for an upcoming change that will require it.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sbin/gpt/gpt.c
cvs rdiff -u -r1.38 -r1.39 src/sbin/gpt/gpt.h
cvs rdiff -u -r1.29 -r1.30 src/sbin/gpt/label.c
cvs rdiff -u -r1.22 -r1.23 src/sbin/gpt/remove.c
cvs rdiff -u -r1.15 -r1.16 src/sbin/gpt/type.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/gpt.c
diff -u src/sbin/gpt/gpt.c:1.78 src/sbin/gpt/gpt.c:1.79
--- src/sbin/gpt/gpt.c:1.78	Thu Jun 20 10:41:58 2019
+++ src/sbin/gpt/gpt.c	Fri Jun 21 02:14:59 2019
@@ -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.78 2019/06/20 10:41:58 martin Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.79 2019/06/21 02:14:59 jnemeth Exp $");
 #endif
 
 #include 
@@ -1015,7 +1015,7 @@ gpt_add_find(gpt_t gpt, struct gpt_find 
 
 int
 gpt_change_ent(gpt_t gpt, const struct gpt_find *find,
-void (*cfn)(struct gpt_ent *, void *), void *v)
+void (*cfn)(struct gpt_ent *, void *, int), void *v)
 {
 	map_t m;
 	struct gpt_hdr *hdr;
@@ -1058,14 +1058,14 @@ gpt_change_ent(gpt_t gpt, const struct g
 			continue;
 
 		/* Change the primary entry. */
-		(*cfn)(ent, v);
+		(*cfn)(ent, v, 0);
 
 		if (gpt_write_primary(gpt) == -1)
 			return -1;
 
 		ent = gpt_ent_backup(gpt, i);
 		/* Change the secondary entry. */
-		(*cfn)(ent, v);
+		(*cfn)(ent, v, 1);
 
 		if (gpt_write_backup(gpt) == -1)
 			return -1;

Index: src/sbin/gpt/gpt.h
diff -u src/sbin/gpt/gpt.h:1.38 src/sbin/gpt/gpt.h:1.39
--- src/sbin/gpt/gpt.h:1.38	Tue Jul  3 03:41:23 2018
+++ src/sbin/gpt/gpt.h	Fri Jun 21 02:14:59 2019
@@ -115,7 +115,7 @@ struct gpt_find {
 	const char *msg;
 };
 int	gpt_change_ent(gpt_t, const struct gpt_find *,
-void (*)(struct gpt_ent *, void *), void *);
+void (*)(struct gpt_ent *, void *, int), void *);
 int	gpt_add_find(gpt_t, struct gpt_find *, int);
 
 #define GPT_AIS "a:i:s:"

Index: src/sbin/gpt/label.c
diff -u src/sbin/gpt/label.c:1.29 src/sbin/gpt/label.c:1.30
--- src/sbin/gpt/label.c:1.29	Tue Jul  3 03:41:24 2018
+++ src/sbin/gpt/label.c	Fri Jun 21 02:14:59 2019
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/label.c,v 1.3 2006/10/04 18:20:25 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: label.c,v 1.29 2018/07/03 03:41:24 jnemeth Exp $");
+__RCSID("$NetBSD: label.c,v 1.30 2019/06/21 02:14:59 jnemeth Exp $");
 #endif
 
 #include 
@@ -68,7 +68,7 @@ struct gpt_cmd c_label = {
 #define usage() gpt_usage(NULL, _label)
 
 static void
-change(struct gpt_ent *ent, void *v)
+change(struct gpt_ent *ent, void *v, int backup)
 {
 	uint8_t *name = v;
 	utf8_to_utf16(name, ent->ent_name, __arraycount(ent->ent_name));

Index: src/sbin/gpt/remove.c
diff -u src/sbin/gpt/remove.c:1.22 src/sbin/gpt/remove.c:1.23
--- src/sbin/gpt/remove.c:1.22	Tue Jul  3 03:41:24 2018
+++ src/sbin/gpt/remove.c	Fri Jun 21 02:14:59 2019
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/remove.c,v 1.10 2006/10/04 18:20:25 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: remove.c,v 1.22 2018/07/03 03:41:24 jnemeth Exp $");
+__RCSID("$NetBSD: remove.c,v 1.23 2019/06/21 02:14:59 jnemeth Exp $");
 #endif
 
 #include 
@@ -66,7 +66,7 @@ struct gpt_cmd c_remove = {
 #define usage() gpt_usage(NULL, _remove)
 
 static void
-change(struct gpt_ent *ent, void *v)
+change(struct gpt_ent *ent, void *v, int backup)
 {
 	/* Remove the primary entry by clearing the partition type. */
 	gpt_uuid_copy(ent->ent_type, gpt_uuid_nil);

Index: src/sbin/gpt/type.c
diff -u src/sbin/gpt/type.c:1.15 src/sbin/gpt/type.c:1.16
--- src/sbin/gpt/type.c:1.15	Tue Jul  3 03:41:24 2018
+++ src/sbin/gpt/type.c	Fri Jun 21 02:14:59 2019
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/remove.c,v 1.10 2006/10/04 18:20:25 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: type.c,v 1.15 2018/07/03 03:41:24 jnemeth Exp $");
+__RCSID("$NetBSD: type.c,v 1.16 2019/06/21 02:14:59 jnemeth Exp $");
 #endif
 
 #include 
@@ -67,7 +67,7 @@ struct gpt_cmd c_type = {
 #define usage() gpt_usage(NULL, _type)
 
 static void
-change(struct gpt_ent *ent, void *v)
+change(struct gpt_ent *ent, void *v, int backup)
 {
 	gpt_uuid_t *newtype = v;
 	gpt_uuid_copy(ent->ent_type, *newtype);



CVS commit: src/sbin/gpt

2019-06-20 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Fri Jun 21 02:14:59 UTC 2019

Modified Files:
src/sbin/gpt: gpt.c gpt.h label.c remove.c type.c

Log Message:
Add a third argument to the "cfn" function that is an argument to
gpt_change_ent().  The purpose of the third argument is to specify
whether the entry to be changed is a primary GPT entry or a secondary
GPT entry.  It is assumed that a secondary GPT entry will always
follow a corresponding primary entry.

This is in preparation for an upcoming change that will require it.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sbin/gpt/gpt.c
cvs rdiff -u -r1.38 -r1.39 src/sbin/gpt/gpt.h
cvs rdiff -u -r1.29 -r1.30 src/sbin/gpt/label.c
cvs rdiff -u -r1.22 -r1.23 src/sbin/gpt/remove.c
cvs rdiff -u -r1.15 -r1.16 src/sbin/gpt/type.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2019-06-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jun 20 10:56:38 UTC 2019

Modified Files:
src/sbin/gpt: biosboot.c

Log Message:
When biosboot is used on an existing wedge and we are switching to
the gpt of the parent device, do not pass the size of the wedge to
gpt_open, it certainly is smaller than the whole device.
Fixes bin/54312.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sbin/gpt/biosboot.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/gpt

2019-06-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jun 20 10:56:38 UTC 2019

Modified Files:
src/sbin/gpt: biosboot.c

Log Message:
When biosboot is used on an existing wedge and we are switching to
the gpt of the parent device, do not pass the size of the wedge to
gpt_open, it certainly is smaller than the whole device.
Fixes bin/54312.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sbin/gpt/biosboot.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/biosboot.c
diff -u src/sbin/gpt/biosboot.c:1.31 src/sbin/gpt/biosboot.c:1.32
--- src/sbin/gpt/biosboot.c:1.31	Thu Apr  4 13:55:40 2019
+++ src/sbin/gpt/biosboot.c	Thu Jun 20 10:56:38 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosboot.c,v 1.31 2019/04/04 13:55:40 martin Exp $ */
+/*	$NetBSD: biosboot.c,v 1.32 2019/06/20 10:56:38 martin Exp $ */
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: biosboot.c,v 1.31 2019/04/04 13:55:40 martin Exp $");
+__RCSID("$NetBSD: biosboot.c,v 1.32 2019/06/20 10:56:38 martin Exp $");
 #endif
 
 #include 
@@ -312,7 +312,7 @@ cmd_biosboot(gpt_t gpt, int argc, char *
 		start = dkw.dkw_offset;
 		size = dkw.dkw_size;
 		ngpt = gpt_open(dkw.dkw_parent, gpt->flags, gpt->verbose,
-		gpt->mediasz, gpt->secsz, gpt->timestamp);
+		0, 0, 0);
 		if (ngpt == NULL)
 			goto cleanup;
 	}



CVS commit: src/sbin/gpt

2019-06-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jun 20 10:41:58 UTC 2019

Modified Files:
src/sbin/gpt: gpt.c

Log Message:
Do not try to close a NULL gpt. Fixes the core dump part of PR bin/54312


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sbin/gpt/gpt.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/gpt.c
diff -u src/sbin/gpt/gpt.c:1.77 src/sbin/gpt/gpt.c:1.78
--- src/sbin/gpt/gpt.c:1.77	Sun Jan 27 13:16:05 2019
+++ src/sbin/gpt/gpt.c	Thu Jun 20 10:41:58 2019
@@ -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.77 2019/01/27 13:16:05 martin Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.78 2019/06/20 10:41:58 martin Exp $");
 #endif
 
 #include 
@@ -590,6 +590,9 @@ void
 gpt_close(gpt_t gpt)
 {
 
+	if (gpt == NULL)
+		return;
+
 	if (!(gpt->flags & GPT_MODIFIED) || !(gpt->flags & GPT_SYNC))
 		goto out;
 



Re: CVS commit: src/sbin/gpt

2017-02-13 Thread David Laight
On Sun, Feb 12, 2017 at 06:20:53PM +, Christos Zoulas wrote:
> In article <87bmu7l1k6@free.fr>,
> Aymeric Vincent   wrote:
> >chris...@astron.com (Christos Zoulas) writes:
> >
> >> Yes, doesn't libcompat provide our getopt()? Or are you trying to compile
> >> this standalone?
> >
> >It does, but from what I understand, we replace only getopt_long()
> >unconditionnally and use the host's getopt() if the optind variable can
> >be linked against.
> >
> >Confirmed on a Linux host in /lib:
> >
> >$ nm libnbcompat.a | grep getopt
> >getopt_long.lo:
> >0098 T __nbcompat_getopt_long
> >$ 
> >
> >I agree it would be nicer to use always our getopt().
> 
> Yes, because the glibc is not posix compliant by default.

More than non-compliaint, completely f*cked.
It reorders argv[] to move all 'options' before filenames.
So 'foo bar -baz' is changed to 'foo -baz bar' before being processed.
I've NFI of the justification for it.
Historically you could do 'rlogin host -l username' but I
don't know of any others.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sbin/gpt

2017-02-12 Thread Christos Zoulas
In article <87bmu7l1k6@free.fr>,
Aymeric Vincent   wrote:
>chris...@astron.com (Christos Zoulas) writes:
>
>> Yes, doesn't libcompat provide our getopt()? Or are you trying to compile
>> this standalone?
>
>It does, but from what I understand, we replace only getopt_long()
>unconditionnally and use the host's getopt() if the optind variable can
>be linked against.
>
>Confirmed on a Linux host in /lib:
>
>$ nm libnbcompat.a | grep getopt
>getopt_long.lo:
>0098 T __nbcompat_getopt_long
>$ 
>
>I agree it would be nicer to use always our getopt().

Yes, because the glibc is not posix compliant by default.

christos



Re: CVS commit: src/sbin/gpt

2017-02-12 Thread Aymeric Vincent
chris...@astron.com (Christos Zoulas) writes:

> Yes, doesn't libcompat provide our getopt()? Or are you trying to compile
> this standalone?

It does, but from what I understand, we replace only getopt_long()
unconditionnally and use the host's getopt() if the optind variable can
be linked against.

Confirmed on a Linux host in /lib:

$ nm libnbcompat.a | grep getopt
getopt_long.lo:
0098 T __nbcompat_getopt_long
$ 

I agree it would be nicer to use always our getopt().

 Aymeric


Re: CVS commit: src/sbin/gpt

2017-02-12 Thread Christos Zoulas
In article <20170212165406.79987f...@cvs.netbsd.org>,
Aymeric Vincent  wrote:
>-=-=-=-=-=-
>
>Module Name:   src
>Committed By:  aymeric
>Date:  Sun Feb 12 16:54:06 UTC 2017
>
>Modified Files:
>   src/sbin/gpt: main.c
>
>Log Message:
>Make gpt(8) work when compiled on a glibc-based OS.
>
>This restores the ability to build amd64 install-image's under Linux.

Yes, doesn't libcompat provide our getopt()? Or are you trying to compile
this standalone?

christos



Re: CVS commit: src/sbin/gpt

2016-06-09 Thread Christos Zoulas
In article <201606091738.u59hcf6c007...@server.cornerstoneservice.ca>,
John Nemeth   wrote:
>On Jun 9, 11:12am, "Christos Zoulas" wrote:
>} 
>} Module Name: src
>} Committed By:christos
>} Date:Thu Jun  9 15:12:54 UTC 2016
>} 
>} Modified Files:
>}  src/sbin/gpt: biosboot.c create.c gpt.8 gpt.c gpt.h migrate.c show.c
>} 
>} Log Message:
>} PR/51230: Add the ability to set the active flag in the PMBR.
>
> I would have just set the active flag in biosboot always since
>it is unlikely to cause problems.  Also, I would not have bothered
>with adding the ability to set the active flag to create and migrate,
>since without running biosboot the disk won't be legacy bootable
>anyways, so there is no point.  Not clearing the active flag in
>gpt_create_pmbr_part() was likely a bug.

So no flags, just make the PMBR active is biosboot is called. When do
you clear it?

christos



Re: CVS commit: src/sbin/gpt

2016-06-09 Thread John Nemeth
On Jun 9, 11:12am, "Christos Zoulas" wrote:
} 
} Module Name:  src
} Committed By: christos
} Date: Thu Jun  9 15:12:54 UTC 2016
} 
} Modified Files:
}   src/sbin/gpt: biosboot.c create.c gpt.8 gpt.c gpt.h migrate.c show.c
} 
} Log Message:
} PR/51230: Add the ability to set the active flag in the PMBR.

 I would have just set the active flag in biosboot always since
it is unlikely to cause problems.  Also, I would not have bothered
with adding the ability to set the active flag to create and migrate,
since without running biosboot the disk won't be legacy bootable
anyways, so there is no point.  Not clearing the active flag in
gpt_create_pmbr_part() was likely a bug.

}-- End of excerpt from "Christos Zoulas"


Re: CVS commit: src/sbin/gpt

2015-12-02 Thread Robert Elz
Date:Wed, 2 Dec 2015 07:36:53 -0500
From:"Christos Zoulas" 
Message-ID:  <20151202123653.7531...@cvs.netbsd.org>

  | Modified Files:
  | src/sbin/gpt: backup.c gpt.8 restore.c
  | 
  | Log Message:
  | Allow backup and restore to operate on files.

Will that modified code still (really) support writing to stdout?
The man page suggests it should, but I don't see how the code can.

kre



Re: CVS commit: src/sbin/gpt

2015-12-02 Thread Christos Zoulas
In article <28433.1449088...@andromeda.noi.kre.to>,
Robert Elz   wrote:
>Date:Wed, 2 Dec 2015 07:36:53 -0500
>From:"Christos Zoulas" 
>Message-ID:  <20151202123653.7531...@cvs.netbsd.org>
>
>  | Modified Files:
>  |src/sbin/gpt: backup.c gpt.8 restore.c
>  | 
>  | Log Message:
>  | Allow backup and restore to operate on files.
>
>Will that modified code still (really) support writing to stdout?
>The man page suggests it should, but I don't see how the code can.

"/dev/stdout".

christos



Re: CVS commit: src/sbin/gpt

2015-12-02 Thread Christos Zoulas
On Dec 3,  5:37am, k...@munnari.oz.au (Robert Elz) wrote:
-- Subject: Re: CVS commit: src/sbin/gpt

| Sure, but "how do write to stdout" wasn't what I asked ...
| 
|  gpt backup [-o outfile]
|  The backup command dumps the MBR or (PMBR) and GPT partition
|  tables to standard output or to a file specified by the outfile
|  argument in a format to be used by the restore command.  The
|  format is a plist.  It should not be modified.
| 
| What I meant was, if the "-o outfile" is not there, and the dump is
| "tables to standard output" and not "or to a file specified" ...
| 
| How does that work now?
| 
| Of, if you like, take your new version, and just try "gpt backup XXXn"
| (or whatever device is relevant) and observe.

I observe data going to stdout because:

static const char *outfile = "/dev/stdout";

It does not work for you?

christos


Re: CVS commit: src/sbin/gpt

2015-12-02 Thread Robert Elz
Date:Wed, 2 Dec 2015 17:41:08 -0500
From:chris...@zoulas.com (Christos Zoulas)
Message-ID:  <20151202224108.9064b17f...@rebar.astron.com>

  | I observe data going to stdout because:
  | static const char *outfile = "/dev/stdout";

Oh yes, OK, sorry - missed that.It isn't a style I would use, so
I wasn't expecting that.   I dislike assigning to a gobal var from a
source that might come from anywhere ... in current invocation it is
from the arg list, so isstable, but someone might add an interactive
gpt mode, and then this method would break badly.

kre



Re: CVS commit: src/sbin/gpt

2015-12-02 Thread Christos Zoulas
On Dec 3,  6:54am, k...@munnari.oz.au (Robert Elz) wrote:
-- Subject: Re: CVS commit: src/sbin/gpt

| Date:Wed, 2 Dec 2015 17:41:08 -0500
| From:chris...@zoulas.com (Christos Zoulas)
| Message-ID:  <20151202224108.9064b17f...@rebar.astron.com>
| 
|   | I observe data going to stdout because:
|   | static const char *outfile = "/dev/stdout";
| 
| Oh yes, OK, sorry - missed that.It isn't a style I would use, so
| I wasn't expecting that.   I dislike assigning to a gobal var from a
| source that might come from anywhere ... in current invocation it is
| from the arg list, so isstable, but someone might add an interactive
| gpt mode, and then this method would break badly.

Yes, I am fixing those in the next pass (no static globals).

christos


Re: CVS commit: src/sbin/gpt

2015-12-01 Thread Christos Zoulas
On Dec 1,  7:13am, jnem...@cue.bc.ca (John Nemeth) wrote:
-- Subject: Re: CVS commit: src/sbin/gpt

|  Uh, what a silly question.  As you should know, gpt(8) first
| appeared in NetBSD 4.0.  NetBSD-6 has always supported gpt disks.
| My plan was to pullup everything up to the point of toolification
| to netbsd-6.  However, some useful changes have been made since
| then which should also be pulled up.  These changes will likely
| have to be pulled up by patch now.  Even if the new ioctls are
| pulled up to netbsd-6, I would prefer gpt(8) to be able to use the
| older methods, since that doesn't need a kernel upgrade.

Yes, and still the majority of people are not using it because it
is not supported in sysinst, and the kernel/userland support for
wedges in 6 is lacking. You need to be an expert to be able to
use it before 7.

You have to make choices to move ahead; you can keep tons of
backwards compatibility code around (which is conditionally compiled
and not well tested), or you can cleanup the code and make it better
managed and testable for the future.

christos


Re: CVS commit: src/sbin/gpt

2015-11-30 Thread John Nemeth
On Nov 30,  4:58pm, John Nemeth wrote:
}
}  See question in gpt.c (and others).
} 
} On Nov 30,  2:59pm, "Christos Zoulas" wrote:
} }
} } This is a multi-part message in MIME format.
} } 
} } --_--=_1448913574208280
} } Content-Disposition: inline
} } Content-Transfer-Encoding: 8bit
} } Content-Type: text/plain; charset="US-ASCII"
} } 
} } Module Name:src
} } Committed By:   christos
} } Date:   Mon Nov 30 19:59:34 UTC 2015
} } 
} } Modified Files:
} } src/sbin/gpt: Makefile add.c gpt.8 gpt.c gpt.h resize.c
} } Added Files:
} } src/sbin/gpt: main.c
} } 
} } Log Message:
} } - automatically sync the wedge information unless -n is specified.
} } - document the general options in the traditional way.
} } - split the main program into a separate file.
} } 
} } 
} } To generate a diff of this commit:
} } cvs rdiff -u -r1.15 -r1.16 src/sbin/gpt/Makefile
} } cvs rdiff -u -r1.28 -r1.29 src/sbin/gpt/add.c
} } cvs rdiff -u -r1.37 -r1.38 src/sbin/gpt/gpt.8
} } cvs rdiff -u -r1.45 -r1.46 src/sbin/gpt/gpt.c
} } cvs rdiff -u -r1.21 -r1.22 src/sbin/gpt/gpt.h
} } cvs rdiff -u -r0 -r1.1 src/sbin/gpt/main.c
} } cvs rdiff -u -r1.12 -r1.13 src/sbin/gpt/resize.c
} } 
} } Please note that diffs are not public domain; they are subject to the
} } copyright notices on the relevant files.
} } 
} } 
} } --_--=_1448913574208280
} } Content-Disposition: inline
} } Content-Length: 17047
} } Content-Transfer-Encoding: binary
} } Content-Type: text/x-diff; charset=us-ascii
} } 
} } Modified files:
} } 
} } Index: src/sbin/gpt/gpt.c
} } diff -u src/sbin/gpt/gpt.c:1.45 src/sbin/gpt/gpt.c:1.46
} } --- src/sbin/gpt/gpt.c:1.45 Sun Nov 29 09:03:35 2015
} } +++ src/sbin/gpt/gpt.c  Mon Nov 30 14:59:34 2015
} } @@ -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.45 2015/11/29 14:03:35 christos Exp $");
} } +__RCSID("$NetBSD: gpt.c,v 1.46 2015/11/30 19:59:34 christos Exp $");
} }  #endif
} }  
} }  #include 
} } @@ -68,7 +68,9 @@ off_t mediasz;
} }  u_int  parts;
} }  u_int  secsz;
} }  
} } -intreadonly, verbose, quiet;
} } +intreadonly, verbose, quiet, nosync;
} } +
} } +static int modified;
} }  
} }  static uint32_t crc32_tab[] = {
} } 0x, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
} } @@ -269,10 +271,11 @@ gpt_write(int fd, map_t *map)
} }  
} } count = map->map_size * secsz;
} } ofs = map->map_start * secsz;
} } -   if (lseek(fd, ofs, SEEK_SET) == ofs &&
} } -   write(fd, map->map_data, count) == (ssize_t)count)
} } -   return (0);
} } -   return (-1);
} } +   if (lseek(fd, ofs, SEEK_SET) != ofs ||
} 
}  Why did you change the "&&" to "||"?  If the lseek() fails,
} you will now be writing data to the wrong place on the disk.

 Never mind, I just looked at it again.  Of course, if the
lseek() fails, the whole expression is true, and short circuiting
rules apply.

} } +   write(fd, map->map_data, count) != (ssize_t)count)
} } +   return -1;
} } +   modified = 1;
} } +   return 0;
} }  }
} }  
} }  static int
} } 
} } --_--=_1448913574208280--
} } 
} }-- End of excerpt from "Christos Zoulas"
}-- End of excerpt from John Nemeth


Re: CVS commit: src/sbin/gpt

2015-11-30 Thread Christos Zoulas
In article <201512010058.tb10wtzj029...@server.cornerstoneservice.ca>,
John Nemeth   wrote:
> See question in gpt.c (and others).
>
>} -printf("Partition %d added, use:\n", i + 1);
>} -printf("\tdkctl %s addwedge  %" PRIu64 " %" PRIu64
>} -" \n", device_arg, map->map_start, map->map_size);
>} -printf("to create a wedge for it\n");
>} +printf("Partition %d added on %s: ", i + 1, device_arg);
>} +printf("%s %" PRIu64 " %" PRIu64 "\n", type, map->map_start,
>} +map->map_size);
>
> This message needs to depend on the new -n flag, otherwise it
>may give incorrect information.

I will add a message to clarify that thanks!

>} @@ -269,10 +271,11 @@ gpt_write(int fd, map_t *map)
>}  
>}  count = map->map_size * secsz;
>}  ofs = map->map_start * secsz;
>} -if (lseek(fd, ofs, SEEK_SET) == ofs &&
>} -write(fd, map->map_data, count) == (ssize_t)count)
>} -return (0);
>} -return (-1);
>} +if (lseek(fd, ofs, SEEK_SET) != ofs ||
>
> Why did you change the "&&" to "||"?  If the lseek() fails,
>you will now be writing data to the wrong place on the disk.

Nope, I flipped the polarity of the tests too.

>
>} +write(fd, map->map_data, count) != (ssize_t)count)
>} +return -1;
>} +modified = 1;
>} +return 0;

christos



Re: CVS commit: src/sbin/gpt

2015-11-30 Thread John Nemeth
On Nov 30,  9:03pm, "Christos Zoulas" wrote:
}
} This is a multi-part message in MIME format.
} 
} --_--=_1448935435147560
} Content-Disposition: inline
} Content-Transfer-Encoding: 8bit
} Content-Type: text/plain; charset="US-ASCII"
} 
} Module Name:  src
} Committed By: christos
} Date: Tue Dec  1 02:03:55 UTC 2015
} 
} Modified Files:
}   src/sbin/gpt: add.c gpt.c resize.c
} 
} Log Message:
} - use gpt_msg to print informational messages (perhaps these should be printed
}   only with -v)
} - don't print any messages with gpt_msg if quiet
} - print a message if we didn't reconfigure the wedges
} 
} 
} To generate a diff of this commit:
} cvs rdiff -u -r1.29 -r1.30 src/sbin/gpt/add.c
} cvs rdiff -u -r1.47 -r1.48 src/sbin/gpt/gpt.c
} cvs rdiff -u -r1.13 -r1.14 src/sbin/gpt/resize.c
} 
} Please note that diffs are not public domain; they are subject to the
} copyright notices on the relevant files.
} 
} 
} --_--=_1448935435147560
} Content-Disposition: inline
} Content-Length: 2767
} Content-Transfer-Encoding: binary
} Content-Type: text/x-diff; charset=us-ascii
} 
} Modified files:
} 
} Index: src/sbin/gpt/gpt.c
} diff -u src/sbin/gpt/gpt.c:1.47 src/sbin/gpt/gpt.c:1.48
} --- src/sbin/gpt/gpt.c:1.47   Mon Nov 30 20:49:23 2015
} +++ src/sbin/gpt/gpt.cMon Nov 30 21:03:55 2015
} @@ -573,15 +573,22 @@ void
}  gpt_close(int fd)
}  {
}  
} - if (modified && !nosync) {
} + if (!modified)
} + goto out;
} +
} + if (!nosync) {
}  #ifdef DIOCMWEDGES
}   int bits;
}   if (ioctl(fd, DIOCMWEDGES, ) == -1)
}   warn("Can't update wedge information");
} + else
} + goto out;
}  #endif
}   }
} + gpt_msg("You need to run \"dkctl %s makewedges\""
} + " for the changes to take effect\n", device_name);

 dkctl makewedges is just ioctl(DIOCMWEDGES), so if DIOCMWEDGES
doesn't exist or it fails, then dkctl makewedges won't do anything,
which means that the user would either need to use dkctl add, etc.,
or reboot.

}  
} - /* XXX post processing? */
} +out:
}   close(fd);
}  }
}  
} --_--=_1448935435147560--
} 
}-- End of excerpt from "Christos Zoulas"


Re: CVS commit: src/sbin/gpt

2015-11-30 Thread John Nemeth
 See question in gpt.c (and others).

On Nov 30,  2:59pm, "Christos Zoulas" wrote:
}
} This is a multi-part message in MIME format.
} 
} --_--=_1448913574208280
} Content-Disposition: inline
} Content-Transfer-Encoding: 8bit
} Content-Type: text/plain; charset="US-ASCII"
} 
} Module Name:  src
} Committed By: christos
} Date: Mon Nov 30 19:59:34 UTC 2015
} 
} Modified Files:
}   src/sbin/gpt: Makefile add.c gpt.8 gpt.c gpt.h resize.c
} Added Files:
}   src/sbin/gpt: main.c
} 
} Log Message:
} - automatically sync the wedge information unless -n is specified.
} - document the general options in the traditional way.
} - split the main program into a separate file.
} 
} 
} To generate a diff of this commit:
} cvs rdiff -u -r1.15 -r1.16 src/sbin/gpt/Makefile
} cvs rdiff -u -r1.28 -r1.29 src/sbin/gpt/add.c
} cvs rdiff -u -r1.37 -r1.38 src/sbin/gpt/gpt.8
} cvs rdiff -u -r1.45 -r1.46 src/sbin/gpt/gpt.c
} cvs rdiff -u -r1.21 -r1.22 src/sbin/gpt/gpt.h
} cvs rdiff -u -r0 -r1.1 src/sbin/gpt/main.c
} cvs rdiff -u -r1.12 -r1.13 src/sbin/gpt/resize.c
} 
} Please note that diffs are not public domain; they are subject to the
} copyright notices on the relevant files.
} 
} 
} --_--=_1448913574208280
} Content-Disposition: inline
} Content-Length: 17047
} Content-Transfer-Encoding: binary
} Content-Type: text/x-diff; charset=us-ascii
} 
} Modified files:
} 
} Index: src/sbin/gpt/add.c
} diff -u src/sbin/gpt/add.c:1.28 src/sbin/gpt/add.c:1.29
} --- src/sbin/gpt/add.c:1.28   Sat Nov 28 19:14:46 2015
} +++ src/sbin/gpt/add.cMon Nov 30 14:59:34 2015
} @@ -33,7 +33,7 @@
}  __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp 
$");
}  #endif
}  #ifdef __RCSID
} -__RCSID("$NetBSD: add.c,v 1.28 2015/11/29 00:14:46 christos Exp $");
} +__RCSID("$NetBSD: add.c,v 1.29 2015/11/30 19:59:34 christos Exp $");
}  #endif
}  
}  #include 
} @@ -180,10 +180,9 @@ add(int fd)
}   gpt_write(fd, lbt);
}   gpt_write(fd, tpg);
}  
} - printf("Partition %d added, use:\n", i + 1);
} - printf("\tdkctl %s addwedge  %" PRIu64 " %" PRIu64
} - " \n", device_arg, map->map_start, map->map_size);
} - printf("to create a wedge for it\n");
} + printf("Partition %d added on %s: ", i + 1, device_arg);
} + printf("%s %" PRIu64 " %" PRIu64 "\n", type, map->map_start,
} + map->map_size);

 This message needs to depend on the new -n flag, otherwise it
may give incorrect information.

}  }
}  
}  int
} 
} Index: src/sbin/gpt/gpt.c
} diff -u src/sbin/gpt/gpt.c:1.45 src/sbin/gpt/gpt.c:1.46
} --- src/sbin/gpt/gpt.c:1.45   Sun Nov 29 09:03:35 2015
} +++ src/sbin/gpt/gpt.cMon Nov 30 14:59:34 2015
} @@ -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.45 2015/11/29 14:03:35 christos Exp $");
} +__RCSID("$NetBSD: gpt.c,v 1.46 2015/11/30 19:59:34 christos Exp $");
}  #endif
}  
}  #include 
} @@ -68,7 +68,9 @@ off_t   mediasz;
}  u_intparts;
}  u_intsecsz;
}  
} -int  readonly, verbose, quiet;
} +int  readonly, verbose, quiet, nosync;
} +
} +static int modified;
}  
}  static uint32_t crc32_tab[] = {
}   0x, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
} @@ -269,10 +271,11 @@ gpt_write(int fd, map_t *map)
}  
}   count = map->map_size * secsz;
}   ofs = map->map_start * secsz;
} - if (lseek(fd, ofs, SEEK_SET) == ofs &&
} - write(fd, map->map_data, count) == (ssize_t)count)
} - return (0);
} - return (-1);
} + if (lseek(fd, ofs, SEEK_SET) != ofs ||

 Why did you change the "&&" to "||"?  If the lseek() fails,
you will now be writing data to the wrong place on the disk.

} + write(fd, map->map_data, count) != (ssize_t)count)
} + return -1;
} + modified = 1;
} + return 0;
}  }
}  
}  static int
} @@ -569,6 +572,12 @@ gpt_open(const char *dev, int flags)
}  void
}  gpt_close(int fd)
}  {
} + int bits;
} +
} + if (modified && !nosync)
} + if (ioctl(fd, DIOCMWEDGES, ) == -1)
} + warn("Can't update wedge information");
} +
}   /* XXX post processing? */
}   close(fd);
}  }
} @@ -583,172 +592,3 @@ gpt_msg(const char *fmt, ...)
}   va_end(ap);
}   printf("\n");
}  }
} -
} -static struct {
} - int (*fptr)(int, char *[]);
} - 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" },
} - { cmd_header, "header" },
} - { NULL, "help" },
} - { cmd_label, "label" },
} - { cmd_migrate, "migrate" },
} - { cmd_recover, "recover" },
} - { cmd_remove, "remove" },
} - { NULL, "rename" },
} - { cmd_resize, "resize" },
} - { cmd_resizedisk, "resizedisk" },
} -#ifndef 

Re: CVS commit: src/sbin/gpt

2015-11-30 Thread Christos Zoulas
On Nov 29, 11:22pm, jnem...@cue.bc.ca (John Nemeth) wrote:
-- Subject: Re: CVS commit: src/sbin/gpt

|  I have read the Makefile.  I think there is confusion between
| the tool version and the crossbuilt version intended to go in the
| release being built.  Obviously, the tool version will use the
| system headers, and that may be the one that I saw fail (I don't
| have the log anymore).

The cross-built version is not affected either. In current it will just
use the ioctls and be happy. In older versions it will use what it had,
since it is not changed.

|  Maybe so, but one could just lift the source code from -current
| and plunk it on an older version of NetBSD and it would just work.
| Now, one can not do that.  Having to update the kernel for a
| relatively small userland utility is kind of annoying.

That's the only disadvantage. Even if you wanted to do this, I am
saying I would prefer that the pullup was done to the kernel to
support the missing ioctls. And we are talking only about NetBSD-6
where the utility is not that useful, since NetBSD-7 has them. Are
you really planning to support gpt disks on NetBSD-6?

christos


Re: CVS commit: src/sbin/gpt

2015-11-29 Thread John Nemeth
On Nov 29,  8:46am, "Christos Zoulas" wrote:
}
} This is a multi-part message in MIME format.
} 
} --_--=_1448804783204230
} Content-Disposition: inline
} Content-Transfer-Encoding: 8bit
} Content-Type: text/plain; charset="US-ASCII"
} 
} Module Name:  src
} Committed By: christos
} Date: Sun Nov 29 13:46:23 UTC 2015
} 
} Modified Files:
}   src/sbin/gpt: gpt.c
} 
} Log Message:
} Only use the ioctl's if we have them.

 Why did you leave out the call to getdisksize() for when the
ioctls don't exist?  Actually, why did you even bother with this
patch, since it is pretty much equivalent to what was there before,
minus the missing functionality?

} To generate a diff of this commit:
} cvs rdiff -u -r1.43 -r1.44 src/sbin/gpt/gpt.c
} 
} Please note that diffs are not public domain; they are subject to the
} copyright notices on the relevant files.
} 
} 
} --_--=_1448804783204230
} Content-Disposition: inline
} Content-Length: 1887
} Content-Transfer-Encoding: binary
} Content-Type: text/x-diff; charset=us-ascii
} 
} Modified files:
} 
} Index: src/sbin/gpt/gpt.c
} diff -u src/sbin/gpt/gpt.c:1.43 src/sbin/gpt/gpt.c:1.44
} --- src/sbin/gpt/gpt.c:1.43   Sun Nov 29 08:24:28 2015
} +++ src/sbin/gpt/gpt.cSun Nov 29 08:46:23 2015
} @@ -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.43 2015/11/29 13:24:28 jnemeth Exp $");
} +__RCSID("$NetBSD: gpt.c,v 1.44 2015/11/29 13:46:23 christos Exp $");
}  #endif
}  
}  #include 
} @@ -486,24 +486,38 @@ gpt_open(const char *dev, int flags)
}   }
}  
}   if ((sb.st_mode & S_IFMT) != S_IFREG) {
} + if (secsz == 0) {
}  #ifdef DIOCGSECTORSIZE
} - if ((secsz == 0 && ioctl(fd, DIOCGSECTORSIZE, ) == -1) ||
} -   (mediasz == 0 && ioctl(fd, DIOCGMEDIASIZE, ) == -1)) {
} - if (!quiet)
} - warn("Cannot get sector/media size for `%s'",
} - device_name);
} - goto close;
} - }
} -#else
} - if (getdisksize(device_name, , ) == -1) {
} - if (!quiet)
} - warn("Cannot get sector/media size for `%s'",
} - device_name);
} - goto close;
} + if (ioctl(fd, DIOCGSECTORSIZE, ) == -1) {
} + if (!quiet)
} + warn("Cannot get sector size for `%s'",
} + device_name);
} + goto close;
} + }
} +#endif
} + if (secsz == 0) {
} + if (!quiet)
} + warnx("Sector size for `%s' can't be 0",
} + device_name);
} + goto close;
} + }
}   }
} + if (mediasz == 0) {
} +#ifdef DIOCGMEDIASIZE
} + if (ioctl(fd, DIOCGMEDIASIZE, ) == -1) {
} + if (!quiet)
} + warn("Cannot get media size for `%s'",
} + device_name);
} + goto close;
} + }
}  #endif
} - if (secsz == 0 || mediasz == 0)
} - errx(1, "Please specify sector/media size");
} + if (mediasz == 0) {
} + if (!quiet)
} + warnx("Media size for `%s' can't be 0",
} + device_name);
} + goto close;
} + }
} + }
}   } else {
}   if (secsz == 0)
}   secsz = 512;/* Fixed size for files. */
} 
} 
} --_--=_1448804783204230--
} 
}-- End of excerpt from "Christos Zoulas"




Re: CVS commit: src/sbin/gpt

2015-11-29 Thread Christos Zoulas
In article <201511291418.tateiwrt002...@server.cornerstoneservice.ca>,
John Nemeth   wrote:
>
> Why did you leave out the call to getdisksize() for when the
>ioctls don't exist?  Actually, why did you even bother with this
>patch, since it is pretty much equivalent to what was there before,
>minus the missing functionality?

Because who has this functionality (drvctl) and does not have the
ioctls? Only the NetBSD-6 tools build. This is too much complexity
for very little benefit. It is simpler to add the ioctls to NetBSD-6
than keeping all this messy libprop code around (which we have again
in fsck...) :-)

christos



Re: CVS commit: src/sbin/gpt

2015-11-29 Thread John Nemeth
On Nov 29,  8:24pm, Christos Zoulas wrote:
} On Nov 29,  5:01pm, jnem...@cue.bc.ca (John Nemeth) wrote:
} 
} |  The reason I noticed it was due to a build failure.  The system
} | I was building it on is:
} | 
} | NetBSD msgate 7.0_BETA NetBSD 7.0_BETA (GENERIC.201408231540Z) amd64
} | 
} | (Yes, it needs to be updated, but that's beside the point.)  Granted,
} | this did point out an additional problem, which is:  why was it
} | using the system headers and not the headers from the source tree
} | (a full cvs update was done immediately before the build)?
} 
} Is that the tools build or the regular build? The tools build is supposed
} to work as consistently as possible across platforms. At least the ioctls
} are not NetBSD only (FreeBSD has them too).

 Tools build.  Full command line is:

./build.sh -j 10 -R /usr/local/NetBSD-current/amd64-releasedir -D 
/usr/local/NetBSD-current/amd64-destdir -T 
/usr/local/NetBSD-current/amd64-tooldir -O 
/usr/local/NetBSD-current/amd64-objdir -X /usr/local/NetBSD-current/xsrc -x -u 
-m amd64 tools sourcesets release iso-image-source |& tee ../buildlog

} |  BTW, if you're going to take out getdisksize(), then there is
} | really no point in having #ifdef DIOCGSECTORSIZE, since it won't
} | work even if it does compile.
} 
} It does work with parameters from the command line, as it always did.

 True, but extremely sucky.

}-- End of excerpt from Christos Zoulas


Re: CVS commit: src/sbin/gpt

2015-11-29 Thread Christos Zoulas
On Nov 29,  5:28pm, jnem...@cue.bc.ca (John Nemeth) wrote:
-- Subject: Re: CVS commit: src/sbin/gpt

|  Tools build.  Full command line is:
| 
| ./build.sh -j 10 -R /usr/local/NetBSD-current/amd64-releasedir -D 
/usr/local/NetBSD-current/amd64-destdir -T 
/usr/local/NetBSD-current/amd64-tooldir -O 
/usr/local/NetBSD-current/amd64-objdir -X /usr/local/NetBSD-current/xsrc -x -u 
-m amd64 tools sourcesets release iso-image-source |& tee ../buildlog

Tools build never used the drvctl or the partutil code; read the Makefile.
(How could it? It would have been broken on anything but NetBSD?)

| } It does work with parameters from the command line, as it always did.
| 
|  True, but extremely sucky.

It is no different than before. The tools version never worked on OS's that
lack the ioctls without parameters from the command line.

christos


Re: CVS commit: src/sbin/gpt

2015-11-29 Thread John Nemeth
On Nov 29, 10:32am, "Christos Zoulas" wrote:
}
} This is a multi-part message in MIME format.
} 
} --_--=_1448811166297500
} Content-Disposition: inline
} Content-Transfer-Encoding: 8bit
} Content-Type: text/plain; charset="US-ASCII"
} 
} Module Name:  src
} Committed By: christos
} Date: Sun Nov 29 15:32:46 UTC 2015
} 
} Modified Files:
}   src/sbin/gpt: Makefile gpt.h
} Removed Files:
}   src/sbin/gpt: drvctl.c
} 
} Log Message:
} Remove getdisksize support; we either have the ioctls (current/-7) or we
} don't (non-netbsd-current/7+tools).

 Now, you're just making it harder to pullup improvements to
older releases.

} To generate a diff of this commit:
} cvs rdiff -u -r1.14 -r1.15 src/sbin/gpt/Makefile
} cvs rdiff -u -r1.1 -r0 src/sbin/gpt/drvctl.c
} cvs rdiff -u -r1.20 -r1.21 src/sbin/gpt/gpt.h
} 
} Please note that diffs are not public domain; they are subject to the
} copyright notices on the relevant files.
} 
} 
} --_--=_1448811166297500
} Content-Disposition: inline
} Content-Length: 1289
} Content-Transfer-Encoding: binary
} Content-Type: text/x-diff; charset=us-ascii
} 
} Modified files:
} 
} Index: src/sbin/gpt/Makefile
} diff -u src/sbin/gpt/Makefile:1.14 src/sbin/gpt/Makefile:1.15
} --- src/sbin/gpt/Makefile:1.14Mon Nov  2 21:19:24 2015
} +++ src/sbin/gpt/Makefile Sun Nov 29 10:32:46 2015
} @@ -1,4 +1,4 @@
} -# $NetBSD: Makefile,v 1.14 2015/11/03 02:19:24 jnemeth Exp $
} +# $NetBSD: Makefile,v 1.15 2015/11/29 15:32:46 christos Exp $
}  # $FreeBSD: src/sbin/gpt/Makefile,v 1.7 2005/09/01 02:49:20 marcel Exp $
}  
}  PROG=gpt
} @@ -11,16 +11,6 @@ MAN=   gpt.8
}  SRCS+= backup.c restore.c
}  LDADD+=  -lprop -lutil
}  DPADD+= ${LIBPROP} ${LIBUTIL}
} -
} -.if ${USE_DRVCTL:Uno} == "yes"
} -CPPFLAGS+=-DUSE_DRVCTL
} -SRCS+=drvctl.c
} -.else
} -.PATH: ${.CURDIR}/../fsck
} -CPPFLAGS+=-I${.CURDIR}/../fsck
} -SRCS+=partutil.c
} -.endif
}  .endif
}  
} -
}  .include 
} 
} Index: src/sbin/gpt/gpt.h
} diff -u src/sbin/gpt/gpt.h:1.20 src/sbin/gpt/gpt.h:1.21
} --- src/sbin/gpt/gpt.h:1.20   Sat Nov 28 19:14:46 2015
} +++ src/sbin/gpt/gpt.hSun Nov 29 10:32:46 2015
} @@ -96,16 +96,4 @@ intcmd_show(int, char *[]);
}  int  cmd_type(int, char *[]);
}  int  cmd_unset(int, char *[]);
}  
} -#ifndef HAVE_NBTOOL_CONFIG_H
} -# ifdef USE_DRVCTL
} -int  getdisksize(const char *, u_int *, off_t *);
} -# else
} -#  include "partutil.h"
} -# endif
} -#else
} -# define getdisksize(a, b, c) 0
} -#endif
} -
} -#define GPT_FORCE 1
} -
}  #endif /* _GPT_H_ */
} 
} 
} --_--=_1448811166297500--
} 
}-- End of excerpt from "Christos Zoulas"




Re: CVS commit: src/sbin/gpt

2015-11-29 Thread John Nemeth
On Nov 29,  4:16pm, Christos Zoulas wrote:
} In article <201511291418.tateiwrt002...@server.cornerstoneservice.ca>,
} John Nemeth   wrote:
} >
} > Why did you leave out the call to getdisksize() for when the
} >ioctls don't exist?  Actually, why did you even bother with this
} >patch, since it is pretty much equivalent to what was there before,
} >minus the missing functionality?
} 
} Because who has this functionality (drvctl) and does not have the
} ioctls? Only the NetBSD-6 tools build. This is too much complexity
} for very little benefit. It is simpler to add the ioctls to NetBSD-6
} than keeping all this messy libprop code around (which we have again
} in fsck...) :-)

 The reason I noticed it was due to a build failure.  The system
I was building it on is:

NetBSD msgate 7.0_BETA NetBSD 7.0_BETA (GENERIC.201408231540Z) amd64

(Yes, it needs to be updated, but that's beside the point.)  Granted,
this did point out an additional problem, which is:  why was it
using the system headers and not the headers from the source tree
(a full cvs update was done immediately before the build)?

 BTW, if you're going to take out getdisksize(), then there is
really no point in having #ifdef DIOCGSECTORSIZE, since it won't
work even if it does compile.

}-- End of excerpt from Christos Zoulas


Re: CVS commit: src/sbin/gpt

2015-11-29 Thread Christos Zoulas
On Nov 29,  5:01pm, jnem...@cue.bc.ca (John Nemeth) wrote:
-- Subject: Re: CVS commit: src/sbin/gpt

|  The reason I noticed it was due to a build failure.  The system
| I was building it on is:
| 
| NetBSD msgate 7.0_BETA NetBSD 7.0_BETA (GENERIC.201408231540Z) amd64
| 
| (Yes, it needs to be updated, but that's beside the point.)  Granted,
| this did point out an additional problem, which is:  why was it
| using the system headers and not the headers from the source tree
| (a full cvs update was done immediately before the build)?

Is that the tools build or the regular build? The tools build is supposed
to work as consistently as possible across platforms. At least the ioctls
are not NetBSD only (FreeBSD has them too).

|  BTW, if you're going to take out getdisksize(), then there is
| really no point in having #ifdef DIOCGSECTORSIZE, since it won't
| work even if it does compile.

It does work with parameters from the command line, as it always did.

christos


Re: CVS commit: src/sbin/gpt

2015-11-29 Thread John Nemeth
On Nov 29, 10:40pm, Christos Zoulas wrote:
} On Nov 29,  5:28pm, jnem...@cue.bc.ca (John Nemeth) wrote:
} 
} |  Tools build.  Full command line is:
} | 
} | ./build.sh -j 10 -R /usr/local/NetBSD-current/amd64-releasedir -D 
/usr/local/NetBSD-current/amd64-destdir -T 
/usr/local/NetBSD-current/amd64-tooldir -O 
/usr/local/NetBSD-current/amd64-objdir -X /usr/local/NetBSD-current/xsrc -x -u 
-m amd64 tools sourcesets release iso-image-source |& tee ../buildlog
} 
} Tools build never used the drvctl or the partutil code; read the Makefile.
} (How could it? It would have been broken on anything but NetBSD?)

 I have read the Makefile.  I think there is confusion between
the tool version and the crossbuilt version intended to go in the
release being built.  Obviously, the tool version will use the
system headers, and that may be the one that I saw fail (I don't
have the log anymore).

} | } It does work with parameters from the command line, as it always did.
} | 
} |  True, but extremely sucky.
} 
} It is no different than before. The tools version never worked on OS's that
} lack the ioctls without parameters from the command line.

 Maybe so, but one could just lift the source code from -current
and plunk it on an older version of NetBSD and it would just work.
Now, one can not do that.  Having to update the kernel for a
relatively small userland utility is kind of annoying.

}-- End of excerpt from Christos Zoulas


Re: CVS commit: src/sbin/gpt

2014-10-03 Thread S.P.Zeidler
Hi Jörg,

Thus wrote Joerg Sonnenberger (jo...@netbsd.org):

 Module Name:  src
 Committed By: joerg
 Date: Thu Oct  2 19:15:21 UTC 2014
 
 Modified Files:
   src/sbin/gpt: biosboot.c gpt.c
 
 Log Message:
 Fix tools build on !NetBSD.

It would be nice if it still built on NetBSD, too.

/home/spz/cvs/src/tools/gpt/../../sbin/gpt/biosboot.c: In function 'cmd_biosboot
':
/home/spz/cvs/src/tools/gpt/../../sbin/gpt/biosboot.c:274:22: error: storage siz
e of 'dkw' isn't known
  struct dkwedge_info dkw;

regards,
spz


Re: CVS commit: src/sbin/gpt

2013-10-20 Thread David Laight
On Sat, Oct 19, 2013 at 01:19:03AM +, John Nemeth wrote:
 Module Name:  src
 Committed By: jnemeth
 Date: Sat Oct 19 01:19:03 UTC 2013
 
 Modified Files:
   src/sbin/gpt: gpt.8
 
 Log Message:
 type fix: accommodate. - accomodate.

Why? The correct spelling has two 'm's
At least in accommodation, can't imagine accommodate being different.

David

-- 
avid Laight: da...@l8s.co.uk


Re: CVS commit: src/sbin/gpt

2013-10-20 Thread Marc Balmer
Am 20.10.13 20:25, schrieb David Laight:
 On Sat, Oct 19, 2013 at 01:19:03AM +, John Nemeth wrote:
 Module Name: src
 Committed By:jnemeth
 Date:Sat Oct 19 01:19:03 UTC 2013

 Modified Files:
  src/sbin/gpt: gpt.8

 Log Message:
 type fix: accommodate. - accomodate.
 
 Why? The correct spelling has two 'm's
 At least in accommodation, can't imagine accommodate being different.

The verb is 'to accommodate' with two 'm's.




Re: CVS commit: src/sbin/gpt

2013-10-20 Thread John Nemeth
On Oct 20,  7:25pm, David Laight wrote:
} Subject: Re: CVS commit: src/sbin/gpt
} On Sat, Oct 19, 2013 at 01:19:03AM +, John Nemeth wrote:
}  Module Name:src
}  Committed By:   jnemeth
}  Date:   Sat Oct 19 01:19:03 UTC 2013
}  
}  Modified Files:
}  src/sbin/gpt: gpt.8
}  
}  Log Message:
}  type fix: accommodate. - accomodate.
} 
} Why? The correct spelling has two 'm's
} At least in accommodation, can't imagine accommodate being different.

 Yeah, you're right, should have verified instead of just taking
the change from upstream.  Heck, I even typoed the word typo in
the commit message.

}-- End of excerpt from David Laight


CVS commit: src/sbin/gpt

2010-02-20 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 20 08:47:10 UTC 2010

Modified Files:
src/sbin/gpt: gpt.c

Log Message:
Initialize device_name before opendisk to avoid
unable to open device '(null)' error messages
when the opendisk fails.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sbin/gpt/gpt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.