Skip to content

Commit ccdab15

Browse files
libzfs: add zfs_get_underlying_type. Stop including libzfs_impl.h in cmd
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
1 parent 1733982 commit ccdab15

File tree

6 files changed

+657
-638
lines changed

6 files changed

+657
-638
lines changed

cmd/zfs/zfs_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include <zone.h>
5353
#include <grp.h>
5454
#include <pwd.h>
55+
#include <pthread.h>
5556
#include <signal.h>
5657
#include <sys/list.h>
5758
#include <sys/mkdev.h>
@@ -78,7 +79,6 @@
7879
#include "zfs_iter.h"
7980
#include "zfs_util.h"
8081
#include "zfs_comutil.h"
81-
#include "libzfs_impl.h"
8282
#include "zfs_projectutil.h"
8383

8484
libzfs_handle_t *g_zfs;
@@ -3315,7 +3315,7 @@ zfs_do_userspace(int argc, char **argv)
33153315
if ((zhp = zfs_path_to_zhandle(g_zfs, argv[0], ZFS_TYPE_FILESYSTEM |
33163316
ZFS_TYPE_SNAPSHOT)) == NULL)
33173317
return (1);
3318-
if (zhp->zfs_head_type != ZFS_TYPE_FILESYSTEM) {
3318+
if (zfs_get_underlying_type(zhp) != ZFS_TYPE_FILESYSTEM) {
33193319
(void) fprintf(stderr, gettext("operation is only applicable "
33203320
"to filesystems and their snapshots\n"));
33213321
zfs_close(zhp);

cmd/zpool_influxdb/zpool_influxdb.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
#include <stdio.h>
7272
#include <stdint.h>
7373
#include <inttypes.h>
74-
#include <libzfs_impl.h>
74+
#include <libzfs.h>
7575

7676
#define POOL_MEASUREMENT "zpool_stats"
7777
#define SCAN_MEASUREMENT "zpool_scan_stats"
@@ -101,9 +101,10 @@ typedef int (*stat_printer_f)(nvlist_t *, const char *, const char *);
101101
* caller is responsible for freeing result
102102
*/
103103
static char *
104-
escape_string(char *s)
104+
escape_string(const char *s)
105105
{
106-
char *c, *d;
106+
const char *c;
107+
char *d;
107108
char *t = (char *)malloc(ZFS_MAX_DATASET_NAME_LEN * 2);
108109
if (t == NULL) {
109110
fprintf(stderr, "error: cannot allocate memory\n");
@@ -714,7 +715,7 @@ print_stats(zpool_handle_t *zhp, void *data)
714715

715716
/* if not this pool return quickly */
716717
if (data &&
717-
strncmp(data, zhp->zpool_name, ZFS_MAX_DATASET_NAME_LEN) != 0) {
718+
strncmp(data, zpool_get_name(zhp), ZFS_MAX_DATASET_NAME_LEN) != 0) {
718719
zpool_close(zhp);
719720
return (0);
720721
}
@@ -742,7 +743,7 @@ print_stats(zpool_handle_t *zhp, void *data)
742743
return (3);
743744
}
744745

745-
pool_name = escape_string(zhp->zpool_name);
746+
pool_name = escape_string(zpool_get_name(zhp));
746747
err = print_recursive_stats(print_summary_stats, nvroot,
747748
pool_name, NULL, 1);
748749
/* if any of these return an error, skip the rest */

cmd/zstream/zstream_redup.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <ctype.h>
2323
#include <errno.h>
2424
#include <fcntl.h>
25-
#include <libzfs_impl.h>
2625
#include <libzfs.h>
2726
#include <libzutil.h>
2827
#include <stddef.h>

include/libzfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ extern zfs_handle_t *zfs_open(libzfs_handle_t *, const char *, int);
468468
extern zfs_handle_t *zfs_handle_dup(zfs_handle_t *);
469469
extern void zfs_close(zfs_handle_t *);
470470
extern zfs_type_t zfs_get_type(const zfs_handle_t *);
471+
extern zfs_type_t zfs_get_underlying_type(const zfs_handle_t *);
471472
extern const char *zfs_get_name(const zfs_handle_t *);
472473
extern zpool_handle_t *zfs_get_pool_handle(const zfs_handle_t *);
473474
extern const char *zfs_get_pool_name(const zfs_handle_t *);

0 commit comments

Comments
 (0)