subr_hints.c (273174) | subr_hints.c (278320) |
---|---|
1/*- 2 * Copyright (c) 2000,2001 Peter Wemm <peter@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2000,2001 Peter Wemm <peter@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/kern/subr_hints.c 273174 2014-10-16 18:04:43Z davide $"); | 28__FBSDID("$FreeBSD: head/sys/kern/subr_hints.c 278320 2015-02-06 16:09:01Z jhb $"); |
29 30#include <sys/param.h> 31#include <sys/lock.h> 32#include <sys/malloc.h> 33#include <sys/mutex.h> 34#include <sys/sysctl.h> 35#include <sys/systm.h> 36#include <sys/bus.h> --- 419 unchanged lines hidden (view full) --- 456{ 457 int error, value; 458 459 error = resource_int_value(name, unit, "disabled", &value); 460 if (error) 461 return (0); 462 return (value); 463} | 29 30#include <sys/param.h> 31#include <sys/lock.h> 32#include <sys/malloc.h> 33#include <sys/mutex.h> 34#include <sys/sysctl.h> 35#include <sys/systm.h> 36#include <sys/bus.h> --- 419 unchanged lines hidden (view full) --- 456{ 457 int error, value; 458 459 error = resource_int_value(name, unit, "disabled", &value); 460 if (error) 461 return (0); 462 return (value); 463} |
464 465/* 466 * Clear a value associated with a device by removing it from 467 * the kernel environment. This only removes a hint for an 468 * exact unit. 469 */ 470int 471resource_unset_value(const char *name, int unit, const char *resname) 472{ 473 char varname[128]; 474 const char *retname, *retvalue; 475 int error, line; 476 size_t len; 477 478 line = 0; 479 error = resource_find(&line, NULL, name, &unit, resname, NULL, 480 &retname, NULL, NULL, NULL, NULL, &retvalue); 481 if (error) 482 return (error); 483 484 retname -= strlen("hint."); 485 len = retvalue - retname - 1; 486 if (len > sizeof(varname) - 1) 487 return (ENAMETOOLONG); 488 memcpy(varname, retname, len); 489 varname[len] = '\0'; 490 return (kern_unsetenv(varname)); 491} |
|