text stringlengths 0 14.1k |
|---|
* Upgrade a ZFS pool to the latest on-disk version. |
*/ |
int |
zpool_upgrade(zpool_handle_t *zhp, uint64_t new_version) |
{ |
zfs_cmd_t zc = { 0 }; |
libzfs_handle_t *hdl = zhp->zpool_hdl; |
(void) strcpy(zc.zc_name, zhp->zpool_name); |
zc.zc_cookie = new_version; |
if (zfs_ioctl(hdl, ZFS_IOC_POOL_UPGRADE, &zc) != 0) |
return (zpool_standard_error_fmt(hdl, errno, |
dgettext(TEXT_DOMAIN, ""cannot upgrade '%s'""), |
zhp->zpool_name)); |
return (0); |
} |
void |
zpool_set_history_str(const char *subcommand, int argc, char **argv, |
char *history_str) |
{ |
int i; |
(void) strlcpy(history_str, subcommand, HIS_MAX_RECORD_LEN); |
for (i = 1; i < argc; i++) { |
if (strlen(history_str) + 1 + strlen(argv[i]) > |
HIS_MAX_RECORD_LEN) |
break; |
(void) strlcat(history_str, "" "", HIS_MAX_RECORD_LEN); |
(void) strlcat(history_str, argv[i], HIS_MAX_RECORD_LEN); |
} |
} |
/* |
* Stage command history for logging. |
*/ |
int |
zpool_stage_history(libzfs_handle_t *hdl, const char *history_str) |
{ |
if (history_str == NULL) |
return (EINVAL); |
if (strlen(history_str) > HIS_MAX_RECORD_LEN) |
return (EINVAL); |
if (hdl->libzfs_log_str != NULL) |
free(hdl->libzfs_log_str); |
if ((hdl->libzfs_log_str = strdup(history_str)) == NULL) |
return (no_memory(hdl)); |
return (0); |
} |
/* |
* Perform ioctl to get some command history of a pool. |
* |
* 'buf' is the buffer to fill up to 'len' bytes. 'off' is the |
* logical offset of the history buffer to start reading from. |
* |
* Upon return, 'off' is the next logical offset to read from and |
* 'len' is the actual amount of bytes read into 'buf'. |
*/ |
static int |
get_history(zpool_handle_t *zhp, char *buf, uint64_t *off, uint64_t *len) |
{ |
zfs_cmd_t zc = { 0 }; |
libzfs_handle_t *hdl = zhp->zpool_hdl; |
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); |
zc.zc_history = (uint64_t)(uintptr_t)buf; |
zc.zc_history_len = *len; |
zc.zc_history_offset = *off; |
if (ioctl(hdl->libzfs_fd, ZFS_IOC_POOL_GET_HISTORY, &zc) != 0) { |
switch (errno) { |
case EPERM: |
return (zfs_error_fmt(hdl, EZFS_PERM, |
dgettext(TEXT_DOMAIN, |
""cannot show history for pool '%s'""), |
zhp->zpool_name)); |
case ENOENT: |
return (zfs_error_fmt(hdl, EZFS_NOHISTORY, |
dgettext(TEXT_DOMAIN, ""cannot get history for pool "" |
""'%s'""), zhp->zpool_name)); |
case ENOTSUP: |
return (zfs_error_fmt(hdl, EZFS_BADVERSION, |
dgettext(TEXT_DOMAIN, ""cannot get history for pool "" |
""'%s', pool must be upgraded""), zhp->zpool_name)); |
default: |
return (zpool_standard_error_fmt(hdl, errno, |
dgettext(TEXT_DOMAIN, |
""cannot get history for '%s'""), zhp->zpool_name)); |
} |
} |
*len = zc.zc_history_len; |
*off = zc.zc_history_offset; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.