Author: imp
Date: Wed May 18 05:59:05 2016
New Revision: 300117
URL: https://svnweb.freebsd.org/changeset/base/300117

Log:
  Fix several instances where the boot loader ignored pager_output
  return value when it could return 1 (indicating we should stop).
  Fix a few instances of pager_open() / pager_close() not being called.
  Actually use these routines for the environment variable printing code
  I just committed.

Modified:
  head/sys/boot/common/disk.c
  head/sys/boot/common/disk.h
  head/sys/boot/common/module.c
  head/sys/boot/common/part.c
  head/sys/boot/common/part.h
  head/sys/boot/common/pnp.c
  head/sys/boot/efi/libefi/efinet.c
  head/sys/boot/efi/libefi/efipart.c
  head/sys/boot/efi/loader/Makefile
  head/sys/boot/efi/loader/bootinfo.c
  head/sys/boot/efi/loader/main.c
  head/sys/boot/fdt/fdt_loader_cmd.c
  head/sys/boot/i386/libi386/bioscd.c
  head/sys/boot/i386/libi386/biosdisk.c
  head/sys/boot/pc98/libpc98/bioscd.c
  head/sys/boot/pc98/libpc98/biosdisk.c
  head/sys/boot/uboot/lib/disk.c
  head/sys/boot/zfs/zfs.c

Modified: head/sys/boot/common/disk.c
==============================================================================
--- head/sys/boot/common/disk.c Wed May 18 05:58:58 2016        (r300116)
+++ head/sys/boot/common/disk.c Wed May 18 05:59:05 2016        (r300117)
@@ -183,13 +183,14 @@ ptblread(void *d, void *buf, size_t bloc
 }
 
 #define        PWIDTH  35
-static void
+static int
 ptable_print(void *arg, const char *pname, const struct ptable_entry *part)
 {
        struct print_args *pa, bsd;
        struct open_disk *od;
        struct ptable *table;
        char line[80];
+       int res;
 
        pa = (struct print_args *)arg;
        od = (struct open_disk *)pa->dev->d_opendata;
@@ -200,25 +201,29 @@ ptable_print(void *arg, const char *pnam
                    display_size(part->end - part->start + 1,
                    od->sectorsize));
        strcat(line, "\n");
-       pager_output(line);
+       if (pager_output(line))
+               return 1;
+       res = 0;
        if (part->type == PART_FREEBSD) {
                /* Open slice with BSD label */
                pa->dev->d_offset = part->start;
                table = ptable_open(pa->dev, part->end - part->start + 1,
                    od->sectorsize, ptblread);
                if (table == NULL)
-                       return;
+                       return 0;
                sprintf(line, "  %s%s", pa->prefix, pname);
                bsd.dev = pa->dev;
                bsd.prefix = line;
                bsd.verbose = pa->verbose;
-               ptable_iterate(table, &bsd, ptable_print);
+               res = ptable_iterate(table, &bsd, ptable_print);
                ptable_close(table);
        }
+
+       return (res);
 }
 #undef PWIDTH
 
-void
+int
 disk_print(struct disk_devdesc *dev, char *prefix, int verbose)
 {
        struct open_disk *od;
@@ -229,7 +234,7 @@ disk_print(struct disk_devdesc *dev, cha
        pa.dev = dev;
        pa.prefix = prefix;
        pa.verbose = verbose;
-       ptable_iterate(od->table, &pa, ptable_print);
+       return (ptable_iterate(od->table, &pa, ptable_print));
 }
 
 int

Modified: head/sys/boot/common/disk.h
==============================================================================
--- head/sys/boot/common/disk.h Wed May 18 05:58:58 2016        (r300116)
+++ head/sys/boot/common/disk.h Wed May 18 05:59:05 2016        (r300117)
@@ -112,7 +112,7 @@ extern int ptblread(void *d, void *buf, 
 /*
  * Print information about slices on a disk.
  */
-extern void disk_print(struct disk_devdesc *dev, char *prefix, int verbose);
+extern int disk_print(struct disk_devdesc *dev, char *prefix, int verbose);
 extern char* disk_fmtdev(struct disk_devdesc *dev);
 extern int disk_parsedev(struct disk_devdesc *dev, const char *devspec,
     const char **path);

Modified: head/sys/boot/common/module.c
==============================================================================
--- head/sys/boot/common/module.c       Wed May 18 05:58:58 2016        
(r300116)
+++ head/sys/boot/common/module.c       Wed May 18 05:59:05 2016        
(r300117)
@@ -277,7 +277,8 @@ command_lsmod(int argc, char *argv[])
        if (fp->f_args != NULL) {
            pager_output("    args: ");
            pager_output(fp->f_args);
-           pager_output("\n");
+           if (pager_output("\n"))
+                   break;
        }
        if (fp->f_modules) {
            pager_output("  modules: ");
@@ -285,13 +286,15 @@ command_lsmod(int argc, char *argv[])
                sprintf(lbuf, "%s.%d ", mp->m_name, mp->m_version);
                pager_output(lbuf);
            }
-           pager_output("\n");
-       }
+           if (pager_output("\n"))
+                   break;
+               }
        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);
