Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Aug 2017 11:09:18 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r321865 - head/tools/tools/zfsboottest
Message-ID:  <201708011109.v71B9IN1086112@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Tue Aug  1 11:09:18 2017
New Revision: 321865
URL: https://svnweb.freebsd.org/changeset/base/321865

Log:
  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

Modified:
  head/tools/tools/zfsboottest/zfsboottest.c

Modified: head/tools/tools/zfsboottest/zfsboottest.c
==============================================================================
--- head/tools/tools/zfsboottest/zfsboottest.c	Tue Aug  1 11:00:04 2017	(r321864)
+++ head/tools/tools/zfsboottest/zfsboottest.c	Tue Aug  1 11:09:18 2017	(r321865)
@@ -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>
@@ -49,6 +51,20 @@ pager_output(const char *line)
 
 	fprintf(stderr, "%s", 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708011109.v71B9IN1086112>