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.
This commit is contained in:
martin 2018-05-01 08:17:13 +00:00
parent 84a7697bfe
commit 72be6dafa1
2 changed files with 9 additions and 3 deletions

View File

@ -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/bootxx_ffsv1
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 ,

View File

@ -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;