186 */
187 int
188 snapshot_hold(char *volname, char *snapname, char *jname, boolean_t recursive)
189 {
190 zfs_handle_t *zhp;
191 char *p;
192
193 if ((zhp = zfs_open(zlibh, volname, ZFS_TYPE_DATASET)) == 0) {
194 NDMP_LOG(LOG_ERR, "Cannot open volume %s.", volname);
195 return (-1);
196 }
197
198 if (cleanup_fd == -1 && (cleanup_fd = open(ZFS_DEV,
199 O_RDWR|O_EXCL)) < 0) {
200 NDMP_LOG(LOG_ERR, "Cannot open dev %d", errno);
201 zfs_close(zhp);
202 return (-1);
203 }
204
205 p = strchr(snapname, '@') + 1;
206 if (zfs_hold(zhp, p, jname, recursive, B_FALSE, cleanup_fd) != 0) {
207 NDMP_LOG(LOG_ERR, "Cannot hold snapshot %s", p);
208 zfs_close(zhp);
209 return (-1);
210 }
211 zfs_close(zhp);
212 return (0);
213 }
214
215 int
216 snapshot_release(char *volname, char *snapname, char *jname,
217 boolean_t recursive)
218 {
219 zfs_handle_t *zhp;
220 char *p;
221 int rv = 0;
222
223 if ((zhp = zfs_open(zlibh, volname, ZFS_TYPE_DATASET)) == 0) {
224 NDMP_LOG(LOG_ERR, "Cannot open volume %s", volname);
225 return (-1);
226 }
|
186 */
187 int
188 snapshot_hold(char *volname, char *snapname, char *jname, boolean_t recursive)
189 {
190 zfs_handle_t *zhp;
191 char *p;
192
193 if ((zhp = zfs_open(zlibh, volname, ZFS_TYPE_DATASET)) == 0) {
194 NDMP_LOG(LOG_ERR, "Cannot open volume %s.", volname);
195 return (-1);
196 }
197
198 if (cleanup_fd == -1 && (cleanup_fd = open(ZFS_DEV,
199 O_RDWR|O_EXCL)) < 0) {
200 NDMP_LOG(LOG_ERR, "Cannot open dev %d", errno);
201 zfs_close(zhp);
202 return (-1);
203 }
204
205 p = strchr(snapname, '@') + 1;
206 if (zfs_hold(zhp, p, jname, recursive, cleanup_fd) != 0) {
207 NDMP_LOG(LOG_ERR, "Cannot hold snapshot %s", p);
208 zfs_close(zhp);
209 return (-1);
210 }
211 zfs_close(zhp);
212 return (0);
213 }
214
215 int
216 snapshot_release(char *volname, char *snapname, char *jname,
217 boolean_t recursive)
218 {
219 zfs_handle_t *zhp;
220 char *p;
221 int rv = 0;
222
223 if ((zhp = zfs_open(zlibh, volname, ZFS_TYPE_DATASET)) == 0) {
224 NDMP_LOG(LOG_ERR, "Cannot open volume %s", volname);
225 return (-1);
226 }
|