[Midnightbsd-cvs] src: sbin/gpt: update gpt(8)
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Jan 17 13:43:39 EST 2009
Log Message:
-----------
update gpt(8)
Modified Files:
--------------
src/sbin/gpt:
Makefile (r1.1.1.1 -> r1.2)
add.c (r1.1.1.1 -> r1.2)
create.c (r1.1.1.1 -> r1.2)
destroy.c (r1.1.1.1 -> r1.2)
gpt.8 (r1.1.1.1 -> r1.2)
gpt.c (r1.1.1.1 -> r1.2)
gpt.h (r1.1.1.1 -> r1.2)
label.c (r1.1.1.1 -> r1.2)
map.c (r1.1.1.1 -> r1.2)
map.h (r1.1.1.1 -> r1.2)
migrate.c (r1.1.1.1 -> r1.2)
recover.c (r1.1.1.1 -> r1.2)
remove.c (r1.1.1.1 -> r1.2)
show.c (r1.1.1.1 -> r1.2)
-------------- next part --------------
Index: show.c
===================================================================
RCS file: /home/cvs/src/sbin/gpt/show.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sbin/gpt/show.c -L sbin/gpt/show.c -u -r1.1.1.1 -r1.2
--- sbin/gpt/show.c
+++ sbin/gpt/show.c
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sbin/gpt/show.c,v 1.11.2.1 2005/09/06 23:59:01 marcel Exp $");
+__FBSDID("$FreeBSD: src/sbin/gpt/show.c,v 1.14 2006/06/22 22:22:32 marcel Exp $");
#include <sys/types.h>
@@ -57,6 +57,7 @@
static uuid_t efi_slice = GPT_ENT_TYPE_EFI;
static uuid_t mslinux = GPT_ENT_TYPE_MS_BASIC_DATA;
static uuid_t freebsd = GPT_ENT_TYPE_FREEBSD;
+ static uuid_t hfs = GPT_ENT_TYPE_APPLE_HFS;
static uuid_t linuxswap = GPT_ENT_TYPE_LINUX_SWAP;
static uuid_t msr = GPT_ENT_TYPE_MS_RESERVED;
static uuid_t swap = GPT_ENT_TYPE_FREEBSD_SWAP;
@@ -85,6 +86,8 @@
return ("Linux swap");
if (uuid_equal(t, &msr, NULL))
return ("Windows reserved");
+ if (uuid_equal(t, &hfs, NULL))
+ return ("Apple HFS");
unfriendly:
uuid_to_string(t, &s, NULL);
Index: create.c
===================================================================
RCS file: /home/cvs/src/sbin/gpt/create.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sbin/gpt/create.c -L sbin/gpt/create.c -u -r1.1.1.1 -r1.2
--- sbin/gpt/create.c
+++ sbin/gpt/create.c
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sbin/gpt/create.c,v 1.10.2.1 2005/09/06 23:59:01 marcel Exp $");
+__FBSDID("$FreeBSD: src/sbin/gpt/create.c,v 1.11 2005/08/31 01:47:19 marcel Exp $");
#include <sys/types.h>
Index: gpt.h
===================================================================
RCS file: /home/cvs/src/sbin/gpt/gpt.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sbin/gpt/gpt.h -L sbin/gpt/gpt.h -u -r1.1.1.1 -r1.2
--- sbin/gpt/gpt.h
+++ sbin/gpt/gpt.h
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/sbin/gpt/gpt.h,v 1.7.2.1 2005/09/06 23:59:01 marcel Exp $
+ * $FreeBSD: src/sbin/gpt/gpt.h,v 1.11 2006/06/22 22:05:28 marcel Exp $
*/
#ifndef _GPT_H_
@@ -36,6 +36,7 @@
void le_uuid_dec(void const *, uuid_t *);
void le_uuid_enc(void *, uuid_t const *);
+int parse_uuid(const char *, uuid_t *);
struct mbr_part {
uint8_t part_flag; /* bootstrap flags */
Index: map.c
===================================================================
RCS file: /home/cvs/src/sbin/gpt/map.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sbin/gpt/map.c -L sbin/gpt/map.c -u -r1.1.1.1 -r1.2
--- sbin/gpt/map.c
+++ sbin/gpt/map.c
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sbin/gpt/map.c,v 1.5.8.1 2005/09/06 23:59:01 marcel Exp $");
+__FBSDID("$FreeBSD: src/sbin/gpt/map.c,v 1.6 2005/08/31 01:47:19 marcel Exp $");
#include <sys/types.h>
#include <err.h>
Index: label.c
===================================================================
RCS file: /home/cvs/src/sbin/gpt/label.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sbin/gpt/label.c -L sbin/gpt/label.c -u -r1.1.1.1 -r1.2
--- sbin/gpt/label.c
+++ sbin/gpt/label.c
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sbin/gpt/label.c,v 1.1.2.1 2005/09/06 23:59:01 marcel Exp $");
+__FBSDID("$FreeBSD: src/sbin/gpt/label.c,v 1.3 2006/10/04 18:20:25 marcel Exp $");
#include <sys/types.h>
@@ -172,7 +172,6 @@
{
char *p;
int ch, fd;
- uint32_t status;
/* Get the label options */
while ((ch = getopt(argc, argv, "ab:f:i:l:s:t:")) != -1) {
@@ -185,7 +184,7 @@
case 'b':
if (block > 0)
usage_label();
- block = strtol(optarg, &p, 10);
+ block = strtoll(optarg, &p, 10);
if (*p != 0 || block < 1)
usage_label();
break;
@@ -209,31 +208,15 @@
case 's':
if (size > 0)
usage_label();
- size = strtol(optarg, &p, 10);
+ size = strtoll(optarg, &p, 10);
if (*p != 0 || size < 1)
usage_label();
break;
case 't':
if (!uuid_is_nil(&type, NULL))
usage_label();
- uuid_from_string(optarg, &type, &status);
- if (status != uuid_s_ok) {
- if (strcmp(optarg, "efi") == 0) {
- uuid_t efi = GPT_ENT_TYPE_EFI;
- type = efi;
- } else if (strcmp(optarg, "swap") == 0) {
- uuid_t sw = GPT_ENT_TYPE_FREEBSD_SWAP;
- type = sw;
- } else if (strcmp(optarg, "ufs") == 0) {
- uuid_t ufs = GPT_ENT_TYPE_FREEBSD_UFS;
- type = ufs;
- } else if (strcmp(optarg, "linux") == 0 ||
- strcmp(optarg, "windows") == 0) {
- uuid_t m = GPT_ENT_TYPE_MS_BASIC_DATA;
- type = m;
- } else
- usage_label();
- }
+ if (parse_uuid(optarg, &type) != 0)
+ usage_label();
break;
default:
usage_label();
Index: remove.c
===================================================================
RCS file: /home/cvs/src/sbin/gpt/remove.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sbin/gpt/remove.c -L sbin/gpt/remove.c -u -r1.1.1.1 -r1.2
--- sbin/gpt/remove.c
+++ sbin/gpt/remove.c
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sbin/gpt/remove.c,v 1.4.2.1 2005/09/06 23:59:01 marcel Exp $");
+__FBSDID("$FreeBSD: src/sbin/gpt/remove.c,v 1.10 2006/10/04 18:20:25 marcel Exp $");
#include <sys/types.h>
@@ -143,7 +143,6 @@
{
char *p;
int ch, fd;
- uint32_t status;
/* Get the remove options */
while ((ch = getopt(argc, argv, "ab:i:s:t:")) != -1) {
@@ -156,7 +155,7 @@
case 'b':
if (block > 0)
usage_remove();
- block = strtol(optarg, &p, 10);
+ block = strtoll(optarg, &p, 10);
if (*p != 0 || block < 1)
usage_remove();
break;
@@ -170,31 +169,15 @@
case 's':
if (size > 0)
usage_remove();
- size = strtol(optarg, &p, 10);
+ size = strtoll(optarg, &p, 10);
if (*p != 0 || size < 1)
usage_remove();
break;
case 't':
if (!uuid_is_nil(&type, NULL))
usage_remove();
- uuid_from_string(optarg, &type, &status);
- if (status != uuid_s_ok) {
- if (strcmp(optarg, "efi") == 0) {
- uuid_t efi = GPT_ENT_TYPE_EFI;
- type = efi;
- } else if (strcmp(optarg, "swap") == 0) {
- uuid_t sw = GPT_ENT_TYPE_FREEBSD_SWAP;
- type = sw;
- } else if (strcmp(optarg, "ufs") == 0) {
- uuid_t ufs = GPT_ENT_TYPE_FREEBSD_UFS;
- type = ufs;
- } else if (strcmp(optarg, "linux") == 0 ||
- strcmp(optarg, "windows") == 0) {
- uuid_t m = GPT_ENT_TYPE_MS_BASIC_DATA;
- type = m;
- } else
- usage_remove();
- }
+ if (parse_uuid(optarg, &type) != 0)
+ usage_remove();
break;
default:
usage_remove();
Index: gpt.8
===================================================================
RCS file: /home/cvs/src/sbin/gpt/gpt.8,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sbin/gpt/gpt.8 -L sbin/gpt/gpt.8 -u -r1.1.1.1 -r1.2
--- sbin/gpt/gpt.8
+++ sbin/gpt/gpt.8
@@ -22,9 +22,9 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/sbin/gpt/gpt.8,v 1.13.2.1 2005/09/06 23:59:01 marcel Exp $
+.\" $FreeBSD: src/sbin/gpt/gpt.8,v 1.17 2006/06/22 22:22:32 marcel Exp $
.\"
-.Dd August 31, 2005
+.Dd June 22, 2006
.Os
.Dt GPT 8
.Sh NAME
@@ -130,7 +130,7 @@
The type is given as an UUID, but
.Nm
accepts
-.Cm efi , swap , ufs , linux
+.Cm efi , swap , ufs , hfs , linux
and
.Cm windows
as aliases for the most commonly used partition types.
@@ -224,7 +224,9 @@
option is used to read the label from the specified file.
Only the first line is read from the file and the trailing newline
character is stripped.
-If the file name is the dash or minus sign (-), the label is read from
+If the file name is the dash or minus sign
+.Pq Fl ,
+the label is read from
the standard input.
The
.Fl l Ar label
@@ -286,7 +288,7 @@
The option has no effect on non-GPT partitions.
With the
.Fl u
-option the GPT partition type is displayed as an UUID instead of in an
+option the GPT partition type is displayed as an UUID instead of in a
user friendly form.
The
.Fl l
Index: gpt.c
===================================================================
RCS file: /home/cvs/src/sbin/gpt/gpt.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sbin/gpt/gpt.c -L sbin/gpt/gpt.c -u -r1.1.1.1 -r1.2
--- sbin/gpt/gpt.c
+++ sbin/gpt/gpt.c
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sbin/gpt/gpt.c,v 1.10.2.1 2005/09/06 23:59:01 marcel Exp $");
+__FBSDID("$FreeBSD: src/sbin/gpt/gpt.c,v 1.16.2.1 2007/11/09 02:29:43 jhb Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -258,6 +258,62 @@
p[10 + i] = uuid->node[i];
}
+int
+parse_uuid(const char *s, uuid_t *uuid)
+{
+ uint32_t status;
+
+ uuid_from_string(s, uuid, &status);
+ if (status == uuid_s_ok)
+ return (0);
+
+ switch (*s) {
+ case 'e':
+ if (strcmp(s, "efi") == 0) {
+ uuid_t efi = GPT_ENT_TYPE_EFI;
+ *uuid = efi;
+ return (0);
+ }
+ break;
+ case 'h':
+ if (strcmp(s, "hfs") == 0) {
+ uuid_t hfs = GPT_ENT_TYPE_APPLE_HFS;
+ *uuid = hfs;
+ return (0);
+ }
+ break;
+ case 'l':
+ if (strcmp(s, "linux") == 0) {
+ uuid_t lnx = GPT_ENT_TYPE_MS_BASIC_DATA;
+ *uuid = lnx;
+ return (0);
+ }
+ break;
+ case 's':
+ if (strcmp(s, "swap") == 0) {
+ uuid_t sw = GPT_ENT_TYPE_FREEBSD_SWAP;
+ *uuid = sw;
+ return (0);
+ }
+ break;
+ case 'u':
+ if (strcmp(s, "ufs") == 0) {
+ uuid_t ufs = GPT_ENT_TYPE_FREEBSD_UFS;
+ *uuid = ufs;
+ return (0);
+ }
+ break;
+ case 'w':
+ if (strcmp(s, "windows") == 0) {
+ uuid_t win = GPT_ENT_TYPE_MS_BASIC_DATA;
+ *uuid = win;
+ return (0);
+ }
+ break;
+ }
+ return (EINVAL);
+}
+
void*
gpt_read(int fd, off_t lba, size_t count)
{
@@ -529,10 +585,16 @@
if (gpt_mbr(fd, 0LL) == -1)
goto close;
- if (gpt_gpt(fd, 1LL) == -1)
- goto close;
- if (gpt_gpt(fd, mediasz / secsz - 1LL) == -1)
- goto close;
+
+ /*
+ * Don't look for a GPT unless we have a valid PMBR.
+ */
+ if (map_find(MAP_TYPE_PMBR) != NULL) {
+ if (gpt_gpt(fd, 1LL) == -1)
+ goto close;
+ if (gpt_gpt(fd, mediasz / secsz - 1LL) == -1)
+ goto close;
+ }
return (fd);
Index: recover.c
===================================================================
RCS file: /home/cvs/src/sbin/gpt/recover.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sbin/gpt/recover.c -L sbin/gpt/recover.c -u -r1.1.1.1 -r1.2
--- sbin/gpt/recover.c
+++ sbin/gpt/recover.c
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sbin/gpt/recover.c,v 1.7.2.1 2005/09/06 23:59:01 marcel Exp $");
+__FBSDID("$FreeBSD: src/sbin/gpt/recover.c,v 1.8 2005/08/31 01:47:19 marcel Exp $");
#include <sys/types.h>
Index: map.h
===================================================================
RCS file: /home/cvs/src/sbin/gpt/map.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sbin/gpt/map.h -L sbin/gpt/map.h -u -r1.1.1.1 -r1.2
--- sbin/gpt/map.h
+++ sbin/gpt/map.h
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/sbin/gpt/map.h,v 1.5.8.1 2005/09/06 23:59:01 marcel Exp $
+ * $FreeBSD: src/sbin/gpt/map.h,v 1.6 2005/08/31 01:47:19 marcel Exp $
*/
#ifndef _MAP_H_
Index: migrate.c
===================================================================
RCS file: /home/cvs/src/sbin/gpt/migrate.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sbin/gpt/migrate.c -L sbin/gpt/migrate.c -u -r1.1.1.1 -r1.2
--- sbin/gpt/migrate.c
+++ sbin/gpt/migrate.c
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sbin/gpt/migrate.c,v 1.13.2.1 2005/09/06 23:59:01 marcel Exp $");
+__FBSDID("$FreeBSD: src/sbin/gpt/migrate.c,v 1.16 2005/09/01 02:42:52 marcel Exp $");
#include <sys/types.h>
#include <sys/disklabel.h>
Index: Makefile
===================================================================
RCS file: /home/cvs/src/sbin/gpt/Makefile,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sbin/gpt/Makefile -L sbin/gpt/Makefile -u -r1.1.1.1 -r1.2
--- sbin/gpt/Makefile
+++ sbin/gpt/Makefile
@@ -1,4 +1,4 @@
-# $FreeBSD: src/sbin/gpt/Makefile,v 1.6.8.1 2005/09/06 23:59:01 marcel Exp $
+# $FreeBSD: src/sbin/gpt/Makefile,v 1.7 2005/09/01 02:49:20 marcel Exp $
PROG= gpt
SRCS= add.c create.c destroy.c gpt.c label.c map.c migrate.c recover.c \
Index: add.c
===================================================================
RCS file: /home/cvs/src/sbin/gpt/add.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sbin/gpt/add.c -L sbin/gpt/add.c -u -r1.1.1.1 -r1.2
--- sbin/gpt/add.c
+++ sbin/gpt/add.c
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.11.2.1 2005/09/06 23:59:01 marcel Exp $");
+__FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.15 2006/10/04 18:20:25 marcel Exp $");
#include <sys/types.h>
@@ -156,7 +156,6 @@
{
char *p;
int ch, fd;
- uint32_t status;
/* Get the migrate options */
while ((ch = getopt(argc, argv, "b:i:s:t:")) != -1) {
@@ -164,7 +163,7 @@
case 'b':
if (block > 0)
usage_add();
- block = strtol(optarg, &p, 10);
+ block = strtoll(optarg, &p, 10);
if (*p != 0 || block < 1)
usage_add();
break;
@@ -178,31 +177,15 @@
case 's':
if (size > 0)
usage_add();
- size = strtol(optarg, &p, 10);
+ size = strtoll(optarg, &p, 10);
if (*p != 0 || size < 1)
usage_add();
break;
case 't':
if (!uuid_is_nil(&type, NULL))
usage_add();
- uuid_from_string(optarg, &type, &status);
- if (status != uuid_s_ok) {
- if (strcmp(optarg, "efi") == 0) {
- uuid_t efi = GPT_ENT_TYPE_EFI;
- type = efi;
- } else if (strcmp(optarg, "swap") == 0) {
- uuid_t sw = GPT_ENT_TYPE_FREEBSD_SWAP;
- type = sw;
- } else if (strcmp(optarg, "ufs") == 0) {
- uuid_t ufs = GPT_ENT_TYPE_FREEBSD_UFS;
- type = ufs;
- } else if (strcmp(optarg, "linux") == 0 ||
- strcmp(optarg, "windows") == 0) {
- uuid_t m = GPT_ENT_TYPE_MS_BASIC_DATA;
- type = m;
- } else
- usage_add();
- }
+ if (parse_uuid(optarg, &type) != 0)
+ usage_add();
break;
default:
usage_add();
Index: destroy.c
===================================================================
RCS file: /home/cvs/src/sbin/gpt/destroy.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sbin/gpt/destroy.c -L sbin/gpt/destroy.c -u -r1.1.1.1 -r1.2
--- sbin/gpt/destroy.c
+++ sbin/gpt/destroy.c
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sbin/gpt/destroy.c,v 1.5.2.1 2005/09/06 23:59:01 marcel Exp $");
+__FBSDID("$FreeBSD: src/sbin/gpt/destroy.c,v 1.6 2005/08/31 01:47:19 marcel Exp $");
#include <sys/types.h>
More information about the Midnightbsd-cvs
mailing list