Changeset View
Changeset View
Standalone View
Standalone View
cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
Show First 20 Lines • Show All 5,466 Lines • ▼ Show 20 Lines | if (holding && tag[0] == '.') { | ||||
/* tags starting with '.' are reserved for libzfs */ | /* tags starting with '.' are reserved for libzfs */ | ||||
(void) fprintf(stderr, gettext("tag may not start with '.'\n")); | (void) fprintf(stderr, gettext("tag may not start with '.'\n")); | ||||
usage(B_FALSE); | usage(B_FALSE); | ||||
} | } | ||||
for (i = 0; i < argc; ++i) { | for (i = 0; i < argc; ++i) { | ||||
zfs_handle_t *zhp; | zfs_handle_t *zhp; | ||||
char parent[ZFS_MAXNAMELEN]; | char parent[ZFS_MAXNAMELEN]; | ||||
const char *delim; | const char *delim, *snapshot; | ||||
char *path = argv[i]; | char *path = argv[i]; | ||||
delim = strchr(path, '@'); | delim = strchr(path, '@'); | ||||
if (delim == NULL) { | if (delim == NULL) { | ||||
if (holding) { | |||||
(void) fprintf(stderr, | (void) fprintf(stderr, | ||||
gettext("'%s' is not a snapshot\n"), path); | gettext("'%s' is not a snapshot\n"), path); | ||||
++errors; | ++errors; | ||||
continue; | continue; | ||||
} | } | ||||
(void) strcpy(parent, path); | |||||
snapshot = NULL; | |||||
} else { | |||||
(void) strncpy(parent, path, delim - path); | (void) strncpy(parent, path, delim - path); | ||||
parent[delim - path] = '\0'; | parent[delim - path] = '\0'; | ||||
snapshot = delim + 1; | |||||
} | |||||
zhp = zfs_open(g_zfs, parent, | zhp = zfs_open(g_zfs, parent, | ||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME); | ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME); | ||||
if (zhp == NULL) { | if (zhp == NULL) { | ||||
++errors; | ++errors; | ||||
continue; | continue; | ||||
} | } | ||||
if (holding) { | if (holding) { | ||||
if (zfs_hold(zhp, delim+1, tag, recursive, -1) != 0) | if (zfs_hold(zhp, snapshot, tag, recursive, -1) != 0) | ||||
++errors; | ++errors; | ||||
} else { | } else { | ||||
if (zfs_release(zhp, delim+1, tag, recursive) != 0) | if (zfs_release(zhp, snapshot, tag, recursive) != 0) | ||||
++errors; | ++errors; | ||||
} | } | ||||
zfs_close(zhp); | zfs_close(zhp); | ||||
} | } | ||||
return (errors != 0); | return (errors != 0); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,656 Lines • Show Last 20 Lines |