Skip to content

Commit

Permalink
Factor Linux specific functionality out of libzutil
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Macy <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
  • Loading branch information
mattmacy authored and Ryan Moeller committed Sep 30, 2019
1 parent 7bb0c29 commit 1ad1365
Show file tree
Hide file tree
Showing 8 changed files with 1,506 additions and 1,336 deletions.
10 changes: 5 additions & 5 deletions cmd/zed/agents/zfs_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ zfs_process_add(zpool_handle_t *zhp, nvlist_t *vdev, boolean_t labeled)
char rawpath[PATH_MAX], fullpath[PATH_MAX];
char devpath[PATH_MAX];
int ret;
int is_dm = 0;
int is_sd = 0;
boolean_t is_dm = B_FALSE;
boolean_t is_sd = B_FALSE;
uint_t c;
vdev_stat_t *vs;

Expand Down Expand Up @@ -221,8 +221,8 @@ zfs_process_add(zpool_handle_t *zhp, nvlist_t *vdev, boolean_t labeled)

is_dm = zfs_dev_is_dm(path);
zed_log_msg(LOG_INFO, "zfs_process_add: pool '%s' vdev '%s', phys '%s'"
" wholedisk %d, dm %d (%llu)", zpool_get_name(zhp), path,
physpath ? physpath : "NULL", wholedisk, is_dm,
" wholedisk %d, %s dm (guid %llu)", zpool_get_name(zhp), path,
physpath ? physpath : "NULL", wholedisk, is_dm ? "is" : "not",
(long long unsigned int)guid);

/*
Expand Down Expand Up @@ -267,7 +267,7 @@ zfs_process_add(zpool_handle_t *zhp, nvlist_t *vdev, boolean_t labeled)
* testing)
*/
if (physpath != NULL && strcmp("scsidebug", physpath) == 0)
is_sd = 1;
is_sd = B_TRUE;

/*
* If the pool doesn't have the autoreplace property set, then use
Expand Down
13 changes: 2 additions & 11 deletions include/libzutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,10 @@ extern const char * const * zpool_default_search_paths(size_t *count);
extern int zpool_read_label(int, nvlist_t **, int *);
extern int zpool_label_disk_wait(const char *, int);

#ifdef HAVE_LIBUDEV
struct udev_device;

extern int zfs_device_get_devid(struct udev_device *, char *, size_t);
extern int zfs_device_get_physical(struct udev_device *, char *, size_t);
#else
#define zfs_device_get_devid(dev, bufptr, buflen) (ENODATA)
#define zfs_device_get_physical(dev, bufptr, buflen) (ENODATA)
#endif

extern void update_vdev_config_dev_strs(nvlist_t *);

Expand All @@ -106,16 +101,12 @@ extern char *zfs_strip_partition_path(char *);

extern int zfs_strcmp_pathname(const char *, const char *, int);

extern int zfs_dev_is_dm(const char *);
extern int zfs_dev_is_whole_disk(const char *);
extern boolean_t zfs_dev_is_dm(const char *);
extern boolean_t zfs_dev_is_whole_disk(const char *);
extern char *zfs_get_underlying_path(const char *);
extern char *zfs_get_enclosure_sysfs_path(const char *);

#ifdef HAVE_LIBUDEV
extern boolean_t is_mpath_whole_disk(const char *);
#else
#define is_mpath_whole_disk(path) (B_FALSE)
#endif

/*
* Formats for iostat numbers. Examples: "12K", "30ms", "4B", "2321234", "-".
Expand Down
10 changes: 9 additions & 1 deletion lib/libzutil/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,24 @@ AM_CFLAGS += $(NO_UNUSED_BUT_SET_VARIABLE)

DEFAULT_INCLUDES += \
-I$(top_srcdir)/include \
-I$(top_srcdir)/lib/libspl/include
-I$(top_srcdir)/lib/libspl/include \
-I.

noinst_LTLIBRARIES = libzutil.la

USER_C = \
zutil_device_path.c \
zutil_import.c \
zutil_import.h \
zutil_nicenum.c \
zutil_pool.c

if BUILD_LINUX
USER_C += \
os/linux/zutil_device_path_os.c \
os/linux/zutil_import_os.c
endif

nodist_libzutil_la_SOURCES = $(USER_C)

libzutil_la_LIBADD = \
Expand Down
Loading

0 comments on commit 1ad1365

Please sign in to comment.