From 72be6dafa18d318e1db6f824da30f8705fe37ae9 Mon Sep 17 00:00:00 2001 From: martin Date: Tue, 1 May 2018 08:17:13 +0000 Subject: [PATCH] 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. --- sbin/gpt/gpt.8 | 8 +++++++- sbin/gpt/header.c | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sbin/gpt/gpt.8 b/sbin/gpt/gpt.8 index 2f8bff9c090d..03a322e0da98 100644 --- a/sbin/gpt/gpt.8 +++ b/sbin/gpt/gpt.8 @@ -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 , diff --git a/sbin/gpt/header.c b/sbin/gpt/header.c index c4973d5d57bd..6e61465cb900 100644 --- a/sbin/gpt/header.c +++ b/sbin/gpt/header.c @@ -33,7 +33,7 @@ #include #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 @@ -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;