From 2be111bf7dda0f18d645f0e201b6555bbe3da1ac Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Thu, 16 Oct 2014 18:04:43 +0000 Subject: [PATCH] Follow up to r225617. In order to maximize the re-usability of kernel code in userland rename in-kernel getenv()/setenv() to kern_setenv()/kern_getenv(). This fixes a namespace collision with libc symbols. Submitted by: kmacy Tested by: make universe --- sys/amd64/amd64/machdep.c | 6 +++--- sys/amd64/vmm/vmm.c | 2 +- sys/arm/arm/machdep.c | 2 +- sys/cam/ata/ata_da.c | 2 +- .../opensolaris/uts/common/dtrace/dtrace.c | 2 +- sys/dev/acpica/acpi.c | 16 ++++++++-------- sys/dev/asmc/asmc.c | 2 +- sys/dev/cfi/cfi_core.c | 2 +- sys/dev/drm2/drm_crtc_helper.c | 2 +- sys/dev/hatm/if_hatm.c | 2 +- sys/dev/mii/brgphy.c | 2 +- sys/dev/nfe/if_nfe.c | 8 ++++---- sys/dev/patm/if_patm_attach.c | 2 +- sys/dev/pci/pci.c | 4 ++-- sys/dev/pci/pci_pci.c | 4 ++-- sys/dev/rt/if_rt.c | 4 ++-- sys/dev/uart/uart_subr.c | 4 ++-- sys/fs/nfsclient/nfs_clvfsops.c | 2 +- sys/geom/geom_dev.c | 4 ++-- sys/geom/raid/g_raid.c | 2 +- sys/geom/sched/g_sched.c | 4 ++-- sys/i386/i386/bios.c | 4 ++-- sys/i386/i386/machdep.c | 4 ++-- sys/i386/xen/xen_machdep.c | 2 +- sys/kern/init_main.c | 2 +- sys/kern/kern_environment.c | 14 +++++++------- sys/kern/kern_sysctl.c | 2 +- sys/kern/subr_hints.c | 2 +- sys/kern/subr_param.c | 4 ++-- sys/kern/vfs_mountroot.c | 6 +++--- sys/mips/atheros/ar71xx_machdep.c | 10 +++++----- sys/mips/nlm/xlp_machdep.c | 10 +++++----- sys/mips/rmi/xlr_machdep.c | 6 +++--- sys/nfs/bootp_subr.c | 4 ++-- sys/nfs/nfs_diskless.c | 18 +++++++++--------- sys/nfsclient/nfs_vfsops.c | 2 +- sys/powerpc/aim/machdep.c | 2 +- sys/sparc64/sparc64/machdep.c | 2 +- sys/sys/systm.h | 6 +++--- sys/vm/vm_page.c | 2 +- sys/x86/iommu/busdma_dmar.c | 2 +- sys/x86/x86/tsc.c | 2 +- sys/x86/xen/pv.c | 2 +- 43 files changed, 93 insertions(+), 93 deletions(-) diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index ab827718d764..95d67c039f39 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -244,7 +244,7 @@ cpu_startup(dummy) * We do this by disabling a bit in the SMI_EN (SMI Control and * Enable register) of the Intel ICH LPC Interface Bridge. */ - sysenv = getenv("smbios.system.product"); + sysenv = kern_getenv("smbios.system.product"); if (sysenv != NULL) { if (strncmp(sysenv, "MacBook1,1", 10) == 0 || strncmp(sysenv, "MacBook3,1", 10) == 0 || @@ -276,7 +276,7 @@ cpu_startup(dummy) * Display physical memory if SMBIOS reports reasonable amount. */ memsize = 0; - sysenv = getenv("smbios.memory.enabled"); + sysenv = kern_getenv("smbios.memory.enabled"); if (sysenv != NULL) { memsize = (uintmax_t)strtoul(sysenv, (char **)NULL, 10) << 10; freeenv(sysenv); @@ -2070,7 +2070,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) thread0.td_pcb->pcb_cr3 = KPML4phys; /* PCID 0 is reserved for kernel */ thread0.td_frame = &proc0_tf; - env = getenv("kernelname"); + env = kern_getenv("kernelname"); if (env != NULL) strlcpy(kernelname, env, sizeof(kernelname)); diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index 8f987b7c7d10..dd0829c6aeb6 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -1934,7 +1934,7 @@ vmm_is_pptdev(int bus, int slot, int func) /* set pptdevs="1/2/3 4/5/6 7/8/9 10/11/12" */ found = 0; for (i = 0; names[i] != NULL && !found; i++) { - cp = val = getenv(names[i]); + cp = val = kern_getenv(names[i]); while (cp != NULL && *cp != '\0') { if ((cp2 = strchr(cp, ' ')) != NULL) *cp2 = '\0'; diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c index 98c424e21953..96c5b20a3f01 100644 --- a/sys/arm/arm/machdep.c +++ b/sys/arm/arm/machdep.c @@ -1245,7 +1245,7 @@ initarm(struct arm_boot_params *abp) debugf(" dtbp = 0x%08x\n", (uint32_t)dtbp); print_kenv(); - env = getenv("kernelname"); + env = kern_getenv("kernelname"); if (env != NULL) strlcpy(kernelname, env, sizeof(kernelname)); diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c index 9209e36ffffe..17c585431a0f 100644 --- a/sys/cam/ata/ata_da.c +++ b/sys/cam/ata/ata_da.c @@ -1316,7 +1316,7 @@ adaregister(struct cam_periph *periph, void *arg) softc->disk->d_name, softc->disk->d_unit); snprintf(buf1, sizeof(buf1), "ad%d", legacy_id); - setenv(announce_buf, buf1); + kern_setenv(announce_buf, buf1); } } else legacy_id = -1; diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c index 3efe022ec2bd..0cd832e2180e 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c +++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c @@ -13052,7 +13052,7 @@ dtrace_dof_property(const char *name) char *p; char *p_env; - if ((p_env = getenv(name)) == NULL) + if ((p_env = kern_getenv(name)) == NULL) return (NULL); len = strlen(p_env) / 2; diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index abbc9b5a8b06..1389bad81716 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -594,7 +594,7 @@ acpi_attach(device_t dev) sc->acpi_sleep_delay = 1; if (bootverbose) sc->acpi_verbose = 1; - if ((env = getenv("hw.acpi.verbose")) != NULL) { + if ((env = kern_getenv("hw.acpi.verbose")) != NULL) { if (strcmp(env, "0") != 0) sc->acpi_verbose = 1; freeenv(env); @@ -3337,7 +3337,7 @@ acpi_avoid(ACPI_HANDLE handle) np = acpi_name(handle); if (*np == '\\') np++; - if ((env = getenv("debug.acpi.avoid")) == NULL) + if ((env = kern_getenv("debug.acpi.avoid")) == NULL) return (0); /* Scan the avoid list checking for a match */ @@ -3370,7 +3370,7 @@ acpi_disabled(char *subsys) char *cp, *env; int len; - if ((env = getenv("debug.acpi.disabled")) == NULL) + if ((env = kern_getenv("debug.acpi.disabled")) == NULL) return (0); if (strcmp(env, "all") == 0) { freeenv(env); @@ -3753,8 +3753,8 @@ acpi_set_debugging(void *junk) AcpiDbgLevel = 0; } - layer = getenv("debug.acpi.layer"); - level = getenv("debug.acpi.level"); + layer = kern_getenv("debug.acpi.layer"); + level = kern_getenv("debug.acpi.level"); if (layer == NULL && level == NULL) return; @@ -3813,9 +3813,9 @@ acpi_debug_sysctl(SYSCTL_HANDLER_ARGS) /* If the user is setting a string, parse it. */ if (error == 0 && req->newptr != NULL) { - *dbg = 0; - setenv((char *)oidp->oid_arg1, (char *)req->newptr); - acpi_set_debugging(NULL); + *dbg = 0; + kern_setenv((char *)oidp->oid_arg1, (char *)req->newptr); + acpi_set_debugging(NULL); } ACPI_SERIAL_END(acpi); diff --git a/sys/dev/asmc/asmc.c b/sys/dev/asmc/asmc.c index 5933307f3e9c..b61dedb7fca9 100644 --- a/sys/dev/asmc/asmc.c +++ b/sys/dev/asmc/asmc.c @@ -310,7 +310,7 @@ asmc_match(device_t dev) int i; char *model; - model = getenv("smbios.system.product"); + model = kern_getenv("smbios.system.product"); if (model == NULL) return (NULL); diff --git a/sys/dev/cfi/cfi_core.c b/sys/dev/cfi/cfi_core.c index 3393ca6ea277..5150b779f0e5 100644 --- a/sys/dev/cfi/cfi_core.c +++ b/sys/dev/cfi/cfi_core.c @@ -410,7 +410,7 @@ cfi_attach(device_t dev) device_get_nameunit(dev)) < (sizeof(name) - 1) && snprintf(value, sizeof(value), "0x%016jx", ppr) < (sizeof(value) - 1)) - (void) setenv(name, value); + (void) kern_setenv(name, value); } #endif diff --git a/sys/dev/drm2/drm_crtc_helper.c b/sys/dev/drm2/drm_crtc_helper.c index b798a57bae10..77e134640f96 100644 --- a/sys/dev/drm2/drm_crtc_helper.c +++ b/sys/dev/drm2/drm_crtc_helper.c @@ -53,7 +53,7 @@ drm_fetch_cmdline_mode_from_kenv(struct drm_connector *connector, strlen(drm_get_connector_name(connector)), M_TEMP, M_WAITOK); strcpy(tun_var_name, tun_prefix); strcat(tun_var_name, drm_get_connector_name(connector)); - tun_mode = getenv(tun_var_name); + tun_mode = kern_getenv(tun_var_name); if (tun_mode != NULL) { res = drm_mode_parse_command_line_for_connector(tun_mode, connector, cmdline_mode); diff --git a/sys/dev/hatm/if_hatm.c b/sys/dev/hatm/if_hatm.c index c022724f4daa..0be8a3d17b83 100644 --- a/sys/dev/hatm/if_hatm.c +++ b/sys/dev/hatm/if_hatm.c @@ -1319,7 +1319,7 @@ kenv_getuint(struct hatm_softc *sc, const char *var, snprintf(full, sizeof(full), "hw.%s.%s", device_get_nameunit(sc->dev), var); - if ((val = getenv(full)) == NULL) + if ((val = kern_getenv(full)) == NULL) return (0); u = strtoul(val, &end, 0); if (end == val || *end != '\0') { diff --git a/sys/dev/mii/brgphy.c b/sys/dev/mii/brgphy.c index b8ec89c59923..dba35a02224d 100644 --- a/sys/dev/mii/brgphy.c +++ b/sys/dev/mii/brgphy.c @@ -171,7 +171,7 @@ detect_hs21(struct bce_softc *bce_sc) found = 0; if (bce_sc->bce_chipid == HS21_BCM_CHIPID) { - sysenv = getenv("smbios.system.product"); + sysenv = kern_getenv("smbios.system.product"); if (sysenv != NULL) { if (strncmp(sysenv, HS21_PRODUCT_ID, strlen(HS21_PRODUCT_ID)) == 0) diff --git a/sys/dev/nfe/if_nfe.c b/sys/dev/nfe/if_nfe.c index 4c7ccb1a6193..e9952a0af2d9 100644 --- a/sys/dev/nfe/if_nfe.c +++ b/sys/dev/nfe/if_nfe.c @@ -345,8 +345,8 @@ nfe_detect_msik9(struct nfe_softc *sc) int found; found = 0; - m = getenv("smbios.planar.maker"); - p = getenv("smbios.planar.product"); + m = kern_getenv("smbios.planar.maker"); + p = kern_getenv("smbios.planar.product"); if (m != NULL && p != NULL) { if (strcmp(m, maker) == 0 && strcmp(p, product) == 0) found = 1; @@ -839,8 +839,8 @@ nfe_can_use_msix(struct nfe_softc *sc) * Search base board manufacturer and product name table * to see this system has a known MSI/MSI-X issue. */ - maker = getenv("smbios.planar.maker"); - product = getenv("smbios.planar.product"); + maker = kern_getenv("smbios.planar.maker"); + product = kern_getenv("smbios.planar.product"); use_msix = 1; if (maker != NULL && product != NULL) { count = sizeof(msix_blacklists) / sizeof(msix_blacklists[0]); diff --git a/sys/dev/patm/if_patm_attach.c b/sys/dev/patm/if_patm_attach.c index d93fd008162e..f4b8c4e9f51d 100644 --- a/sys/dev/patm/if_patm_attach.c +++ b/sys/dev/patm/if_patm_attach.c @@ -579,7 +579,7 @@ patm_env_getuint(struct patm_softc *sc, u_int *var, const char *name) snprintf(full, sizeof(full), "hw.%s.%s", device_get_nameunit(sc->dev), name); - if ((val = getenv(full)) != NULL) { + if ((val = kern_getenv(full)) != NULL) { u = strtoul(val, &end, 0); if (end > val && *end == '\0') { if (bootverbose) diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 2666d7fa831a..485f7289c964 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -3270,14 +3270,14 @@ pci_reserve_secbus(device_t bus, device_t dev, pcicfgregs *cfg, case 0x00dd10de: /* Compaq R3000 BIOS sets wrong subordinate bus number. */ - if ((cp = getenv("smbios.planar.maker")) == NULL) + if ((cp = kern_getenv("smbios.planar.maker")) == NULL) break; if (strncmp(cp, "Compal", 6) != 0) { freeenv(cp); break; } freeenv(cp); - if ((cp = getenv("smbios.planar.product")) == NULL) + if ((cp = kern_getenv("smbios.planar.product")) == NULL) break; if (strncmp(cp, "08A0", 4) != 0) { freeenv(cp); diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c index 3c5842be44c6..f35b481a1ab6 100644 --- a/sys/dev/pci/pci_pci.c +++ b/sys/dev/pci/pci_pci.c @@ -977,14 +977,14 @@ pcib_attach_common(device_t dev) { char *cp; - if ((cp = getenv("smbios.planar.maker")) == NULL) + if ((cp = kern_getenv("smbios.planar.maker")) == NULL) break; if (strncmp(cp, "Compal", 6) != 0) { freeenv(cp); break; } freeenv(cp); - if ((cp = getenv("smbios.planar.product")) == NULL) + if ((cp = kern_getenv("smbios.planar.product")) == NULL) break; if (strncmp(cp, "08A0", 4) != 0) { freeenv(cp); diff --git a/sys/dev/rt/if_rt.c b/sys/dev/rt/if_rt.c index 910276fdc719..f89f6dc512a1 100644 --- a/sys/dev/rt/if_rt.c +++ b/sys/dev/rt/if_rt.c @@ -241,8 +241,8 @@ ether_request_mac(device_t dev, uint8_t *mac) * "kmac" is passed via argv on RouterBOOT platforms */ #if defined(__U_BOOT__) || defined(__REDBOOT__) || defined(__ROUTERBOOT__) - if ((var = getenv("ethaddr")) != NULL || - (var = getenv("kmac")) != NULL ) { + if ((var = kern_getenv("ethaddr")) != NULL || + (var = kern_getenv("kmac")) != NULL ) { if(!macaddr_atoi(var, mac)) { printf("%s: use %s macaddr from KENV\n", diff --git a/sys/dev/uart/uart_subr.c b/sys/dev/uart/uart_subr.c index 0277b2137179..d1e408cba692 100644 --- a/sys/dev/uart/uart_subr.c +++ b/sys/dev/uart/uart_subr.c @@ -214,9 +214,9 @@ uart_getenv(int devtype, struct uart_devinfo *di, struct uart_class *class) * port (resp). */ if (devtype == UART_DEV_CONSOLE) - spec = getenv("hw.uart.console"); + spec = kern_getenv("hw.uart.console"); else if (devtype == UART_DEV_DBGPORT) - spec = getenv("hw.uart.dbgport"); + spec = kern_getenv("hw.uart.dbgport"); else spec = NULL; if (spec == NULL) diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c index 6b0935618876..49047f69a612 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -442,7 +442,7 @@ nfs_mountroot(struct mount *mp) error = ifioctl(so, SIOCAIFADDR, (caddr_t)&nd->myif, td); if (error) panic("nfs_mountroot: SIOCAIFADDR: %d", error); - if ((cp = getenv("boot.netif.mtu")) != NULL) { + if ((cp = kern_getenv("boot.netif.mtu")) != NULL) { ir.ifr_mtu = strtol(cp, NULL, 10); bcopy(nd->myif.ifra_name, ir.ifr_name, IFNAMSIZ); freeenv(cp); diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c index e6213ee43882..faad3e6af308 100644 --- a/sys/geom/geom_dev.c +++ b/sys/geom/geom_dev.c @@ -116,7 +116,7 @@ static void g_dev_init(struct g_class *mp) { - dumpdev = getenv("dumpdev"); + dumpdev = kern_getenv("dumpdev"); } static void @@ -302,7 +302,7 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused) for (len = MIN(strlen(gp->name), sizeof(buf) - 15); len > 0; len--) { snprintf(buf, sizeof(buf), "kern.devalias.%s", gp->name); buf[14 + len] = 0; - val = getenv(buf); + val = kern_getenv(buf); if (val != NULL) { snprintf(buf, sizeof(buf), "%s%s", val, gp->name + len); diff --git a/sys/geom/raid/g_raid.c b/sys/geom/raid/g_raid.c index db9cf445ecb2..546bd2072931 100644 --- a/sys/geom/raid/g_raid.c +++ b/sys/geom/raid/g_raid.c @@ -1656,7 +1656,7 @@ g_raid_launch_provider(struct g_raid_volume *vol) "kern.devalias.%s", name); snprintf(buf1, sizeof(buf1), "ar%d", vol->v_global_id); - setenv(announce_buf, buf1); + kern_setenv(announce_buf, buf1); } pp = g_new_providerf(sc->sc_geom, "%s", name); diff --git a/sys/geom/sched/g_sched.c b/sys/geom/sched/g_sched.c index 12a04615411f..009a58cedee5 100644 --- a/sys/geom/sched/g_sched.c +++ b/sys/geom/sched/g_sched.c @@ -1661,7 +1661,7 @@ g_sched_taste(struct g_class *mp, struct g_provider *pp, if (pp->geom->class == mp) break; - taste_names = getenv("geom.sched.taste"); + taste_names = kern_getenv("geom.sched.taste"); if (taste_names == NULL) break; @@ -1679,7 +1679,7 @@ g_sched_taste(struct g_class *mp, struct g_provider *pp, pp->name, s); /* look up the provider name in the list */ - s = getenv("geom.sched.algo"); + s = kern_getenv("geom.sched.algo"); if (s == NULL) s = "rr"; diff --git a/sys/i386/i386/bios.c b/sys/i386/i386/bios.c index ffe42bae8d77..1bce11c12cd0 100644 --- a/sys/i386/i386/bios.c +++ b/sys/i386/i386/bios.c @@ -106,7 +106,7 @@ bios32_init(void *junk) } /* Allow user override of PCI BIOS search */ - if (((p = getenv("machdep.bios.pci")) == NULL) || strcmp(p, "disable")) { + if (((p = kern_getenv("machdep.bios.pci")) == NULL) || strcmp(p, "disable")) { /* See if there's a PCI BIOS entrypoint here */ PCIbios.ident.id = 0x49435024; /* PCI systems should have this */ @@ -125,7 +125,7 @@ bios32_init(void *junk) * * Allow user override of PnP BIOS search */ - if ((((p = getenv("machdep.bios.pnp")) == NULL) || strcmp(p, "disable")) && + if ((((p = kern_getenv("machdep.bios.pnp")) == NULL) || strcmp(p, "disable")) && ((sigaddr = bios_sigsearch(0, "$PnP", 4, 16, 0)) != 0)) { /* get a virtual pointer to the structure */ diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 9d98f0efdb37..5ed5c5472e0b 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -281,7 +281,7 @@ cpu_startup(dummy) * We do this by disabling a bit in the SMI_EN (SMI Control and * Enable register) of the Intel ICH LPC Interface Bridge. */ - sysenv = getenv("smbios.system.product"); + sysenv = kern_getenv("smbios.system.product"); if (sysenv != NULL) { if (strncmp(sysenv, "MacBook1,1", 10) == 0 || strncmp(sysenv, "MacBook3,1", 10) == 0 || @@ -314,7 +314,7 @@ cpu_startup(dummy) * Display physical memory if SMBIOS reports reasonable amount. */ memsize = 0; - sysenv = getenv("smbios.memory.enabled"); + sysenv = kern_getenv("smbios.memory.enabled"); if (sysenv != NULL) { memsize = (uintmax_t)strtoul(sysenv, (char **)NULL, 10) << 10; freeenv(sysenv); diff --git a/sys/i386/xen/xen_machdep.c b/sys/i386/xen/xen_machdep.c index 46409a54653c..dbaa7ad7cadb 100644 --- a/sys/i386/xen/xen_machdep.c +++ b/sys/i386/xen/xen_machdep.c @@ -165,7 +165,7 @@ xen_boothowto(char *envp) /* get equivalents from the environment */ for (i = 0; howto_names[i].ev != NULL; i++) - if (getenv(howto_names[i].ev) != NULL) + if (kern_getenv(howto_names[i].ev) != NULL) howto |= howto_names[i].mask; return howto; } diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 141d43846924..9faea009e68e 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -716,7 +716,7 @@ start_init(void *dummy) p->p_vmspace->vm_maxsaddr = (caddr_t)addr; p->p_vmspace->vm_ssize = 1; - if ((var = getenv("init_path")) != NULL) { + if ((var = kern_getenv("init_path")) != NULL) { strlcpy(init_path, var, sizeof(init_path)); freeenv(var); } diff --git a/sys/kern/kern_environment.c b/sys/kern/kern_environment.c index ff453cb91f25..d58fefe0b715 100644 --- a/sys/kern/kern_environment.c +++ b/sys/kern/kern_environment.c @@ -30,7 +30,7 @@ * dynamic array of strings later when the VM subsystem is up. * * We make these available through the kenv(2) syscall for userland - * and through getenv()/freeenv() setenv() unsetenv() testenv() for + * and through kern_getenv()/freeenv() kern_setenv() kern_unsetenv() testenv() for * the kernel. */ @@ -156,7 +156,7 @@ sys_kenv(td, uap) if (error) goto done; #endif - value = getenv(name); + value = kern_getenv(name); if (value == NULL) { error = ENOENT; goto done; @@ -188,7 +188,7 @@ sys_kenv(td, uap) error = mac_kenv_check_set(td->td_ucred, name, value); if (error == 0) #endif - setenv(name, value); + kern_setenv(name, value); free(value, M_TEMP); break; case KENV_UNSET: @@ -197,7 +197,7 @@ sys_kenv(td, uap) if (error) goto done; #endif - error = unsetenv(name); + error = kern_unsetenv(name); if (error) error = ENOENT; break; @@ -312,7 +312,7 @@ _getenv_static(const char *name) * after use. */ char * -getenv(const char *name) +kern_getenv(const char *name) { char buf[KENV_MNAMELEN + 1 + KENV_MVALLEN + 1]; char *ret; @@ -373,7 +373,7 @@ setenv_static(const char *name, const char *value) * Set an environment variable by name. */ int -setenv(const char *name, const char *value) +kern_setenv(const char *name, const char *value) { char *buf, *cp, *oldenv; int namelen, vallen, i; @@ -422,7 +422,7 @@ setenv(const char *name, const char *value) * Unset an environment variable string. */ int -unsetenv(const char *name) +kern_unsetenv(const char *name) { char *cp, *oldenv; int i, j; diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 5e74d87ea01d..3c618ecb2df4 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -241,7 +241,7 @@ sysctl_load_tunable_by_oid_locked(struct sysctl_oid *oidp) req.newptr = &val_64; break; case CTLTYPE_STRING: - penv = getenv(path + rem); + penv = kern_getenv(path + rem); if (penv == NULL) return; req.newlen = strlen(penv); diff --git a/sys/kern/subr_hints.c b/sys/kern/subr_hints.c index f9085b2000a5..25838ee34136 100644 --- a/sys/kern/subr_hints.c +++ b/sys/kern/subr_hints.c @@ -109,7 +109,7 @@ sysctl_hintmode(SYSCTL_HANDLER_ARGS) line = malloc(i+1, M_TEMP, M_WAITOK); strcpy(line, cp); line[eqidx] = '\0'; - setenv(line, line + eqidx + 1); + kern_setenv(line, line + eqidx + 1); free(line, M_TEMP); cp += i + 1; } diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c index f589097ffb74..d16f2dc4f113 100644 --- a/sys/kern/subr_param.c +++ b/sys/kern/subr_param.c @@ -188,7 +188,7 @@ detect_virtual(void) char *sysenv; int i; - sysenv = getenv("smbios.bios.vendor"); + sysenv = kern_getenv("smbios.bios.vendor"); if (sysenv != NULL) { for (i = 0; vm_bnames[i] != NULL; i++) if (strcmp(sysenv, vm_bnames[i]) == 0) { @@ -197,7 +197,7 @@ detect_virtual(void) } freeenv(sysenv); } - sysenv = getenv("smbios.system.product"); + sysenv = kern_getenv("smbios.system.product"); if (sysenv != NULL) { for (i = 0; vm_pnames[i] != NULL; i++) if (strcmp(sysenv, vm_pnames[i]) == 0) { diff --git a/sys/kern/vfs_mountroot.c b/sys/kern/vfs_mountroot.c index 9ec7340ad3e6..2816e1ba8c78 100644 --- a/sys/kern/vfs_mountroot.c +++ b/sys/kern/vfs_mountroot.c @@ -445,7 +445,7 @@ parse_dir_ask_printenv(const char *var) { char *val; - val = getenv(var); + val = kern_getenv(var); if (val != NULL) { printf(" %s=%s\n", var, val); freeenv(val); @@ -836,9 +836,9 @@ vfs_mountroot_conf0(struct sbuf *sb) sbuf_printf(sb, "cd9660:/dev/acd0 ro\n"); sbuf_printf(sb, ".timeout %d\n", root_mount_timeout); } - s = getenv("vfs.root.mountfrom"); + s = kern_getenv("vfs.root.mountfrom"); if (s != NULL) { - opt = getenv("vfs.root.mountfrom.options"); + opt = kern_getenv("vfs.root.mountfrom.options"); tok = s; error = parse_token(&tok, &mnt); while (!error) { diff --git a/sys/mips/atheros/ar71xx_machdep.c b/sys/mips/atheros/ar71xx_machdep.c index 22d089d2fff8..d2175f9768c1 100644 --- a/sys/mips/atheros/ar71xx_machdep.c +++ b/sys/mips/atheros/ar71xx_machdep.c @@ -92,9 +92,9 @@ parse_argv(char *str) } else { n = strsep(&v, "="); if (v == NULL) - setenv(n, "1"); + kern_setenv(n, "1"); else - setenv(n, v); + kern_setenv(n, v); } } } @@ -127,8 +127,8 @@ ar71xx_redboot_get_macaddr(void) * "ethaddr" is passed via envp on RedBoot platforms * "kmac" is passed via argv on RouterBOOT platforms */ - if ((var = getenv("ethaddr")) != NULL || - (var = getenv("kmac")) != NULL) { + if ((var = kern_getenv("ethaddr")) != NULL || + (var = kern_getenv("kmac")) != NULL) { count = sscanf(var, "%x%*c%x%*c%x%*c%x%*c%x%*c%x", &ar711_base_mac[0], &ar711_base_mac[1], &ar711_base_mac[2], &ar711_base_mac[3], @@ -296,7 +296,7 @@ platform_start(__register_t a0 __unused, __register_t a1 __unused, if (MIPS_IS_VALID_PTR(envp)) { for (i = 0; envp[i]; i+=2) { printf(" %s = %s\n", envp[i], envp[i+1]); - setenv(envp[i], envp[i+1]); + kern_setenv(envp[i], envp[i+1]); } } else diff --git a/sys/mips/nlm/xlp_machdep.c b/sys/mips/nlm/xlp_machdep.c index 6a5dcb8bf7aa..78fcc72f59c4 100644 --- a/sys/mips/nlm/xlp_machdep.c +++ b/sys/mips/nlm/xlp_machdep.c @@ -282,9 +282,9 @@ xlp_parse_bootargs(char *cmdline) } else { n = strsep(&v, "="); if (v == NULL) - setenv(n, "1"); + kern_setenv(n, "1"); else - setenv(n, v); + kern_setenv(n, v); } } } @@ -349,9 +349,9 @@ xlp_bootargs_init(__register_t arg) v = buf; n = strsep(&v, "="); if (v == NULL) - setenv(n, "1"); + kern_setenv(n, "1"); else - setenv(n, v); + kern_setenv(n, v); p += strlen(p) + 1; } @@ -360,7 +360,7 @@ xlp_bootargs_init(__register_t arg) xlp_hw_thread_mask = mask; /* command line argument */ - v = getenv("bootargs"); + v = kern_getenv("bootargs"); if (v != NULL) { strlcpy(buf, v, sizeof(buf)); xlp_parse_bootargs(buf); diff --git a/sys/mips/rmi/xlr_machdep.c b/sys/mips/rmi/xlr_machdep.c index d6fdf43cbe46..8eaf97ef5f1f 100644 --- a/sys/mips/rmi/xlr_machdep.c +++ b/sys/mips/rmi/xlr_machdep.c @@ -148,7 +148,7 @@ xlr_parse_mmu_options(void) * We don't support sharing TLB per core - TODO */ xlr_shtlb_enabled = 0; - if ((hw_env = getenv("xlr.shtlb")) != NULL) { + if ((hw_env = kern_getenv("xlr.shtlb")) != NULL) { start = hw_env; tmp = strtoul(start, &end, 0); if (start != end) @@ -230,9 +230,9 @@ xlr_set_boot_flags(void) { char *p; - p = getenv("bootflags"); + p = kern_getenv("bootflags"); if (p == NULL) - p = getenv("boot_flags"); /* old style */ + p = kern_getenv("boot_flags"); /* old style */ if (p == NULL) return; diff --git a/sys/nfs/bootp_subr.c b/sys/nfs/bootp_subr.c index 83a3d0731117..5e3145e8dfbe 100644 --- a/sys/nfs/bootp_subr.c +++ b/sys/nfs/bootp_subr.c @@ -1452,7 +1452,7 @@ bootpc_decode_reply(struct nfsv3_diskless *nd, struct bootpc_ifcontext *ifctx, * the server value). */ p = NULL; - if ((s = getenv("vfs.root.mountfrom")) != NULL) { + if ((s = kern_getenv("vfs.root.mountfrom")) != NULL) { if ((p = strstr(s, "nfs:")) != NULL) p = strdup(p + 4, M_TEMP); freeenv(s); @@ -1723,7 +1723,7 @@ bootpc_init(void) if (gctx->gotrootpath != 0) { - setenv("boot.netif.name", ifctx->ifp->if_xname); + kern_setenv("boot.netif.name", ifctx->ifp->if_xname); error = md_mount(&nd->root_saddr, nd->root_hostnam, nd->root_fh, &nd->root_fhsize, diff --git a/sys/nfs/nfs_diskless.c b/sys/nfs/nfs_diskless.c index 26f5036b47fc..3882007dff0f 100644 --- a/sys/nfs/nfs_diskless.c +++ b/sys/nfs/nfs_diskless.c @@ -175,7 +175,7 @@ nfs_setup_diskless(void) return; /* get handle size. If this succeeds, it's an NFSv3 setup. */ - if ((cp = getenv("boot.nfsroot.nfshandlelen")) != NULL) { + if ((cp = kern_getenv("boot.nfsroot.nfshandlelen")) != NULL) { cnt = sscanf(cp, "%d", &len); freeenv(cp); if (cnt != 1 || len == 0 || len > NFSX_V3FHMAX) { @@ -237,7 +237,7 @@ nfs_setup_diskless(void) printf("nfs_diskless: no interface\n"); return; /* no matching interface */ match_done: - setenv("boot.netif.name", ifp->if_xname); + kern_setenv("boot.netif.name", ifp->if_xname); if (is_nfsv3 != 0) { strlcpy(nd3->myif.ifra_name, ifp->if_xname, sizeof(nd3->myif.ifra_name)); @@ -267,11 +267,11 @@ nfs_setup_diskless(void) printf("nfs_diskless: bad NFS handle len=%d\n", fhlen); return; } - if ((cp = getenv("boot.nfsroot.path")) != NULL) { + if ((cp = kern_getenv("boot.nfsroot.path")) != NULL) { strncpy(nd3->root_hostnam, cp, MNAMELEN - 1); freeenv(cp); } - if ((cp = getenv("boot.nfsroot.options")) != NULL) { + if ((cp = kern_getenv("boot.nfsroot.options")) != NULL) { nfs_parse_options(cp, &nd3->root_args); freeenv(cp); } @@ -301,11 +301,11 @@ nfs_setup_diskless(void) printf("nfs_diskless: no NFS handle\n"); return; } - if ((cp = getenv("boot.nfsroot.path")) != NULL) { + if ((cp = kern_getenv("boot.nfsroot.path")) != NULL) { strncpy(nd->root_hostnam, cp, MNAMELEN - 1); freeenv(cp); } - if ((cp = getenv("boot.nfsroot.options")) != NULL) { + if ((cp = kern_getenv("boot.nfsroot.options")) != NULL) { struct nfs_args args; /* @@ -339,7 +339,7 @@ inaddr_to_sockaddr(char *ev, struct sockaddr_in *sa) sa->sin_len = sizeof(*sa); sa->sin_family = AF_INET; - if ((cp = getenv(ev)) == NULL) + if ((cp = kern_getenv(ev)) == NULL) return (1); count = sscanf(cp, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]); freeenv(cp); @@ -362,7 +362,7 @@ hwaddr_to_sockaddr(char *ev, struct sockaddr_dl *sa) sa->sdl_family = AF_LINK; sa->sdl_type = IFT_ETHER; sa->sdl_alen = ETHER_ADDR_LEN; - if ((cp = getenv(ev)) == NULL) + if ((cp = kern_getenv(ev)) == NULL) return (1); count = sscanf(cp, "%x:%x:%x:%x:%x:%x", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]); @@ -384,7 +384,7 @@ decode_nfshandle(char *ev, u_char *fh, int maxfh) u_char *cp, *ep; int len, val; - ep = cp = getenv(ev); + ep = cp = kern_getenv(ev); if (cp == NULL) return (0); if ((strlen(cp) < 2) || (*cp != 'X')) { diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c index cf63c5ef3eed..0c002d2e78b1 100644 --- a/sys/nfsclient/nfs_vfsops.c +++ b/sys/nfsclient/nfs_vfsops.c @@ -485,7 +485,7 @@ nfs_mountroot(struct mount *mp) if (error) panic("nfs_mountroot: SIOCAIFADDR: %d", error); - if ((cp = getenv("boot.netif.mtu")) != NULL) { + if ((cp = kern_getenv("boot.netif.mtu")) != NULL) { ir.ifr_mtu = strtol(cp, NULL, 10); bcopy(nd->myif.ifra_name, ir.ifr_name, IFNAMSIZ); freeenv(cp); diff --git a/sys/powerpc/aim/machdep.c b/sys/powerpc/aim/machdep.c index 17fc452f55e7..5864a02c4694 100644 --- a/sys/powerpc/aim/machdep.c +++ b/sys/powerpc/aim/machdep.c @@ -566,7 +566,7 @@ powerpc_init(vm_offset_t startkernel, vm_offset_t endkernel, /* * Grab booted kernel's name */ - env = getenv("kernelname"); + env = kern_getenv("kernelname"); if (env != NULL) { strlcpy(kernelname, env, sizeof(kernelname)); freeenv(env); diff --git a/sys/sparc64/sparc64/machdep.c b/sys/sparc64/sparc64/machdep.c index 0ee6de3a5131..57d7a66169f9 100644 --- a/sys/sparc64/sparc64/machdep.c +++ b/sys/sparc64/sparc64/machdep.c @@ -511,7 +511,7 @@ sparc64_init(caddr_t mdp, u_long o1, u_long o2, u_long o3, ofw_vec_t *vec) * Initialize tunables. */ init_param2(physmem); - env = getenv("kernelname"); + env = kern_getenv("kernelname"); if (env != NULL) { strlcpy(kernelname, env, sizeof(kernelname)); freeenv(env); diff --git a/sys/sys/systm.h b/sys/sys/systm.h index eae72728a0f8..f4eae5702cd2 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -296,7 +296,7 @@ int cr_cansee(struct ucred *u1, struct ucred *u2); int cr_canseesocket(struct ucred *cred, struct socket *so); int cr_canseeinpcb(struct ucred *cred, struct inpcb *inp); -char *getenv(const char *name); +char *kern_getenv(const char *name); void freeenv(char *env); int getenv_int(const char *name, int *data); int getenv_uint(const char *name, unsigned int *data); @@ -304,8 +304,8 @@ int getenv_long(const char *name, long *data); int getenv_ulong(const char *name, unsigned long *data); int getenv_string(const char *name, char *data, int size); int getenv_quad(const char *name, quad_t *data); -int setenv(const char *name, const char *value); -int unsetenv(const char *name); +int kern_setenv(const char *name, const char *value); +int kern_unsetenv(const char *name); int testenv(const char *name); typedef uint64_t (cpu_tick_f)(void); diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 28dd645824db..a885f1bf14f4 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -453,7 +453,7 @@ vm_page_startup(vm_offset_t vaddr) */ vm_cnt.v_page_count = 0; vm_cnt.v_free_count = 0; - list = getenv("vm.blacklist"); + list = kern_getenv("vm.blacklist"); for (i = 0; phys_avail[i + 1] != 0; i += 2) { pa = phys_avail[i]; last_pa = phys_avail[i + 1]; diff --git a/sys/x86/iommu/busdma_dmar.c b/sys/x86/iommu/busdma_dmar.c index a397f4244691..4f00bdd78e75 100644 --- a/sys/x86/iommu/busdma_dmar.c +++ b/sys/x86/iommu/busdma_dmar.c @@ -76,7 +76,7 @@ dmar_bus_dma_is_dev_disabled(int domain, int bus, int slot, int func) snprintf(str, sizeof(str), "hw.busdma.pci%d.%d.%d.%d.bounce", domain, bus, slot, func); - env = getenv(str); + env = kern_getenv(str); if (env == NULL) return (false); freeenv(env); diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c index 31d6715b6885..b78e3c95b339 100644 --- a/sys/x86/x86/tsc.c +++ b/sys/x86/x86/tsc.c @@ -155,7 +155,7 @@ tsc_freq_vmware(void) if (strncmp(hv_sig, "VMwareVMware", 12) != 0) return (0); } else { - p = getenv("smbios.system.serial"); + p = kern_getenv("smbios.system.serial"); if (p == NULL) return (0); if (strncmp(p, "VMware-", 7) != 0 && diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c index 140d13ff4f83..cd944a188a1f 100644 --- a/sys/x86/xen/pv.c +++ b/sys/x86/xen/pv.c @@ -309,7 +309,7 @@ xen_pv_set_boothowto(void) /* get equivalents from the environment */ for (i = 0; howto_names[i].ev != NULL; i++) { - if (getenv(howto_names[i].ev) != NULL) + if (kern_getenv(howto_names[i].ev) != NULL) boothowto |= howto_names[i].mask; } }