- Fail with an understandable error message if we cannot detect the
sector size, instead of later failing with an error about /boot/mbr not being a multiple of the sector size (since we end up with an assumed sector size of MAX_SEC_SIZE * 2). - We query the sector size via an IOCTL anyway, so if that succeeds use that instead of probing for it via read(2) calls. This fixes the problem with fdisk failing to operate on at least graid3 and md(4) devices on kernels with src/sys/geom/geom_dev.c before rev. 1.90, due to fdisk failing to detect the sector size. - When detecting the root device allow "/" characters in it, which happens with e.g. gmirror devices. Reviewed by: cperciva MFC after: 1 week
This commit is contained in:
parent
274ede62a8
commit
aee85526aa
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=159757
@ -317,7 +317,8 @@ main(int argc, char *argv[])
|
|||||||
/* (abu)use mboot.bootinst to probe for the sector size */
|
/* (abu)use mboot.bootinst to probe for the sector size */
|
||||||
if ((mboot.bootinst = malloc(MAX_SEC_SIZE)) == NULL)
|
if ((mboot.bootinst = malloc(MAX_SEC_SIZE)) == NULL)
|
||||||
err(1, "cannot allocate buffer to determine disk sector size");
|
err(1, "cannot allocate buffer to determine disk sector size");
|
||||||
read_disk(0, mboot.bootinst);
|
if (read_disk(0, mboot.bootinst) == -1)
|
||||||
|
errx(1, "could not detect sector size");
|
||||||
free(mboot.bootinst);
|
free(mboot.bootinst);
|
||||||
mboot.bootinst = NULL;
|
mboot.bootinst = NULL;
|
||||||
|
|
||||||
@ -811,6 +812,8 @@ get_params()
|
|||||||
error = ioctl(fd, DIOCGSECTORSIZE, &u);
|
error = ioctl(fd, DIOCGSECTORSIZE, &u);
|
||||||
if (error != 0 || u == 0)
|
if (error != 0 || u == 0)
|
||||||
u = 512;
|
u = 512;
|
||||||
|
else
|
||||||
|
secsize = u;
|
||||||
|
|
||||||
error = ioctl(fd, DIOCGMEDIASIZE, &o);
|
error = ioctl(fd, DIOCGMEDIASIZE, &o);
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
@ -1395,7 +1398,7 @@ get_rootdisk(void)
|
|||||||
if (statfs("/", &rootfs) == -1)
|
if (statfs("/", &rootfs) == -1)
|
||||||
err(1, "statfs(\"/\")");
|
err(1, "statfs(\"/\")");
|
||||||
|
|
||||||
if ((rv = regcomp(&re, "^(/dev/[a-z]+[0-9]+)([sp][0-9]+)?[a-h]?$",
|
if ((rv = regcomp(&re, "^(/dev/[a-z/]+[0-9]+)([sp][0-9]+)?[a-h]?$",
|
||||||
REG_EXTENDED)) != 0)
|
REG_EXTENDED)) != 0)
|
||||||
errx(1, "regcomp() failed (%d)", rv);
|
errx(1, "regcomp() failed (%d)", rv);
|
||||||
if ((rv = regexec(&re, rootfs.f_mntfromname, NMATCHES, rm, 0)) != 0)
|
if ((rv = regexec(&re, rootfs.f_mntfromname, NMATCHES, rm, 0)) != 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user