6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2014 Gary Mills
24 *
25 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
26 */
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <stdint.h>
31 #include <strings.h>
32 #include <assert.h>
33 #include <pthread.h>
34 #include <sys/byteorder.h>
35 #include <sys/types.h>
36 #include <sys/nvpair.h>
37
38 #include "libfru.h"
39 #include "libfrup.h"
40 #include "fru_tag.h"
41 #include "libfrureg.h"
42 #include "nvfru.h"
43
44 #define NUM_ITER_BYTES 4
45 #define HEAD_ITER 0
385 {
386 fru_errno_t fru_err;
387 fru_nodehdl_t hdl;
388 int err;
389
390 (void) pthread_mutex_lock(&gLock);
391 fru_err = fru_open_data_source("raw", buffer, bufsize, cont_type,
392 NULL);
393 if (fru_err != FRU_SUCCESS) {
394 (void) pthread_mutex_unlock(&gLock);
395 return (-1);
396 }
397 fru_err = fru_get_root(&hdl);
398 if (fru_err != FRU_SUCCESS) {
399 (void) pthread_mutex_unlock(&gLock);
400 return (-1);
401 }
402
403 err = convert_fru(hdl, nvlist);
404
405 fru_close_data_source();
406
407 (void) pthread_mutex_unlock(&gLock);
408
409 return (err);
410 }
|
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2014 Gary Mills
24 *
25 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
26 *
27 * Copyright (c) 2018, Joyent, Inc.
28 */
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <stdint.h>
33 #include <strings.h>
34 #include <assert.h>
35 #include <pthread.h>
36 #include <sys/byteorder.h>
37 #include <sys/types.h>
38 #include <sys/nvpair.h>
39
40 #include "libfru.h"
41 #include "libfrup.h"
42 #include "fru_tag.h"
43 #include "libfrureg.h"
44 #include "nvfru.h"
45
46 #define NUM_ITER_BYTES 4
47 #define HEAD_ITER 0
387 {
388 fru_errno_t fru_err;
389 fru_nodehdl_t hdl;
390 int err;
391
392 (void) pthread_mutex_lock(&gLock);
393 fru_err = fru_open_data_source("raw", buffer, bufsize, cont_type,
394 NULL);
395 if (fru_err != FRU_SUCCESS) {
396 (void) pthread_mutex_unlock(&gLock);
397 return (-1);
398 }
399 fru_err = fru_get_root(&hdl);
400 if (fru_err != FRU_SUCCESS) {
401 (void) pthread_mutex_unlock(&gLock);
402 return (-1);
403 }
404
405 err = convert_fru(hdl, nvlist);
406
407 (void) fru_close_data_source();
408
409 (void) pthread_mutex_unlock(&gLock);
410
411 return (err);
412 }
|