-               pager_output(lbuf);
+               if (pager_output(lbuf))
+                       break;
            }
        }
     }

Modified: head/sys/boot/common/part.c
==============================================================================
--- head/sys/boot/common/part.c Wed May 18 05:58:58 2016        (r300116)
+++ head/sys/boot/common/part.c Wed May 18 05:59:05 2016        (r300117)
@@ -829,7 +829,7 @@ ptable_getbestpart(const struct ptable *
        return (ENOENT);
 }
 
-void
+int
 ptable_iterate(const struct ptable *table, void *arg, ptable_iterate_t *iter)
 {
        struct pentry *entry;
@@ -856,7 +856,9 @@ ptable_iterate(const struct ptable *tabl
                if (table->type == PTABLE_BSD)
                        sprintf(name, "%c", (u_char) 'a' +
                            entry->part.index);
-               iter(arg, name, &entry->part);
+               if (iter(arg, name, &entry->part))
+                       return 1;
        }
+       return 0;
 }
 

Modified: head/sys/boot/common/part.h
==============================================================================
--- head/sys/boot/common/part.h Wed May 18 05:58:58 2016        (r300116)
+++ head/sys/boot/common/part.h Wed May 18 05:59:05 2016        (r300117)
@@ -63,7 +63,7 @@ struct ptable_entry {
 
 /* The offset and size are in sectors */
 typedef int (diskread_t)(void *arg, void *buf, size_t blocks, off_t offset);
-typedef void (ptable_iterate_t)(void *arg, const char *partname,
+typedef int (ptable_iterate_t)(void *arg, const char *partname,
     const struct ptable_entry *part);
 
 struct ptable *ptable_open(void *dev, off_t sectors, uint16_t sectorsize,
@@ -75,7 +75,7 @@ int ptable_getpart(const struct ptable *
     int index);
 int ptable_getbestpart(const struct ptable *table, struct ptable_entry *part);
 
-void ptable_iterate(const struct ptable *table, void *arg,
+int ptable_iterate(const struct ptable *table, void *arg,
     ptable_iterate_t *iter);
 const char *parttype2str(enum partition_type type);
 

Modified: head/sys/boot/common/pnp.c
==============================================================================
--- head/sys/boot/common/pnp.c  Wed May 18 05:58:58 2016        (r300116)
+++ head/sys/boot/common/pnp.c  Wed May 18 05:59:05 2016        (r300117)
@@ -68,15 +68,18 @@ pnp_scan(int argc, char *argv[]) 
     }
     if (verbose) {
        pager_open();
-       pager_output("PNP scan summary:\n");
+       if (pager_output("PNP scan summary:\n"))
+               goto out;
        STAILQ_FOREACH(pi, &pnp_devices, pi_link) {
            pager_output(STAILQ_FIRST(&pi->pi_ident)->id_ident);        /* 
first ident should be canonical */
            if (pi->pi_desc != NULL) {
                pager_output(" : ");
                pager_output(pi->pi_desc);
            }
-           pager_output("\n");
+           if (pager_output("\n"))
+                   break;
        }
+out:
        pager_close();
     }
     return(CMD_OK);

Modified: head/sys/boot/efi/libefi/efinet.c
==============================================================================
--- head/sys/boot/efi/libefi/efinet.c   Wed May 18 05:58:58 2016        
(r300116)
+++ head/sys/boot/efi/libefi/efinet.c   Wed May 18 05:59:05 2016        
(r300117)
@@ -329,9 +329,12 @@ efinet_dev_print(int verbose)
        EFI_HANDLE h;
        int unit;
 
+       pager_open();
        for (unit = 0, h = efi_find_handle(&efinet_dev, 0);
            h != NULL; h = efi_find_handle(&efinet_dev, ++unit)) {
                sprintf(line, "    %s%d:\n", efinet_dev.dv_name, unit);
-               pager_output(line);
+               if (pager_output(line))
+                       break;
        }
+       pager_close();
 }

Modified: head/sys/boot/efi/libefi/efipart.c
==============================================================================
--- head/sys/boot/efi/libefi/efipart.c  Wed May 18 05:58:58 2016        
(r300116)
+++ head/sys/boot/efi/libefi/efipart.c  Wed May 18 05:59:05 2016        
(r300117)
@@ -180,21 +180,27 @@ efipart_print(int verbose)
        EFI_STATUS status;
        u_int unit;
 
+       pager_open();
        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);
-               pager_output(line);
+               if (pager_output(line))
+                       break;
 
                status = BS->HandleProtocol(h, &blkio_guid, (void **)&blkio);
                if (!EFI_ERROR(status)) {
                        sprintf(line, "    %llu blocks",
                            (unsigned long long)(blkio->Media->LastBlock + 1));
-                       pager_output(line);
+                       if (pager_output(line))
+                               break;
                        if (blkio->Media->RemovableMedia)
-                               pager_output(" (removable)");
+                               if (pager_output(" (removable)"))
+                                       break;
                }
-               pager_output("\n");
+               if (pager_output("\n"))
+                       break;
        }
