Print this page
2882 implement libzfs_core
2883 changing "canmount" property to "on" should not always remount dataset
2900 "zfs snapshot" should be able to create multiple, arbitrary snapshots at once
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Chris Siden <christopher.siden@delphix.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Bill Pijewski <wdp@joyent.com>
Reviewed by: Dan Kruchinin <dan.kruchinin@gmail.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libzfs/common/libzfs.h
          +++ new/usr/src/lib/libzfs/common/libzfs.h
↓ open down ↓ 46 lines elided ↑ open up ↑
  47   47   * Miscellaneous ZFS constants
  48   48   */
  49   49  #define ZFS_MAXNAMELEN          MAXNAMELEN
  50   50  #define ZPOOL_MAXNAMELEN        MAXNAMELEN
  51   51  #define ZFS_MAXPROPLEN          MAXPATHLEN
  52   52  #define ZPOOL_MAXPROPLEN        MAXPATHLEN
  53   53  
  54   54  /*
  55   55   * libzfs errors
  56   56   */
  57      -enum {
       57 +typedef enum zfs_error {
       58 +        EZFS_SUCCESS = 0,       /* no error -- success */
  58   59          EZFS_NOMEM = 2000,      /* out of memory */
  59   60          EZFS_BADPROP,           /* invalid property value */
  60   61          EZFS_PROPREADONLY,      /* cannot set readonly property */
  61   62          EZFS_PROPTYPE,          /* property does not apply to dataset type */
  62   63          EZFS_PROPNONINHERIT,    /* property is not inheritable */
  63   64          EZFS_PROPSPACE,         /* bad quota or reservation */
  64   65          EZFS_BADTYPE,           /* dataset is not of appropriate type */
  65   66          EZFS_BUSY,              /* pool or dataset is busy */
  66   67          EZFS_EXISTS,            /* pool or dataset already exists */
  67   68          EZFS_NOENT,             /* no such pool or dataset */
↓ open down ↓ 51 lines elided ↑ open up ↑
 119  120          EZFS_TAGTOOLONG,        /* snapshot hold/rele: tag too long */
 120  121          EZFS_PIPEFAILED,        /* pipe create failed */
 121  122          EZFS_THREADCREATEFAILED, /* thread create failed */
 122  123          EZFS_POSTSPLIT_ONLINE,  /* onlining a disk after splitting it */
 123  124          EZFS_SCRUBBING,         /* currently scrubbing */
 124  125          EZFS_NO_SCRUB,          /* no active scrub */
 125  126          EZFS_DIFF,              /* general failure of zfs diff */
 126  127          EZFS_DIFFDATA,          /* bad zfs diff data */
 127  128          EZFS_POOLREADONLY,      /* pool is in read-only mode */
 128  129          EZFS_UNKNOWN
 129      -};
      130 +} zfs_error_t;
 130  131  
 131  132  /*
 132  133   * The following data structures are all part
 133  134   * of the zfs_allow_t data structure which is
 134  135   * used for printing 'allow' permissions.
 135  136   * It is a linked list of zfs_allow_t's which
 136  137   * then contain avl tree's for user/group/sets/...
 137  138   * and each one of the entries in those trees have
 138  139   * avl tree's for the permissions they belong to and
 139  140   * whether they are local,descendent or local+descendent
↓ open down ↓ 35 lines elided ↑ open up ↑
 175  176   * Library initialization
 176  177   */
 177  178  extern libzfs_handle_t *libzfs_init(void);
 178  179  extern void libzfs_fini(libzfs_handle_t *);
 179  180  
 180  181  extern libzfs_handle_t *zpool_get_handle(zpool_handle_t *);
 181  182  extern libzfs_handle_t *zfs_get_handle(zfs_handle_t *);
 182  183  
 183  184  extern void libzfs_print_on_error(libzfs_handle_t *, boolean_t);
 184  185  
      186 +extern void zfs_save_arguments(int argc, char **, char *, int);
      187 +extern int zpool_log_history(libzfs_handle_t *, const char *);
      188 +
 185  189  extern int libzfs_errno(libzfs_handle_t *);
 186  190  extern const char *libzfs_error_action(libzfs_handle_t *);
 187  191  extern const char *libzfs_error_description(libzfs_handle_t *);
 188  192  extern void libzfs_mnttab_init(libzfs_handle_t *);
 189  193  extern void libzfs_mnttab_fini(libzfs_handle_t *);
 190  194  extern void libzfs_mnttab_cache(libzfs_handle_t *, boolean_t);
 191  195  extern int libzfs_mnttab_find(libzfs_handle_t *, const char *,
 192  196      struct mnttab *);
 193  197  extern void libzfs_mnttab_add(libzfs_handle_t *, const char *,
 194  198      const char *, const char *);
