Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Feb 2018 17:01:19 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r328889 - in stable/11: lib/libstand sys/boot/common sys/boot/efi/libefi sys/boot/efi/loader sys/boot/i386/libfirewire sys/boot/i386/libi386 sys/boot/mips/beri/loader sys/boot/ofw/libof...
Message-ID:  <201802051701.w15H1JS8046220@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Mon Feb  5 17:01:18 2018
New Revision: 328889
URL: https://svnweb.freebsd.org/changeset/base/328889

Log:
  MFC r308434, 308827
  
  MFC r308434: Loader paged/pageable data is not always paged.
  MFC r308827: lsdev device name section headers should be printed by dv_print
  callback.

Modified:
  stable/11/lib/libstand/stand.h
  stable/11/sys/boot/common/commands.c
  stable/11/sys/boot/common/dev_net.c
  stable/11/sys/boot/common/md.c
  stable/11/sys/boot/common/module.c
  stable/11/sys/boot/common/part.c
  stable/11/sys/boot/common/util.c
  stable/11/sys/boot/common/util.h
  stable/11/sys/boot/efi/libefi/efinet.c
  stable/11/sys/boot/efi/libefi/efipart.c
  stable/11/sys/boot/efi/loader/main.c
  stable/11/sys/boot/i386/libfirewire/firewire.c
  stable/11/sys/boot/i386/libi386/bioscd.c
  stable/11/sys/boot/i386/libi386/biosdisk.c
  stable/11/sys/boot/i386/libi386/pxe.c
  stable/11/sys/boot/mips/beri/loader/beri_disk_cfi.c
  stable/11/sys/boot/mips/beri/loader/beri_disk_sdcard.c
  stable/11/sys/boot/ofw/libofw/ofw_disk.c
  stable/11/sys/boot/pc98/libpc98/bioscd.c
  stable/11/sys/boot/pc98/libpc98/biosdisk.c
  stable/11/sys/boot/powerpc/kboot/hostdisk.c
  stable/11/sys/boot/powerpc/ps3/ps3cdrom.c
  stable/11/sys/boot/powerpc/ps3/ps3disk.c
  stable/11/sys/boot/uboot/lib/disk.c
  stable/11/sys/boot/usb/storage/umass_loader.c
  stable/11/sys/boot/userboot/userboot/host.c
  stable/11/sys/boot/userboot/userboot/userboot_disk.c
  stable/11/sys/boot/zfs/zfs.c
  stable/11/sys/boot/zfs/zfsimpl.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libstand/stand.h
==============================================================================
--- stable/11/lib/libstand/stand.h	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/lib/libstand/stand.h	Mon Feb  5 17:01:18 2018	(r328889)
@@ -143,7 +143,7 @@ struct devsw {
     int		(*dv_open)(struct open_file *f, ...);
     int		(*dv_close)(struct open_file *f);
     int		(*dv_ioctl)(struct open_file *f, u_long cmd, void *data);
-    void	(*dv_print)(int verbose);	/* print device information */
+    int		(*dv_print)(int verbose);	/* print device information */
     void	(*dv_cleanup)(void);
 };
 

