diff options
author | Renato Botelho <renato@netgate.com> | 2016-02-03 18:01:26 -0200 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-02-03 18:01:26 -0200 |
commit | af0758169e63a4e7f6024c241d9254a8bc09908d (patch) | |
tree | a31903fc62c875e8d23a391beb8ae57ed0092c45 /sys/kern/subr_hints.c | |
parent | 79f27b5150f7b79a6f1bcd30e9233f1abb9c3e36 (diff) | |
parent | 6114d518f71115abacc5d610c4d668ef6e0b2f37 (diff) | |
download | FreeBSD-src-af0758169e63a4e7f6024c241d9254a8bc09908d.zip FreeBSD-src-af0758169e63a4e7f6024c241d9254a8bc09908d.tar.gz |
Merge remote-tracking branch 'origin/stable/10' into devel
Diffstat (limited to 'sys/kern/subr_hints.c')
-rw-r--r-- | sys/kern/subr_hints.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/sys/kern/subr_hints.c b/sys/kern/subr_hints.c index f9085b2..08f8e8c 100644 --- a/sys/kern/subr_hints.c +++ b/sys/kern/subr_hints.c @@ -461,3 +461,31 @@ resource_disabled(const char *name, int unit) return (0); return (value); } + +/* + * Clear a value associated with a device by removing it from + * the kernel environment. This only removes a hint for an + * exact unit. + */ +int +resource_unset_value(const char *name, int unit, const char *resname) +{ + char varname[128]; + const char *retname, *retvalue; + int error, line; + size_t len; + + line = 0; + error = resource_find(&line, NULL, name, &unit, resname, NULL, + &retname, NULL, NULL, NULL, NULL, &retvalue); + if (error) + return (error); + + retname -= strlen("hint."); + len = retvalue - retname - 1; + if (len > sizeof(varname) - 1) + return (ENAMETOOLONG); + memcpy(varname, retname, len); + varname[len] = '\0'; + return (unsetenv(varname)); +} |