fix for post-GEOM system.

PR:		45911
Submitted by:	Valentin Nechayev <netch@netch.kiev.ua>
This commit is contained in:
FUJISHIMA Satsuki 2004-10-28 05:18:33 +00:00
parent 6fa57456f7
commit 285c532311
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=120372
2 changed files with 20 additions and 4 deletions

View File

@ -8,7 +8,7 @@
PORTNAME= diskcheckd
PORTVERSION= 20010823
PORTREVISION= 3
PORTREVISION= 4
CATEGORIES= sysutils
MASTER_SITES= # part of port
DISTFILES= # part of port
@ -30,8 +30,6 @@ CFLAGS+= -D_PATH_CONF='\"${PREFIX}/etc/diskcheckd.conf\"'
.if ${OSVERSION} < 500000
IGNORE= "Not tested on anything less than 5.0, use at discretion"
.else
IGNORE= "Does not work on 5.x, see PR ports/45911"
.endif
do-extract:

View File

@ -27,7 +27,7 @@
static const char rcsid[] =
"$FreeBSD$";
#include <sys/types.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <ctype.h>
@ -46,6 +46,7 @@ static const char rcsid[] =
#define DKTYPENAMES
#define FSTYPENAMES
#include <sys/disk.h>
#include <sys/disklabel.h>
#include <sys/diskmbr.h>
@ -757,7 +758,23 @@ readconf(const char *conf_file) {
void
getdisksize(struct disk *dp) {
struct disklabel label;
#if __FreeBSD_version >= 500040
off_t mediasize;
unsigned sectorsize;
if (ioctl(dp->fd, DIOCGSECTORSIZE, &sectorsize) < 0) {
syslog(LOG_NOTICE, "DIOCGSECTORSIZE on %s failed: %m",
dp->device);
exit(EXIT_FAILURE);
}
if (ioctl(dp->fd, DIOCGMEDIASIZE, &mediasize) < 0) {
syslog(LOG_NOTICE, "DIOCGMEDIASIZE on %s failed: %m",
dp->device);
exit(EXIT_FAILURE);
}
dp->secsize = label.d_secsize = sectorsize;
dp->size = mediasize;
#else
if (ioctl(dp->fd, DIOCGDINFO, &label) < 0) {
syslog(LOG_NOTICE, "DIOCGDINFO on %s failed: %m",
dp->device);
@ -766,6 +783,7 @@ getdisksize(struct disk *dp) {
dp->secsize = label.d_secsize;
dp->size = (off_t)label.d_secperunit * label.d_secsize;
#endif
if (label.d_secsize != 512)
syslog(LOG_NOTICE,