Skip to content

Commit 73e9db5

Browse files
committed
Zpool (SunOS): fix the dlsym error
1 parent adc03bd commit 73e9db5

File tree

5 files changed

+42
-92
lines changed

5 files changed

+42
-92
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,8 @@ elseif(SunOS)
11601160
PRIVATE "socket"
11611161
PRIVATE "kstat"
11621162
PRIVATE "proc"
1163+
PRIVATE "zfs"
1164+
PRIVATE "nvpair"
11631165
)
11641166
elseif(ANDROID)
11651167
CHECK_LIBRARY_EXISTS(-l:libandroid-wordexp.a wordexp "" HAVE_LIBANDROID_WORDEXP_STATIC)

src/detection/zpool/libzfs_simplified.h

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -75,82 +75,7 @@ typedef enum {
7575
ZPROP_SRC_RECEIVED = 0x20
7676
} zprop_source_t;
7777

78-
typedef enum zpool_errata {
79-
ZPOOL_ERRATA_NONE,
80-
ZPOOL_ERRATA_ZOL_2094_SCRUB,
81-
ZPOOL_ERRATA_ZOL_2094_ASYNC_DESTROY,
82-
ZPOOL_ERRATA_ZOL_6845_ENCRYPTION,
83-
ZPOOL_ERRATA_ZOL_8308_ENCRYPTION,
84-
} zpool_errata_t;
85-
86-
typedef enum {
87-
/*
88-
* The following correspond to faults as defined in the (fault.fs.zfs.*)
89-
* event namespace. Each is associated with a corresponding message ID.
90-
* This must be kept in sync with the zfs_msgid_table in
91-
* lib/libzfs/libzfs_status.c.
92-
*/
93-
ZPOOL_STATUS_CORRUPT_CACHE, /* corrupt /kernel/drv/zpool.cache */
94-
ZPOOL_STATUS_MISSING_DEV_R, /* missing device with replicas */
95-
ZPOOL_STATUS_MISSING_DEV_NR, /* missing device with no replicas */
96-
ZPOOL_STATUS_CORRUPT_LABEL_R, /* bad device label with replicas */
97-
ZPOOL_STATUS_CORRUPT_LABEL_NR, /* bad device label with no replicas */
98-
ZPOOL_STATUS_BAD_GUID_SUM, /* sum of device guids didn't match */
99-
ZPOOL_STATUS_CORRUPT_POOL, /* pool metadata is corrupted */
100-
ZPOOL_STATUS_CORRUPT_DATA, /* data errors in user (meta)data */
101-
ZPOOL_STATUS_FAILING_DEV, /* device experiencing errors */
102-
ZPOOL_STATUS_VERSION_NEWER, /* newer on-disk version */
103-
ZPOOL_STATUS_HOSTID_MISMATCH, /* last accessed by another system */
104-
ZPOOL_STATUS_HOSTID_ACTIVE, /* currently active on another system */
105-
ZPOOL_STATUS_HOSTID_REQUIRED, /* multihost=on and hostid=0 */
106-
ZPOOL_STATUS_IO_FAILURE_WAIT, /* failed I/O, failmode 'wait' */
107-
ZPOOL_STATUS_IO_FAILURE_CONTINUE, /* failed I/O, failmode 'continue' */
108-
ZPOOL_STATUS_IO_FAILURE_MMP, /* failed MMP, failmode not 'panic' */
109-
ZPOOL_STATUS_BAD_LOG, /* cannot read log chain(s) */
110-
ZPOOL_STATUS_ERRATA, /* informational errata available */
111-
112-
/*
113-
* If the pool has unsupported features but can still be opened in
114-
* read-only mode, its status is ZPOOL_STATUS_UNSUP_FEAT_WRITE. If the
115-
* pool has unsupported features but cannot be opened at all, its
116-
* status is ZPOOL_STATUS_UNSUP_FEAT_READ.
117-
*/
118-
ZPOOL_STATUS_UNSUP_FEAT_READ, /* unsupported features for read */
119-
ZPOOL_STATUS_UNSUP_FEAT_WRITE, /* unsupported features for write */
120-
121-
/*
122-
* These faults have no corresponding message ID. At the time we are
123-
* checking the status, the original reason for the FMA fault (I/O or
124-
* checksum errors) has been lost.
125-
*/
126-
ZPOOL_STATUS_FAULTED_DEV_R, /* faulted device with replicas */
127-
ZPOOL_STATUS_FAULTED_DEV_NR, /* faulted device with no replicas */
128-
129-
/*
130-
* The following are not faults per se, but still an error possibly
131-
* requiring administrative attention. There is no corresponding
132-
* message ID.
133-
*/
134-
ZPOOL_STATUS_VERSION_OLDER, /* older legacy on-disk version */
135-
ZPOOL_STATUS_FEAT_DISABLED, /* supported features are disabled */
136-
ZPOOL_STATUS_RESILVERING, /* device being resilvered */
137-
ZPOOL_STATUS_OFFLINE_DEV, /* device offline */
138-
ZPOOL_STATUS_REMOVED_DEV, /* removed device */
139-
ZPOOL_STATUS_REBUILDING, /* device being rebuilt */
140-
ZPOOL_STATUS_REBUILD_SCRUB, /* recommend scrubbing the pool */
141-
ZPOOL_STATUS_NON_NATIVE_ASHIFT, /* (e.g. 512e dev with ashift of 9) */
142-
ZPOOL_STATUS_COMPATIBILITY_ERR, /* bad 'compatibility' property */
143-
ZPOOL_STATUS_INCOMPATIBLE_FEAT, /* feature set outside compatibility */
144-
145-
/*
146-
* Finally, the following indicates a healthy pool.
147-
*/
148-
ZPOOL_STATUS_OK
149-
} zpool_status_t;
150-
151-
#ifndef __sun
15278
typedef bool boolean_t;
153-
#endif
15479

