From owner-svn-src-head@freebsd.org Sun Nov 3 09:14:30 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7AABB1AD696; Sun, 3 Nov 2019 09:14:30 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 475VcQ2b5yz3N77; Sun, 3 Nov 2019 09:14:30 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3BBE198FC; Sun, 3 Nov 2019 09:14:30 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA39EU7o030084; Sun, 3 Nov 2019 09:14:30 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA39EUxj030083; Sun, 3 Nov 2019 09:14:30 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201911030914.xA39EUxj030083@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Sun, 3 Nov 2019 09:14:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r354278 - head/stand/userboot/test X-SVN-Group: head X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: head/stand/userboot/test X-SVN-Commit-Revision: 354278 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Nov 2019 09:14:30 -0000 Author: tsoome Date: Sun Nov 3 09:14:29 2019 New Revision: 354278 URL: https://svnweb.freebsd.org/changeset/base/354278 Log: loader: userboot/test should accept more than one disk allow to specify multiple -d options, test -d disk1 -d disk2 .. Modified: head/stand/userboot/test/test.c Modified: head/stand/userboot/test/test.c ============================================================================== --- head/stand/userboot/test/test.c Sun Nov 3 07:11:09 2019 (r354277) +++ head/stand/userboot/test/test.c Sun Nov 3 09:14:29 2019 (r354278) @@ -50,10 +50,11 @@ char *host_base = NULL; struct termios term, oldterm; char *image; size_t image_size; -int disk_fd = -1; uint64_t regs[16]; uint64_t pc; +int *disk_fd; +int disk_index = -1; void test_exit(void *arg, int v); @@ -245,9 +246,9 @@ test_diskread(void *arg, int unit, uint64_t offset, vo { ssize_t n; - if (unit != 0 || disk_fd == -1) + if (unit > disk_index || disk_fd[unit] == -1) return (EIO); - n = pread(disk_fd, dst, size, offset); + n = pread(disk_fd[unit], dst, size, offset); if (n < 0) return (errno); *resid_return = size - n; @@ -259,14 +260,14 @@ test_diskioctl(void *arg, int unit, u_long cmd, void * { struct stat sb; - if (unit != 0 || disk_fd == -1) + if (unit > disk_index || disk_fd[unit] == -1) return (EBADF); switch (cmd) { case DIOCGSECTORSIZE: *(u_int *)data = 512; break; case DIOCGMEDIASIZE: - if (fstat(disk_fd, &sb) == 0) + if (fstat(disk_fd[unit], &sb) == 0) *(off_t *)data = sb.st_size; else return (ENOTTY); @@ -424,7 +425,6 @@ main(int argc, char** argv) void *h; void (*func)(struct loader_callbacks *, void *, int, int) __dead2; int opt; - char *disk_image = NULL; const char *userboot_obj = "/boot/userboot.so"; while ((opt = getopt(argc, argv, "b:d:h:")) != -1) { @@ -434,7 +434,12 @@ main(int argc, char** argv) break; case 'd': - disk_image = optarg; + disk_index++; + disk_fd = reallocarray(disk_fd, disk_index + 1, + sizeof (int)); + disk_fd[disk_index] = open(optarg, O_RDONLY); + if (disk_fd[disk_index] < 0) + err(1, "Can't open disk image '%s'", optarg); break; case 'h': @@ -459,11 +464,6 @@ main(int argc, char** argv) image_size = 128*1024*1024; image = malloc(image_size); - if (disk_image) { - disk_fd = open(disk_image, O_RDONLY); - if (disk_fd < 0) - err(1, "Can't open disk image '%s'", disk_image); - } tcgetattr(0, &term); oldterm = term; @@ -471,5 +471,5 @@ main(int argc, char** argv) term.c_lflag &= ~(ICANON|ECHO); tcsetattr(0, TCSAFLUSH, &term); - func(&cb, NULL, USERBOOT_VERSION_3, disk_fd >= 0); + func(&cb, NULL, USERBOOT_VERSION_3, disk_index + 1); }