Modified: stable/11/sys/boot/common/commands.c
==============================================================================
--- stable/11/sys/boot/common/commands.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/common/commands.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -491,10 +491,8 @@ command_lsdev(int argc, char *argv[])
     pager_open();
     for (i = 0; devsw[i] != NULL; i++) {
 	if (devsw[i]->dv_print != NULL){
-	    sprintf(line, "%s devices:\n", devsw[i]->dv_name);
-	    if (pager_output(line))
-		    break;
-	    devsw[i]->dv_print(verbose);
+	    if (devsw[i]->dv_print(verbose))
+		break;
 	} else {
 	    sprintf(line, "%s: (unknown)\n", devsw[i]->dv_name);
 	    if (pager_output(line))

Modified: stable/11/sys/boot/common/dev_net.c
==============================================================================
--- stable/11/sys/boot/common/dev_net.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/common/dev_net.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -80,7 +80,7 @@ static int	net_open(struct open_file *, ...);
 static int	net_close(struct open_file *);
 static void	net_cleanup(void);
 static int	net_strategy();
-static void	net_print(int);
+static int	net_print(int);
 
 static int net_getparams(int sock);
 
@@ -325,23 +325,34 @@ exit:
 	return (0);
 }
 
-static void
+static int
 net_print(int verbose)
 {
 	struct netif_driver *drv;
 	int i, d, cnt;
+	int ret = 0;
 
+	if (netif_drivers[0] == NULL)
+		return (ret);
+
+	printf("%s devices:", netdev.dv_name);
+	if ((ret = pager_output("\n")) != 0)
+		return (ret);
+
 	cnt = 0;
 	for (d = 0; netif_drivers[d]; d++) {
 		drv = netif_drivers[d];
 		for (i = 0; i < drv->netif_nifs; i++) {
-			printf("\t%s%d:", "net", cnt++);
-			if (verbose)
+			printf("\t%s%d:", netdev.dv_name, cnt++);
+			if (verbose) {
 				printf(" (%s%d)", drv->netif_bname,
 				    drv->netif_ifs[i].dif_unit);
+			}
+			if ((ret = pager_output("\n")) != 0)
+				return (ret);
 		}
 	}
-	printf("\n");
+	return (ret);
 }
 
 /*

Modified: stable/11/sys/boot/common/md.c
==============================================================================
--- stable/11/sys/boot/common/md.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/common/md.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -63,7 +63,7 @@ static int md_init(void);
 static int md_strategy(void *, int, daddr_t, size_t, char *, size_t *);
 static int md_open(struct open_file *, ...);
 static int md_close(struct open_file *);
-static void md_print(int);
+static int md_print(int);
 
 struct devsw md_dev = {
 	"md",
@@ -143,9 +143,14 @@ md_close(struct open_file *f)
 	return ((dev->d_unit != 0) ? ENXIO : 0);
 }
 
-static void
+static int
 md_print(int verbose)
 {
 
-	printf("MD (%u bytes)\n", MD_IMAGE_SIZE);
+	printf("%s devices:", md_dev.dv_name);
+	if (pager_output("\n") != 0)
+		return (1);
+
+	printf("MD (%u bytes)", MD_IMAGE_SIZE);
+	return (pager_output("\n"));
 }

Modified: stable/11/sys/boot/common/module.c
==============================================================================
--- stable/11/sys/boot/common/module.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/common/module.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -252,7 +252,7 @@ command_lsmod(int argc, char *argv[])
     struct kernel_module	*mp;
     struct file_metadata	*md;
     char			lbuf[80];
-    int				ch, verbose;
+    int				ch, verbose, ret = 0;
 
     verbose = 0;
     optind = 1;
@@ -271,11 +271,13 @@ command_lsmod(int argc, char *argv[])
 
     pager_open();
     for (fp = preloaded_files; fp; fp = fp->f_next) {
-	sprintf(lbuf, " %p: ", (void *) fp->f_addr);
+	snprintf(lbuf, sizeof(lbuf), " %p: ", (void *) fp->f_addr);
 	pager_output(lbuf);
 	pager_output(fp->f_name);
-	sprintf(lbuf, " (%s, 0x%lx)\n", fp->f_type, (long)fp->f_size);
-	pager_output(lbuf);
+	snprintf(lbuf, sizeof(lbuf), " (%s, 0x%lx)\n", fp->f_type,
+	    (long)fp->f_size);
+	if (pager_output(lbuf))
+	    break;
 	if (fp->f_args != NULL) {
 	    pager_output("    args: ");
 	    pager_output(fp->f_args);
@@ -285,7 +287,8 @@ command_lsmod(int argc, char *argv[])
 	if (fp->f_modules) {
 	    pager_output("  modules: ");
 	    for (mp = fp->f_modules; mp; mp = mp->m_next) {
-		sprintf(lbuf, "%s.%d ", mp->m_name, mp->m_version);
+		snprintf(lbuf, sizeof(lbuf), "%s.%d ", mp->m_name,
+		    mp->m_version);
 		pager_output(lbuf);
 	    }
 	    if (pager_output("\n"))
@@ -294,11 +297,14 @@ command_lsmod(int argc, char *argv[])
 	if (verbose) {
 	    /* XXX could add some formatting smarts here to display some better */
 	    for (md = fp->f_metadata; md != NULL; md = md->md_next) {
-		sprintf(lbuf, "      0x%04x, 0x%lx\n", md->md_type, (long) md->md_size);
+		snprintf(lbuf, sizeof(lbuf), "      0x%04x, 0x%lx\n",
+		    md->md_type, (long) md->md_size);
 		if (pager_output(lbuf))
 			break;
 	    }
 	}
+	if (ret)
+	    break;
     }
     pager_close();
     return(CMD_OK);

Modified: stable/11/sys/boot/common/part.c
==============================================================================
--- stable/11/sys/boot/common/part.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/common/part.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -835,6 +835,7 @@ ptable_iterate(const struct ptable *table, void *arg, 
 {
 	struct pentry *entry;
 	char name[32];
+	int ret = 0;
 
 	name[0] = '\0';
 	STAILQ_FOREACH(entry, &table->entries, entry) {
@@ -857,9 +858,8 @@ ptable_iterate(const struct ptable *table, void *arg, 
 		if (table->type == PTABLE_BSD)
 			sprintf(name, "%c", (u_char) 'a' +
 			    entry->part.index);
-		if (iter(arg, name, &entry->part))
-			return 1;
+		if ((ret = iter(arg, name, &entry->part)) != 0)
+			return (ret);
 	}
-	return 0;
+	return (ret);
 }
-

Modified: stable/11/sys/boot/common/util.c
==============================================================================
--- stable/11/sys/boot/common/util.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/common/util.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -114,7 +114,7 @@ strlen(const char *s)
 	return (len);
 }
 
-void
+int
 printf(const char *fmt, ...)
 {
 	va_list ap;
@@ -178,4 +178,5 @@ nextfmt:
 		}
 	}
 	va_end(ap);
+	return (0);
 }