15580
typedef struct libzfs_handle libzfs_handle_t;
15681
typedef struct zpool_handle zpool_handle_t;
@@ -162,4 +87,3 @@ extern void libzfs_fini(libzfs_handle_t *);
16287
extern uint64_t zpool_get_prop_int(zpool_handle_t *, zpool_prop_t, zprop_source_t *);
16388
extern const char *zpool_get_name(zpool_handle_t *);
16489
extern const char *zpool_get_state_str(zpool_handle_t *);
165-
extern zpool_status_t zpool_get_status(zpool_handle_t *, const char **, zpool_errata_t *);

src/detection/zpool/zpool.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ typedef struct FFZpoolResult
66
{
77
FFstrbuf name;
88
FFstrbuf state;
9-
FFstrbuf status;
109
uint64_t used;
1110
uint64_t total;
1211
uint64_t version;

src/detection/zpool/zpool_linux.c

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,43 @@
11
#include "zpool.h"
2-
#include "common/library.h"
2+
3+
#ifdef __sun
4+
#define FF_DISABLE_DLOPEN
5+
#include <libzfs.h>
6+
7+
const char* zpool_get_state_str(zpool_handle_t* zpool)
8+
{
9+
if (zpool_get_state(zpool) == POOL_STATE_UNAVAIL)
10+
return "FAULTED";
11+
else
12+
{
13+
const char *str;
14+
zpool_errata_t errata;
15+
zpool_status_t status = zpool_get_status(zpool, (char**) &str, &errata);
16+
if (status == ZPOOL_STATUS_IO_FAILURE_WAIT ||
17+
status == ZPOOL_STATUS_IO_FAILURE_CONTINUE ||
18+
status == ZPOOL_STATUS_IO_FAILURE_MMP)
19+
return "SUSPENDED";
20+
else
21+
{
22+
nvlist_t *nvroot = fnvlist_lookup_nvlist(zpool_get_config(zpool, NULL), ZPOOL_CONFIG_VDEV_TREE);
23+
uint_t vsc;
24+
vdev_stat_t *vs;
25+
#ifdef __x86_64__
26+
if (nvlist_lookup_uint64_array(nvroot, ZPOOL_CONFIG_VDEV_STATS, (uint64_t**) &vs, &vsc) != 0)
27+
#else
28+
if (nvlist_lookup_uint32_array(nvroot, ZPOOL_CONFIG_VDEV_STATS, (uint32_t**) &vs, &vsc) != 0)
29+
#endif
30+
return "UNKNOWN";
31+
else
32+
return zpool_state_to_name(vs->vs_state, vs->vs_aux);
33+
}
34+
}
35+
}
36+
#else
337
#include "libzfs_simplified.h"
38+
#endif
39+
40+
#include "common/library.h"
441

542
typedef struct FFZfsData
643
{
@@ -9,7 +46,6 @@ typedef struct FFZfsData
946
FF_LIBRARY_SYMBOL(zpool_get_prop_int)
1047
FF_LIBRARY_SYMBOL(zpool_get_name)
1148
FF_LIBRARY_SYMBOL(zpool_get_state_str)
12-
FF_LIBRARY_SYMBOL(zpool_get_status)
1349

1450
libzfs_handle_t* handle;
1551
FFlist* result;
@@ -31,13 +67,6 @@ static int enumZpoolCallback(zpool_handle_t* zpool, void* param)
3167
FFZpoolResult* item = ffListAdd(data->result);
3268
ffStrbufInitS(&item->name, data->ffzpool_get_name(zpool));
3369
ffStrbufInitS(&item->state, data->ffzpool_get_state_str(zpool));
34-
const char* msgid = NULL;
35-
zpool_status_t status = data->ffzpool_get_status(zpool, &msgid, NULL);
36-
if (msgid && *msgid)
37-
ffStrbufInitS(&item->status, msgid);
38-
else
39-
ffStrbufInitStatic(&item->status, status == ZPOOL_STATUS_OK ? "OK" : "NOT OK");
40-
4170
item->version = data->ffzpool_get_prop_int(zpool, ZPOOL_PROP_VERSION, &source);
4271
item->total = data->ffzpool_get_prop_int(zpool, ZPOOL_PROP_SIZE, &source);
4372
item->used = item->total - data->ffzpool_get_prop_int(zpool, ZPOOL_PROP_FREE, &source);
@@ -63,7 +92,6 @@ const char* ffDetectZpool(FFlist* result /* list of FFZpoolResult */)
6392
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libzfs, data, zpool_get_prop_int);
6493
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libzfs, data, zpool_get_name);
6594
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libzfs, data, zpool_get_state_str);
66-
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libzfs, data, zpool_get_status);
6795

