From owner-svn-src-head@FreeBSD.ORG Wed May 20 06:01:20 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B311B106566C; Wed, 20 May 2009 06:01:20 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A13618FC15; Wed, 20 May 2009 06:01:20 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4K61Kcj020946; Wed, 20 May 2009 06:01:20 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4K61K6Q020945; Wed, 20 May 2009 06:01:20 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <200905200601.n4K61K6Q020945@svn.freebsd.org> From: Marcel Moolenaar Date: Wed, 20 May 2009 06:01:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192424 - head/lib/libdisk X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2009 06:01:21 -0000 Author: marcel Date: Wed May 20 06:01:20 2009 New Revision: 192424 URL: http://svn.freebsd.org/changeset/base/192424 Log: Simplify now that we have gpart. Modified: head/lib/libdisk/open_ia64_disk.c Modified: head/lib/libdisk/open_ia64_disk.c ============================================================================== --- head/lib/libdisk/open_ia64_disk.c Wed May 20 05:49:06 2009 (r192423) +++ head/lib/libdisk/open_ia64_disk.c Wed May 20 06:01:20 2009 (r192424) @@ -40,16 +40,9 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include "libdisk.h" -static uuid_t _efi = GPT_ENT_TYPE_EFI; -static uuid_t _mbr = GPT_ENT_TYPE_MBR; -static uuid_t _fbsd = GPT_ENT_TYPE_FREEBSD; -static uuid_t _swap = GPT_ENT_TYPE_FREEBSD_SWAP; -static uuid_t _ufs = GPT_ENT_TYPE_FREEBSD_UFS; - static struct disk * parse_disk(char *conftxt, const char *name) { @@ -147,11 +140,9 @@ struct disk * Int_Open_Disk(const char *name, char *conftxt) { struct chunk chunk; - uuid_t uuid; struct disk *disk; - char *p, *q, *r, *s, *sd, *type; + char *p, *q, *r, *s, *sd; u_long i; - uint32_t status; p = conftxt; while (p != NULL && *p != 0) { @@ -186,17 +177,27 @@ Int_Open_Disk(const char *name, char *co if (conftxt != NULL) *conftxt++ = '\0'; + /* + * 1 PART da0p4 34359738368 512 + * i 4 o 52063912960 ty freebsd-ufs + * xs GPT xt 516e7cb6-6ecf-11d6-8ff8-00022d09712b + */ sd = strsep(&p, " "); /* depth */ if (strcmp(sd, "0") == 0) break; - type = strsep(&p, " "); /* type */ + q = strsep(&p, " "); /* type */ + if (strcmp(q, "PART") != 0) + continue; + chunk.name = strsep(&p, " "); /* name */ + q = strsep(&p, " "); /* length */ i = strtoimax(q, &r, 0); if (*r) abort(); chunk.end = i / disk->sector_size; + q = strsep(&p, " "); /* sector size */ for (;;) { @@ -205,82 +206,30 @@ Int_Open_Disk(const char *name, char *co break; r = strsep(&p, " "); i = strtoimax(r, &s, 0); - if (*s) { - status = uuid_s_ok; + if (strcmp(q, "ty") == 0 && *s != '\0') { if (!strcmp(r, "efi")) - uuid = _efi; - else if (!strcmp(r, "mbr")) - uuid = _mbr; - else if (!strcmp(r, "freebsd")) - uuid = _fbsd; - else if (!strcmp(r, "freebsd-swap")) - uuid = _swap; - else if (!strcmp(r, "freebsd-ufs")) - uuid = _ufs; - else { - if (!strcmp(type, "PART")) - uuid_from_string(r + 1, &uuid, - &status); - else - uuid_from_string(r, &uuid, - &status); + chunk.type = efi; + else if (!strcmp(r, "freebsd")) { + chunk.type = freebsd; + chunk.subtype = 0xa5; + } else if (!strcmp(r, "freebsd-swap")) { + chunk.type = part; + chunk.subtype = FS_SWAP; + } else if (!strcmp(r, "freebsd-ufs")) { + chunk.type = part; + chunk.subtype = FS_BSDFFS; + } else { + chunk.type = part; + chunk.subtype = FS_OTHER; } - } else - status = uuid_s_invalid_string_uuid; - if (!strcmp(q, "o")) - chunk.offset = i / disk->sector_size; - else if (!strcmp(q, "i")) - chunk.flags = CHUNK_ITOF(i) | CHUNK_HAS_INDEX; - else if (!strcmp(q, "ty")) - chunk.subtype = i; - } - - if (strncmp(type, "MBR", 3) == 0) { - switch (chunk.subtype) { - case 0xa5: - chunk.type = freebsd; - break; - case 0x01: - case 0x04: - case 0x06: - case 0x0b: - case 0x0c: - case 0x0e: - chunk.type = fat; - break; - case 0xef: /* EFI */ - chunk.type = efi; - break; - default: - chunk.type = mbr; - break; + } else { + if (!strcmp(q, "o")) + chunk.offset = i / disk->sector_size; + else if (!strcmp(q, "i")) + chunk.flags = CHUNK_ITOF(i) | + CHUNK_HAS_INDEX; } - } else if (strcmp(type, "BSD") == 0) { - chunk.type = part; - } else if (strcmp(type, "GPT") == 0 || - strcmp(type, "PART") == 0) { - chunk.subtype = 0; - if (status != uuid_s_ok) - abort(); - if (uuid_is_nil(&uuid, NULL)) - chunk.type = unused; - else if (uuid_equal(&uuid, &_efi, NULL)) - chunk.type = efi; - else if (uuid_equal(&uuid, &_mbr, NULL)) - chunk.type = mbr; - else if (uuid_equal(&uuid, &_fbsd, NULL)) { - chunk.type = freebsd; - chunk.subtype = 0xa5; - } else if (uuid_equal(&uuid, &_swap, NULL)) { - chunk.type = part; - chunk.subtype = FS_SWAP; - } else if (uuid_equal(&uuid, &_ufs, NULL)) { - chunk.type = part; - chunk.subtype = FS_BSDFFS; - } else - chunk.type = part; - } else - abort(); + } Add_Chunk(disk, chunk.offset, chunk.end, chunk.name, chunk.type, chunk.subtype, chunk.flags, 0);