Modified: stable/11/sys/boot/common/util.h
==============================================================================
--- stable/11/sys/boot/common/util.h	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/common/util.h	Mon Feb  5 17:01:18 2018	(r328889)
@@ -48,6 +48,6 @@ void strcat(char *dst, const char *src);
 char *strchr(const char *s, char ch);
 size_t strlen(const char *s);
 
-void printf(const char *fmt, ...);
+int printf(const char *fmt, ...);
 
 #endif	/* !_UTIL_H_ */

Modified: stable/11/sys/boot/efi/libefi/efinet.c
==============================================================================
--- stable/11/sys/boot/efi/libefi/efinet.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/efi/libefi/efinet.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -252,7 +252,7 @@ efinet_end(struct netif *nif)
 }
 
 static int efinet_dev_init(void);
-static void efinet_dev_print(int);
+static int efinet_dev_print(int);
 
 struct devsw efinet_dev = {
 	.dv_name = "net",
@@ -346,14 +346,17 @@ efinet_dev_init()
 	return (0);
 }
 
-static void
+static int
 efinet_dev_print(int verbose)
 {
 	CHAR16 *text;
 	EFI_HANDLE h;
-	int unit;
+	int unit, ret = 0;
 
-	pager_open();
+	printf("%s devices:", efinet_dev.dv_name);
+	if ((ret = pager_output("\n")) != 0)
+		return (ret);
+
 	for (unit = 0, h = efi_find_handle(&efinet_dev, 0);
 	    h != NULL; h = efi_find_handle(&efinet_dev, ++unit)) {
 		printf("    %s%d:", efinet_dev.dv_name, unit);
@@ -362,8 +365,8 @@ efinet_dev_print(int verbose)
 			printf("    %S", text);
 			efi_free_devpath_name(text);
 		}
-		if (pager_output("\n"))
+		if ((ret = pager_output("\n")) != 0)
 			break;
 	}
-	pager_close();
+	return (ret);
 }

