Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146951012
D5461.id22076.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
28 KB
Referenced Files
None
Subscribers
None
D5461.id22076.diff
View Options
Index: head/lib/libstand/stand.h
===================================================================
--- head/lib/libstand/stand.h
+++ head/lib/libstand/stand.h
@@ -143,7 +143,7 @@
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);
};
Index: head/sys/boot/common/dev_net.c
===================================================================
--- head/sys/boot/common/dev_net.c
+++ head/sys/boot/common/dev_net.c
@@ -80,7 +80,7 @@
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,27 @@
return (0);
}
-static void
+static int
net_print(int verbose)
{
struct netif_driver *drv;
int i, d, cnt;
+ int ret = 0;
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)
+ 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);
}
/*
Index: head/sys/boot/common/module.c
===================================================================
--- head/sys/boot/common/module.c
+++ head/sys/boot/common/module.c
@@ -254,7 +254,7 @@
struct kernel_module *mp;
struct file_metadata *md;
char lbuf[80];
- int ch, verbose;
+ int ch, verbose, ret = 0;
verbose = 0;
optind = 1;
@@ -273,11 +273,13 @@
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);
@@ -287,7 +289,8 @@
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"))
@@ -296,11 +299,14 @@
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);
Index: head/sys/boot/common/part.c
===================================================================
--- head/sys/boot/common/part.c
+++ head/sys/boot/common/part.c
@@ -834,6 +834,7 @@
{
struct pentry *entry;
char name[32];
+ int ret = 0;
name[0] = '\0';
STAILQ_FOREACH(entry, &table->entries, entry) {
@@ -856,9 +857,8 @@
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);
}
-
Index: head/sys/boot/common/util.h
===================================================================
--- head/sys/boot/common/util.h
+++ head/sys/boot/common/util.h
@@ -48,6 +48,6 @@
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_ */
Index: head/sys/boot/common/util.c
===================================================================
--- head/sys/boot/common/util.c
+++ head/sys/boot/common/util.c
@@ -114,7 +114,7 @@
return (len);
}
-void
+int
printf(const char *fmt, ...)
{
va_list ap;
@@ -178,4 +178,5 @@
}
}
va_end(ap);
+ return (0);
}
Index: head/sys/boot/efi/libefi/efinet.c
===================================================================
--- head/sys/boot/efi/libefi/efinet.c
+++ head/sys/boot/efi/libefi/efinet.c
@@ -252,7 +252,7 @@
}
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,13 @@
return (0);
}
-static void
+static int
efinet_dev_print(int verbose)
{
CHAR16 *text;
EFI_HANDLE h;
- int unit;
+ int unit, ret = 0;
- pager_open();
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);
@@ -364,8 +363,8 @@
efi_free_devpath_name(text);
}
}
- if (pager_output("\n"))
+ if ((ret = pager_output("\n")) != 0)
break;
}
- pager_close();
+ return (ret);
}
Index: head/sys/boot/efi/libefi/efipart.c
===================================================================
--- head/sys/boot/efi/libefi/efipart.c
+++ head/sys/boot/efi/libefi/efipart.c
@@ -47,7 +47,7 @@
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",
@@ -162,7 +162,7 @@
return (err);
}
-static void
+static int
efipart_print(int verbose)
{
char line[80];
@@ -170,28 +170,29 @@
EFI_HANDLE h;
EFI_STATUS status;
u_int unit;
+ int ret = 0;
- 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);
- 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
Index: head/sys/boot/efi/loader/main.c
===================================================================
--- head/sys/boot/efi/loader/main.c
+++ head/sys/boot/efi/loader/main.c
@@ -533,6 +533,7 @@
UINT32 dver;
EFI_STATUS status;
int i, ndesc;
+ char line[80];
static char *types[] = {
"Reserved",
"LoaderCode",
@@ -564,14 +565,19 @@
}
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)
@@ -588,9 +594,11 @@
printf("RP ");
if (p->Attribute & EFI_MEMORY_XP)
printf("XP ");
- printf("\n");
+ if (pager_output("\n"))
+ break;
}
+ pager_close();
return (CMD_OK);
}
@@ -612,10 +620,17 @@
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;
@@ -642,9 +657,13 @@
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);
}
Index: head/sys/boot/i386/libfirewire/firewire.c
===================================================================
--- head/sys/boot/i386/libfirewire/firewire.c
+++ head/sys/boot/i386/libfirewire/firewire.c
@@ -69,7 +69,7 @@
size_t offset, 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,26 @@
/*
* 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;
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
Index: head/sys/boot/i386/libi386/bioscd.c
===================================================================
--- head/sys/boot/i386/libi386/bioscd.c
+++ head/sys/boot/i386/libi386/bioscd.c
@@ -100,7 +100,7 @@
size_t offset, 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,19 @@
/*
* Print information about disks
*/
-static void
+static int
bc_print(int verbose)
{
char line[80];
- int i;
+ int i, ret = 0;
- pager_open();
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);
}
/*
Index: head/sys/boot/i386/libi386/biosdisk.c
===================================================================
--- head/sys/boot/i386/libi386/biosdisk.c
+++ head/sys/boot/i386/libi386/biosdisk.c
@@ -135,7 +135,7 @@
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
@@ -321,21 +321,21 @@
/*
* 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();
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;
@@ -346,12 +346,14 @@
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);
}
/*
Index: head/sys/boot/i386/libi386/pxe.c
===================================================================
--- head/sys/boot/i386/libi386/pxe.c
+++ head/sys/boot/i386/libi386/pxe.c
@@ -75,7 +75,7 @@
size_t offset, 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);
@@ -381,14 +381,20 @@
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);
+ 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
Index: head/sys/boot/mips/beri/loader/beri_disk_cfi.c
===================================================================
--- head/sys/boot/mips/beri/loader/beri_disk_cfi.c
+++ head/sys/boot/mips/beri/loader/beri_disk_cfi.c
@@ -47,7 +47,7 @@
static void beri_cfi_disk_cleanup(void);
static int beri_cfi_disk_strategy(void *, int, daddr_t, size_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,29 @@
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);
+ 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
Index: head/sys/boot/mips/beri/loader/beri_disk_sdcard.c
===================================================================
--- head/sys/boot/mips/beri/loader/beri_disk_sdcard.c
+++ head/sys/boot/mips/beri/loader/beri_disk_sdcard.c
@@ -47,7 +47,7 @@
static void beri_sdcard_disk_cleanup(void);
static int beri_sdcard_disk_strategy(void *, int, daddr_t, size_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,23 @@
{
struct disk_devdesc dev;
char line[80];
+ int ret;
- sprintf(line, " sdcard%d Altera SD card drive\n", 0);
- pager_output(line);
+ 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
Index: head/sys/boot/ofw/libofw/ofw_disk.c
===================================================================
--- head/sys/boot/ofw/libofw/ofw_disk.c
+++ head/sys/boot/ofw/libofw/ofw_disk.c
@@ -47,7 +47,7 @@
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 @@
return (EINVAL);
}
-static void
+static int
ofwd_print(int verbose __unused)
{
-
+ return (0);
}
Index: head/sys/boot/pc98/libpc98/bioscd.c
===================================================================
--- head/sys/boot/pc98/libpc98/bioscd.c
+++ head/sys/boot/pc98/libpc98/bioscd.c
@@ -99,7 +99,7 @@
size_t offset, 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,19 @@
/*
* Print information about disks
*/
-static void
+static int
bc_print(int verbose)
{
char line[80];
- int i;
+ int i, ret = 0;
- pager_open();
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);
}
/*
Index: head/sys/boot/pc98/libpc98/biosdisk.c
===================================================================
--- head/sys/boot/pc98/libpc98/biosdisk.c
+++ head/sys/boot/pc98/libpc98/biosdisk.c
@@ -123,7 +123,7 @@
size_t offset, 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,21 +249,20 @@
/*
* 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;
+ 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;
@@ -278,17 +277,17 @@
/* 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. */
Index: head/sys/boot/powerpc/kboot/hostdisk.c
===================================================================
--- head/sys/boot/powerpc/kboot/hostdisk.c
+++ head/sys/boot/powerpc/kboot/hostdisk.c
@@ -37,7 +37,7 @@
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 @@
return (EINVAL);
}
-static void
+static int
hostdisk_print(int verbose)
{
-
+ return (0);
}
Index: head/sys/boot/powerpc/ps3/ps3cdrom.c
===================================================================
--- head/sys/boot/powerpc/ps3/ps3cdrom.c
+++ head/sys/boot/powerpc/ps3/ps3cdrom.c
@@ -49,7 +49,7 @@
size_t offset, 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 @@
return 0;
}
-static void ps3cdrom_print(int verbose)
+static int ps3cdrom_print(int verbose)
{
+ return (0);
}
Index: head/sys/boot/powerpc/ps3/ps3disk.c
===================================================================
--- head/sys/boot/powerpc/ps3/ps3disk.c
+++ head/sys/boot/powerpc/ps3/ps3disk.c
@@ -61,7 +61,7 @@
size_t offset, 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 @@
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)
Index: head/sys/boot/uboot/lib/disk.c
===================================================================
--- head/sys/boot/uboot/lib/disk.c
+++ head/sys/boot/uboot/lib/disk.c
@@ -78,7 +78,7 @@
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 = {
@@ -238,30 +238,31 @@
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();
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
Index: head/sys/boot/usb/storage/umass_loader.c
===================================================================
--- head/sys/boot/usb/storage/umass_loader.c
+++ head/sys/boot/usb/storage/umass_loader.c
@@ -50,7 +50,7 @@
static int umass_disk_ioctl(struct open_file *, u_long, void *);
static int umass_disk_strategy(void *, int, daddr_t, size_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",
@@ -170,23 +170,26 @@
return (disk_close(dev));
}
-static void
+static int
umass_disk_print(int verbose)
{
struct disk_devdesc dev;
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
Index: head/sys/boot/userboot/userboot/host.c
===================================================================
--- head/sys/boot/userboot/userboot/host.c
+++ head/sys/boot/userboot/userboot/host.c
@@ -134,13 +134,13 @@
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);
+ snprintf(line, sizeof(line), " host%d: Host filesystem\n", 0);
+ return (pager_output(line));
}
/*
Index: head/sys/boot/userboot/userboot/userboot_disk.c
===================================================================
--- head/sys/boot/userboot/userboot/userboot_disk.c
+++ head/sys/boot/userboot/userboot/userboot_disk.c
@@ -60,7 +60,7 @@
static int userdisk_open(struct open_file *f, ...);
static int userdisk_close(struct open_file *f);
static int userdisk_ioctl(struct open_file *f, u_long cmd, void *data);
-static void userdisk_print(int verbose);
+static int userdisk_print(int verbose);
struct devsw userboot_disk = {
"disk",
@@ -116,27 +116,33 @@
/*
* Print information about disks
*/
-static void
+static int
userdisk_print(int verbose)
{
struct disk_devdesc dev;
char line[80];
- int i;
+ int i, ret = 0;
for (i = 0; i < userdisk_maxunit; i++) {
- sprintf(line, " disk%d: Guest drive image\n", i);
- pager_output(line);
+ snprintf(line, sizeof(line),
+ " disk%d: Guest drive image\n", i);
+ ret = pager_output(line);
+ if (ret != 0)
+ break;
dev.d_dev = &userboot_disk;
dev.d_unit = i;
dev.d_slice = -1;
dev.d_partition = -1;
if (disk_open(&dev, ud_info[i].mediasize,
ud_info[i].sectorsize, 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)
+ break;
}
}
+ return (ret);
}
/*
Index: head/sys/boot/zfs/zfs.c
===================================================================
--- head/sys/boot/zfs/zfs.c
+++ head/sys/boot/zfs/zfs.c
@@ -514,20 +514,23 @@
/*
* Print information about ZFS pools
*/
-static void
+static int
zfs_dev_print(int verbose)
{
spa_t *spa;
char line[80];
+ int ret = 0;
if (verbose) {
- spa_all_status();
- return;
+ return (spa_all_status());
}
STAILQ_FOREACH(spa, &zfs_pools, spa_link) {
- sprintf(line, " zfs:%s\n", spa->spa_name);
- pager_output(line);
+ snprintf(line, sizeof(line), " zfs:%s\n", spa->spa_name);
+ ret = pager_output(line);
+ if (ret != 0)
+ break;
}
+ return (ret);
}
/*
Index: head/sys/boot/zfs/zfsimpl.c
===================================================================
--- head/sys/boot/zfs/zfsimpl.c
+++ head/sys/boot/zfs/zfsimpl.c
@@ -780,7 +780,7 @@
#else
-static void
+static int
pager_printf(const char *fmt, ...)
{
char line[80];
@@ -789,14 +789,14 @@
va_start(args, fmt);
vsprintf(line, fmt, args);
va_end(args);
- pager_output(line);
+ return (pager_output(line));
}
#endif
#define STATUS_FORMAT " %s %s\n"
-static void
+static int
print_state(int indent, const char *name, vdev_state_t state)
{
int i;
@@ -806,40 +806,56 @@
for (i = 0; i < indent; i++)
strcat(buf, " ");
strcat(buf, name);
- pager_printf(STATUS_FORMAT, buf, state_name(state));
+ return (pager_printf(STATUS_FORMAT, buf, state_name(state)));
}
-static void
+static int
vdev_status(vdev_t *vdev, int indent)
{
vdev_t *kid;
- print_state(indent, vdev->v_name, vdev->v_state);
+ int ret;
+ ret = print_state(indent, vdev->v_name, vdev->v_state);
+ if (ret != 0)
+ return (ret);
STAILQ_FOREACH(kid, &vdev->v_children, v_childlink) {
- vdev_status(kid, indent + 1);
+ ret = vdev_status(kid, indent + 1);
+ if (ret != 0)
+ return (ret);
}
+ return (ret);
}
-static void
+static int
spa_status(spa_t *spa)
{
static char bootfs[ZFS_MAXNAMELEN];
uint64_t rootid;
vdev_t *vdev;
- int good_kids, bad_kids, degraded_kids;
+ int good_kids, bad_kids, degraded_kids, ret;
vdev_state_t state;
- pager_printf(" pool: %s\n", spa->spa_name);
+ ret = pager_printf(" pool: %s\n", spa->spa_name);
+ if (ret != 0)
+ return (ret);
+
if (zfs_get_root(spa, &rootid) == 0 &&
zfs_rlookup(spa, rootid, bootfs) == 0) {
if (bootfs[0] == '\0')
- pager_printf("bootfs: %s\n", spa->spa_name);
+ ret = pager_printf("bootfs: %s\n", spa->spa_name);
else
- pager_printf("bootfs: %s/%s\n", spa->spa_name, bootfs);
- }
- pager_printf("config:\n\n");
- pager_printf(STATUS_FORMAT, "NAME", "STATE");
+ ret = pager_printf("bootfs: %s/%s\n", spa->spa_name,
+ bootfs);
+ if (ret != 0)
+ return (ret);
+ }
+ ret = pager_printf("config:\n\n");
+ if (ret != 0)
+ return (ret);
+ ret = pager_printf(STATUS_FORMAT, "NAME", "STATE");
+ if (ret != 0)
+ return (ret);
good_kids = 0;
degraded_kids = 0;
@@ -859,24 +875,35 @@
else if ((good_kids + degraded_kids) > 0)
state = VDEV_STATE_DEGRADED;
- print_state(0, spa->spa_name, state);
+ ret = print_state(0, spa->spa_name, state);
+ if (ret != 0)
+ return (ret);
STAILQ_FOREACH(vdev, &spa->spa_vdevs, v_childlink) {
- vdev_status(vdev, 1);
+ ret = vdev_status(vdev, 1);
+ if (ret != 0)
+ return (ret);
}
+ return (ret);
}
-static void
+static int
spa_all_status(void)
{
spa_t *spa;
- int first = 1;
+ int first = 1, ret = 0;
STAILQ_FOREACH(spa, &zfs_pools, spa_link) {
- if (!first)
- pager_printf("\n");
+ if (!first) {
+ ret = pager_printf("\n");
+ if (ret != 0)
+ return (ret);
+ }
first = 0;
- spa_status(spa);
+ ret = spa_status(spa);
+ if (ret != 0)
+ return (ret);
}
+ return (ret);
}
static int
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 8, 1:35 AM (5 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29374623
Default Alt Text
D5461.id22076.diff (28 KB)
Attached To
Mode
D5461: Paged/pageable data is not always paged.
Attached
Detach File
Event Timeline
Log In to Comment