summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2018-05-17 11:22:36 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2018-05-17 11:22:36 +0000
commit2df613f7b7aa3978e80f8e63f228b7ed64ea5d5a (patch)
treee3c0ebb2f4afe40ab202d7595e0cc852bcb1a750
parent1c2625a53ebd46792e9152ddddeb63a52c03b3a2 (diff)
parent5250bfb8bce969e3b3bfc3c0b9d4d7f32896031e (diff)
downloadillumos-joyent-2df613f7b7aa3978e80f8e63f228b7ed64ea5d5a.tar.gz
[illumos-gate merge]
commit 5250bfb8bce969e3b3bfc3c0b9d4d7f32896031e 9528 Loader man pages should only be installed for x86 commit 804635d7bfa86d5f677fada06cb30420313f1159 9511 printf family isn't aware of multibyte decimal point characters commit 4540c8e2f029ecd3f040b27b7489b1c9f2d920c0 9503 libefi now depends on libsmbios commit 0a4f1df16f07808514bc5838bc55709f93f9e93e 9476 loader: Don't leak memory when displaying help. 9480 loader: commands.c should only use snprintf 9481 loader: commands.c use __unused commit c7a0678d54bbc87f507a8909a193f75cbb463ede 9374 svr4pkg: comparison between pointer and zero character constant commit a5f0d1fc79d4435b41cb64c37207978b97d8146b 9358 svc: this statement may fall through commit 911abd25cb2923fb6c6e6aeef37f833c16598ca7 9277 libefi: remove unused routines commit 76b35943c866f9d879ff5fc7e6fab17bef2b3402 9275 loader: Use the actual struct devdesc at the start of all *_devdesc structs
-rw-r--r--usr/src/boot/sys/boot/common/commands.c45
-rw-r--r--usr/src/boot/sys/boot/common/disk.c30
-rw-r--r--usr/src/boot/sys/boot/common/disk.h5
-rw-r--r--usr/src/boot/sys/boot/efi/libefi/efipart.c14
-rw-r--r--usr/src/boot/sys/boot/efi/libefi/efizfs.c1
-rw-r--r--usr/src/boot/sys/boot/efi/libefi/env.c51
-rw-r--r--usr/src/boot/sys/boot/efi/loader/main.c12
-rw-r--r--usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c20
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/bioscd.c8
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/biosdisk.c33
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/bootinfo32.c14
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/devicename.c12
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/libi386.h14
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/linux.c2
-rw-r--r--usr/src/boot/sys/boot/i386/loader/chain.c2
-rw-r--r--usr/src/boot/sys/boot/i386/loader/main.c27
-rw-r--r--usr/src/boot/sys/boot/ofw/libofw/devicename.c9
-rw-r--r--usr/src/boot/sys/boot/ofw/libofw/libofw.h12
-rw-r--r--usr/src/boot/sys/boot/sparc64/loader/main.c8
-rw-r--r--usr/src/boot/sys/boot/uboot/common/main.c24
-rw-r--r--usr/src/boot/sys/boot/uboot/lib/devicename.c13
-rw-r--r--usr/src/boot/sys/boot/uboot/lib/disk.c13
-rw-r--r--usr/src/boot/sys/boot/uboot/lib/libuboot.h7
-rw-r--r--usr/src/boot/sys/boot/userboot/userboot/devicename.c17
-rw-r--r--usr/src/boot/sys/boot/userboot/userboot/main.c26
-rw-r--r--usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c43
-rw-r--r--usr/src/boot/sys/boot/zfs/libzfs.h5
-rw-r--r--usr/src/boot/sys/boot/zfs/zfs.c12
-rw-r--r--usr/src/cmd/svc/svccfg/svccfg_xml.c3
-rw-r--r--usr/src/cmd/svc/svcprop/svcprop.c19
-rw-r--r--usr/src/cmd/svc/svcs/svcs.c15
-rw-r--r--usr/src/cmd/svr4pkg/libinst/pkgops.c6
-rw-r--r--usr/src/cmd/svr4pkg/pkgcond/main.c4
-rw-r--r--usr/src/common/ficl/emu/loader_emu.c47
-rw-r--r--usr/src/lib/Makefile2
-rw-r--r--usr/src/lib/libc/port/print/doprnt.c46
-rw-r--r--usr/src/man/man4/Makefile5
-rw-r--r--usr/src/man/man5/Makefile32
-rw-r--r--usr/src/pkg/manifests/system-test-libctest.mf3
-rw-r--r--usr/src/test/libc-tests/doc/README10
-rw-r--r--usr/src/test/libc-tests/runfiles/default.run2
-rw-r--r--usr/src/test/libc-tests/tests/Makefile1
-rw-r--r--usr/src/test/libc-tests/tests/printf-9511.c70
43 files changed, 409 insertions, 335 deletions
diff --git a/usr/src/boot/sys/boot/common/commands.c b/usr/src/boot/sys/boot/common/commands.c
index 65941a2f2b..942e6d09fb 100644
--- a/usr/src/boot/sys/boot/common/commands.c
+++ b/usr/src/boot/sys/boot/common/commands.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* All rights reserved.
*
@@ -25,7 +25,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#include <stand.h>
#include <string.h>
@@ -64,7 +63,9 @@ static int
help_getnext(int fd, char **topic, char **subtopic, char **desc)
{
char line[81], *cp, *ep;
-
+
+ /* Make sure we provide sane values. */
+ *topic = *subtopic = *desc = NULL;
for (;;) {
if (fgetstr(line, 80, fd) < 0)
return(0);
@@ -72,9 +73,8 @@ help_getnext(int fd, char **topic, char **subtopic, char **desc)
if ((strlen(line) < 3) || (line[0] != '#') || (line[1] != ' '))
continue;
- *topic = *subtopic = *desc = NULL;
cp = line + 2;
- while((cp != NULL) && (*cp != 0)) {
+ while ((cp != NULL) && (*cp != 0)) {
ep = strchr(cp, ' ');
if ((*cp == 'T') && (*topic == NULL)) {
if (ep != NULL)
@@ -91,11 +91,10 @@ help_getnext(int fd, char **topic, char **subtopic, char **desc)
cp = ep;
}
if (*topic == NULL) {
- if (*subtopic != NULL)
free(*subtopic);
- if (*desc != NULL)
free(*desc);
- continue;
+ *subtopic = *desc = NULL;
+ continue;
}
return(1);
}
@@ -132,7 +131,7 @@ command_help(int argc, char *argv[])
char *topic, *subtopic, *t, *s, *d;
/* page the help text from our load path */
- sprintf(buf, "%s/boot/loader.help", getenv("loaddev"));
+ snprintf(buf, sizeof (buf), "%s/boot/loader.help", getenv("loaddev"));
if ((hfd = open(buf, O_RDONLY)) < 0) {
printf("Verbose help not available, use '?' to list commands\n");
return(CMD_OK);
@@ -161,7 +160,7 @@ command_help(int argc, char *argv[])
/* Scan the helpfile looking for help matching the request */
pager_open();
- while(help_getnext(hfd, &t, &s, &d)) {
+ while (help_getnext(hfd, &t, &s, &d)) {
if (doindex) { /* dink around formatting */
if (help_emitsummary(t, s, d))
@@ -169,7 +168,7 @@ command_help(int argc, char *argv[])
} else if (strcmp(topic, t)) {
/* topic mismatch */
- if(matched) /* nothing more on this topic, stop scanning */
+ if (matched) /* nothing more on this topic, stop scanning */
break;
} else {
@@ -178,7 +177,7 @@ command_help(int argc, char *argv[])
if (((subtopic == NULL) && (s == NULL)) ||
((subtopic != NULL) && (s != NULL) && !strcmp(subtopic, s))) {
/* exact match, print text */
- while((fgetstr(buf, 80, hfd) >= 0) && (buf[0] != '#')) {
+ while ((fgetstr(buf, 80, hfd) >= 0) && (buf[0] != '#')) {
if (pager_output(buf))
break;
if (pager_output("\n"))
@@ -193,29 +192,29 @@ command_help(int argc, char *argv[])
free(t);
free(s);
free(d);
+ t = s = d = NULL;
}
+ free(t);
+ free(s);
+ free(d);
pager_close();
close(hfd);
if (!matched) {
snprintf(command_errbuf, sizeof (command_errbuf),
"no help available for '%s'", topic);
free(topic);
- if (subtopic)
- free(subtopic);
+ free(subtopic);
return(CMD_ERROR);
}
free(topic);
- if (subtopic)
- free(subtopic);
+ free(subtopic);
return(CMD_OK);
}
-
COMMAND_SET(commandlist, "?", "list commands", command_commandlist);
static int
-command_commandlist(int argc __attribute((unused)),
- char *argv[] __attribute((unused)))
+command_commandlist(int argc __unused, char *argv[] __unused)
{
struct bootblk_command **cmdp;
int res;
@@ -228,7 +227,7 @@ command_commandlist(int argc __attribute((unused)),
if (res)
break;
if (((*cmdp)->c_name != NULL) && ((*cmdp)->c_desc != NULL)) {
- sprintf(name, " %-15s ", (*cmdp)->c_name);
+ snprintf(name, sizeof (name), " %-15s ", (*cmdp)->c_name);
pager_output(name);
pager_output((*cmdp)->c_desc);
res = pager_output("\n");
@@ -446,12 +445,12 @@ command_more(int argc, char *argv[])
res=0;
pager_open();
for (i = 1; (i < argc) && (res == 0); i++) {
- sprintf(line, "*** FILE %s BEGIN ***\n", argv[i]);
+ snprintf(line, sizeof (line), "*** FILE %s BEGIN ***\n", argv[i]);
if (pager_output(line))
break;
res = page_file(argv[i]);
if (!res) {
- sprintf(line, "*** FILE %s END ***\n", argv[i]);
+ snprintf(line, sizeof (line), "*** FILE %s END ***\n", argv[i]);
res = pager_output(line);
}
}
@@ -512,7 +511,7 @@ command_lsdev(int argc, char *argv[])
if (devsw[i]->dv_print(verbose))
break;
} else {
- sprintf(line, "%s: (unknown)\n", devsw[i]->dv_name);
+ snprintf(line, sizeof (line), "%s: (unknown)\n", devsw[i]->dv_name);
if (pager_output(line))
break;
}
diff --git a/usr/src/boot/sys/boot/common/disk.c b/usr/src/boot/sys/boot/common/disk.c
index e45cb93905..2b89274473 100644
--- a/usr/src/boot/sys/boot/common/disk.c
+++ b/usr/src/boot/sys/boot/common/disk.c
@@ -84,7 +84,7 @@ ptblread(void *d, void *buf, size_t blocks, uint64_t offset)
struct open_disk *od;
dev = (struct disk_devdesc *)d;
- od = (struct open_disk *)dev->d_opendata;
+ od = (struct open_disk *)dev->dd.d_opendata;
/*
* The strategy function assumes the offset is in units of 512 byte
@@ -96,7 +96,7 @@ ptblread(void *d, void *buf, size_t blocks, uint64_t offset)
* As the GPT backup partition is located at the end of the disk,
* to avoid reading past disk end, flag bcache not to use RA.
*/
- return (dev->d_dev->dv_strategy(dev, F_READ | F_NORA , offset,
+ return (dev->dd.d_dev->dv_strategy(dev, F_READ | F_NORA , offset,
blocks * od->sectorsize, (char *)buf, NULL));
}
@@ -112,7 +112,7 @@ ptable_print(void *arg, const char *pname, const struct ptable_entry *part)
int ret = 0;
pa = (struct print_args *)arg;
- od = (struct open_disk *)pa->dev->d_opendata;
+ od = (struct open_disk *)pa->dev->dd.d_opendata;
sprintf(line, " %s%s: %s", pa->prefix, pname,
parttype2str(part->type));
if (pa->verbose)
@@ -125,8 +125,8 @@ ptable_print(void *arg, const char *pname, const struct ptable_entry *part)
return (ret);
if (part->type == PART_FREEBSD || part->type == PART_SOLARIS2) {
/* Open slice with BSD or VTOC label */
- dev.d_dev = pa->dev->d_dev;
- dev.d_unit = pa->dev->d_unit;
+ dev.dd.d_dev = pa->dev->dd.d_dev;
+ dev.dd.d_unit = pa->dev->dd.d_unit;
dev.d_slice = part->index;
dev.d_partition = -1;
if (disk_open(&dev, part->end - part->start + 1,
@@ -162,7 +162,7 @@ disk_print(struct disk_devdesc *dev, char *prefix, int verbose)
struct print_args pa;
/* Disk should be opened */
- od = (struct open_disk *)dev->d_opendata;
+ od = (struct open_disk *)dev->dd.d_opendata;
pa.dev = dev;
pa.prefix = prefix;
pa.verbose = verbose;
@@ -175,8 +175,8 @@ disk_read(struct disk_devdesc *dev, void *buf, uint64_t offset, u_int blocks)
struct open_disk *od;
int ret;
- od = (struct open_disk *)dev->d_opendata;
- ret = dev->d_dev->dv_strategy(dev, F_READ, dev->d_offset + offset,
+ od = (struct open_disk *)dev->dd.d_opendata;
+ ret = dev->dd.d_dev->dv_strategy(dev, F_READ, dev->d_offset + offset,
blocks * od->sectorsize, buf, NULL);
return (ret);
@@ -188,8 +188,8 @@ disk_write(struct disk_devdesc *dev, void *buf, uint64_t offset, u_int blocks)
struct open_disk *od;
int ret;
- od = (struct open_disk *)dev->d_opendata;
- ret = dev->d_dev->dv_strategy(dev, F_WRITE, dev->d_offset + offset,
+ od = (struct open_disk *)dev->dd.d_opendata;
+ ret = dev->dd.d_dev->dv_strategy(dev, F_WRITE, dev->d_offset + offset,
blocks * od->sectorsize, buf, NULL);
return (ret);
@@ -198,7 +198,7 @@ disk_write(struct disk_devdesc *dev, void *buf, uint64_t offset, u_int blocks)
int
disk_ioctl(struct disk_devdesc *dev, u_long cmd, void *data)
{
- struct open_disk *od = dev->d_opendata;
+ struct open_disk *od = dev->dd.d_opendata;
if (od == NULL)
return (ENOTTY);
@@ -242,7 +242,7 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize, u_int sectorsize)
DEBUG("no memory");
return (ENOMEM);
}
- dev->d_opendata = od;
+ dev->dd.d_opendata = od;
od->entrysize = 0;
od->mediasize = mediasize;
od->sectorsize = sectorsize;
@@ -353,7 +353,7 @@ disk_close(struct disk_devdesc *dev)
{
struct open_disk *od;
- od = (struct open_disk *)dev->d_opendata;
+ od = (struct open_disk *)dev->dd.d_opendata;
DEBUG("%s closed => %p", disk_fmtdev(dev), od);
ptable_close(od->table);
free(od);
@@ -366,7 +366,7 @@ disk_fmtdev(struct disk_devdesc *dev)
static char buf[128];
char *cp;
- cp = buf + sprintf(buf, "%s%d", dev->d_dev->dv_name, dev->d_unit);
+ cp = buf + sprintf(buf, "%s%d", dev->dd.d_dev->dv_name, dev->dd.d_unit);
if (dev->d_slice >= 0) {
#ifdef LOADER_GPT_SUPPORT
if (dev->d_partition == 255) {
@@ -428,7 +428,7 @@ disk_parsedev(struct disk_devdesc *dev, const char *devspec, const char **path)
if (*cp != '\0' && *cp != ':')
return (EINVAL);
- dev->d_unit = unit;
+ dev->dd.d_unit = unit;
dev->d_slice = slice;
dev->d_partition = partition;
if (path != NULL)
diff --git a/usr/src/boot/sys/boot/common/disk.h b/usr/src/boot/sys/boot/common/disk.h
index 0de50a1763..b833dce2a7 100644
--- a/usr/src/boot/sys/boot/common/disk.h
+++ b/usr/src/boot/sys/boot/common/disk.h
@@ -86,10 +86,7 @@
/* Note: Must match the 'struct devdesc' in stand.h */
struct disk_devdesc {
- struct devsw *d_dev;
- int d_type;
- int d_unit;
- void *d_opendata;
+ struct devdesc dd;
int d_slice;
int d_partition;
uint64_t d_offset;
diff --git a/usr/src/boot/sys/boot/efi/libefi/efipart.c b/usr/src/boot/sys/boot/efi/libefi/efipart.c
index 86545cbab2..e272f5db6f 100644
--- a/usr/src/boot/sys/boot/efi/libefi/efipart.c
+++ b/usr/src/boot/sys/boot/efi/libefi/efipart.c
@@ -743,8 +743,8 @@ efipart_print_common(struct devsw *dev, pdinfo_list_t *pdlist, int verbose)
continue;
pd->pd_blkio = blkio;
- pd_dev.d_dev = dev;
- pd_dev.d_unit = pd->pd_unit;
+ pd_dev.dd.d_dev = dev;
+ pd_dev.dd.d_unit = pd->pd_unit;
pd_dev.d_slice = -1;
pd_dev.d_partition = -1;
ret = disk_open(&pd_dev, blkio->Media->BlockSize *
@@ -819,7 +819,7 @@ efipart_open(struct open_file *f, ...)
if (pd->pd_bcache == NULL)
pd->pd_bcache = bcache_allocate();
- if (dev->d_dev->dv_type == DEVT_DISK) {
+ if (dev->dd.d_dev->dv_type == DEVT_DISK) {
int rc;
rc = disk_open(dev,
@@ -858,7 +858,7 @@ efipart_close(struct open_file *f)
bcache_free(pd->pd_bcache);
pd->pd_bcache = NULL;
}
- if (dev->d_dev->dv_type == DEVT_DISK)
+ if (dev->dd.d_dev->dv_type == DEVT_DISK)
return (disk_close(dev));
return (0);
}
@@ -878,7 +878,7 @@ efipart_ioctl(struct open_file *f, u_long cmd, void *data)
if (pd == NULL)
return (EINVAL);
- if (dev->d_dev->dv_type == DEVT_DISK) {
+ if (dev->dd.d_dev->dv_type == DEVT_DISK) {
rc = disk_ioctl(dev, cmd, data);
if (rc != ENOTTY)
return (rc);
@@ -965,7 +965,7 @@ efipart_strategy(void *devdata, int rw, daddr_t blk, size_t size,
bcd.dv_devdata = devdata;
bcd.dv_cache = pd->pd_bcache;
- if (dev->d_dev->dv_type == DEVT_DISK) {
+ if (dev->dd.d_dev->dv_type == DEVT_DISK) {
daddr_t offset;
offset = dev->d_offset * pd->pd_blkio->Media->BlockSize;
@@ -1009,7 +1009,7 @@ efipart_realstrategy(void *devdata, int rw, daddr_t blk, size_t size,
* partition.
*/
disk_blocks = 0;
- if (dev->d_dev->dv_type == DEVT_DISK) {
+ if (dev->dd.d_dev->dv_type == DEVT_DISK) {
if (disk_ioctl(dev, DIOCGMEDIASIZE, &disk_blocks) == 0) {
/* DIOCGMEDIASIZE does return bytes. */
disk_blocks /= blkio->Media->BlockSize;
diff --git a/usr/src/boot/sys/boot/efi/libefi/efizfs.c b/usr/src/boot/sys/boot/efi/libefi/efizfs.c
index f60249221f..5826ff52ec 100644
--- a/usr/src/boot/sys/boot/efi/libefi/efizfs.c
+++ b/usr/src/boot/sys/boot/efi/libefi/efizfs.c
@@ -29,6 +29,7 @@
#include <sys/param.h>
#include <sys/disk.h>
+#include <stand.h>
#include <libzfs.h>
diff --git a/usr/src/boot/sys/boot/efi/libefi/env.c b/usr/src/boot/sys/boot/efi/libefi/env.c
index bd92324021..663d343bf3 100644
--- a/usr/src/boot/sys/boot/efi/libefi/env.c
+++ b/usr/src/boot/sys/boot/efi/libefi/env.c
@@ -312,35 +312,6 @@ efi_guid_to_name(EFI_GUID *guid, char **name)
return (efi_guid_to_str(guid, name));
}
-/*
- * Simple wrappers to the underlying UEFI functions.
- * See http://wiki.phoenix.com/wiki/index.php/EFI_RUNTIME_SERVICES
- * for details.
- */
-EFI_STATUS
-efi_get_next_variable_name(UINTN *variable_name_size, CHAR16 *variable_name,
- EFI_GUID *vendor_guid)
-{
- return (RS->GetNextVariableName(variable_name_size, variable_name,
- vendor_guid));
-}
-
-EFI_STATUS
-efi_get_variable(CHAR16 *variable_name, EFI_GUID *vendor_guid,
- UINT32 *attributes, UINTN *data_size, void *data)
-{
- return (RS->GetVariable(variable_name, vendor_guid, attributes,
- data_size, data));
-}
-
-EFI_STATUS
-efi_set_variable(CHAR16 *variable_name, EFI_GUID *vendor_guid,
- UINT32 attributes, UINTN data_size, void *data)
-{
- return (RS->SetVariable(variable_name, vendor_guid, attributes,
- data_size, data));
-}
-
void
efi_init_environment(void)
{
@@ -665,7 +636,7 @@ efi_print_var(CHAR16 *varnamearg, EFI_GUID *matchguid, int lflag)
str = NULL;
datasz = 0;
- status = efi_get_variable(varnamearg, matchguid, &attr, &datasz, NULL);
+ status = RS->GetVariable(varnamearg, matchguid, &attr, &datasz, NULL);
if (status != EFI_BUFFER_TOO_SMALL) {
printf("Can't get the variable: error %#lx\n",
EFI_ERROR_CODE(status));
@@ -677,7 +648,7 @@ efi_print_var(CHAR16 *varnamearg, EFI_GUID *matchguid, int lflag)
return (CMD_ERROR);
}
- status = efi_get_variable(varnamearg, matchguid, &attr, &datasz, data);
+ status = RS->GetVariable(varnamearg, matchguid, &attr, &datasz, data);
if (status != EFI_SUCCESS) {
printf("Can't get the variable: error %#lx\n",
EFI_ERROR_CODE(status));
@@ -849,7 +820,7 @@ command_efi_show(int argc, char *argv[])
varname[0] = 0;
while (1) {
varsz = varalloc;
- status = efi_get_next_variable_name(&varsz, varname, &varguid);
+ status = RS->GetNextVariableName(&varsz, varname, &varguid);
if (status == EFI_BUFFER_TOO_SMALL) {
varalloc = varsz;
newnm = realloc(varname, varalloc);
@@ -934,7 +905,7 @@ command_efi_set(int argc, char *argv[])
}
cpy8to16(var, wvar, nitems(wvar));
#if 0
- err = efi_set_variable(wvar, &guid, EFI_VARIABLE_NON_VOLATILE |
+ err = RS->SetVariable(wvar, &guid, EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,
strlen(val) + 1, val);
if (EFI_ERROR(err)) {
@@ -970,7 +941,7 @@ command_efi_unset(int argc, char *argv[])
}
cpy8to16(var, wvar, nitems(wvar));
#if 0
- err = efi_set_variable(wvar, &guid, 0, 0, NULL);
+ err = RS->SetVariable(wvar, &guid, 0, 0, NULL);
if (EFI_ERROR(err)) {
printf("Failed to unset variable: error %lu\n",
EFI_ERROR_CODE(err));
@@ -985,14 +956,14 @@ command_efi_unset(int argc, char *argv[])
/*
* Loader interaction words and extras
*
- * efi-setenv ( value n name n guid n attr -- 0 | -1)
- * efi-getenv ( guid n addr n -- addr' n' | -1 )
- * efi-unsetenv ( name n guid n'' -- )
+ * efi-setenv ( value n name n guid n attr -- 0 | -1)
+ * efi-getenv ( guid n addr n -- addr' n' | -1 )
+ * efi-unsetenv ( name n guid n'' -- )
*/
/*
* efi-setenv
- * efi-setenv ( value n name n guid n attr -- 0 | -1)
+ * efi-setenv ( value n name n guid n attr -- 0 | -1)
*
* Set environment variables using the SetVariable EFI runtime service.
*
@@ -1072,12 +1043,12 @@ ficlEfiSetenv(ficlVm *pVM)
}
memcpy(value, valuep, values);
- status = efi_set_variable(name, (EFI_GUID *)&u, attr, values, value);
+ status = RS->SetVariable(name, (EFI_GUID *)&u, attr, values, value);
if (status == EFI_SUCCESS) {
ficlStackPushInteger(pStack, 0);
} else {
ficlStackPushInteger(pStack, -1);
- error = "Error: efi_set_variable failed";
+ error = "Error: SetVariable failed";
}
out:
diff --git a/usr/src/boot/sys/boot/efi/loader/main.c b/usr/src/boot/sys/boot/efi/loader/main.c
index 1e2939e507..547418679a 100644
--- a/usr/src/boot/sys/boot/efi/loader/main.c
+++ b/usr/src/boot/sys/boot/efi/loader/main.c
@@ -186,9 +186,9 @@ find_currdev(EFI_LOADED_IMAGE *img)
if (pool_guid != 0) {
struct zfs_devdesc currdev;
- currdev.d_dev = &zfs_dev;
- currdev.d_unit = 0;
- currdev.d_type = currdev.d_dev->dv_type;
+ currdev.dd.d_dev = &zfs_dev;
+ currdev.dd.d_unit = 0;
+ currdev.dd.d_type = currdev.dd.d_dev->dv_type;
currdev.pool_guid = pool_guid;
currdev.root_guid = 0;
devname = efi_fmtdev(&currdev);
@@ -205,9 +205,9 @@ find_currdev(EFI_LOADED_IMAGE *img)
STAILQ_FOREACH(dp, pdi_list, pd_link) {
struct disk_devdesc currdev;
- currdev.d_dev = &efipart_hddev;
- currdev.d_type = currdev.d_dev->dv_type;
- currdev.d_unit = dp->pd_unit;
+ currdev.dd.d_dev = &efipart_hddev;
+ currdev.dd.d_type = currdev.dd.d_dev->dv_type;
+ currdev.dd.d_unit = dp->pd_unit;
currdev.d_slice = -1;
currdev.d_partition = -1;
diff --git a/usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c b/usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c
index 623114d1ae..8abf4f0b2f 100644
--- a/usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c
+++ b/usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c
@@ -176,13 +176,13 @@ main(void)
disk_parsedev(&devdesc, boot_devname+4, NULL);
- bootdev = MAKEBOOTDEV(dev_maj[devdesc.d_type], devdesc.d_slice + 1,
- devdesc.d_unit, devdesc.d_partition >= 0? devdesc.d_partition:0xff);
+ bootdev = MAKEBOOTDEV(dev_maj[DEVT_DISK], devdesc.d_slice + 1,
+ devdesc.dd.d_unit, devdesc.d_partition >= 0? devdesc.d_partition:0xff);
/*
* zfs_fmtdev() can be called only after dv_init
*/
- if (bdev != NULL && bdev->d_type == DEVT_ZFS) {
+ if (bdev != NULL && bdev->dd.d_type == DEVT_ZFS) {
/* set up proper device name string for ZFS */
strncpy(boot_devname, zfs_fmtdev(bdev), sizeof (boot_devname));
}
@@ -373,7 +373,7 @@ load(void)
bootinfo.bi_esymtab = VTOP(p);
bootinfo.bi_kernelname = VTOP(kname);
- if (bdev->d_type == DEVT_ZFS) {
+ if (bdev->dd.d_type == DEVT_ZFS) {
zfsargs.size = sizeof(zfsargs);
zfsargs.pool = bdev->d_kind.zfs.pool_guid;
zfsargs.root = bdev->d_kind.zfs.root_guid;
@@ -409,15 +409,15 @@ mount_root(char *arg)
if (bdev != NULL)
free(bdev);
bdev = ddesc;
- if (bdev->d_type == DEVT_DISK) {
+ if (bdev->dd.d_type == DEVT_DISK) {
if (bdev->d_kind.biosdisk.partition == -1)
part = 0xff;
else
part = bdev->d_kind.biosdisk.partition;
- bootdev = MAKEBOOTDEV(dev_maj[bdev->d_type],
+ bootdev = MAKEBOOTDEV(dev_maj[bdev->dd.d_type],
bdev->d_kind.biosdisk.slice + 1,
- bdev->d_unit, part);
- bootinfo.bi_bios_dev = bd_unit2bios(bdev->d_unit);
+ bdev->dd.d_unit, part);
+ bootinfo.bi_bios_dev = bd_unit2bios(bdev->dd.d_unit);
}
setenv("currdev", root, 1);
free(root);
@@ -638,8 +638,8 @@ probe_partition(void *arg, const char *partname,
if (pool_guid != 0 && bdev == NULL) {
bdev = malloc(sizeof (struct i386_devdesc));
bzero(bdev, sizeof (struct i386_devdesc));
- bdev->d_type = DEVT_ZFS;
- bdev->d_dev = &zfs_dev;
+ bdev->dd.d_type = DEVT_ZFS;
+ bdev->dd.d_dev = &zfs_dev;
bdev->d_kind.zfs.pool_guid = pool_guid;
/*
diff --git a/usr/src/boot/sys/boot/i386/libi386/bioscd.c b/usr/src/boot/sys/boot/i386/libi386/bioscd.c
index ac76c08c69..d4c10c361d 100644
--- a/usr/src/boot/sys/boot/i386/libi386/bioscd.c
+++ b/usr/src/boot/sys/boot/i386/libi386/bioscd.c
@@ -89,7 +89,7 @@ static struct bcinfo {
} bcinfo [MAXBCDEV];
static int nbcinfo = 0;
-#define BC(dev) (bcinfo[(dev)->d_unit])
+#define BC(dev) (bcinfo[(dev)->dd.d_unit])
static int bc_read(int unit, daddr_t dblk, int blks, caddr_t dest);
static int bc_init(void);
@@ -211,7 +211,7 @@ bc_open(struct open_file *f, ...)
va_start(ap, f);
dev = va_arg(ap, struct i386_devdesc *);
va_end(ap);
- if (dev->d_unit >= nbcinfo) {
+ if (dev->dd.d_unit >= nbcinfo) {
DEBUG("attempt to open nonexistent disk");
return(ENXIO);
}
@@ -271,7 +271,7 @@ bc_realstrategy(void *devdata, int rw, daddr_t dblk, size_t size,
if ((rw & F_MASK) != F_READ)
return(EROFS);
dev = (struct i386_devdesc *)devdata;
- unit = dev->d_unit;
+ unit = dev->dd.d_unit;
blks = size / BIOSCD_SECSIZE;
if (dblk % (BIOSCD_SECSIZE / DEV_BSIZE) != 0)
return (EINVAL);
@@ -429,7 +429,7 @@ bc_getdev(struct i386_devdesc *dev)
int major;
int rootdev;
- unit = dev->d_unit;
+ unit = dev->dd.d_unit;
biosdev = bc_unit2bios(unit);
DEBUG("unit %d BIOS device %d", unit, biosdev);
if (biosdev == -1) /* not a BIOS device */
diff --git a/usr/src/boot/sys/boot/i386/libi386/biosdisk.c b/usr/src/boot/sys/boot/i386/libi386/biosdisk.c
index cb3bb66ccf..100fa0b481 100644
--- a/usr/src/boot/sys/boot/i386/libi386/biosdisk.c
+++ b/usr/src/boot/sys/boot/i386/libi386/biosdisk.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* Copyright (c) 2012 Andrey V. Elsukov <ae@FreeBSD.org>
* All rights reserved.
@@ -91,7 +91,7 @@ static struct bdinfo
} bdinfo [MAXBDDEV];
static int nbdinfo = 0;
-#define BD(dev) (bdinfo[(dev)->d_unit])
+#define BD(dev) (bdinfo[(dev)->dd.d_unit])
static int bd_io(struct disk_devdesc *, daddr_t, int, caddr_t, int);
static int bd_int13probe(struct bdinfo *bd);
@@ -307,8 +307,8 @@ bd_print(int verbose)
if (ret != 0)
return (ret);
- dev.d_dev = &biosdisk;
- dev.d_unit = i;
+ dev.dd.d_dev = &biosdisk;
+ dev.dd.d_unit = i;
dev.d_slice = -1;
dev.d_partition = -1;
if (disk_open(&dev,
@@ -347,7 +347,7 @@ bd_open(struct open_file *f, ...)
dev = va_arg(ap, struct disk_devdesc *);
va_end(ap);
- if (dev->d_unit < 0 || dev->d_unit >= nbdinfo)
+ if (dev->dd.d_unit < 0 || dev->dd.d_unit >= nbdinfo)
return (EIO);
BD(dev).bd_open++;
if (BD(dev).bd_bcache == NULL)
@@ -360,10 +360,9 @@ bd_open(struct open_file *f, ...)
* During bd_probe() we tested if the mulitplication of bd_sectors
* would overflow so it should be safe to perform here.
*/
- disk.d_dev = dev->d_dev;
- disk.d_type = dev->d_type;
- disk.d_unit = dev->d_unit;
- disk.d_opendata = NULL;
+ disk.dd.d_dev = dev->dd.d_dev;
+ disk.dd.d_type = dev->dd.d_type;
+ disk.dd.d_unit = dev->dd.d_unit;
disk.d_slice = -1;
disk.d_partition = -1;
disk.d_offset = 0;
@@ -693,12 +692,14 @@ bd_io(struct disk_devdesc *dev, daddr_t dblk, int blks, caddr_t dest,
if (result != 0 && result != 0x20) {
if (dowrite != 0) {
printf("%s%d: Write %d sector(s) from %p (0x%x) "
- "to %lld: 0x%x", dev->d_dev->dv_name, dev->d_unit,
- blks, dest, VTOP(dest), dblk, result);
+ "to %lld: 0x%x", dev->dd.d_dev->dv_name,
+ dev->dd.d_unit, blks, dest, VTOP(dest), dblk,
+ result);
} else {
printf("%s%d: Read %d sector(s) from %lld to %p "
- "(0x%x): 0x%x", dev->d_dev->dv_name, dev->d_unit,
- blks, dblk, dest, VTOP(dest), result);
+ "(0x%x): 0x%x", dev->dd.d_dev->dv_name,
+ dev->dd.d_unit, blks, dblk, dest, VTOP(dest),
+ result);
}
if (result != 0)
@@ -754,8 +755,8 @@ bd_getdev(struct i386_devdesc *d)
int i, unit;
dev = (struct disk_devdesc *)d;
- biosdev = bd_unit2bios(dev->d_unit);
- DEBUG("unit %d BIOS device %d", dev->d_unit, biosdev);
+ biosdev = bd_unit2bios(dev->dd.d_unit);
+ DEBUG("unit %d BIOS device %d", dev->dd.d_unit, biosdev);
if (biosdev == -1) /* not a BIOS device */
return(-1);
if (disk_open(dev, BD(dev).bd_sectors * BD(dev).bd_sectorsize,
@@ -766,7 +767,7 @@ bd_getdev(struct i386_devdesc *d)
if (biosdev < 0x80) {
/* floppy (or emulated floppy) or ATAPI device */
- if (bdinfo[dev->d_unit].bd_type == DT_ATAPI) {
+ if (bdinfo[dev->dd.d_unit].bd_type == DT_ATAPI) {
/* is an ATAPI disk */
major = WFDMAJOR;
} else {
diff --git a/usr/src/boot/sys/boot/i386/libi386/bootinfo32.c b/usr/src/boot/sys/boot/i386/libi386/bootinfo32.c
index d434427835..3386fd777f 100644
--- a/usr/src/boot/sys/boot/i386/libi386/bootinfo32.c
+++ b/usr/src/boot/sys/boot/i386/libi386/bootinfo32.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* All rights reserved.
*
@@ -25,7 +25,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#include <stand.h>
#include <sys/param.h>
@@ -169,25 +168,26 @@ bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, vm_offset_t
/* XXX - use a default bootdev of 0. Is this ok??? */
bootdevnr = 0;
- switch(rootdev->d_type) {
+ switch(rootdev->dd.d_type) {
case DEVT_CD:
/* Pass in BIOS device number. */
- bi.bi_bios_dev = bc_unit2bios(rootdev->d_unit);
+ bi.bi_bios_dev = bc_unit2bios(rootdev->dd.d_unit);
bootdevnr = bc_getdev(rootdev);
break;
case DEVT_DISK:
/* pass in the BIOS device number of the current disk */
- bi.bi_bios_dev = bd_unit2bios(rootdev->d_unit);
+ bi.bi_bios_dev = bd_unit2bios(rootdev->dd.d_unit);
bootdevnr = bd_getdev(rootdev);
break;
case DEVT_NET:
case DEVT_ZFS:
break;
-
+
default:
- printf("WARNING - don't know how to boot from device type %d\n", rootdev->d_type);
+ printf("WARNING - don't know how to boot from device type %d\n",
+ rootdev->dd.d_type);
}
if (bootdevnr == -1) {
printf("root device %s invalid\n", i386_fmtdev(rootdev));
diff --git a/usr/src/boot/sys/boot/i386/libi386/devicename.c b/usr/src/boot/sys/boot/i386/libi386/devicename.c
index b692214b95..fb676ab7a5 100644
--- a/usr/src/boot/sys/boot/i386/libi386/devicename.c
+++ b/usr/src/boot/sys/boot/i386/libi386/devicename.c
@@ -151,14 +151,14 @@ i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path)
goto fail;
}
- idev->d_unit = unit;
+ idev->dd.d_unit = unit;
if (path != NULL)
*path = (*cp == '\0') ? cp : cp + 1;
break;
}
- idev->d_dev = dv;
- idev->d_type = dv->dv_type;
+ idev->dd.d_dev = dv;
+ idev->dd.d_type = dv->dv_type;
if (dev != NULL)
*dev = idev;
@@ -178,7 +178,7 @@ i386_fmtdev(void *vdev)
struct i386_devdesc *dev = (struct i386_devdesc *)vdev;
static char buf[SPECNAMELEN + 1];
- switch (dev->d_type) {
+ switch (dev->dd.d_type) {
case DEVT_NONE:
strlcpy(buf, "(no device)", sizeof (buf));
break;
@@ -190,8 +190,8 @@ i386_fmtdev(void *vdev)
return (zfs_fmtdev(vdev));
default:
- snprintf(buf, sizeof (buf), "%s%d:", dev->d_dev->dv_name,
- dev->d_unit);
+ snprintf(buf, sizeof (buf), "%s%d:", dev->dd.d_dev->dv_name,
+ dev->dd.d_unit);
break;
}
return (buf);
diff --git a/usr/src/boot/sys/boot/i386/libi386/libi386.h b/usr/src/boot/sys/boot/i386/libi386/libi386.h
index f5106bd8f5..a6bd20b5c1 100644
--- a/usr/src/boot/sys/boot/i386/libi386/libi386.h
+++ b/usr/src/boot/sys/boot/i386/libi386/libi386.h
@@ -34,20 +34,14 @@
*/
/* Note: Must match the 'struct devdesc' in stand.h */
struct i386_devdesc {
- struct devsw *d_dev;
- int d_type;
- int d_unit;
- void *d_opendata;
- union
- {
- struct
- {
+ struct devdesc dd;
+ union {
+ struct {
int slice;
int partition;
off_t offset;
} biosdisk;
- struct
- {
+ struct {
uint64_t pool_guid;
uint64_t root_guid;
} zfs;
diff --git a/usr/src/boot/sys/boot/i386/libi386/linux.c b/usr/src/boot/sys/boot/i386/libi386/linux.c
index fe15b14a30..d0c8bf68a4 100644
--- a/usr/src/boot/sys/boot/i386/libi386/linux.c
+++ b/usr/src/boot/sys/boot/i386/libi386/linux.c
@@ -292,7 +292,7 @@ linux_exec(struct preloaded_file *fp)
i386_getdev((void **)(&rootdev), fp->f_name, NULL);
if (rootdev != NULL)
- relocator_edx = bd_unit2bios(rootdev->d_unit);
+ relocator_edx = bd_unit2bios(rootdev->dd.d_unit);
/*
* command line
diff --git a/usr/src/boot/sys/boot/i386/loader/chain.c b/usr/src/boot/sys/boot/i386/loader/chain.c
index faa1dbb608..160f498065 100644
--- a/usr/src/boot/sys/boot/i386/loader/chain.c
+++ b/usr/src/boot/sys/boot/i386/loader/chain.c
@@ -100,7 +100,7 @@ command_chain(int argc, char *argv[])
relocater_data[0].dest = 0x7C00;
relocater_data[0].size = size;
- relocator_edx = bd_unit2bios(rootdev->d_unit);
+ relocator_edx = bd_unit2bios(rootdev->dd.d_unit);
relocator_esi = relocater_size;
relocator_ds = 0;
relocator_es = 0;
diff --git a/usr/src/boot/sys/boot/i386/loader/main.c b/usr/src/boot/sys/boot/i386/loader/main.c
index 1966928911..577e186c4c 100644
--- a/usr/src/boot/sys/boot/i386/loader/main.c
+++ b/usr/src/boot/sys/boot/i386/loader/main.c
@@ -225,18 +225,18 @@ extract_currdev(void)
int biosdev = -1;
/* Assume we are booting from a BIOS disk by default */
- new_currdev.d_dev = &biosdisk;
+ new_currdev.dd.d_dev = &biosdisk;
/* new-style boot loaders such as pxeldr and cdldr */
if (kargs->bootinfo == 0) {
if ((kargs->bootflags & KARGS_FLAGS_CD) != 0) {
/* we are booting from a CD with cdboot */
- new_currdev.d_dev = &bioscd;
- new_currdev.d_unit = bc_bios2unit(initial_bootdev);
+ new_currdev.dd.d_dev = &bioscd;
+ new_currdev.dd.d_unit = bc_bios2unit(initial_bootdev);
} else if ((kargs->bootflags & KARGS_FLAGS_PXE) != 0) {
/* we are booting from pxeldr */
- new_currdev.d_dev = &pxedisk;
- new_currdev.d_unit = 0;
+ new_currdev.dd.d_dev = &pxedisk;
+ new_currdev.dd.d_unit = 0;
} else {
/* we don't know what our boot device is */
new_currdev.d_kind.biosdisk.slice = -1;
@@ -266,7 +266,7 @@ extract_currdev(void)
new_currdev.d_kind.zfs.pool_guid = kargs->zfspool;
new_currdev.d_kind.zfs.root_guid = 0;
}
- new_currdev.d_dev = &zfs_dev;
+ new_currdev.dd.d_dev = &zfs_dev;
#endif
} else if ((initial_bootdev & B_MAGICMASK) != B_DEVMAGIC) {
/* The passed-in boot device is bad */
@@ -287,26 +287,19 @@ extract_currdev(void)
if ((biosdev == 0) && (B_TYPE(initial_bootdev) != 2)) /* biosdev doesn't match major */
biosdev = 0x80 + B_UNIT(initial_bootdev); /* assume harddisk */
}
- new_currdev.d_type = new_currdev.d_dev->dv_type;
+ new_currdev.dd.d_type = new_currdev.dd.d_dev->dv_type;
/*
* If we are booting off of a BIOS disk and we didn't succeed in determining
* which one we booted off of, just use disk0: as a reasonable default.
*/
- if ((new_currdev.d_type == biosdisk.dv_type) &&
- ((new_currdev.d_unit = bd_bios2unit(biosdev)) == -1)) {
+ if ((new_currdev.dd.d_type == biosdisk.dv_type) &&
+ ((new_currdev.dd.d_unit = bd_bios2unit(biosdev)) == -1)) {
printf("Can't work out which disk we are booting from.\n"
"Guessed BIOS device 0x%x not found by probes, defaulting to disk0:\n", biosdev);
- new_currdev.d_unit = 0;
+ new_currdev.dd.d_unit = 0;
}
-#ifdef LOADER_ZFS_SUPPORT
-#ifdef __FreeBSD__
- if (new_currdev.d_type == DEVT_ZFS)
- init_zfs_bootenv(zfs_fmtdev(&new_currdev));
-#endif
-#endif
-
env_setenv("currdev", EV_VOLATILE, i386_fmtdev(&new_currdev),
i386_setcurrdev, env_nounset);
env_setenv("loaddev", EV_VOLATILE, i386_fmtdev(&new_currdev), env_noset,
diff --git a/usr/src/boot/sys/boot/ofw/libofw/devicename.c b/usr/src/boot/sys/boot/ofw/libofw/devicename.c
index c9814b76e9..62076c9c1d 100644
--- a/usr/src/boot/sys/boot/ofw/libofw/devicename.c
+++ b/usr/src/boot/sys/boot/ofw/libofw/devicename.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* All rights reserved.
*
@@ -25,7 +25,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#include <stand.h>
@@ -113,9 +112,9 @@ found:
return ENOMEM;
}
strcpy(idev->d_path, name);
- idev->d_dev = dv;
- idev->d_type = dv->dv_type;
- if (idev->d_type == DEVT_ZFS) {
+ idev->dd.d_dev = dv;
+ idev->dd.d_type = dv->dv_type;
+ if (idev->dd.d_type == DEVT_ZFS) {
p = devspec + strlen(dv->dv_name);
err = zfs_parsedev((struct zfs_devdesc *)idev, p, path);
if (err != 0) {
diff --git a/usr/src/boot/sys/boot/ofw/libofw/libofw.h b/usr/src/boot/sys/boot/ofw/libofw/libofw.h
index 9845e03399..b211766d57 100644
--- a/usr/src/boot/sys/boot/ofw/libofw/libofw.h
+++ b/usr/src/boot/sys/boot/ofw/libofw/libofw.h
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (C) 2000 Benno Rice.
* All rights reserved.
*
@@ -29,12 +29,12 @@
/* Note: Must match the 'struct devdesc' in stand.h */
struct ofw_devdesc {
- struct devsw *d_dev;
- int d_type;
- int d_unit;
- ihandle_t d_handle;
+ struct devdesc dd;
union {
- char d_path[256];
+ struct {
+ ihandle_t d_handle;
+ char d_path[256];
+ };
struct {
uint64_t pool_guid;
uint64_t root_guid;
diff --git a/usr/src/boot/sys/boot/sparc64/loader/main.c b/usr/src/boot/sys/boot/sparc64/loader/main.c
index cce5a3da7a..cee45a234c 100644
--- a/usr/src/boot/sys/boot/sparc64/loader/main.c
+++ b/usr/src/boot/sys/boot/sparc64/loader/main.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Initial implementation:
* Copyright (c) 2001 Robert Drehmel
* All rights reserved.
@@ -6,7 +6,7 @@
* As long as the above copyright statement and this notice remain
* unchanged, you can do what ever you want with this file.
*/
-/*-
+/*
* Copyright (c) 2008 - 2012 Marius Strobl <marius@FreeBSD.org>
* All rights reserved.
*
@@ -808,8 +808,8 @@ sparc64_zfs_probe(void)
if (guid != 0) {
zfs_currdev.pool_guid = guid;
zfs_currdev.root_guid = 0;
- zfs_currdev.d_dev = &zfs_dev;
- zfs_currdev.d_type = zfs_currdev.d_dev->dv_type;
+ zfs_currdev.dd.d_dev = &zfs_dev;
+ zfs_currdev.dd.d_type = zfs_currdev.dd.d_dev->dv_type;
}
}
#endif /* LOADER_ZFS_SUPPORT */
diff --git a/usr/src/boot/sys/boot/uboot/common/main.c b/usr/src/boot/sys/boot/uboot/common/main.c
index 3f053a2720..9de0e7b4df 100644
--- a/usr/src/boot/sys/boot/uboot/common/main.c
+++ b/usr/src/boot/sys/boot/uboot/common/main.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 2000 Benno Rice <benno@jeamland.net>
* Copyright (c) 2000 Stephane Potvin <sepotvin@videotron.ca>
* Copyright (c) 2007-2008 Semihalf, Rafal Jaworowski <raj@semihalf.com>
@@ -317,12 +317,12 @@ print_disk_probe_info()
strcpy(partition, "<auto>");
printf(" Checking unit=%d slice=%s partition=%s...",
- currdev.d_unit, slice, partition);
+ currdev.dd.d_unit, slice, partition);
}
static int
-probe_disks(int devidx, int load_type, int load_unit, int load_slice,
+probe_disks(int devidx, int load_type, int load_unit, int load_slice,
int load_partition)
{
int open_result, unit;
@@ -337,8 +337,8 @@ probe_disks(int devidx, int load_type, int load_unit, int load_slice,
if (load_type == -1) {
printf(" Probing all disk devices...\n");
/* Try each disk in succession until one works. */
- for (currdev.d_unit = 0; currdev.d_unit < UB_MAX_DEV;
- currdev.d_unit++) {
+ for (currdev.dd.d_unit = 0; currdev.dd.d_unit < UB_MAX_DEV;
+ currdev.dd.d_unit++) {
print_disk_probe_info();
open_result = devsw[devidx]->dv_open(&f, &currdev);
if (open_result == 0) {
@@ -354,8 +354,8 @@ probe_disks(int devidx, int load_type, int load_unit, int load_slice,
printf(" Probing all %s devices...\n", device_typename(load_type));
/* Try each disk of given type in succession until one works. */
for (unit = 0; unit < UB_MAX_DEV; unit++) {
- currdev.d_unit = uboot_diskgetunit(load_type, unit);
- if (currdev.d_unit == -1)
+ currdev.dd.d_unit = uboot_diskgetunit(load_type, unit);
+ if (currdev.dd.d_unit == -1)
break;
print_disk_probe_info();
open_result = devsw[devidx]->dv_open(&f, &currdev);
@@ -368,7 +368,7 @@ probe_disks(int devidx, int load_type, int load_unit, int load_slice,
return (-1);
}
- if ((currdev.d_unit = uboot_diskgetunit(load_type, load_unit)) != -1) {
+ if ((currdev.dd.d_unit = uboot_diskgetunit(load_type, load_unit)) != -1) {
print_disk_probe_info();
open_result = devsw[devidx]->dv_open(&f,&currdev);
if (open_result == 0) {
@@ -453,13 +453,13 @@ main(void)
printf("Found U-Boot device: %s\n", devsw[i]->dv_name);
- currdev.d_dev = devsw[i];
- currdev.d_type = currdev.d_dev->dv_type;
- currdev.d_unit = 0;
+ currdev.dd.d_dev = devsw[i];
+ currdev.dd.d_type = currdev.d_dev->dv_type;
+ currdev.dd.d_unit = 0;
if ((load_type == -1 || (load_type & DEV_TYP_STOR)) &&
strcmp(devsw[i]->dv_name, "disk") == 0) {
- if (probe_disks(i, load_type, load_unit, load_slice,
+ if (probe_disks(i, load_type, load_unit, load_slice,
load_partition) == 0)
break;
}
diff --git a/usr/src/boot/sys/boot/uboot/lib/devicename.c b/usr/src/boot/sys/boot/uboot/lib/devicename.c
index 9e68f9df9e..9f4bb679d9 100644
--- a/usr/src/boot/sys/boot/uboot/lib/devicename.c
+++ b/usr/src/boot/sys/boot/uboot/lib/devicename.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* All rights reserved.
*
@@ -25,7 +25,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#include <stand.h>
#include <string.h>
@@ -136,7 +135,7 @@ uboot_parsedev(struct uboot_devdesc **dev, const char *devspec,
err = EINVAL;
goto fail;
}
- idev->d_unit = unit;
+ idev->dd.d_unit = unit;
if (path != NULL)
*path = (*cp == 0) ? cp : cp + 1;
@@ -146,8 +145,8 @@ uboot_parsedev(struct uboot_devdesc **dev, const char *devspec,
err = EINVAL;
goto fail;
}
- idev->d_dev = dv;
- idev->d_type = dv->dv_type;
+ idev->dd.d_dev = dv;
+ idev->dd.d_type = dv->dv_type;
if (dev == NULL) {
free(idev);
} else {
@@ -167,7 +166,7 @@ uboot_fmtdev(void *vdev)
struct uboot_devdesc *dev = (struct uboot_devdesc *)vdev;
static char buf[128];
- switch(dev->d_type) {
+ switch(dev->dd.d_type) {
case DEVT_NONE:
strcpy(buf, "(no device)");
break;
@@ -178,7 +177,7 @@ uboot_fmtdev(void *vdev)
#endif
case DEVT_NET:
- sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
+ sprintf(buf, "%s%d:", dev->dd.d_dev->dv_name, dev->dd.d_unit);
break;
}
return(buf);
diff --git a/usr/src/boot/sys/boot/uboot/lib/disk.c b/usr/src/boot/sys/boot/uboot/lib/disk.c
index 26ae50e220..c2c625ee9a 100644
--- a/usr/src/boot/sys/boot/uboot/lib/disk.c
+++ b/usr/src/boot/sys/boot/uboot/lib/disk.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 2008 Semihalf, Rafal Jaworowski
* Copyright (c) 2009 Semihalf, Piotr Ziecik
* Copyright (c) 2012 Andrey V. Elsukov <ae@FreeBSD.org>
@@ -32,7 +32,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/disk.h>
@@ -46,7 +45,7 @@ __FBSDID("$FreeBSD$");
#include "libuboot.h"
#define stor_printf(fmt, args...) do { \
- printf("%s%d: ", dev->d_dev->dv_name, dev->d_unit); \
+ printf("%s%d: ", dev->dd.d_dev->dv_name, dev->dd.d_unit); \
printf(fmt, ##args); \
} while (0)
@@ -65,7 +64,7 @@ static struct {
u_int bsize; /* block size */
} stor_info[UB_MAX_DEV];
-#define SI(dev) (stor_info[(dev)->d_unit])
+#define SI(dev) (stor_info[(dev)->dd.d_unit])
static int stor_info_no = 0;
static int stor_opendev(struct disk_devdesc *);
@@ -191,7 +190,7 @@ stor_opendev(struct disk_devdesc *dev)
{
int err;
- if (dev->d_unit < 0 || dev->d_unit >= stor_info_no)
+ if (dev->dd.d_unit < 0 || dev->dd.d_unit >= stor_info_no)
return (EIO);
if (SI(dev).opened == 0) {
@@ -252,8 +251,8 @@ stor_print(int verbose)
return (ret);
for (i = 0; i < stor_info_no; i++) {
- dev.d_dev = &uboot_storage;
- dev.d_unit = i;
+ dev.dd.d_dev = &uboot_storage;
+ dev.dd.d_unit = i;
dev.d_slice = -1;
dev.d_partition = -1;
sprintf(line, "\tdisk%d (%s)\n", i,
diff --git a/usr/src/boot/sys/boot/uboot/lib/libuboot.h b/usr/src/boot/sys/boot/uboot/lib/libuboot.h
index 384e03789f..4c0d5066bd 100644
--- a/usr/src/boot/sys/boot/uboot/lib/libuboot.h
+++ b/usr/src/boot/sys/boot/uboot/lib/libuboot.h
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (C) 2000 Benno Rice.
* Copyright (C) 2007 Semihalf, Rafal Jaworowski <raj@semihalf.com>
* All rights reserved.
@@ -29,10 +29,7 @@
/* Note: Must match the 'struct devdesc' in stand.h */
struct uboot_devdesc {
- struct devsw *d_dev;
- int d_type;
- int d_unit;
- void *d_opendata;
+ struct devdesc dd;
union {
struct {
int slice;
diff --git a/usr/src/boot/sys/boot/userboot/userboot/devicename.c b/usr/src/boot/sys/boot/userboot/userboot/devicename.c
index efa5634e54..c20187b198 100644
--- a/usr/src/boot/sys/boot/userboot/userboot/devicename.c
+++ b/usr/src/boot/sys/boot/userboot/userboot/devicename.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* All rights reserved.
*
@@ -25,7 +25,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#include <stand.h>
#include <string.h>
@@ -139,7 +138,7 @@ userboot_parsedev(struct disk_devdesc **dev, const char *devspec, const char **p
goto fail;
}
- idev->d_unit = unit;
+ idev->dd.d_unit = unit;
if (path != NULL)
*path = (*cp == 0) ? cp : cp + 1;
break;
@@ -158,8 +157,8 @@ userboot_parsedev(struct disk_devdesc **dev, const char *devspec, const char **p
err = EINVAL;
goto fail;
}
- idev->d_dev = dv;
- idev->d_type = dv->dv_type;
+ idev->dd.d_dev = dv;
+ idev->dd.d_type = dv->dv_type;
if (dev == NULL) {
free(idev);
} else {
@@ -179,27 +178,27 @@ userboot_fmtdev(void *vdev)
struct disk_devdesc *dev = (struct disk_devdesc *)vdev;
static char buf[128]; /* XXX device length constant? */
- switch(dev->d_type) {
+ switch(dev->dd.d_type) {
case DEVT_NONE:
strcpy(buf, "(no device)");
break;
case DEVT_CD:
- sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
+ sprintf(buf, "%s%d:", dev->dd.d_dev->dv_name, dev->dd.d_unit);
break;
case DEVT_DISK:
return (disk_fmtdev(vdev));
case DEVT_NET:
- sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
+ sprintf(buf, "%s%d:", dev->dd.d_dev->dv_name, dev->dd.d_unit);
break;
case DEVT_ZFS:
#if defined(USERBOOT_ZFS_SUPPORT)
return (zfs_fmtdev(vdev));
#else
- sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
+ sprintf(buf, "%s%d:", dev->dd.d_dev->dv_name, dev->dd.d_unit);
#endif
break;
}
diff --git a/usr/src/boot/sys/boot/userboot/userboot/main.c b/usr/src/boot/sys/boot/userboot/userboot/main.c
index fa10b5acbf..5abd95b5cf 100644
--- a/usr/src/boot/sys/boot/userboot/userboot/main.c
+++ b/usr/src/boot/sys/boot/userboot/userboot/main.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* Copyright (c) 1998,2000 Doug Rabson <dfr@freebsd.org>
* All rights reserved.
@@ -26,7 +26,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#include <stand.h>
#include <string.h>
@@ -154,37 +153,38 @@ extract_currdev(void)
//bzero(&dev, sizeof(dev));
#if defined(USERBOOT_ZFS_SUPPORT)
+ CTASSERT(sizeof(struct disk_devdesc) >= sizeof(struct zfs_devdesc));
if (userboot_zfs_found) {
struct zfs_devdesc zdev;
-
+
/* Leave the pool/root guid's unassigned */
bzero(&zdev, sizeof(zdev));
- zdev.d_dev = &zfs_dev;
- zdev.d_type = zdev.d_dev->dv_type;
-
+ zdev.dd.d_dev = &zfs_dev;
+ zdev.dd.d_type = zdev.dd.d_dev->dv_type;
+
dev = *(struct disk_devdesc *)&zdev;
init_zfs_bootenv(zfs_fmtdev(&dev));
} else
#endif
if (userboot_disk_maxunit > 0) {
- dev.d_dev = &userboot_disk;
- dev.d_type = dev.d_dev->dv_type;
- dev.d_unit = 0;
+ dev.dd.d_dev = &userboot_disk;
+ dev.dd.d_type = dev.dd.d_dev->dv_type;
+ dev.dd.d_unit = 0;
dev.d_slice = 0;
dev.d_partition = 0;
/*
* If we cannot auto-detect the partition type then
* access the disk as a raw device.
*/
- if (dev.d_dev->dv_open(NULL, &dev)) {
+ if (dev.dd.d_dev->dv_open(NULL, &dev)) {
dev.d_slice = -1;
dev.d_partition = -1;
}
} else {
- dev.d_dev = &host_dev;
- dev.d_type = dev.d_dev->dv_type;
- dev.d_unit = 0;
+ dev.dd.d_dev = &host_dev;
+ dev.dd.d_type = dev.dd.d_dev->dv_type;
+ dev.dd.d_unit = 0;
}
env_setenv("currdev", EV_VOLATILE, userboot_fmtdev(&dev),
diff --git a/usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c b/usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c
index 16bbc1b14c..5e87ef1e25 100644
--- a/usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c
+++ b/usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 2011 Google, Inc.
* All rights reserved.
*
@@ -25,7 +25,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
/*
* Userboot disk image handling.
@@ -127,8 +126,8 @@ userdisk_print(int verbose)
for (i = 0; i < userdisk_maxunit; i++) {
sprintf(line, " disk%d: Guest drive image\n", i);
pager_output(line);
- dev.d_dev = &userboot_disk;
- dev.d_unit = i;
+ dev.dd.d_dev = &userboot_disk;
+ dev.dd.d_unit = i;
dev.d_slice = -1;
dev.d_partition = -1;
if (disk_open(&dev, ud_info[i].mediasize,
@@ -153,11 +152,13 @@ userdisk_open(struct open_file *f, ...)
dev = va_arg(ap, struct disk_devdesc *);
va_end(ap);
- if (dev->d_unit < 0 || dev->d_unit >= userdisk_maxunit)
+ if (dev->dd.d_unit < 0 || dev->dd.d_unit >= userdisk_maxunit)
return (EIO);
-
- return (disk_open(dev, ud_info[dev->d_unit].mediasize,
- ud_info[dev->d_unit].sectorsize));
+ ud_info[dev->dd.d_unit].ud_open++;
+ if (ud_info[dev->dd.d_unit].ud_bcache == NULL)
+ ud_info[dev->dd.d_unit].ud_bcache = bcache_allocate();
+ return (disk_open(dev, ud_info[dev->dd.d_unit].mediasize,
+ ud_info[dev->dd.d_unit].sectorsize));
}
static int
@@ -166,6 +167,11 @@ userdisk_close(struct open_file *f)
struct disk_devdesc *dev;
dev = (struct disk_devdesc *)f->f_devdata;
+ ud_info[dev->dd.d_unit].ud_open--;
+ if (ud_info[dev->dd.d_unit].ud_open == 0) {
+ bcache_free(ud_info[dev->dd.d_unit].ud_bcache);
+ ud_info[dev->dd.d_unit].ud_bcache = NULL;
+ }
return (disk_close(dev));
}
@@ -173,6 +179,21 @@ static int
userdisk_strategy(void *devdata, int rw, daddr_t dblk, size_t size,
char *buf, size_t *rsize)
{
+ struct bcache_devdata bcd;
+ struct disk_devdesc *dev;
+
+ dev = (struct disk_devdesc *)devdata;
+ bcd.dv_strategy = userdisk_realstrategy;
+ bcd.dv_devdata = devdata;
+ bcd.dv_cache = ud_info[dev->dd.d_unit].ud_bcache;
+ return (bcache_strategy(&bcd, rw, dblk + dev->d_offset,
+ size, buf, rsize));
+}
+
+static int
+userdisk_realstrategy(void *devdata, int rw, daddr_t dblk, size_t size,
+ char *buf, size_t *rsize)
+{
struct disk_devdesc *dev = devdata;
uint64_t off;
size_t resid;
@@ -185,8 +206,8 @@ userdisk_strategy(void *devdata, int rw, daddr_t dblk, size_t size,
return (EINVAL);
if (rsize)
*rsize = 0;
- off = (dblk + dev->d_offset) * ud_info[dev->d_unit].sectorsize;
- rc = CALLBACK(diskread, dev->d_unit, off, buf, size, &resid);
+ off = dblk * ud_info[dev->dd.d_unit].sectorsize;
+ rc = CALLBACK(diskread, dev->dd.d_unit, off, buf, size, &resid);
if (rc)
return (rc);
if (rsize)
@@ -200,5 +221,5 @@ userdisk_ioctl(struct open_file *f, u_long cmd, void *data)
struct disk_devdesc *dev;
dev = (struct disk_devdesc *)f->f_devdata;
- return (CALLBACK(diskioctl, dev->d_unit, cmd, data));
+ return (CALLBACK(diskioctl, dev->dd.d_unit, cmd, data));
}
diff --git a/usr/src/boot/sys/boot/zfs/libzfs.h b/usr/src/boot/sys/boot/zfs/libzfs.h
index 05d1620425..5945b465f8 100644
--- a/usr/src/boot/sys/boot/zfs/libzfs.h
+++ b/usr/src/boot/sys/boot/zfs/libzfs.h
@@ -38,10 +38,7 @@
*/
/* Note: Must match the 'struct devdesc' in stand.h */
struct zfs_devdesc {
- struct devsw *d_dev;
- int d_type;
- int d_unit;
- void *d_opendata;
+ struct devdesc dd;
uint64_t pool_guid;
uint64_t root_guid;
};
diff --git a/usr/src/boot/sys/boot/zfs/zfs.c b/usr/src/boot/sys/boot/zfs/zfs.c
index 9a4b944178..d5e932ff0d 100644
--- a/usr/src/boot/sys/boot/zfs/zfs.c
+++ b/usr/src/boot/sys/boot/zfs/zfs.c
@@ -691,8 +691,8 @@ zfs_parsedev(struct zfs_devdesc *dev, const char *devspec, const char **path)
return (rv);
if (path != NULL)
*path = (*end == '\0') ? end : end + 1;
- dev->d_dev = &zfs_dev;
- dev->d_type = zfs_dev.dv_type;
+ dev->dd.d_dev = &zfs_dev;
+ dev->dd.d_type = zfs_dev.dv_type;
return (0);
}
@@ -707,7 +707,7 @@ zfs_bootfs(void *zdev)
int n;
buf[0] = '\0';
- if (dev->d_type != DEVT_ZFS)
+ if (dev->dd.d_type != DEVT_ZFS)
return (buf);
spa = spa_find_by_guid(dev->pool_guid);
@@ -762,7 +762,7 @@ zfs_fmtdev(void *vdev)
spa_t *spa;
buf[0] = '\0';
- if (dev->d_type != DEVT_ZFS)
+ if (dev->dd.d_type != DEVT_ZFS)
return (buf);
if (dev->pool_guid == 0) {
@@ -784,9 +784,9 @@ zfs_fmtdev(void *vdev)
}
if (rootname[0] == '\0')
- sprintf(buf, "%s:%s:", dev->d_dev->dv_name, spa->spa_name);
+ sprintf(buf, "%s:%s:", dev->dd.d_dev->dv_name, spa->spa_name);
else
- sprintf(buf, "%s:%s/%s:", dev->d_dev->dv_name, spa->spa_name,
+ sprintf(buf, "%s:%s/%s:", dev->dd.d_dev->dv_name, spa->spa_name,
rootname);
return (buf);
}
diff --git a/usr/src/cmd/svc/svccfg/svccfg_xml.c b/usr/src/cmd/svc/svccfg/svccfg_xml.c
index 0e0a455b07..2cee741477 100644
--- a/usr/src/cmd/svc/svccfg/svccfg_xml.c
+++ b/usr/src/cmd/svc/svccfg/svccfg_xml.c
@@ -1612,7 +1612,7 @@ lxml_get_notification_parameters(entity_t *entity, xmlNodePtr np)
if (entity->sc_etype != SVCCFG_INSTANCE_OBJECT ||
strcmp(entity->sc_fmri, SCF_NOTIFY_PARAMS_INST) != 0) {
semerr(gettext(
- "Non-SMF transition evenst must go to %s\n"),
+ "Non-SMF transition events must go to %s\n"),
SCF_NOTIFY_PARAMS_INST);
goto out;
}
@@ -1625,6 +1625,7 @@ lxml_get_notification_parameters(entity_t *entity, xmlNodePtr np)
lxml_get_event(entity, pgname, np);
}
+ break;
default: /* smf state transition tokens */
if (entity->sc_etype == SVCCFG_SERVICE_OBJECT &&
diff --git a/usr/src/cmd/svc/svcprop/svcprop.c b/usr/src/cmd/svc/svcprop/svcprop.c
index 78614bbb4f..6b6f1663f1 100644
--- a/usr/src/cmd/svc/svcprop/svcprop.c
+++ b/usr/src/cmd/svc/svcprop/svcprop.c
@@ -53,7 +53,7 @@
* Error functions. These can change if the quiet (-q) option is used.
*/
static void (*warn)(const char *, ...) = uu_warn;
-static void (*die)(const char *, ...) = uu_die;
+static __NORETURN void (*die)(const char *, ...) = uu_die;
/*
* Entity encapsulation. This allows me to treat services and instances
@@ -121,7 +121,7 @@ static int return_code; /* main's return code */
* uu_die() from appending the errno error.
*/
static void
-scfdie()
+scfdie(void)
{
die(gettext("Unexpected libscf error: %s. Exiting.\n"),
scf_strerror(scf_error()));
@@ -140,7 +140,7 @@ safe_malloc(size_t sz)
}
static void
-usage()
+usage(void)
{
(void) fprintf(stderr, gettext("Usage: %1$s [-fqtv] "
"[-C | -c | -s snapshot] [-z zone] "
@@ -816,8 +816,6 @@ do_wait(void *unused, scf_walkinfo_t *wip)
case SCF_ERROR_NOT_FOUND:
die(emsg_not_found);
- /* NOTREACHED */
-
default:
scfdie();
}
@@ -842,12 +840,11 @@ do_wait(void *unused, scf_walkinfo_t *wip)
uu_xdie(UU_EXIT_USAGE, gettext("Invalid "
"property group name \"%s\".\n"),
p->spn_comp1);
+ /* NOTREACHED */
case SCF_ERROR_NOT_FOUND:
die(emsg_not_found);
- /* NOTREACHED */
-
default:
scfdie();
}
@@ -863,12 +860,11 @@ do_wait(void *unused, scf_walkinfo_t *wip)
uu_xdie(UU_EXIT_USAGE,
gettext("Invalid property name "
"\"%s\".\n"), propname);
+ /* NOTREACHED */
case SCF_ERROR_NOT_FOUND:
die(emsg_not_found);
- /* NOTREACHED */
-
default:
scfdie();
}
@@ -891,6 +887,7 @@ do_wait(void *unused, scf_walkinfo_t *wip)
uu_xdie(UU_EXIT_USAGE, gettext("Invalid "
"property group name \"%s\".\n"),
p->spn_comp1);
+ /* NOTREACHED */
case SCF_ERROR_NOT_FOUND:
die(emsg_not_found);
@@ -916,8 +913,6 @@ do_wait(void *unused, scf_walkinfo_t *wip)
case SCF_ERROR_NOT_FOUND:
die(emsg_not_found);
- /* NOTREACHED */
-
default:
scfdie();
}
@@ -986,7 +981,7 @@ quiet_warn(const char *fmt, ...)
}
/*ARGSUSED*/
-static void
+static __NORETURN void
quiet_die(const char *fmt, ...)
{
exit(UU_EXIT_FATAL);
diff --git a/usr/src/cmd/svc/svcs/svcs.c b/usr/src/cmd/svc/svcs/svcs.c
index 0c7da2eb69..39caabb7d5 100644
--- a/usr/src/cmd/svc/svcs/svcs.c
+++ b/usr/src/cmd/svc/svcs/svcs.c
@@ -1889,7 +1889,7 @@ description_of_column(int c)
static void
-print_usage(const char *progname, FILE *f, boolean_t do_exit)
+print_usage(const char *progname, FILE *f)
{
(void) fprintf(f, gettext(
"Usage: %1$s [-aHpv] [-o col[,col ... ]] [-R restarter] "
@@ -1899,19 +1899,21 @@ print_usage(const char *progname, FILE *f, boolean_t do_exit)
" %1$s [-l | -L] [-Z | -z zone] <service> ...\n"
" %1$s -x [-v] [-Z | -z zone] [<service> ...]\n"
" %1$s -?\n"), progname);
-
- if (do_exit)
- exit(UU_EXIT_USAGE);
}
-#define argserr(progname) print_usage(progname, stderr, B_TRUE)
+static __NORETURN void
+argserr(const char *progname)
+{
+ print_usage(progname, stderr);
+ exit(UU_EXIT_USAGE);
+}
static void
print_help(const char *progname)
{
int i;
- print_usage(progname, stdout, B_FALSE);
+ print_usage(progname, stdout);
(void) printf(gettext("\n"
"\t-a list all service instances rather than "
@@ -3631,7 +3633,6 @@ main(int argc, char **argv)
case '?':
argserr(progname);
- /* NOTREACHED */
default:
assert(0);
diff --git a/usr/src/cmd/svr4pkg/libinst/pkgops.c b/usr/src/cmd/svr4pkg/libinst/pkgops.c
index b88e673379..404ea2b412 100644
--- a/usr/src/cmd/svr4pkg/libinst/pkgops.c
+++ b/usr/src/cmd/svr4pkg/libinst/pkgops.c
@@ -1150,10 +1150,10 @@ pkgTestInstalled(char *a_packageName, char *a_rootPath)
/* entry assertions */
- assert(a_packageName != (char *)NULL);
+ assert(a_packageName != NULL);
assert(*a_packageName != '\0');
- assert(a_rootPath != (char *)NULL);
- assert(a_rootPath != '\0');
+ assert(a_rootPath != NULL);
+ assert(*a_rootPath != '\0');
/* entry debugging info */
diff --git a/usr/src/cmd/svr4pkg/pkgcond/main.c b/usr/src/cmd/svr4pkg/pkgcond/main.c
index e3f5ac723d..e5710241e4 100644
--- a/usr/src/cmd/svr4pkg/pkgcond/main.c
+++ b/usr/src/cmd/svr4pkg/pkgcond/main.c
@@ -3458,11 +3458,11 @@ resolvePath(char **r_path)
/* entry assertions */
- assert(r_path != (char **)NULL);
+ assert(r_path != NULL);
/* return error if the path is completely empty */
- if (*r_path == '\0') {
+ if (**r_path == '\0') {
return (R_FAILURE);
}
diff --git a/usr/src/common/ficl/emu/loader_emu.c b/usr/src/common/ficl/emu/loader_emu.c
index d109016176..ad5ce87cbc 100644
--- a/usr/src/common/ficl/emu/loader_emu.c
+++ b/usr/src/common/ficl/emu/loader_emu.c
@@ -799,7 +799,8 @@ bf_init(const char *rc, ficlOutputFunction out)
printf("error interpreting forth: %d\n", rv);
exit(1);
}
- sprintf(create_buf, "builtin: %s", cmdp->c_name);
+ snprintf(create_buf, sizeof (create_buf), "builtin: %s",
+ cmdp->c_name);
rv = ficlVmEvaluate(bf_vm, create_buf);
if (rv != FICL_VM_STATUS_OUT_OF_TEXT) {
printf("error interpreting forth: %d\n", rv);
@@ -1068,6 +1069,7 @@ help_getnext(int fd, char **topic, char **subtopic, char **desc)
{
char line[81], *cp, *ep;
+ *topic = *subtopic = *desc = NULL;
for (;;) {
if (fgetstr(line, 80, fd) < 0)
return (0);
@@ -1094,10 +1096,8 @@ help_getnext(int fd, char **topic, char **subtopic, char **desc)
cp = ep;
}
if (*topic == NULL) {
- if (*subtopic != NULL)
- free(*subtopic);
- if (*desc != NULL)
- free(*desc);
+ free(*subtopic);
+ free(*desc);
continue;
}
return (1);
@@ -1134,7 +1134,7 @@ command_help(int argc, char *argv[])
char *topic, *subtopic, *t, *s, *d;
/* page the help text from our load path */
- sprintf(buf, "/boot/loader.help");
+ snprintf(buf, sizeof (buf), "/boot/loader.help");
if ((hfd = open(buf, O_RDONLY)) < 0) {
printf("Verbose help not available, "
"use '?' to list commands\n");
@@ -1198,25 +1198,27 @@ command_help(int argc, char *argv[])
free(t);
free(s);
free(d);
+ t = s = d = NULL;
}
+ free(t);
+ free(s);
+ free(d);
pager_close();
close(hfd);
if (!matched) {
snprintf(command_errbuf, sizeof (command_errbuf),
"no help available for '%s'", topic);
free(topic);
- if (subtopic)
- free(subtopic);
+ free(subtopic);
return (CMD_ERROR);
}
free(topic);
- if (subtopic)
- free(subtopic);
+ free(subtopic);
return (CMD_OK);
}
static int
-command_commandlist(int argc, char *argv[])
+command_commandlist(int argc __unused, char *argv[] __unused)
{
struct bootblk_command *cmdp;
int res;
@@ -1230,7 +1232,8 @@ command_commandlist(int argc, char *argv[])
if (res)
break;
if ((cmdp->c_name != NULL) && (cmdp->c_desc != NULL)) {
- sprintf(name, " %-15s ", cmdp->c_name);
+ snprintf(name, sizeof (name), " %-15s ",
+ cmdp->c_name);
pager_output(name);
pager_output(cmdp->c_desc);
res = pager_output("\n");
@@ -1451,14 +1454,16 @@ command_more(int argc, char *argv[])
res = 0;
pager_open();
for (i = 1; (i < argc) && (res == 0); i++) {
- sprintf(line, "*** FILE %s BEGIN ***\n", argv[i]);
+ snprintf(line, sizeof (line), "*** FILE %s BEGIN ***\n",
+ argv[i]);
if (pager_output(line))
break;
name = get_dev(argv[i]);
res = page_file(name);
free(name);
if (!res) {
- sprintf(line, "*** FILE %s END ***\n", argv[i]);
+ snprintf(line, sizeof (line), "*** FILE %s END ***\n",
+ argv[i]);
res = pager_output(line);
}
}
@@ -1537,20 +1542,22 @@ command_ls(int argc, char *argv[])
sb.st_size = 0;
sb.st_mode = 0;
buf = malloc(strlen(path) + strlen(d->d_name) + 2);
- if (path[0] == '\0')
- sprintf(buf, "%s", d->d_name);
- else
- sprintf(buf, "%s/%s", path, d->d_name);
+ if (path[0] == '\0') {
+ snprintf(buf, sizeof (buf), "%s", d->d_name);
+ } else {
+ snprintf(buf, sizeof (buf), "%s/%s", path,
+ d->d_name);
+ }
/* ignore return, could be symlink, etc. */
if (stat(buf, &sb))
sb.st_size = 0;
free(buf);
if (verbose) {
- sprintf(lbuf, " %c %8d %s\n",
+ snprintf(lbuf, sizeof (lbuf), " %c %8d %s\n",
typestr[sb.st_mode >> 12],
(int)sb.st_size, d->d_name);
} else {
- sprintf(lbuf, " %c %s\n",
+ snprintf(lbuf, sizeof (lbuf), " %c %s\n",
typestr[sb.st_mode >> 12], d->d_name);
}
if (pager_output(lbuf))
diff --git a/usr/src/lib/Makefile b/usr/src/lib/Makefile
index 3bdaeda439..113de250ce 100644
--- a/usr/src/lib/Makefile
+++ b/usr/src/lib/Makefile
@@ -625,7 +625,7 @@ libds: libsysevent
libdscfg: libnsctl libunistat libadm
libdtrace: libproc libgen libctf libmapmalloc
libdtrace_jni: libuutil libdtrace
-libefi: libuuid
+libefi: libuuid libsmbios
libelfsign: libcryptoutil libkmf ../cmd/sgs/libelf
libeti: libcurses
libexacct/demo: libexacct libproject
diff --git a/usr/src/lib/libc/port/print/doprnt.c b/usr/src/lib/libc/port/print/doprnt.c
index 0c0fe0cacb..b6e8ceef0a 100644
--- a/usr/src/lib/libc/port/print/doprnt.c
+++ b/usr/src/lib/libc/port/print/doprnt.c
@@ -195,11 +195,11 @@ static const wchar_t widenullstr[] = L"(null)";
#define CHAR 0x2000 /* hh for char */
#ifdef _WIDE
-static wchar_t *
-insert_thousands_sep(wchar_t *bp, wchar_t *ep);
+static wchar_t *insert_decimal_point(wchar_t *ep);
+static wchar_t *insert_thousands_sep(wchar_t *bp, wchar_t *ep);
#else /* _WIDE */
-static char *
-insert_thousands_sep(char *bp, char *ep);
+static char *insert_decimal_point(char *ep);
+static char *insert_thousands_sep(char *bp, char *ep);
#endif /* _WIDE */
static int _rec_scrswidth(wchar_t *, ssize_t);
@@ -571,8 +571,6 @@ _ndoprnt(const char *format, va_list in_args, FILE *iop, int prflag)
/* arglst[1] is the second arg, etc */
int starflg = 0; /* set to 1 if * format specifier seen */
- struct lconv *locptr = localeconv();
- char decimal_point = *locptr->decimal_point;
/*
* Initialize args and sargs to the start of the argument list.
@@ -1344,11 +1342,11 @@ _ndoprnt(const char *format, va_list in_args, FILE *iop, int prflag)
p = &buf[0];
*p++ = (*bp != '\0') ? *bp++ : '0';
- /* put in a decimal point if needed */
+ /* Put in a decimal point if needed */
if (prec != 0 || (flagword & FSHARP))
- *p++ = decimal_point;
+ p = insert_decimal_point(p);
- /* create the rest of the mantissa */
+ /* Create the rest of the mantissa */
rz = prec;
if (fcode == 'A') {
for (; rz > 0 && *bp != '\0'; --rz) {
@@ -1452,7 +1450,7 @@ _ndoprnt(const char *format, va_list in_args, FILE *iop, int prflag)
/* Put in a decimal point if needed */
if (prec != 0 || (flagword & FSHARP))
- *p++ = decimal_point;
+ p = insert_decimal_point(p);
/* Create the rest of the mantissa */
rz = prec;
@@ -1575,9 +1573,9 @@ _ndoprnt(const char *format, va_list in_args, FILE *iop, int prflag)
if (quote)
p = insert_thousands_sep(buf, p);
- /* Decide whether we need a decimal point */
- if ((flagword & FSHARP) || prec > 0)
- *p++ = decimal_point;
+ /* Put in a decimal point if needed */
+ if (prec != 0 || (flagword & FSHARP))
+ p = insert_decimal_point(p);
/* Digits (if any) after the decimal point */
nn = min(prec, MAXFCVT);
@@ -2662,6 +2660,28 @@ insert_thousands_sep(char *bp, char *ep)
return (ep);
}
+#ifdef _WIDE
+static wchar_t *
+insert_decimal_point(wchar_t *ep)
+#else
+static char *
+insert_decimal_point(char *ep)
+#endif
+{
+ struct lconv *locptr = localeconv();
+ char *dp = locptr->decimal_point;
+#ifdef _WIDE
+ wchar_t wdp;
+
+ (void) mbtowc(&wdp, dp, MB_CUR_MAX);
+ *ep = wdp;
+ return (ep + 1);
+#else
+ (void) memcpy(ep, dp, strlen(dp));
+ return (ep + strlen(dp));
+#endif
+}
+
/*
* Recovery scrswidth function -
diff --git a/usr/src/man/man4/Makefile b/usr/src/man/man4/Makefile
index d02c23ecc1..431c5323db 100644
--- a/usr/src/man/man4/Makefile
+++ b/usr/src/man/man4/Makefile
@@ -13,6 +13,7 @@
# Copyright 2011, Richard Lowe
# Copyright 2015, Joyent, Inc.
# Copyright 2016 Nexenta Systems, Inc.
+# Copyright 2018 Gary Mills
#
include $(SRC)/Makefile.master
@@ -100,7 +101,6 @@ _MANFILES= Intro.4 \
ldapfilter.conf.4 \
ldapsearchprefs.conf.4 \
ldaptemplates.conf.4 \
- loader.conf.4 \
logadm.conf.4 \
logindevperm.4 \
loginlog.4 \
@@ -206,7 +206,8 @@ _MANFILES= Intro.4 \
sparc_MANFILES= sbus.4
-i386_MANFILES= sysbus.4
+i386_MANFILES= loader.conf.4 \
+ sysbus.4
_MANLINKS= addresses.4 \
devid_cache.4 \
diff --git a/usr/src/man/man5/Makefile b/usr/src/man/man5/Makefile
index 422ce7435f..b224320c05 100644
--- a/usr/src/man/man5/Makefile
+++ b/usr/src/man/man5/Makefile
@@ -15,13 +15,14 @@
# Copyright 2014 Nexenta Systems, Inc.
# Copyright 2014 Garrett D'Amore <garrett@damore.org>
# Copyright 2016, Joyent, Inc.
+# Copyright 2018 Gary Mills
#
include $(SRC)/Makefile.master
MANSECT= 5
-MANFILES= Intro.5 \
+_MANFILES= Intro.5 \
acl.5 \
ad.5 \
ascii.5 \
@@ -29,21 +30,17 @@ MANFILES= Intro.5 \
audit_binfile.5 \
audit_remote.5 \
audit_syslog.5 \
- brand.4th.5 \
brands.5 \
byteorder.5 \
cancellation.5 \
charmap.5 \
- check-password.4th.5 \
condition.5 \
- color.4th.5 \
crypt_bsdbf.5 \
crypt_bsdmd5.5 \
crypt_sha256.5 \
crypt_sha512.5 \
crypt_sunmd5.5 \
crypt_unix.5 \
- delay.4th.5 \
device_clean.5 \
dhcp.5 \
environ.5 \
@@ -56,7 +53,6 @@ MANFILES= Intro.5 \
fnmatch.5 \
formats.5 \
fsattr.5 \
- gptzfsboot.5 \
grub.5 \
gss_auth_rules.5 \
hal.5 \
@@ -74,8 +70,6 @@ MANFILES= Intro.5 \
lf64.5 \
lfcompile.5 \
lfcompile64.5 \
- loader.5 \
- loader.4th.5 \
locale.5 \
lx.5 \
man.5 \
@@ -85,8 +79,6 @@ MANFILES= Intro.5 \
mdoc.5 \
me.5 \
mech_spnego.5 \
- menu.4th.5 \
- menusets.4th.5 \
mm.5 \
ms.5 \
mutex.5 \
@@ -120,7 +112,6 @@ MANFILES= Intro.5 \
pkcs11_tpm.5 \
privileges.5 \
prof.5 \
- pxeboot.5 \
rbac.5 \
regex.5 \
regexp.5 \
@@ -140,12 +131,25 @@ MANFILES= Intro.5 \
threads.5 \
timerfd.5 \
trusted_extensions.5 \
- version.4th.5 \
vgrindefs.5 \
- zfsloader.5 \
zones.5 \
zpool-features.5
+sparc_MANFILES=
+
+i386_MANFILES= brand.4th.5 \
+ check-password.4th.5 \
+ color.4th.5 \
+ delay.4th.5 \
+ gptzfsboot.5 \
+ loader.5 \
+ loader.4th.5 \
+ menu.4th.5 \
+ menusets.4th.5 \
+ pxeboot.5 \
+ version.4th.5 \
+ zfsloader.5
+
MANLINKS= ANSI.5 \
C++.5 \
C.5 \
@@ -180,6 +184,8 @@ MANLINKS= ANSI.5 \
step.5 \
teclarc.5
+MANFILES= $(_MANFILES) $($(MACH)_MANFILES)
+
intro.5 := LINKSRC = Intro.5
CSI.5 := LINKSRC = attributes.5
diff --git a/usr/src/pkg/manifests/system-test-libctest.mf b/usr/src/pkg/manifests/system-test-libctest.mf
index 32cb761128..f2eb069681 100644
--- a/usr/src/pkg/manifests/system-test-libctest.mf
+++ b/usr/src/pkg/manifests/system-test-libctest.mf
@@ -98,6 +98,8 @@ file path=opt/libc-tests/tests/nl_langinfo_test mode=0555
file path=opt/libc-tests/tests/nl_langinfo_test.$(ARCH) mode=0555
file path=opt/libc-tests/tests/nl_langinfo_test.$(ARCH64) mode=0555
file path=opt/libc-tests/tests/printf-6961.64 mode=0555
+file path=opt/libc-tests/tests/printf-9511.32 mode=0555
+file path=opt/libc-tests/tests/printf-9511.64 mode=0555
file path=opt/libc-tests/tests/priv_gettext mode=0555
file path=opt/libc-tests/tests/psignal mode=0555
file path=opt/libc-tests/tests/psignal-5097.32 mode=0555
@@ -202,6 +204,7 @@ hardlink path=opt/libc-tests/tests/symbols/wctype_h target=setup
license lic_CDDL license=lic_CDDL
license usr/src/test/libc-tests/tests/regex/THIRDPARTYLICENSE \
license=usr/src/test/libc-tests/tests/regex/THIRDPARTYLICENSE
+depend fmri=locale/ar type=require
depend fmri=locale/de type=require
depend fmri=locale/en type=require
depend fmri=locale/en-extra type=require
diff --git a/usr/src/test/libc-tests/doc/README b/usr/src/test/libc-tests/doc/README
index f5640c58dd..e74f398ec1 100644
--- a/usr/src/test/libc-tests/doc/README
+++ b/usr/src/test/libc-tests/doc/README
@@ -49,16 +49,16 @@ install the Utils Unit Test Suite.
Note, the framework will be installed automatically, as this test suite
depends on it.
-Additionally some text locales are required, specifically, en_US.UTF-8,
-de_DE.UTF-8, ja_JP.UTF-8, and ru_RU.UTF-8. Again, these are listed as
-dependencies and will be automatically installed.
+Additionally some text locales are required, specifically, ar_AE.UTF-8,
+de_DE.UTF-8, en_US.UTF-8, ja_JP.UTF-8, and ru_RU.UTF-8. Again, these are
+listed as dependencies and will be automatically installed.
3. Running this Unit Test Suite
The pre-requisites for running the this Unit Test Suite are:
- Any user may perform these tests.
- - The en_US.UTF-8, en_GB.ISO8859-15, ja_JP.UTF-8, de_DE.UTF-8, and
- ru_RU.UTF-8 locales must be installed.
+ - The ar_AE.UTF-8, de_DE.UTF-8, en_US.UTF-8, en_GB.ISO8859-15,
+ ja_JP.UTF-8, and ru_RU.UTF-8 locales must be installed.
Once the pre-requisites are satisfied, simply run the libctest script:
diff --git a/usr/src/test/libc-tests/runfiles/default.run b/usr/src/test/libc-tests/runfiles/default.run
index fec836d207..35b04fd9fc 100644
--- a/usr/src/test/libc-tests/runfiles/default.run
+++ b/usr/src/test/libc-tests/runfiles/default.run
@@ -82,6 +82,8 @@ timeout = 600
[/opt/libc-tests/tests/quick_exit]
[/opt/libc-tests/tests/psignal]
[/opt/libc-tests/tests/printf-6961.64]
+[/opt/libc-tests/tests/printf-9511.32]
+[/opt/libc-tests/tests/printf-9511.64]
[/opt/libc-tests/tests/priv_gettext]
[/opt/libc-tests/tests/strerror]
[/opt/libc-tests/tests/timespec_get.32]
diff --git a/usr/src/test/libc-tests/tests/Makefile b/usr/src/test/libc-tests/tests/Makefile
index 4a3a449723..c587231ac1 100644
--- a/usr/src/test/libc-tests/tests/Makefile
+++ b/usr/src/test/libc-tests/tests/Makefile
@@ -39,6 +39,7 @@ PROGS = \
endian \
env-7076 \
fnmatch \
+ printf-9511 \
psignal-5097 \
quick_exit_order \
quick_exit_status \
diff --git a/usr/src/test/libc-tests/tests/printf-9511.c b/usr/src/test/libc-tests/tests/printf-9511.c
new file mode 100644
index 0000000000..98823f0d10
--- /dev/null
+++ b/usr/src/test/libc-tests/tests/printf-9511.c
@@ -0,0 +1,70 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2018 Nexenta Systems, Inc.
+ */
+
+/*
+ * Note that this file is easiest edited with a UTF-8 capable editor,
+ * as there are embedded UTF-8 symbols in some of the strings.
+ */
+
+#include <err.h>
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+
+struct {
+ const char *locale;
+ const char *convspec;
+ const float fp;
+ const char *expected;
+} fpconv[] = {
+ "C", "%a", 3.2, "0x1.99999a0000000p+1",
+ "C", "%e", 3.2, "3.200000e+00",
+ "C", "%f", 3.2, "3.200000",
+ "C", "%g", 3.2, "3.2",
+ "ar_AE.UTF-8", "%a", 3.2, "0x1٫99999a0000000p+1",
+ "ar_AE.UTF-8", "%e", 3.2, "3٫200000e+00",
+ "ar_AE.UTF-8", "%f", 3.2, "3٫200000",
+ "ar_AE.UTF-8", "%g", 3.2, "3٫2",
+ "en_US.UTF-8", "%a", 3.2, "0x1.99999a0000000p+1",
+ "en_US.UTF-8", "%e", 3.2, "3.200000e+00",
+ "en_US.UTF-8", "%f", 3.2, "3.200000",
+ "en_US.UTF-8", "%g", 3.2, "3.2",
+ "ru_RU.UTF-8", "%a", 3.2, "0x1,99999a0000000p+1",
+ "ru_RU.UTF-8", "%e", 3.2, "3,200000e+00",
+ "ru_RU.UTF-8", "%f", 3.2, "3,200000",
+ "ru_RU.UTF-8", "%g", 3.2, "3,2",
+ NULL, NULL, 0, NULL
+};
+
+int
+main(void)
+{
+ char buf[100];
+ int i;
+
+ for (i = 0; fpconv[i].locale != NULL; i++) {
+ if (setlocale(LC_ALL, fpconv[i].locale) == NULL)
+ err(1, "failed to set locale to %s", fpconv[i].locale);
+
+ (void) sprintf(buf, fpconv[i].convspec, fpconv[i].fp);
+ if (strcmp(fpconv[i].expected, buf) != 0) {
+ errx(1, "locale=%s, convspec=%s, expected=%s, got=%s",
+ fpconv[i].locale, fpconv[i].convspec,
+ fpconv[i].expected, buf);
+ }
+ }
+
+ return (0);
+}