6896
if (ffzpool_iter(handle, enumZpoolCallback, &data) < 0)
6997
return "zpool_iter() failed";

src/modules/zpool/zpool.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "modules/zpool/zpool.h"
66
#include "util/stringUtils.h"
77

8-
#define FF_ZPOOL_NUM_FORMAT_ARGS 9
8+
#define FF_ZPOOL_NUM_FORMAT_ARGS 8
99

1010
static void printZpool(FFZpoolOptions* options, FFZpoolResult* result, uint8_t index)
1111
{
@@ -44,7 +44,7 @@ static void printZpool(FFZpoolOptions* options, FFZpoolResult* result, uint8_t i
4444
ffPercentAppendNum(&buffer, bytesPercentage, options->percent, false, &options->moduleArgs);
4545
ffStrbufAppendS(&buffer, ", ");
4646
ffPercentAppendNum(&buffer, fragPercentage, options->percent, false, &options->moduleArgs);
47-
ffStrbufAppendF(&buffer, " frag) - %s", result->status.chars);
47+
ffStrbufAppendF(&buffer, " frag) - %s", result->state.chars);
4848
ffStrbufPutTo(&buffer, stdout);
4949
}
5050
else
@@ -62,7 +62,6 @@ static void printZpool(FFZpoolOptions* options, FFZpoolResult* result, uint8_t i
6262
FF_PRINT_FORMAT_CHECKED(buffer.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_ZPOOL_NUM_FORMAT_ARGS, ((FFformatarg[]) {
6363
{FF_FORMAT_ARG_TYPE_STRBUF, &result->name, "name"},
6464
{FF_FORMAT_ARG_TYPE_STRBUF, &result->state, "state"},
65-
{FF_FORMAT_ARG_TYPE_STRBUF, &result->status, "status"},
6665
{FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty, "size-used"},
6766
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty, "size-total"},
6867
{FF_FORMAT_ARG_TYPE_STRBUF, &bytesPercentageNum, "size-percentage"},
@@ -165,7 +164,6 @@ void ffGenerateZpoolJsonResult(FF_MAYBE_UNUSED FFZpoolOptions* options, yyjson_m
165164
yyjson_mut_val* obj = yyjson_mut_arr_add_obj(doc, arr);
166165
yyjson_mut_obj_add_strbuf(doc, obj, "name", &zpool->name);
167166
yyjson_mut_obj_add_strbuf(doc, obj, "state", &zpool->state);
168-
yyjson_mut_obj_add_strbuf(doc, obj, "status", &zpool->status);
169167
yyjson_mut_obj_add_uint(doc, obj, "used", zpool->used);
170168
yyjson_mut_obj_add_uint(doc, obj, "total", zpool->total);
171169
yyjson_mut_obj_add_uint(doc, obj, "version", zpool->version);
@@ -184,7 +182,6 @@ void ffPrintZpoolHelpFormat(void)
184182
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_ZPOOL_MODULE_NAME, "{3} / {4} ({5}, {6} frag)", FF_ZPOOL_NUM_FORMAT_ARGS, ((const char* []) {
185183
"Zpool name - name",
186184
"Zpool state - state",
187-
"Zpool health status - status",
188185
"Size used - size-used",
189186
"Size total - size-total",
190187
"Size percentage num - size-percentage",

0 commit comments

Comments
 (0)