+       pager_close();
 }
 
 static int

Modified: head/sys/boot/efi/loader/Makefile
==============================================================================
--- head/sys/boot/efi/loader/Makefile   Wed May 18 05:58:58 2016        
(r300116)
+++ head/sys/boot/efi/loader/Makefile   Wed May 18 05:59:05 2016        
(r300117)
@@ -30,6 +30,10 @@ CWARNFLAGS.zfs.c+=   -Wno-sign-compare
 CWARNFLAGS.zfs.c+=     -Wno-array-bounds
 CWARNFLAGS.zfs.c+=     -Wno-missing-prototypes
 .endif
+# In the loader, %S is for CHAR16 strings, not wchar_t strings. This
+# mismatch causes issues on some archs, so just ignore it for now.
+# The printf in libstand implements CHAR16 strings always.
+CWARNFLAGS.main.c+=    -Wno-format
 
 # We implement a slightly non-stadard %S in that it always takes a
 # CHAR16 that's common in UEFI-land instaed of a wchar_t. This only

Modified: head/sys/boot/efi/loader/bootinfo.c
==============================================================================
--- head/sys/boot/efi/loader/bootinfo.c Wed May 18 05:58:58 2016        
(r300116)
+++ head/sys/boot/efi/loader/bootinfo.c Wed May 18 05:59:05 2016        
(r300117)
@@ -422,7 +422,7 @@ bi_load(char *args, vm_offset_t *modulep
        if (dtb_size)
                file_addmetadata(kfp, MODINFOMD_DTBP, sizeof dtbp, &dtbp);
        else
-               pager_output("WARNING! Trying to fire up the kernel, but no "
+               printf("WARNING! Trying to fire up the kernel, but no "
                    "device tree blob found!\n");
 #endif
        file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof kernend, &kernend);

Modified: head/sys/boot/efi/loader/main.c
==============================================================================
--- head/sys/boot/efi/loader/main.c     Wed May 18 05:58:58 2016        
(r300116)
+++ head/sys/boot/efi/loader/main.c     Wed May 18 05:59:05 2016        
(r300117)
@@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/param.h>
 #include <sys/reboot.h>
 #include <sys/boot.h>
+#include <inttypes.h>
 #include <stand.h>
 #include <string.h>
 #include <setjmp.h>
@@ -649,6 +650,7 @@ command_nvram(int argc, char *argv[])
        /* Initiate the search */
        status = RS->GetNextVariableName(&varsz, NULL, NULL);
 
+       pager_open();
        for (; status != EFI_NOT_FOUND; ) {
                status = RS->GetNextVariableName(&varsz, var, &varguid);
                //if (EFI_ERROR(status))
@@ -671,10 +673,11 @@ command_nvram(int argc, char *argv[])
                                        printf("\\x%02x", data[i]);
                        }
                }
