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 26, 2019
1 parent d359e99 commit 0798708
Show file tree
Hide file tree
Showing 10 changed files with 1,352 additions and 1,216 deletions.
4 changes: 2 additions & 2 deletions cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4643,7 +4643,7 @@ get_interval_count(int *argcp, char **argv, float *iv,
/*
* Determine if the last argument is an integer or a pool name
*/
if (argc > 0 && isnumber(argv[argc - 1])) {
if (argc > 0 && zfs_isnumber(argv[argc - 1])) {
char *end;

errno = 0;
Expand Down Expand Up @@ -4673,7 +4673,7 @@ get_interval_count(int *argcp, char **argv, float *iv,
* If the last argument is also an integer, then we have both a count
* and an interval.
*/
if (argc > 0 && isnumber(argv[argc - 1])) {
if (argc > 0 && zfs_isnumber(argv[argc - 1])) {
char *end;

errno = 0;
Expand Down
14 changes: 0 additions & 14 deletions cmd/zpool/zpool_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,6 @@ array64_max(uint64_t array[], unsigned int len)
return (max);
}

/*
* Return 1 if "str" is a number string, 0 otherwise. Works for integer and
* floating point numbers.
*/
int
isnumber(char *str)
{
for (; *str; str++)
if (!(isdigit(*str) || (*str == '.')))
return (0);

return (1);
}

/*
* Find highest one bit set.
* Returns bit number + 1 of highest bit that is set, otherwise returns 0.
Expand Down
1 change: 0 additions & 1 deletion cmd/zpool/zpool_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ void *safe_malloc(size_t);
void zpool_no_memory(void);
uint_t num_logs(nvlist_t *nv);
uint64_t array64_max(uint64_t array[], unsigned int len);
int isnumber(char *str);
int highbit64(uint64_t i);
int lowbit64(uint64_t i);

Expand Down
8 changes: 0 additions & 8 deletions cmd/zpool/zpool_vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,6 @@ static vdev_disk_db_entry_t vdev_disk_database[] = {
{"ATA WDC WD2500BEVT-0", 4096},
{"ATA WDC WD3200BEVT-0", 4096},
{"ATA WDC WD5000BEVT-0", 4096},
/* Virtual disks: Assume zvols with default volblocksize */
#if 0
{"ATA QEMU HARDDISK ", 8192},
{"IET VIRTUAL-DISK ", 8192},
{"OI COMSTAR ", 8192},
{"SUN COMSTAR ", 8192},
{"NETAPP LUN ", 8192},
#endif
};

static const int vdev_disk_database_size =
Expand Down
18 changes: 18 additions & 0 deletions include/libzutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ extern boolean_t is_mpath_whole_disk(const char *);
#define is_mpath_whole_disk(path) (B_FALSE)
#endif

extern int zfs_isnumber(const char *);

/*
* Formats for iostat numbers. Examples: "12K", "30ms", "4B", "2321234", "-".
*
Expand Down Expand Up @@ -149,6 +151,22 @@ extern void zpool_dump_ddt(const ddt_stat_t *, const ddt_histogram_t *);
extern int zpool_history_unpack(char *, uint64_t, uint64_t *, nvlist_t ***,
uint_t *);

struct libpc_handle;
typedef struct libpc_handle libpc_handle_t;

extern int zutil_error(libpc_handle_t *hdl, const char *error, const char *msg);
extern void zutil_error_aux(libpc_handle_t *hdl, const char *fmt, ...);
extern int zutil_no_memory(libpc_handle_t *hdl);
extern void * zutil_alloc(libpc_handle_t *hdl, size_t size);
extern char *zutil_strdup(libpc_handle_t *hdl, const char *str);
extern int zutil_pool_active(libpc_handle_t *hdl, const char *name,
uint64_t guid, boolean_t *isactive);
extern nvlist_t *zutil_refresh_config(libpc_handle_t *hdl, nvlist_t *tryconfig);
extern int zutil_error_fmt(libpc_handle_t *hdl, const char *error,
const char *fmt, ...);

extern nvlist_t *zpool_find_import_impl(libpc_handle_t *hdl,
importargs_t *iarg);
#ifdef __cplusplus
}
#endif
Expand Down
6 changes: 6 additions & 0 deletions lib/libzutil/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ 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_import_os.c
endif

nodist_libzutil_la_SOURCES = $(USER_C)

libzutil_la_LIBADD = \
Expand Down
Loading

0 comments on commit 0798708

Please sign in to comment.