1 /*
2 * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2015, 2015 SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
42 _odm_set_path = (fun_odm_set_path )dlsym(_libhandle, "odm_set_path" );
43 _odm_mount_class = (fun_odm_mount_class)dlsym(_libhandle, "odm_mount_class");
44 _odm_get_obj = (fun_odm_get_obj )dlsym(_libhandle, "odm_get_obj" );
45 _odm_terminate = (fun_odm_terminate )dlsym(_libhandle, "odm_terminate" );
46 if (!_odm_initialize || !_odm_set_path || !_odm_mount_class || !_odm_get_obj || !_odm_terminate) {
47 trcVerbose("Couldn't find all required odm symbols from %s", libodmname);
48 dlclose(_libhandle);
49 _libhandle = NULL;
50 return;
51 }
52 }
53
54 dynamicOdm::~dynamicOdm() {
55 if (_libhandle) { dlclose(_libhandle); }
56 }
57
58
59 void odmWrapper::clean_data() { if (_data) { free(_data); _data = NULL; } }
60
61
62 int odmWrapper::class_offset(char *field, bool is_aix_5)
63 {
64 assert(has_class(), "initialization");
65 for (int i = 0; i < odm_class()->nelem; i++) {
66 if (strcmp(odm_class()->elem[i].elemname, field) == 0) {
67 int offset = odm_class()->elem[i].offset;
68 if (is_aix_5) { offset += LINK_VAL_OFFSET; }
69 return offset;
70 }
71 }
72 return -1;
73 }
74
75
76 void odmWrapper::determine_os_kernel_version(uint32_t* p_ver) {
77 int major_aix_version = ((*p_ver) >> 24) & 0xFF,
78 minor_aix_version = ((*p_ver) >> 16) & 0xFF;
79 assert(*p_ver, "must be initialized");
80
81 odmWrapper odm("product", "/usr/lib/objrepos"); // could also use "lpp"
82 if (!odm.has_class()) {
|
1 /*
2 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2015, 2019 SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
42 _odm_set_path = (fun_odm_set_path )dlsym(_libhandle, "odm_set_path" );
43 _odm_mount_class = (fun_odm_mount_class)dlsym(_libhandle, "odm_mount_class");
44 _odm_get_obj = (fun_odm_get_obj )dlsym(_libhandle, "odm_get_obj" );
45 _odm_terminate = (fun_odm_terminate )dlsym(_libhandle, "odm_terminate" );
46 if (!_odm_initialize || !_odm_set_path || !_odm_mount_class || !_odm_get_obj || !_odm_terminate) {
47 trcVerbose("Couldn't find all required odm symbols from %s", libodmname);
48 dlclose(_libhandle);
49 _libhandle = NULL;
50 return;
51 }
52 }
53
54 dynamicOdm::~dynamicOdm() {
55 if (_libhandle) { dlclose(_libhandle); }
56 }
57
58
59 void odmWrapper::clean_data() { if (_data) { free(_data); _data = NULL; } }
60
61
62 int odmWrapper::class_offset(const char *field, bool is_aix_5)
63 {
64 assert(has_class(), "initialization");
65 for (int i = 0; i < odm_class()->nelem; i++) {
66 if (strcmp(odm_class()->elem[i].elemname, field) == 0) {
67 int offset = odm_class()->elem[i].offset;
68 if (is_aix_5) { offset += LINK_VAL_OFFSET; }
69 return offset;
70 }
71 }
72 return -1;
73 }
74
75
76 void odmWrapper::determine_os_kernel_version(uint32_t* p_ver) {
77 int major_aix_version = ((*p_ver) >> 24) & 0xFF,
78 minor_aix_version = ((*p_ver) >> 16) & 0xFF;
79 assert(*p_ver, "must be initialized");
80
81 odmWrapper odm("product", "/usr/lib/objrepos"); // could also use "lpp"
82 if (!odm.has_class()) {
|