5147 const char *delim;
5148 char *path = argv[i];
5149
5150 delim = strchr(path, '@');
5151 if (delim == NULL) {
5152 (void) fprintf(stderr,
5153 gettext("'%s' is not a snapshot\n"), path);
5154 ++errors;
5155 continue;
5156 }
5157 (void) strncpy(parent, path, delim - path);
5158 parent[delim - path] = '\0';
5159
5160 zhp = zfs_open(g_zfs, parent,
5161 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME);
5162 if (zhp == NULL) {
5163 ++errors;
5164 continue;
5165 }
5166 if (holding) {
5167 if (zfs_hold(zhp, delim+1, tag, recursive,
5168 B_FALSE, -1) != 0)
5169 ++errors;
5170 } else {
5171 if (zfs_release(zhp, delim+1, tag, recursive) != 0)
5172 ++errors;
5173 }
5174 zfs_close(zhp);
5175 }
5176
5177 return (errors != 0);
5178 }
5179
5180 /*
5181 * zfs hold [-r] [-t] <tag> <snap> ...
5182 *
5183 * -r Recursively hold
5184 *
5185 * Apply a user-hold with the given tag to the list of snapshots.
5186 */
5187 static int
5188 zfs_do_hold(int argc, char **argv)
|
5147 const char *delim;
5148 char *path = argv[i];
5149
5150 delim = strchr(path, '@');
5151 if (delim == NULL) {
5152 (void) fprintf(stderr,
5153 gettext("'%s' is not a snapshot\n"), path);
5154 ++errors;
5155 continue;
5156 }
5157 (void) strncpy(parent, path, delim - path);
5158 parent[delim - path] = '\0';
5159
5160 zhp = zfs_open(g_zfs, parent,
5161 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME);
5162 if (zhp == NULL) {
5163 ++errors;
5164 continue;
5165 }
5166 if (holding) {
5167 if (zfs_hold(zhp, delim+1, tag, recursive, -1) != 0)
5168 ++errors;
5169 } else {
5170 if (zfs_release(zhp, delim+1, tag, recursive) != 0)
5171 ++errors;
5172 }
5173 zfs_close(zhp);
5174 }
5175
5176 return (errors != 0);
5177 }
5178
5179 /*
5180 * zfs hold [-r] [-t] <tag> <snap> ...
5181 *
5182 * -r Recursively hold
5183 *
5184 * Apply a user-hold with the given tag to the list of snapshots.
5185 */
5186 static int
5187 zfs_do_hold(int argc, char **argv)
|