svn commit: r323739 - stable/10/usr.sbin/bhyveload
Andriy Gapon
avg at FreeBSD.org
Tue Sep 19 08:19:21 UTC 2017
Author: avg
Date: Tue Sep 19 08:19:20 2017
New Revision: 323739
URL: https://svnweb.freebsd.org/changeset/base/323739
Log:
MFV r320195: bhyveload: correctly query size of disks
On FreeBSD fstat(2) works fine for querying sizes of plain files,
but not so much for character devices.
So, use DIOCGMEDIASIZE to try to get the correct size for disks
and disk-like devices (e.g. zvols).
PR: 220186
Modified:
stable/10/usr.sbin/bhyveload/bhyveload.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/usr.sbin/bhyveload/bhyveload.c
==============================================================================
--- stable/10/usr.sbin/bhyveload/bhyveload.c Tue Sep 19 07:56:24 2017 (r323738)
+++ stable/10/usr.sbin/bhyveload/bhyveload.c Tue Sep 19 08:19:20 2017 (r323739)
@@ -312,10 +312,12 @@ cb_diskioctl(void *arg, int unit, u_long cmd, void *da
*(u_int *)data = 512;
break;
case DIOCGMEDIASIZE:
- if (fstat(disk_fd[unit], &sb) == 0)
- *(off_t *)data = sb.st_size;
- else
+ if (fstat(disk_fd[unit], &sb) != 0)
return (ENOTTY);
+ if (S_ISCHR(sb.st_mode) &&
+ ioctl(disk_fd[unit], DIOCGMEDIASIZE, &sb.st_size) != 0)
+ return (ENOTTY);
+ *(off_t *)data = sb.st_size;
break;
default:
return (ENOTTY);
More information about the svn-src-stable
mailing list