Modified: stable/11/sys/boot/efi/libefi/efipart.c
==============================================================================
--- stable/11/sys/boot/efi/libefi/efipart.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/efi/libefi/efipart.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -45,7 +45,7 @@ static int efipart_strategy(void *, int, daddr_t, size
 static int efipart_realstrategy(void *, int, daddr_t, size_t, char *, size_t *);
 static int efipart_open(struct open_file *, ...);
 static int efipart_close(struct open_file *);
-static void efipart_print(int);
+static int efipart_print(int);
 
 struct devsw efipart_dev = {
 	.dv_name = "part",
@@ -160,7 +160,7 @@ efipart_init(void) 
 	return (err);
 }
 
-static void
+static int
 efipart_print(int verbose)
 {
 	char line[80];
@@ -168,28 +168,33 @@ efipart_print(int verbose)
 	EFI_HANDLE h;
 	EFI_STATUS status;
 	u_int unit;
+	int ret = 0;
 
-	pager_open();
+	printf("%s devices:", efipart_dev.dv_name);
+	if ((ret = pager_output("\n")) != 0)
+		return (ret);
+
 	for (unit = 0, h = efi_find_handle(&efipart_dev, 0);
 	    h != NULL; h = efi_find_handle(&efipart_dev, ++unit)) {
-		sprintf(line, "    %s%d:", efipart_dev.dv_name, unit);
-		if (pager_output(line))
+		snprintf(line, sizeof(line), "    %s%d:",
+		    efipart_dev.dv_name, unit);
+		if ((ret = pager_output(line)) != 0)
 			break;
 
 		status = BS->HandleProtocol(h, &blkio_guid, (void **)&blkio);
 		if (!EFI_ERROR(status)) {
-			sprintf(line, "    %llu blocks",
+			snprintf(line, sizeof(line), "    %llu blocks",
 			    (unsigned long long)(blkio->Media->LastBlock + 1));
-			if (pager_output(line))
+			if ((ret = pager_output(line)) != 0)
 				break;
 			if (blkio->Media->RemovableMedia)
-				if (pager_output(" (removable)"))
+				if ((ret = pager_output(" (removable)")) != 0)
 					break;
 		}
-		if (pager_output("\n"))
+		if ((ret = pager_output("\n")) != 0)
 			break;
 	}
-	pager_close();
+	return (ret);
 }
 
 static int

Modified: stable/11/sys/boot/efi/loader/main.c
==============================================================================
--- stable/11/sys/boot/efi/loader/main.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/efi/loader/main.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -503,6 +503,7 @@ command_memmap(int argc, char *argv[])
 	UINT32 dver;
 	EFI_STATUS status;
 	int i, ndesc;
+	char line[80];
 	static char *types[] = {
 	    "Reserved",
 	    "LoaderCode",
@@ -534,14 +535,19 @@ command_memmap(int argc, char *argv[])
 	}
 
 	ndesc = sz / dsz;
-	printf("%23s %12s %12s %8s %4s\n",
+	snprintf(line, sizeof(line), "%23s %12s %12s %8s %4s\n",
 	    "Type", "Physical", "Virtual", "#Pages", "Attr");
+	pager_open();
+	if (pager_output(line)) {
+		pager_close();
+		return (CMD_OK);
+	}
 
 	for (i = 0, p = map; i < ndesc;
 	     i++, p = NextMemoryDescriptor(p, dsz)) {
 		printf("%23s %012jx %012jx %08jx ", types[p->Type],
-		   (uintmax_t)p->PhysicalStart, (uintmax_t)p->VirtualStart,
-		   (uintmax_t)p->NumberOfPages);
+		    (uintmax_t)p->PhysicalStart, (uintmax_t)p->VirtualStart,
+		    (uintmax_t)p->NumberOfPages);
 		if (p->Attribute & EFI_MEMORY_UC)
 			printf("UC ");
 		if (p->Attribute & EFI_MEMORY_WC)
@@ -558,9 +564,11 @@ command_memmap(int argc, char *argv[])
 			printf("RP ");
 		if (p->Attribute & EFI_MEMORY_XP)
 			printf("XP ");
-		printf("\n");
+		if (pager_output("\n"))
+			break;
 	}
 
+	pager_close();
 	return (CMD_OK);
 }
 
@@ -582,10 +590,17 @@ guid_to_string(EFI_GUID *guid)
 static int
 command_configuration(int argc, char *argv[])
 {
+	char line[80];
 	UINTN i;
 
-	printf("NumberOfTableEntries=%lu\n",
+	snprintf(line, sizeof(line), "NumberOfTableEntries=%lu\n",
 		(unsigned long)ST->NumberOfTableEntries);
+	pager_open();
+	if (pager_output(line)) {
+		pager_close();
+		return (CMD_OK);
+	}
+
 	for (i = 0; i < ST->NumberOfTableEntries; i++) {
 		EFI_GUID *guid;
 
@@ -611,9 +626,13 @@ command_configuration(int argc, char *argv[])
 			printf("FDT Table");
 		else
 			printf("Unknown Table (%s)", guid_to_string(guid));
-		printf(" at %p\n", ST->ConfigurationTable[i].VendorTable);
+		snprintf(line, sizeof(line), " at %p\n",
+		    ST->ConfigurationTable[i].VendorTable);
+		if (pager_output(line))
+			break;
 	}
 
+	pager_close();
 	return (CMD_OK);
 }
 

Modified: stable/11/sys/boot/i386/libfirewire/firewire.c
==============================================================================
--- stable/11/sys/boot/i386/libfirewire/firewire.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/i386/libfirewire/firewire.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -69,7 +69,7 @@ static int	fw_strategy(void *devdata, int flag, daddr_
 		    size_t size, char *buf, size_t *rsize);
 static int	fw_open(struct open_file *f, ...);
 static int	fw_close(struct open_file *f);
-static void	fw_print(int verbose);
+static int	fw_print(int verbose);
 static void	fw_cleanup(void);
 
 void		fw_enable(void);
@@ -148,21 +148,30 @@ fw_init(void) 
 /*
  * Print information about OHCI chips
  */
-static void
+static int
 fw_print(int verbose)
 {
-	int i;
+	char line[80];
+	int i, ret = 0;
 	struct fwohci_softc *sc;
 
+	printf("%s devices:", fwohci.dv_name);
+	if ((ret = pager_output("\n")) != 0)
+		return (ret);
+
 	for (i = 0; i < MAX_OHCI; i ++) {
 		sc = &fwinfo[i];
 		if (sc->state == FWOHCI_STATE_DEAD)
 			break;
-		printf("%d: locator=0x%04x devid=0x%08x"
+		snprintf(line, sizeof(line), "%d: locator=0x%04x devid=0x%08x"
 			" base_addr=0x%08x handle=0x%08x bus_id=0x%08x\n",
 			i, sc->locator, sc->devid,
 			sc->base_addr, sc->handle, sc->bus_id);
+		ret = pager_output(line);
+		if (ret != 0)
+			break;
 	}
+	return (ret);
 }
 
 static int 

Modified: stable/11/sys/boot/i386/libi386/bioscd.c
==============================================================================
--- stable/11/sys/boot/i386/libi386/bioscd.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/i386/libi386/bioscd.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -100,7 +100,7 @@ static int	bc_realstrategy(void *devdata, int flag, da
     size_t size, char *buf, size_t *rsize);
 static int	bc_open(struct open_file *f, ...);
 static int	bc_close(struct open_file *f);
-static void	bc_print(int verbose);
+static int	bc_print(int verbose);
 
 struct devsw bioscd = {
 	"cd", 
@@ -177,20 +177,26 @@ bc_add(int biosdev)
 /*
  * Print information about disks
  */
-static void
+static int
 bc_print(int verbose)
 {
 	char line[80];
-	int i;
+	int i, ret = 0;
 
-	pager_open();
+	if (nbcinfo == 0)
+		return (0);
+
+	printf("%s devices:", bioscd.dv_name);
+	if ((ret = pager_output("\n")) != 0)
+		return (ret);
+
 	for (i = 0; i < nbcinfo; i++) {
-		sprintf(line, "    cd%d: Device 0x%x\n", i,
+		snprintf(line, sizeof(line), "    cd%d: Device 0x%x\n", i,
 		    bcinfo[i].bc_sp.sp_devicespec);
-		if (pager_output(line))
+		if ((ret = pager_output(line)) != 0)
 			break;
 	}
-	pager_close();
+	return (ret);
 }
 
 /*

Modified: stable/11/sys/boot/i386/libi386/biosdisk.c
==============================================================================
--- stable/11/sys/boot/i386/libi386/biosdisk.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/i386/libi386/biosdisk.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -135,7 +135,7 @@ static int bd_realstrategy(void *devdata, int flag, da
 static int bd_open(struct open_file *f, ...);
 static int bd_close(struct open_file *f);
 static int bd_ioctl(struct open_file *f, u_long cmd, void *data);
-static void bd_print(int verbose);
+static int bd_print(int verbose);
 static void bd_cleanup(void);
 
 #ifdef LOADER_GELI_SUPPORT
@@ -306,21 +306,28 @@ bd_int13probe(struct bdinfo *bd)
 /*
  * Print information about disks
  */
-static void
+static int
 bd_print(int verbose)
 {
 	static char line[80];
 	struct disk_devdesc dev;
-	int i;
+	int i, ret = 0;
 
-	pager_open();
+	if (nbdinfo == 0)
+		return (0);
+
+	printf("%s devices:", biosdisk.dv_name);
+	if ((ret = pager_output("\n")) != 0)
+		return (ret);
+
 	for (i = 0; i < nbdinfo; i++) {
-		sprintf(line, "    disk%d:   BIOS drive %c (%ju X %u):\n", i,
+		snprintf(line, sizeof(line),
+		    "    disk%d:   BIOS drive %c (%ju X %u):\n", i,
 		    (bdinfo[i].bd_unit < 0x80) ? ('A' + bdinfo[i].bd_unit):
 		    ('C' + bdinfo[i].bd_unit - 0x80),
 		    (uintmax_t)bdinfo[i].bd_sectors,
 		    bdinfo[i].bd_sectorsize);
-		if (pager_output(line))
+		if ((ret = pager_output(line)) != 0)
 			break;
 		dev.d_dev = &biosdisk;
 		dev.d_unit = i;
@@ -331,12 +338,14 @@ bd_print(int verbose)
 		    bdinfo[i].bd_sectorsize,
 		    (bdinfo[i].bd_flags & BD_FLOPPY) ?
 		    DISK_F_NOCACHE: 0) == 0) {
-			sprintf(line, "    disk%d", i);
-			disk_print(&dev, line, verbose);
+			snprintf(line, sizeof(line), "    disk%d", i);
+			ret = disk_print(&dev, line, verbose);
 			disk_close(&dev);
+			if (ret != 0)
+			    return (ret);
 		}
 	}
-	pager_close();
+	return (ret);
 }
 
 /*

Modified: stable/11/sys/boot/i386/libi386/pxe.c
==============================================================================
--- stable/11/sys/boot/i386/libi386/pxe.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/i386/libi386/pxe.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -75,7 +75,7 @@ static int	pxe_strategy(void *devdata, int flag, daddr
 			     size_t size, char *buf, size_t *rsize);
 static int	pxe_open(struct open_file *f, ...);
 static int	pxe_close(struct open_file *f);
-static void	pxe_print(int verbose);
+static int	pxe_print(int verbose);
 static void	pxe_cleanup(void);
 static void	pxe_setnfshandle(char *rootpath);
 
@@ -382,14 +382,23 @@ pxe_close(struct open_file *f)
     return (0);
 }
 
-static void
+static int
 pxe_print(int verbose)
 {
-
+	char line[255];
 	if (pxe_call == NULL)
-		return;
+		return (0);
 
-	printf("    pxe0:    %s:%s\n", inet_ntoa(rootip), rootpath);
+	printf("%s devices:", pxedisk.dv_name);
+	if (pager_output("\n") != 0)
+		return (1);
+	if (verbose) {
+		snprintf(line, sizeof(line), "    pxe0:    %s:%s\n",
+		    inet_ntoa(rootip), rootpath);
+	} else {
+		snprintf(line, sizeof(line), "    pxe0:\n");
+	}
+	return (pager_output(line));
 }
 
 static void

Modified: stable/11/sys/boot/mips/beri/loader/beri_disk_cfi.c
==============================================================================
--- stable/11/sys/boot/mips/beri/loader/beri_disk_cfi.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/mips/beri/loader/beri_disk_cfi.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -47,7 +47,7 @@ static int	beri_cfi_disk_close(struct open_file *);
 static void	beri_cfi_disk_cleanup(void);
 static int	beri_cfi_disk_strategy(void *, int, daddr_t, size_t,
 		    char *, size_t *);
-static void	beri_cfi_disk_print(int);
+static int	beri_cfi_disk_print(int);
 
 struct devsw beri_cfi_disk = {
 	.dv_name = "cfi",
@@ -112,25 +112,33 @@ beri_cfi_disk_close(struct open_file *f)
 	return (disk_close(dev));
 }
 
-static void
+static int
 beri_cfi_disk_print(int verbose)
 {
 	struct disk_devdesc dev;
 	char line[80];
+	int ret;
 
-	sprintf(line, "    cfi%d   CFI flash device\n", 0);
-	pager_output(line);
+	printf("%s devices:", beri_cfi_disk.dv_name);
+	if ((ret = pager_output("\n")) != 0)
+		return (ret);
+
+	snprintf(line, sizeof(line), "    cfi%d   CFI flash device\n", 0);
+	ret = pager_output(line);
+	if (ret != 0)
+		return (ret);
 	dev.d_dev = &beri_cfi_disk;
 	dev.d_unit = 0;
 	dev.d_slice = -1;
 	dev.d_partition = -1;
 	if (disk_open(&dev, cfi_get_mediasize(),
 	    cfi_get_sectorsize(), 0) == 0) {
-		sprintf(line, "    cfi%d", 0);
-		disk_print(&dev, line, verbose);
+		snprintf(line, sizeof(line), "    cfi%d", 0);
+		ret = disk_print(&dev, line, verbose);
 		disk_close(&dev);
 	}
 
+	return (ret);
 }
 
 static void

Modified: stable/11/sys/boot/mips/beri/loader/beri_disk_sdcard.c
==============================================================================
--- stable/11/sys/boot/mips/beri/loader/beri_disk_sdcard.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/mips/beri/loader/beri_disk_sdcard.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -47,7 +47,7 @@ static int	beri_sdcard_disk_close(struct open_file *);
 static void	beri_sdcard_disk_cleanup(void);
 static int	beri_sdcard_disk_strategy(void *, int, daddr_t, size_t,
 		    char *, size_t *);
-static void	beri_sdcard_disk_print(int);
+static int	beri_sdcard_disk_print(int);
 
 struct devsw beri_sdcard_disk = {
 	.dv_name = "sdcard",
@@ -123,19 +123,27 @@ beri_sdcard_disk_print(int verbose)
 {
 	struct disk_devdesc dev;
 	char line[80];
+	int ret;
 
-	sprintf(line, "    sdcard%d   Altera SD card drive\n", 0);
-	pager_output(line);
+	printf("%s devices:", beri_sdcard_disk.dv_name);
+	if ((ret = pager_output("\n")) != 0)
+		return (ret);
+	
+	snprintf(line, sizeof(line), "    sdcard%d   Altera SD card drive\n", 0);
+	ret = pager_output(line);
+	if (ret != 0)
+	    return (ret);
 	dev.d_dev = &beri_sdcard_disk;
 	dev.d_unit = 0;
 	dev.d_slice = -1;
 	dev.d_partition = -1;
 	if (disk_open(&dev, altera_sdcard_get_mediasize(),
 	    altera_sdcard_get_sectorsize(), 0) == 0) {
-		sprintf(line, "    sdcard%d", 0);
-		disk_print(&dev, line, verbose);
+		snprintf(line, sizeof(line), "    sdcard%d", 0);
+		ret = disk_print(&dev, line, verbose);
 		disk_close(&dev);
 	}
+	return (ret);
 }
 
 static void

Modified: stable/11/sys/boot/ofw/libofw/ofw_disk.c
==============================================================================
--- stable/11/sys/boot/ofw/libofw/ofw_disk.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/ofw/libofw/ofw_disk.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -47,7 +47,7 @@ static int	ofwd_strategy(void *devdata, int flag, dadd
 static int	ofwd_open(struct open_file *f, ...);
 static int	ofwd_close(struct open_file *f);
 static int	ofwd_ioctl(struct open_file *f, u_long cmd, void *data);
-static void	ofwd_print(int verbose);
+static int	ofwd_print(int verbose);
 
 struct devsw ofwdisk = {
 	"block",
@@ -161,8 +161,8 @@ ofwd_ioctl(struct open_file *f __unused, u_long cmd __
 	return (EINVAL);
 }
 
-static void
+static int
 ofwd_print(int verbose __unused)
 {
-
+	return (0);
 }

Modified: stable/11/sys/boot/pc98/libpc98/bioscd.c
==============================================================================
--- stable/11/sys/boot/pc98/libpc98/bioscd.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/pc98/libpc98/bioscd.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -99,7 +99,7 @@ static int	bc_realstrategy(void *devdata, int flag, da
 		    size_t size, char *buf, size_t *rsize);
 static int	bc_open(struct open_file *f, ...);
 static int	bc_close(struct open_file *f);
-static void	bc_print(int verbose);
+static int	bc_print(int verbose);
 
 struct devsw bioscd = {
 	"cd", 
@@ -173,20 +173,26 @@ bc_add(int biosdev)
 /*
  * Print information about disks
  */
-static void
+static int
 bc_print(int verbose)
 {
 	char line[80];
-	int i;
+	int i, ret = 0;
 
-	pager_open();
+	if (nbcinfo == 0)
+		return (0);
+
+	printf("%s devices:", bioscd.dv_name);
+	if ((ret = pager_output("\n")) != 0)
+		return (ret);
+
 	for (i = 0; i < nbcinfo; i++) {
 		sprintf(line, "    cd%d: Device 0x%x\n", i,
 		    bcinfo[i].bc_sp.sp_devicespec);
-		if (pager_output(line))
+		if ((ret = pager_output(line)) != 0)
 			break;
 	}
-	pager_close();
+	return (ret);
 }
 
 /*

Modified: stable/11/sys/boot/pc98/libpc98/biosdisk.c
==============================================================================
--- stable/11/sys/boot/pc98/libpc98/biosdisk.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/pc98/libpc98/biosdisk.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -123,7 +123,7 @@ static int	bd_realstrategy(void *devdata, int flag, da
 		    size_t size, char *buf, size_t *rsize);
 static int	bd_open(struct open_file *f, ...);
 static int	bd_close(struct open_file *f);
-static void	bd_print(int verbose);
+static int	bd_print(int verbose);
 
 struct devsw biosdisk = {
     "disk", 
@@ -249,22 +249,28 @@ bd_int13probe(struct bdinfo *bd)
 /*
  * Print information about disks
  */
-static void
+static int
 bd_print(int verbose)
 {
-    int				i, j, done;
+    int				i, j, ret = 0;
     char			line[80];
     struct i386_devdesc		dev;
     struct open_disk		*od;
     struct pc98_partition	*dptr;
     
-    pager_open();
-    done = 0;
-    for (i = 0; i < nbdinfo && !done; i++) {
-	sprintf(line, "    disk%d:   BIOS drive %c:\n", i, 'A' + i);
-	if (pager_output(line))
-		break;
+    if (nbdinfo == 0)
+	return (0);
 
+    printf("%s devices:", biosdisk.dv_name);
+    if ((ret = pager_output("\n")) != 0)
+	return (ret);
+
+    for (i = 0; i < nbdinfo; i++) {
+	snprintf(line, sizeof(line), "    disk%d:   BIOS drive %c:\n",
+	    i, 'A' + i);
+	if ((ret = pager_output(line)) != 0)
+	    break;
+
 	/* try to open the whole disk */
 	dev.d_unit = i;
 	dev.d_kind.biosdisk.slice = -1;
@@ -278,17 +284,17 @@ bd_print(int verbose)
 
 		/* Check for a "dedicated" disk */
 		for (j = 0; j < od->od_nslices; j++) {
-		    sprintf(line, "      disk%ds%d", i, j + 1);
-		    if (bd_printslice(od, &dptr[j], line, verbose)) {
-			    done = 1;
-			    break;
-		    }
+		    snprintf(line, sizeof(line), "      disk%ds%d", i, j + 1);
+		    if ((ret = bd_printslice(od, &dptr[j], line, verbose)) != 0)
+			break;
 		}
 	    }
 	    bd_closedisk(od);
+	    if (ret != 0)
+		break;
 	}
     }
-    pager_close();
+    return (ret);
 }
 
 /* Given a size in 512 byte sectors, convert it to a human-readable number. */

Modified: stable/11/sys/boot/powerpc/kboot/hostdisk.c
==============================================================================
--- stable/11/sys/boot/powerpc/kboot/hostdisk.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/powerpc/kboot/hostdisk.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -37,7 +37,7 @@ static int hostdisk_strategy(void *devdata, int flag, 
 static int hostdisk_open(struct open_file *f, ...);
 static int hostdisk_close(struct open_file *f);
 static int hostdisk_ioctl(struct open_file *f, u_long cmd, void *data);
-static void hostdisk_print(int verbose);
+static int hostdisk_print(int verbose);
 
 struct devsw hostdisk = {
 	"/dev",
@@ -117,9 +117,9 @@ hostdisk_ioctl(struct open_file *f, u_long cmd, void *
 	return (EINVAL);
 }
 
-static void
+static int
 hostdisk_print(int verbose)
 {
-
+	return (0);
 }
 

Modified: stable/11/sys/boot/powerpc/ps3/ps3cdrom.c
==============================================================================
--- stable/11/sys/boot/powerpc/ps3/ps3cdrom.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/powerpc/ps3/ps3cdrom.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -49,7 +49,7 @@ static int ps3cdrom_strategy(void *devdata, int flag, 
 	size_t size, char *buf, size_t *rsize);
 static int ps3cdrom_open(struct open_file *f, ...);
 static int ps3cdrom_close(struct open_file *f);
-static void ps3cdrom_print(int verbose);
+static int ps3cdrom_print(int verbose);
 
 struct devsw ps3cdrom = {
 	"cd",
@@ -149,6 +149,7 @@ static int ps3cdrom_close(struct open_file *f)
 	return 0;
 }
 
-static void ps3cdrom_print(int verbose)
+static int ps3cdrom_print(int verbose)
 {
+	return (0);
 }

Modified: stable/11/sys/boot/powerpc/ps3/ps3disk.c
==============================================================================
--- stable/11/sys/boot/powerpc/ps3/ps3disk.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/powerpc/ps3/ps3disk.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -61,7 +61,7 @@ static int ps3disk_strategy(void *devdata, int flag, d
 	size_t size, char *buf, size_t *rsize);
 static int ps3disk_open(struct open_file *f, ...);
 static int ps3disk_close(struct open_file *f);
-static void ps3disk_print(int verbose);
+static int ps3disk_print(int verbose);
 
 struct devsw ps3disk = {
 	"disk",
@@ -186,8 +186,9 @@ static int ps3disk_close(struct open_file *f)
 	return 0;
 }
 
-static void ps3disk_print(int verbose)
+static int ps3disk_print(int verbose)
 {
+	return (0);
 }
 
 static int ps3disk_open_gpt(struct ps3_devdesc *dev, struct open_dev *od)

Modified: stable/11/sys/boot/uboot/lib/disk.c
==============================================================================
--- stable/11/sys/boot/uboot/lib/disk.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/uboot/lib/disk.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -77,7 +77,7 @@ static int stor_strategy(void *, int, daddr_t, size_t,
 static int stor_open(struct open_file *, ...);
 static int stor_close(struct open_file *);
 static int stor_ioctl(struct open_file *f, u_long cmd, void *data);
-static void stor_print(int);
+static int stor_print(int);
 static void stor_cleanup(void);
 
 struct devsw uboot_storage = {
@@ -237,30 +237,38 @@ stor_readdev(struct disk_devdesc *dev, daddr_t blk, si
 	return (err);
 }
 
-static void
+static int
 stor_print(int verbose)
 {
 	struct disk_devdesc dev;
 	static char line[80];
-	int i;
+	int i, ret = 0;
 
-	pager_open();
+	if (stor_info_no == 0)
+		return (ret);
+
+	printf("%s devices:", uboot_storage.dv_name);
+	if ((ret = pager_output("\n")) != 0)
+		return (ret);
+
 	for (i = 0; i < stor_info_no; i++) {
 		dev.d_dev = &uboot_storage;
 		dev.d_unit = i;
 		dev.d_slice = -1;
 		dev.d_partition = -1;
-		sprintf(line, "\tdisk%d (%s)\n", i,
+		snprintf(line, sizeof(line), "\tdisk%d (%s)\n", i,
 		    ub_stor_type(SI(&dev).type));
-		if (pager_output(line))
+		if ((ret = pager_output(line)) != 0)
 			break;
 		if (stor_opendev(&dev) == 0) {
 			sprintf(line, "\tdisk%d", i);
-			disk_print(&dev, line, verbose);
+			ret = disk_print(&dev, line, verbose);
 			disk_close(&dev);
+			if (ret != 0)
+				break;
 		}
 	}
-	pager_close();
+	return (ret);
 }
 
 static int

Modified: stable/11/sys/boot/usb/storage/umass_loader.c
==============================================================================
--- stable/11/sys/boot/usb/storage/umass_loader.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/usb/storage/umass_loader.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -49,7 +49,7 @@ static int umass_disk_close(struct open_file *);
 static void umass_disk_cleanup(void);
 static int umass_disk_ioctl(struct open_file *, u_long, void *);
 static int umass_disk_strategy(void *, int, daddr_t, size_t, char *, size_t *);
-static void umass_disk_print(int);
+static int umass_disk_print(int);
 
 struct devsw umass_disk = {
 	.dv_name = "umass",
@@ -169,23 +169,30 @@ umass_disk_close(struct open_file *f)
 	return (disk_close(dev));
 }
 
-static void
+static int
 umass_disk_print(int verbose)
 {
 	struct disk_devdesc dev;
 
+	printf("%s devices:", umass_disk.dv_name);
+	if (pager_output("\n") != 0)
+		return (1);
+
 	memset(&dev, 0, sizeof(dev));
 
-	pager_output("    umass0   UMASS device\n");
+	ret = pager_output("    umass0   UMASS device\n");
+	if (ret != 0)
+		return (ret);
 	dev.d_dev = &umass_disk;
 	dev.d_unit = 0;
 	dev.d_slice = -1;
 	dev.d_partition = -1;
 
 	if (umass_disk_open_sub(&dev) == 0) {
-		disk_print(&dev, "    umass0", verbose);
+		ret = disk_print(&dev, "    umass0", verbose);
 		disk_close(&dev);
 	}
+	return (ret);
 }
 
 static void

Modified: stable/11/sys/boot/userboot/userboot/host.c
==============================================================================
--- stable/11/sys/boot/userboot/userboot/host.c	Mon Feb  5 16:28:03 2018	(r328888)
+++ stable/11/sys/boot/userboot/userboot/host.c	Mon Feb  5 17:01:18 2018	(r328889)
@@ -134,13 +134,17 @@ host_dev_init(void)
 	return (0);
 }
 
-static void
+static int
 host_dev_print(int verbose)
 {
 	char line[80];
 
-	sprintf(line, "    host%d:   Host filesystem\n", 0);
-	pager_output(line);
+	printf("%s devices:", host_dev.dv_name);
+	if (pager_output("\n") != 0)
+		return (1);
+
+	snprintf(line, sizeof(line), "    host%d:   Host filesystem\n", 0);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



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