-               /* XXX */
-               pager_output("\n");
                free(data);
+               if (pager_output("\n"))
+                       break;
        }
+       pager_close();
 
        return (CMD_OK);
 }
@@ -761,9 +764,11 @@ efi_print_var(CHAR16 *varnamearg, EFI_GU
                return (CMD_ERROR);
        }
        uuid_to_string((uuid_t *)matchguid, &str, &uuid_status);
-       printf("%s %S=%S\n", str, varnamearg, data);
+       printf("%s %S=%S", str, varnamearg, data);
        free(str);
        free(data);
+       if (pager_output("\n"))
+               return (CMD_WARN);
        return (CMD_OK);
 }
 
@@ -783,7 +788,7 @@ command_efi_printenv(int argc, char *arg
         */
        /* XXX We assume EFI_GUID is the same as uuid_t */
        int             aflag = 0, gflag = 0, lflag = 0, vflag = 0;
-       int             ch;
+       int             ch, rv;
        unsigned        i;
        EFI_STATUS      status;
        EFI_GUID        varguid = { 0,0,0,{0,0,0,0,0,0,0,0} };
@@ -842,14 +847,19 @@ command_efi_printenv(int argc, char *arg
        argc -= optind;
        argv += optind;
 
-       if (vflag && gflag)
-               return efi_print_var(varnamearg, &matchguid, lflag);
+       pager_open();
+       if (vflag && gflag) {
+               rv = efi_print_var(varnamearg, &matchguid, lflag);
+               pager_close();
+               return (rv);
+       }
 
        if (argc == 2) {
                optarg = argv[0];
                if (strlen(optarg) >= nitems(varnamearg)) {
                        printf("Variable %s is longer than %zd characters\n",
                            optarg, nitems(varnamearg));
+                       pager_close();
                        return (CMD_ERROR);
                }
                for (i = 0; i < strlen(optarg); i++)
@@ -860,13 +870,17 @@ command_efi_printenv(int argc, char *arg
                    &uuid_status);
                if (uuid_status != uuid_s_ok) {
                        printf("uid %s could not be parsed\n", optarg);
+                       pager_close();
                        return (CMD_ERROR);
                }
-               return efi_print_var(varnamearg, &matchguid, lflag);
+               rv = efi_print_var(varnamearg, &matchguid, lflag);
+               pager_close();
+               return (rv);
        }
 
        if (argc != 0) {
                printf("Too many args\n");
+               pager_close();
                return (CMD_ERROR);
        }
 
@@ -882,19 +896,23 @@ command_efi_printenv(int argc, char *arg
                status = RS->GetNextVariableName(&varsz, varname,
                    &varguid);
                if (aflag) {
-                       efi_print_var(varname, &varguid, lflag);
+                       if (efi_print_var(varname, &varguid, lflag) != CMD_OK)
+                               break;
                        continue;
                }
                if (vflag) {
                        if (wcscmp(varnamearg, varname) == 0)
-                               efi_print_var(varname, &varguid, lflag);
+                               if (efi_print_var(varname, &varguid, lflag) != 
CMD_OK)
+                                       break;
                }
                if (gflag) {
                        if (memcmp(&varguid, &matchguid, sizeof(varguid)) == 0)
-                               efi_print_var(varname, &varguid, lflag);
+                               if (efi_print_var(varname, &varguid, lflag) != 
CMD_OK)
+                                       break;
                }
        }
-       
+       pager_close();
+
        return (CMD_OK);
 }
 

Modified: head/sys/boot/fdt/fdt_loader_cmd.c
==============================================================================
--- head/sys/boot/fdt/fdt_loader_cmd.c  Wed May 18 05:58:58 2016        
(r300116)
+++ head/sys/boot/fdt/fdt_loader_cmd.c  Wed May 18 05:59:05 2016        
(r300117)
@@ -970,40 +970,52 @@ fdt_cmd_hdr(int argc __unused, char *arg
        ver = fdt_version(fdtp);
        pager_open();
        sprintf(line, "\nFlattened device tree header (%p):\n", fdtp);
-       pager_output(line);
+       if (pager_output(line))
+               goto out;
        sprintf(line, " magic                   = 0x%08x\n", fdt_magic(fdtp));
-       pager_output(line);
+       if (pager_output(line))
+               goto out;
        sprintf(line, " size                    = %d\n", fdt_totalsize(fdtp));
-       pager_output(line);
+       if (pager_output(line))
+               goto out;
        sprintf(line, " off_dt_struct           = 0x%08x\n",
            fdt_off_dt_struct(fdtp));
-       pager_output(line);
+       if (pager_output(line))
+               goto out;
        sprintf(line, " off_dt_strings          = 0x%08x\n",
            fdt_off_dt_strings(fdtp));
-       pager_output(line);
+       if (pager_output(line))
+               goto out;
        sprintf(line, " off_mem_rsvmap          = 0x%08x\n",
            fdt_off_mem_rsvmap(fdtp));
-       pager_output(line);
+       if (pager_output(line))
+               goto out;
        sprintf(line, " version                 = %d\n", ver); 
-       pager_output(line);
+       if (pager_output(line))
+               goto out;
        sprintf(line, " last compatible version = %d\n",
            fdt_last_comp_version(fdtp));
-       pager_output(line);
+       if (pager_output(line))
+               goto out;
        if (ver >= 2) {
                sprintf(line, " boot_cpuid              = %d\n",
                    fdt_boot_cpuid_phys(fdtp));
-               pager_output(line);
+               if (pager_output(line))
+                       goto out;
        }
        if (ver >= 3) {
                sprintf(line, " size_dt_strings         = %d\n",
                    fdt_size_dt_strings(fdtp));
-               pager_output(line);
+               if (pager_output(line))
+                       goto out;
        }
        if (ver >= 17) {
                sprintf(line, " size_dt_struct          = %d\n",
                    fdt_size_dt_struct(fdtp));
-               pager_output(line);
+               if (pager_output(line))
+                       goto out;
        }
+out:
        pager_close();
 
        return (CMD_OK);
@@ -1678,15 +1690,18 @@ fdt_cmd_mres(int argc, char *argv[])
        pager_open();
        total = fdt_num_mem_rsv(fdtp);
        if (total > 0) {
-               pager_output("Reserved memory regions:\n");
+               if (pager_output("Reserved memory regions:\n"))
+                       goto out;
                for (i = 0; i < total; i++) {
                        fdt_get_mem_rsv(fdtp, i, &start, &size);
                        sprintf(line, "reg#%d: (start: 0x%jx, size: 0x%jx)\n", 
                            i, start, size);
-                       pager_output(line);
+                       if (pager_output(line))
+                               goto out;
                }
        } else
                pager_output("No reserved memory regions\n");
+out:
        pager_close();
 
        return (CMD_OK);

Modified: head/sys/boot/i386/libi386/bioscd.c
==============================================================================
--- head/sys/boot/i386/libi386/bioscd.c Wed May 18 05:58:58 2016        
(r300116)
+++ head/sys/boot/i386/libi386/bioscd.c Wed May 18 05:59:05 2016        
(r300117)
@@ -183,11 +183,14 @@ bc_print(int verbose)
        char line[80];
        int i;
 
+       pager_open();
        for (i = 0; i < nbcinfo; i++) {
                sprintf(line, "    cd%d: Device 0x%x\n", i,
                    bcinfo[i].bc_sp.sp_devicespec);
-               pager_output(line);
+               if (pager_output(line))
+                       break;
        }
+       pager_close();
 }
 
 /*

Modified: head/sys/boot/i386/libi386/biosdisk.c
==============================================================================
--- head/sys/boot/i386/libi386/biosdisk.c       Wed May 18 05:58:58 2016        
(r300116)
+++ head/sys/boot/i386/libi386/biosdisk.c       Wed May 18 05:59:05 2016        
(r300117)
@@ -313,11 +313,13 @@ bd_print(int verbose)
        struct disk_devdesc dev;
        int i;
 
+       pager_open();
        for (i = 0; i < nbdinfo; i++) {
                sprintf(line, "    disk%d:   BIOS drive %c:\n", i,
                    (bdinfo[i].bd_unit < 0x80) ? ('A' + bdinfo[i].bd_unit):
                    ('C' + bdinfo[i].bd_unit - 0x80));
-               pager_output(line);
+               if (pager_output(line))
+                       break;
                dev.d_dev = &biosdisk;
                dev.d_unit = i;
                dev.d_slice = -1;
@@ -332,6 +334,7 @@ bd_print(int verbose)
                        disk_close(&dev);
                }
        }
+       pager_close();
 }
 
 /*

Modified: head/sys/boot/pc98/libpc98/bioscd.c
==============================================================================
--- head/sys/boot/pc98/libpc98/bioscd.c Wed May 18 05:58:58 2016        
(r300116)
+++ head/sys/boot/pc98/libpc98/bioscd.c Wed May 18 05:59:05 2016        
(r300117)
@@ -179,11 +179,14 @@ bc_print(int verbose)
        char line[80];
        int i;
 
+       pager_open();
        for (i = 0; i < nbcinfo; i++) {
                sprintf(line, "    cd%d: Device 0x%x\n", i,
                    bcinfo[i].bc_sp.sp_devicespec);
-               pager_output(line);
+               if (pager_output(line))
+                       break;
        }
+       pager_close();
 }
 
 /*

Modified: head/sys/boot/pc98/libpc98/biosdisk.c
==============================================================================
--- head/sys/boot/pc98/libpc98/biosdisk.c       Wed May 18 05:58:58 2016        
(r300116)
+++ head/sys/boot/pc98/libpc98/biosdisk.c       Wed May 18 05:59:05 2016        
(r300117)
@@ -111,9 +111,9 @@ static int  bd_write(struct open_disk *od
 
 static int     bd_int13probe(struct bdinfo *bd);
 
-static void    bd_printslice(struct open_disk *od, struct pc98_partition *dp,
+static int     bd_printslice(struct open_disk *od, struct pc98_partition *dp,
                    char *prefix, int verbose);
-static void    bd_printbsdslice(struct open_disk *od, daddr_t offset,
+static int     bd_printbsdslice(struct open_disk *od, daddr_t offset,
                    char *prefix, int verbose);
 
 static int     bd_init(void);
@@ -252,15 +252,18 @@ bd_int13probe(struct bdinfo *bd)
 static void
 bd_print(int verbose)
 {
-    int                                i, j;
+    int                                i, j, done;
     char                       line[80];
     struct i386_devdesc                dev;
     struct open_disk           *od;
     struct pc98_partition      *dptr;
     
-    for (i = 0; i < nbdinfo; i++) {
+    pager_open();
+    done = 0;
+    for (i = 0; i < nbdinfo && !done; i++) {
        sprintf(line, "    disk%d:   BIOS drive %c:\n", i, 'A' + i);
-       pager_output(line);
+       if (pager_output(line))
+               break;
 
        /* try to open the whole disk */
        dev.d_unit = i;
@@ -276,12 +279,16 @@ 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);
-                   bd_printslice(od, &dptr[j], line, verbose);
+                   if (bd_printslice(od, &dptr[j], line, verbose)) {
+                           done = 1;
+                           break;
+                   }
                }
            }
            bd_closedisk(od);
        }
     }