↓ open down ↓ 14 lines elided ↑ open up ↑
 209  213   * Iterate over all active pools in the system.
 210  214   */
 211  215  typedef int (*zpool_iter_f)(zpool_handle_t *, void *);
 212  216  extern int zpool_iter(libzfs_handle_t *, zpool_iter_f, void *);
 213  217  
 214  218  /*
 215  219   * Functions to create and destroy pools
 216  220   */
 217  221  extern int zpool_create(libzfs_handle_t *, const char *, nvlist_t *,
 218  222      nvlist_t *, nvlist_t *);
 219      -extern int zpool_destroy(zpool_handle_t *);
      223 +extern int zpool_destroy(zpool_handle_t *, const char *);
 220  224  extern int zpool_add(zpool_handle_t *, nvlist_t *);
 221  225  
 222  226  typedef struct splitflags {
 223  227          /* do not split, but return the config that would be split off */
 224  228          int dryrun : 1;
 225  229  
 226  230          /* after splitting, import the pool */
 227  231          int import : 1;
 228  232  } splitflags_t;
 229  233  
↓ open down ↓ 101 lines elided ↑ open up ↑
 331  335   * Statistics and configuration functions.
 332  336   */
 333  337  extern nvlist_t *zpool_get_config(zpool_handle_t *, nvlist_t **);
 334  338  extern nvlist_t *zpool_get_features(zpool_handle_t *);
 335  339  extern int zpool_refresh_stats(zpool_handle_t *, boolean_t *);
 336  340  extern int zpool_get_errlog(zpool_handle_t *, nvlist_t **);
 337  341  
 338  342  /*
 339  343   * Import and export functions
 340  344   */
 341      -extern int zpool_export(zpool_handle_t *, boolean_t);
 342      -extern int zpool_export_force(zpool_handle_t *);
      345 +extern int zpool_export(zpool_handle_t *, boolean_t, const char *);
      346 +extern int zpool_export_force(zpool_handle_t *, const char *);
 343  347  extern int zpool_import(libzfs_handle_t *, nvlist_t *, const char *,
 344  348      char *altroot);
 345  349  extern int zpool_import_props(libzfs_handle_t *, nvlist_t *, const char *,
 346  350      nvlist_t *, int);
 347  351  extern void zpool_print_unsup_feat(nvlist_t *config);
 348  352  
 349  353  /*
 350  354   * Search for pools to import
 351  355   */
 352  356  
