Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Apr 2017 11:16:16 +0000 (UTC)
From:      Toomas Soome <tsoome@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r316654 - head/sys/boot/userboot/userboot
Message-ID:  <201704091116.v39BGGJu001023@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tsoome
Date: Sun Apr  9 11:16:16 2017
New Revision: 316654
URL: https://svnweb.freebsd.org/changeset/base/316654

Log:
  loader: r316585 did miss userboot update
  
  The work to implement zfs reader to inspect all pool label copies did
  miss the userboot, this update does correct this issue.
  
  Since userboot is already using common/disk.c API (disk_open() etc),
  the fix is quite simple - we only need to make sure the userdisk_iocl()
  will call disk_ioctl(). In addition, the diskioctl callback does return
  int, not pointer.
  
  Note, the review request is actually addressing the sparc and userboot,
  but as testing the fix for sparc will take some more time, I am posting the
  userboot fix now.
  
  This patch is part of the implementation presented in review:
  https://reviews.freebsd.org/D10302
  
  Once we have the sparc part tested, we will have the complete fix
  for the issue.
  
  Reviewed by:	imp

Modified:
  head/sys/boot/userboot/userboot/main.c
  head/sys/boot/userboot/userboot/userboot_disk.c

Modified: head/sys/boot/userboot/userboot/main.c
==============================================================================
--- head/sys/boot/userboot/userboot/main.c	Sun Apr  9 07:54:39 2017	(r316653)
+++ head/sys/boot/userboot/userboot/main.c	Sun Apr  9 11:16:16 2017	(r316654)
@@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
 #include <stand.h>
 #include <string.h>
 #include <setjmp.h>
+#include <sys/disk.h>
 
 #include "bootstrap.h"
 #include "disk.h"
@@ -270,6 +271,16 @@ command_reloadbe(int argc, char *argv[])
 
 	return (CMD_OK);
 }
+
+uint64_t
+ldi_get_size(void *priv)
+{
+	int fd = (uintptr_t) priv;
+	uint64_t size;
+
+	ioctl(fd, DIOCGMEDIASIZE, &size);
+	return (size);
+}
 #endif /* USERBOOT_ZFS_SUPPORT */
 
 COMMAND_SET(quit, "quit", "exit the loader", command_quit);

Modified: head/sys/boot/userboot/userboot/userboot_disk.c
==============================================================================
--- head/sys/boot/userboot/userboot/userboot_disk.c	Sun Apr  9 07:54:39 2017	(r316653)
+++ head/sys/boot/userboot/userboot/userboot_disk.c	Sun Apr  9 11:16:16 2017	(r316654)
@@ -91,8 +91,8 @@ userdisk_init(void)
 			return (ENOMEM);
 		for (i = 0; i < userdisk_maxunit; i++) {
 			if (CALLBACK(diskioctl, i, DIOCGSECTORSIZE,
-			    &sectorsize) != NULL || CALLBACK(diskioctl, i,
-			    DIOCGMEDIASIZE, &mediasize) != NULL)
+			    &sectorsize) != 0 || CALLBACK(diskioctl, i,
+			    DIOCGMEDIASIZE, &mediasize) != 0)
 				return (ENXIO);
 			ud_info[i].mediasize = mediasize;
 			ud_info[i].sectorsize = sectorsize;
@@ -230,7 +230,12 @@ static int
 userdisk_ioctl(struct open_file *f, u_long cmd, void *data)
 {
 	struct disk_devdesc *dev;
+	int rc;
 
 	dev = (struct disk_devdesc *)f->f_devdata;
+	rc = disk_ioctl(dev, cmd, data);
+	if (rc != ENOTTY)
+		return (rc);
+
 	return (CALLBACK(diskioctl, dev->d_unit, cmd, data));
 }



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