+    pager_close();
 }
 
 /* Given a size in 512 byte sectors, convert it to a human-readable number. */
@@ -311,7 +318,7 @@ display_size(uint64_t size)
  * Print information about slices on a disk.  For the size calculations we
  * assume a 512 byte sector.
  */
-static void
+static int
 bd_printslice(struct open_disk *od, struct pc98_partition *dp, char *prefix,
        int verbose)
 {
@@ -331,10 +338,9 @@ bd_printslice(struct open_disk *od, stru
 
        switch(dp->dp_mid & PC98_MID_MASK) {
        case PC98_MID_386BSD:
-               bd_printbsdslice(od, start, prefix, verbose);
-               return;
+               return (bd_printbsdslice(od, start, prefix, verbose));
        case 0x00:                              /* unused partition */
-               return;
+               return (0);
        case 0x01:
                sprintf(line, "%s: FAT-12%s\n", prefix, stats);
                break;
@@ -350,14 +356,14 @@ bd_printslice(struct open_disk *od, stru
                sprintf(line, "%s: Unknown fs: 0x%x %s\n", prefix, dp->dp_mid,
                    stats);
        }
-       pager_output(line);
+       return (pager_output(line));
 }
 
 /*
  * Print out each valid partition in the disklabel of a FreeBSD slice.
  * For size calculations, we assume a 512 byte sector size.
  */
-static void
+static int
 bd_printbsdslice(struct open_disk *od, daddr_t offset, char *prefix,
     int verbose)
 {
@@ -368,12 +374,11 @@ bd_printbsdslice(struct open_disk *od, d
 
     /* read disklabel */
     if (bd_read(od, offset + LABELSECTOR, 1, buf))
-       return;
+        return (0);
     lp =(struct disklabel *)(&buf[0]);
     if (lp->d_magic != DISKMAGIC) {
        sprintf(line, "%s: FFS  bad disklabel\n", prefix);
-       pager_output(line);
-       return;
+       return (pager_output(line));
     }
     
     /* Print partitions */
@@ -404,9 +409,11 @@ bd_printbsdslice(struct open_disk *od, d
                    (lp->d_partitions[i].p_fstype == FS_SWAP) ? "swap" : 
                    (lp->d_partitions[i].p_fstype == FS_VINUM) ? "vinum" :
                    "FFS");
-           pager_output(line);
+           if (pager_output(line))
+                   return (1);
        }
     }
+    return (0);
 }
 
 

Modified: head/sys/boot/uboot/lib/disk.c
==============================================================================
--- head/sys/boot/uboot/lib/disk.c      Wed May 18 05:58:58 2016        
(r300116)
+++ head/sys/boot/uboot/lib/disk.c      Wed May 18 05:59:05 2016        
(r300117)
@@ -245,6 +245,7 @@ stor_print(int verbose)
        static char line[80];
        int i;
 
+       pager_open();
        for (i = 0; i < stor_info_no; i++) {
                dev.d_dev = &uboot_storage;
                dev.d_unit = i;
@@ -252,13 +253,15 @@ stor_print(int verbose)
                dev.d_partition = -1;
                sprintf(line, "\tdisk%d (%s)\n", i,
                    ub_stor_type(SI(&dev).type));
-               pager_output(line);
+               if (pager_output(line))
+                       break;
                if (stor_opendev(&dev) == 0) {
                        sprintf(line, "\tdisk%d", i);
                        disk_print(&dev, line, verbose);
                        disk_close(&dev);
                }
        }
+       pager_close();
 }
 
 static int

