Module Name:    src
Committed By:   martin
Date:           Tue May  1 08:17:13 UTC 2018

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

Log Message:
Make the "gpt header" command return EXIT_FAILURE when no GPT is present.
This helps sysinst to tell a GPT labeled disk from others.
Very lazy version of a change proposed by kre.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sbin/gpt/gpt.8
cvs rdiff -u -r1.8 -r1.9 src/sbin/gpt/header.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.8
diff -u src/sbin/gpt/gpt.8:1.59 src/sbin/gpt/gpt.8:1.60
--- src/sbin/gpt/gpt.8:1.59	Wed Apr 11 07:13:18 2018
+++ src/sbin/gpt/gpt.8	Tue May  1 08:17:13 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.59 2018/04/11 07:13:18 mrg Exp $
+.\" $NetBSD: gpt.8,v 1.60 2018/05/01 08:17:13 martin Exp $
 .\"
 .\" Copyright (c) 2002 Marcel Moolenaar
 .\" All rights reserved.
@@ -735,6 +735,12 @@ xotica# installboot /dev/rdk0 /usr/mdec/
 xotica# mount /dev/dk0 /mnt
 xotica# cp /usr/mdec/boot /mnt
 .Ed
+.Sh EXIT STATUS
+The
+.Nm
+command exits with a failure status (1) when the header command
+is used and no GPT header is found.
+This can be used to check for the existance of a GPT in shell scripts.
 .Sh SEE ALSO
 .Xr boot 8 ,
 .Xr dkctl 8 ,

Index: src/sbin/gpt/header.c
diff -u src/sbin/gpt/header.c:1.8 src/sbin/gpt/header.c:1.9
--- src/sbin/gpt/header.c:1.8	Thu Dec 24 17:35:57 2015
+++ src/sbin/gpt/header.c	Tue May  1 08:17:13 2018
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __RCSID
-__RCSID("$NetBSD: header.c,v 1.8 2015/12/24 17:35:57 martin Exp $");
+__RCSID("$NetBSD: header.c,v 1.9 2018/05/01 08:17:13 martin Exp $");
 #endif
 
 #include <sys/types.h>
@@ -83,7 +83,7 @@ header(gpt_t gpt)
 	map = map_find(gpt, MAP_TYPE_PRI_GPT_HDR);
 	if (map == NULL) {
 		printf("- GPT Header not found\n");
-		return 0;
+		return -1;
 	}
 
 	hdr = map->map_data;

Reply via email to