NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kern/57134: st_size of stat on vnd raw partition sometimes is 0, causing newfs to fail
The following reply was made to PR kern/57134; it has been noted by GNATS.
From: "J. Hannken-Illjes" <hannken%mailbox.org@localhost>
To: NetBSD GNATS <gnats-bugs%netbsd.org@localhost>
Cc:
Subject: Re: kern/57134: st_size of stat on vnd raw partition sometimes is 0,
causing newfs to fail
Date: Sun, 1 Jan 2023 11:45:26 +0100
--Apple-Mail=_BE0039CA-ECD5-4A4A-8415-1CC7D566CCF4
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=us-ascii
This has nothing to do with "st_size", I hope it is
undefined for devices but I'm not a POSIX expert.
The problem is sbin/fsck/partutil.c::getdiskinfo()
returning zero size as it assumes "vnd0" (without
partition character at end) is illegal for a
partitioned disk.
Please try the attached diff.
--
J. Hannken-Illjes - hannken%mailbox.org@localhost
--Apple-Mail=_BE0039CA-ECD5-4A4A-8415-1CC7D566CCF4
Content-Disposition: attachment;
filename=001_getdiskinfo.diff
Content-Type: application/octet-stream;
x-unix-mode=0644;
name="001_getdiskinfo.diff"
Content-Transfer-Encoding: 7bit
getdiskinfo
Change getdiskinfo() to no longer infer the partition from the device name.
Since 2016-06-16 we create disk devices "<type><<unit>" as an alias
for "<type><<unit><part>" where "<part>" is the raw partition.
These devices are treated as invalid partitions and a zero geometry
is returned.
Take the partition from "st_rdev" instead.
Should fix PR kern/57134: st_size of stat on vnd raw partition sometimes
is 0, causing newfs to fail
diff -r 70eda1015a53 -r 7705ad77c23e sbin/fsck/partutil.c
--- sbin/fsck/partutil.c
+++ sbin/fsck/partutil.c
@@ -155,9 +155,8 @@ getdiskinfo(const char *s, int fd, const
if (stat(s, &sb) == -1)
return 0;
- ptn = strchr(s, '\0')[-1] - 'a';
- if ((unsigned)ptn >= lp->d_npartitions ||
- (devminor_t)ptn != DISKPART(sb.st_rdev))
+ ptn = DISKPART(sb.st_rdev);
+ if (ptn < 0 || ptn >= lp->d_npartitions)
return 0;
pp = &lp->d_partitions[ptn];
--Apple-Mail=_BE0039CA-ECD5-4A4A-8415-1CC7D566CCF4--
Home |
Main Index |
Thread Index |
Old Index