Modified: head/sys/boot/zfs/zfs.c
==============================================================================
--- head/sys/boot/zfs/zfs.c     Wed May 18 05:58:58 2016        (r300116)
+++ head/sys/boot/zfs/zfs.c     Wed May 18 05:59:05 2016        (r300117)
@@ -438,7 +438,7 @@ zfs_probe(int fd, uint64_t *pool_guid)
        return (ret);
 }
 
-static void
+static int
 zfs_probe_partition(void *arg, const char *partname,
     const struct ptable_entry *part)
 {
@@ -450,7 +450,7 @@ zfs_probe_partition(void *arg, const cha
        /* Probe only freebsd-zfs and freebsd partitions */
        if (part->type != PART_FREEBSD &&
            part->type != PART_FREEBSD_ZFS)
-               return;
+               return 0;
 
        ppa = (struct zfs_probe_args *)arg;
        strncpy(devname, ppa->devname, strlen(ppa->devname) - 1);
@@ -458,10 +458,10 @@ zfs_probe_partition(void *arg, const cha
        sprintf(devname, "%s%s:", devname, partname);
        pa.fd = open(devname, O_RDONLY);
        if (pa.fd == -1)
-               return;
+               return 0;
        ret = zfs_probe(pa.fd, ppa->pool_guid);
        if (ret == 0)
-               return;
+               return 0;
        /* Do we have BSD label here? */
        if (part->type == PART_FREEBSD) {
                pa.devname = devname;
@@ -470,11 +470,12 @@ zfs_probe_partition(void *arg, const cha
                table = ptable_open(&pa, part->end - part->start + 1,
                    ppa->secsz, zfs_diskread);
                if (table != NULL) {
-                       ptable_iterate(table, &pa, zfs_probe_partition);
+                       ret = ptable_iterate(table, &pa, zfs_probe_partition);
                        ptable_close(table);
                }
        }
        close(pa.fd);
+       return (ret);
 }
 
 int
@@ -893,4 +894,4 @@ zfs_set_env(void)
        }
 
        return (rv);
-}
\ No newline at end of file
+}
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to