Date: Thu, 20 Nov 2014 18:28:58 +0300 From: "Andrey V. Elsukov" <ae@FreeBSD.org> To: Warner Losh <imp@bsdimp.com> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers <src-committers@freebsd.org>, Warner Losh <imp@FreeBSD.org> Subject: Re: svn commit: r274661 - in head/sys: conf geom/part modules/geom/geom_part/geom_part_bsd Message-ID: <546E08BA.1020707@FreeBSD.org> In-Reply-To: <AC547D14-AE9E-4E26-9844-B8B6E7C0050D@bsdimp.com> References: <201411181706.sAIH6eS9051888@svn.freebsd.org> <546CC245.3070700@FreeBSD.org> <B523D699-9766-4806-9499-68FD9FF84437@bsdimp.com> <546CDABC.9020103@FreeBSD.org> <AC547D14-AE9E-4E26-9844-B8B6E7C0050D@bsdimp.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <ae@FreeBSD.org> 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 <sys/mount.h>
#include <sys/queue.h>
#include <sys/wait.h>
-#define FSTYPENAMES
-#include <sys/disklabel.h>
+#include <sys/disk.h>
#include <sys/ioctl.h>
=20
#include <ctype.h>
@@ -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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?546E08BA.1020707>
