On 19.11.2014 21:49, Warner Losh wrote: > > On Nov 19, 2014, at 11:00 AM, Andrey V. Elsukov <[email protected]> wrote: > >> On 19.11.2014 19:20, Warner Losh wrote: >>>> Probably you need to use basetable->gpt_entries here instead of >>>> MAXPARTITIONS. >>> >>> I’m having trouble connecting the dots between GPT and BSDlabels. Why >>> would this field be relevant? Is it just poorly named? MAXPARTITIONS >> >> gpt_entries isn't related to GPT, it is `geom partition table's` number >> of partitions entries. Each instance of partition table (i.e. geom) can >> have own number of partitions. MBR always has 4, but GPT or BSD can have >> different numbers. > > Ah, OK. Thanks for the explanation. I understand. I’ll work up a patch.
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? -- WBR, Andrey V. Elsukov
Index: head/sbin/fsck/fsck.c
===================================================================
--- 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>
#include <ctype.h>
@@ -85,6 +84,17 @@ static const char *getfslab(const char *);
static void usage(void) __dead2;
static int isok(struct fstab *);
+static struct {
+ const char *ptype;
+ const char *name;
+} ptype_map[] = {
+ { "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 = maxargc;
}
-
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;
- /* deduce the file system type from the disk label */
if ((fd = open(str, O_RDONLY)) == -1)
err(1, "cannot open `%s'", str);
- if (ioctl(fd, DIOCGDINFO, &dl) == -1) {
+ strncpy(attr.name, "PART::type", sizeof(attr.name));
+ memset(&attr.value, 0, sizeof(attr.value));
+ attr.len = sizeof(attr.value);
+ if (ioctl(fd, DIOCGATTR, &attr) == -1) {
(void) close(fd);
return(NULL);
}
-
(void) close(fd);
-
- p = str[strlen(str) - 1];
-
- if ((p - 'a') >= dl.d_npartitions)
- errx(1, "partition `%s' is not defined on disk", str);
-
- if ((t = dl.d_partitions[p - 'a'].p_fstype) >= FSMAXTYPES)
- errx(1, "partition `%s' is not of a legal vfstype",
- str);
-
- if ((vfstype = fstypenames[t]) == NULL)
- errx(1, "vfstype `%s' on partition `%s' is not supported",
- fstypenames[t], str);
-
- return vfstype;
+ for (i = 0; ptype_map[i].ptype != NULL; i++)
+ if (strstr(attr.value.str, ptype_map[i].ptype) != NULL)
+ return (ptype_map[i].name);
+ return (NULL);
}
signature.asc
Description: OpenPGP digital signature
