From owner-svn-src-head@FreeBSD.ORG Thu Nov 20 15:29:48 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:1900:2254:206a::19:2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 19122B4C; Thu, 20 Nov 2014 15:29:48 +0000 (UTC) Received: from butcher-nb.yandex.net (hub.freebsd.org [IPv6:2001:1900:2254:206c::16:88]) by mx2.freebsd.org (Postfix) with ESMTP id 677CF2556; Thu, 20 Nov 2014 15:29:46 +0000 (UTC) Message-ID: <546E08BA.1020707@FreeBSD.org> Date: Thu, 20 Nov 2014 18:28:58 +0300 From: "Andrey V. Elsukov" User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Warner Losh Subject: Re: svn commit: r274661 - in head/sys: conf geom/part modules/geom/geom_part/geom_part_bsd References: <201411181706.sAIH6eS9051888@svn.freebsd.org> <546CC245.3070700@FreeBSD.org> <546CDABC.9020103@FreeBSD.org> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="H8gBs3C9UWoR1IVOFkPWK6UlvE9a0tTbU" Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers , Warner Losh X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 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: Thu, 20 Nov 2014 15:29:48 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --H8gBs3C9UWoR1IVOFkPWK6UlvE9a0tTbU Content-Type: multipart/mixed; boundary="------------090804010600000704080804" This is a multi-part message in MIME format. --------------090804010600000704080804 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 19.11.2014 21:49, Warner Losh wrote: >=20 > On Nov 19, 2014, at 11:00 AM, Andrey V. Elsukov wrote:= >=20 >> On 19.11.2014 19:20, Warner Losh wrote: >>>> Probably you need to use basetable->gpt_entries here instead of=20 >>>> MAXPARTITIONS. >>> >>> I=92m having trouble connecting the dots between GPT and BSDlabels. W= hy >>> would this field be relevant? Is it just poorly named? MAXPARTITIONS >> >> gpt_entries isn't related to GPT, it is `geom partition table's` numbe= r >> of partitions entries. Each instance of partition table (i.e. geom) ca= n >> have own number of partitions. MBR always has 4, but GPT or BSD can ha= ve >> different numbers. >=20 > Ah, OK. Thanks for the explanation. I understand. I=92ll work up a patc= h. Hi, Warner since there are some reports about strange behavior of old utilities after this commit, maybe we won't repair them by this way? What you think about this path? --=20 WBR, Andrey V. Elsukov --------------090804010600000704080804 Content-Type: text/x-patch; name="fsck.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="fsck.diff" Index: head/sbin/fsck/fsck.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- head/sbin/fsck/fsck.c (revision 274736) +++ head/sbin/fsck/fsck.c (working copy) @@ -41,8 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#define FSTYPENAMES -#include +#include #include =20 #include @@ -85,6 +84,17 @@ static const char *getfslab(const char *); static void usage(void) __dead2; static int isok(struct fstab *); =20 +static struct { + const char *ptype; + const char *name; +} ptype_map[] =3D { + { "ufs", "ffs" }, + { "ffs", "ffs" }, + { "fat", "msdosfs" }, + { "efi", "msdosfs" }, + { NULL, NULL }, +}; + int main(int argc, char *argv[]) { @@ -535,41 +545,27 @@ mangle(char *opts, int *argcp, const char ** volat *maxargcp =3D maxargc; } =20 - static const char * getfslab(const char *str) { - struct disklabel dl; - int fd; - char p; - const char *vfstype; - u_char t; + struct diocgattr_arg attr; + int fd, i; =20 - /* deduce the file system type from the disk label */ if ((fd =3D open(str, O_RDONLY)) =3D=3D -1) err(1, "cannot open `%s'", str); =20 - if (ioctl(fd, DIOCGDINFO, &dl) =3D=3D -1) { + strncpy(attr.name, "PART::type", sizeof(attr.name)); + memset(&attr.value, 0, sizeof(attr.value)); + attr.len =3D sizeof(attr.value); + if (ioctl(fd, DIOCGATTR, &attr) =3D=3D -1) { (void) close(fd); return(NULL); } - (void) close(fd); - - p =3D str[strlen(str) - 1]; - - if ((p - 'a') >=3D dl.d_npartitions) - errx(1, "partition `%s' is not defined on disk", str); - - if ((t =3D dl.d_partitions[p - 'a'].p_fstype) >=3D FSMAXTYPES)=20 - errx(1, "partition `%s' is not of a legal vfstype", - str); - - if ((vfstype =3D fstypenames[t]) =3D=3D NULL) - errx(1, "vfstype `%s' on partition `%s' is not supported", - fstypenames[t], str); - - return vfstype; + for (i =3D 0; ptype_map[i].ptype !=3D NULL; i++) + if (strstr(attr.value.str, ptype_map[i].ptype) !=3D NULL) + return (ptype_map[i].name); + return (NULL); } =20 =20 --------------090804010600000704080804-- --H8gBs3C9UWoR1IVOFkPWK6UlvE9a0tTbU Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJUbgjHAAoJEAHF6gQQyKF6QYAIAISA/Oj5atqC6MS/2N7+SceK 4QpQB78Pd638a04T3F+3enAm1tB5DYEPwqaa0Lfj5wN7Fwl38+M70VvPvkZBtcpt krgTIysyJLB3y6iNRJ80Hfo/Dp+RCyTlYA6MND7ih5IcxTTOEMfsXZjOoCj7rCQJ 5gF/BkVxxvVH56bew78nzJ/zYKigKyPtUN7LIM/cBKlVtK9fbaSLeZLYYpdBZ4au nUHA8L9hImvl6UDUAS5p7cbyhts1HYyGhO7APe9FiZIxCHPTmwR1g7g5XxeaF2td iyEoMVJHrdcdbDUV410KzebQy71QVH9T4XlH1GALY5mX3gqiTpJQDUioi0UQ8Sg= =ecw7 -----END PGP SIGNATURE----- --H8gBs3C9UWoR1IVOFkPWK6UlvE9a0tTbU--