↓ open down ↓ 13 lines elided ↑ open up ↑
 366  370  /* legacy pool search routines */
 367  371  extern nvlist_t *zpool_find_import(libzfs_handle_t *, int, char **);
 368  372  extern nvlist_t *zpool_find_import_cached(libzfs_handle_t *, const char *,
 369  373      char *, uint64_t);
 370  374  
 371  375  /*
 372  376   * Miscellaneous pool functions
 373  377   */
 374  378  struct zfs_cmd;
 375  379  
 376      -extern const char *zfs_history_event_names[LOG_END];
      380 +extern const char *zfs_history_event_names[];
 377  381  
 378  382  extern char *zpool_vdev_name(libzfs_handle_t *, zpool_handle_t *, nvlist_t *,
 379  383      boolean_t verbose);
 380  384  extern int zpool_upgrade(zpool_handle_t *, uint64_t);
 381  385  extern int zpool_get_history(zpool_handle_t *, nvlist_t **);
 382  386  extern int zpool_history_unpack(char *, uint64_t, uint64_t *,
 383  387      nvlist_t ***, uint_t *);
 384      -extern void zpool_set_history_str(const char *subcommand, int argc,
 385      -    char **argv, char *history_str);
 386      -extern int zpool_stage_history(libzfs_handle_t *, const char *);
 387  388  extern void zpool_obj_to_path(zpool_handle_t *, uint64_t, uint64_t, char *,
 388  389      size_t len);
 389  390  extern int zfs_ioctl(libzfs_handle_t *, int, struct zfs_cmd *);
 390  391  extern int zpool_get_physpath(zpool_handle_t *, char *, size_t);
 391  392  extern void zpool_explain_recover(libzfs_handle_t *, const char *, int,
 392  393      nvlist_t *);
 393  394  
 394  395  /*
 395  396   * Basic handle manipulations.  These functions do not create or destroy the
 396  397   * underlying datasets, only the references to them.
↓ open down ↓ 32 lines elided ↑ open up ↑
 429  430  extern int zfs_prop_get_userquota_int(zfs_handle_t *zhp, const char *propname,
 430  431      uint64_t *propvalue);
 431  432  extern int zfs_prop_get_userquota(zfs_handle_t *zhp, const char *propname,
 432  433      char *propbuf, int proplen, boolean_t literal);
 433  434  extern int zfs_prop_get_written_int(zfs_handle_t *zhp, const char *propname,
 434  435      uint64_t *propvalue);
 435  436  extern int zfs_prop_get_written(zfs_handle_t *zhp, const char *propname,
 436  437      char *propbuf, int proplen, boolean_t literal);
 437  438  extern int zfs_prop_get_feature(zfs_handle_t *zhp, const char *propname,
 438  439      char *buf, size_t len);
 439      -extern int zfs_get_snapused_int(zfs_handle_t *firstsnap, zfs_handle_t *lastsnap,
 440      -    uint64_t *usedp);
 441  440  extern uint64_t zfs_prop_get_int(zfs_handle_t *, zfs_prop_t);
 442  441  extern int zfs_prop_inherit(zfs_handle_t *, const char *, boolean_t);
 443  442  extern const char *zfs_prop_values(zfs_prop_t);
 444  443  extern int zfs_prop_is_string(zfs_prop_t prop);
 445  444  extern nvlist_t *zfs_get_user_props(zfs_handle_t *);
 446  445  extern nvlist_t *zfs_get_recvd_props(zfs_handle_t *);
 447  446  extern nvlist_t *zfs_get_clones_nvl(zfs_handle_t *);
 448  447  
 449  448  
 450  449  typedef struct zprop_list {
↓ open down ↓ 95 lines elided ↑ open up ↑
 546  545   * Functions to create and destroy datasets.
 547  546   */
 548  547  extern int zfs_create(libzfs_handle_t *, const char *, zfs_type_t,
 549  548      nvlist_t *);
 550  549  extern int zfs_create_ancestors(libzfs_handle_t *, const char *);
 551  550  extern int zfs_destroy(zfs_handle_t *, boolean_t);
 552  551  extern int zfs_destroy_snaps(zfs_handle_t *, char *, boolean_t);
 553  552  extern int zfs_destroy_snaps_nvl(zfs_handle_t *, nvlist_t *, boolean_t);
 554  553  extern int zfs_clone(zfs_handle_t *, const char *, nvlist_t *);
 555  554  extern int zfs_snapshot(libzfs_handle_t *, const char *, boolean_t, nvlist_t *);
      555 +extern int zfs_snapshot_nvl(libzfs_handle_t *hdl, nvlist_t *snaps,
      556 +    nvlist_t *props);
 556  557  extern int zfs_rollback(zfs_handle_t *, zfs_handle_t *, boolean_t);
 557  558  extern int zfs_rename(zfs_handle_t *, const char *, boolean_t, boolean_t);
 558  559  
 559  560  typedef struct sendflags {
 560  561          /* print informational messages (ie, -v was specified) */
 561  562          boolean_t verbose;
 562  563  
 563  564          /* recursive send  (ie, -R) */
 564  565          boolean_t replicate;
 565  566  
↓ open down ↓ 190 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX