zfsboottest: catch up with r316585 and provide ldi_get_size method
This method is required for querying file / disk sizes which is needed at least for finding all copies of ZFS VDEV labels. Reported by: ngie MFC after: 1 week
This commit is contained in:
parent
4a43503667
commit
856340754c
@ -28,7 +28,9 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/disk.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/stat.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
@ -51,6 +53,20 @@ pager_output(const char *line)
|
||||
return (0);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
ldi_get_size(void *priv)
|
||||
{
|
||||
struct stat sb;
|
||||
int fd;
|
||||
|
||||
fd = *(int *)priv;
|
||||
if (fstat(fd, &sb) != 0)
|
||||
return (0);
|
||||
if (S_ISCHR(sb.st_mode) && ioctl(fd, DIOCGMEDIASIZE, &sb.st_size) != 0)
|
||||
return (0);
|
||||
return (sb.st_size);
|
||||
}
|
||||
|
||||
#define ZFS_TEST
|
||||
#define printf(...) fprintf(stderr, __VA_ARGS__)
|
||||
#include "libzfs.h"
|
||||
|
Loading…
Reference in New Issue
Block a user