Deleted Added
full compact
libzfs_dataset.c (339119) libzfs_dataset.c (339129)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 3435 unchanged lines hidden (view full) ---

3444/*
3445 * Creates non-existing ancestors of the given path.
3446 */
3447int
3448zfs_create_ancestors(libzfs_handle_t *hdl, const char *path)
3449{
3450 int prefix;
3451 char *path_copy;
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 3435 unchanged lines hidden (view full) ---

3444/*
3445 * Creates non-existing ancestors of the given path.
3446 */
3447int
3448zfs_create_ancestors(libzfs_handle_t *hdl, const char *path)
3449{
3450 int prefix;
3451 char *path_copy;
3452 char errbuf[1024];
3452 int rc = 0;
3453
3453 int rc = 0;
3454
3455 (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
3456 "cannot create '%s'"), path);
3457
3458 /*
3459 * Check that we are not passing the nesting limit
3460 * before we start creating any ancestors.
3461 */
3462 if (dataset_nestcheck(path) != 0) {
3463 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
3464 "maximum name nesting depth exceeded"));
3465 return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf));
3466 }
3467
3454 if (check_parents(hdl, path, NULL, B_TRUE, &prefix) != 0)
3455 return (-1);
3456
3457 if ((path_copy = strdup(path)) != NULL) {
3458 rc = create_parents(hdl, path_copy, prefix);
3459 free(path_copy);
3460 }
3461 if (path_copy == NULL || rc != 0)

--- 19 unchanged lines hidden (view full) ---

3481
3482 (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
3483 "cannot create '%s'"), path);
3484
3485 /* validate the path, taking care to note the extended error message */
3486 if (!zfs_validate_name(hdl, path, type, B_TRUE))
3487 return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf));
3488
3468 if (check_parents(hdl, path, NULL, B_TRUE, &prefix) != 0)
3469 return (-1);
3470
3471 if ((path_copy = strdup(path)) != NULL) {
3472 rc = create_parents(hdl, path_copy, prefix);
3473 free(path_copy);
3474 }
3475 if (path_copy == NULL || rc != 0)

--- 19 unchanged lines hidden (view full) ---

3495
3496 (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
3497 "cannot create '%s'"), path);
3498
3499 /* validate the path, taking care to note the extended error message */
3500 if (!zfs_validate_name(hdl, path, type, B_TRUE))
3501 return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf));
3502
3503 if (dataset_nestcheck(path) != 0) {
3504 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
3505 "maximum name nesting depth exceeded"));
3506 return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf));
3507 }
3508
3489 /* validate parents exist */
3490 if (check_parents(hdl, path, &zoned, B_FALSE, NULL) != 0)
3491 return (-1);
3492
3493 /*
3494 * The failure modes when creating a dataset of a different type over
3495 * one that already exists is a little strange. In particular, if you
3496 * try to create a dataset on top of an existing dataset, the ioctl()

--- 784 unchanged lines hidden (view full) ---

4281 != 0 || zhp->zfs_name[delim - target] != '@') {
4282 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
4283 "snapshots must be part of same "
4284 "dataset"));
4285 return (zfs_error(hdl, EZFS_CROSSTARGET,
4286 errbuf));
4287 }
4288 }
3509 /* validate parents exist */
3510 if (check_parents(hdl, path, &zoned, B_FALSE, NULL) != 0)
3511 return (-1);
3512
3513 /*
3514 * The failure modes when creating a dataset of a different type over
3515 * one that already exists is a little strange. In particular, if you
3516 * try to create a dataset on top of an existing dataset, the ioctl()

--- 784 unchanged lines hidden (view full) ---

4301 != 0 || zhp->zfs_name[delim - target] != '@') {
4302 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
4303 "snapshots must be part of same "
4304 "dataset"));
4305 return (zfs_error(hdl, EZFS_CROSSTARGET,
4306 errbuf));
4307 }
4308 }
4309
4289 if (!zfs_validate_name(hdl, target, zhp->zfs_type, B_TRUE))
4290 return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf));
4291 } else {
4292 if (flags.recurse) {
4293 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
4294 "recursive rename must be a snapshot"));
4295 return (zfs_error(hdl, EZFS_BADTYPE, errbuf));
4296 }

--- 914 unchanged lines hidden ---
4310 if (!zfs_validate_name(hdl, target, zhp->zfs_type, B_TRUE))
4311 return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf));
4312 } else {
4313 if (flags.recurse) {
4314 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
4315 "recursive rename must be a snapshot"));
4316 return (zfs_error(hdl, EZFS_BADTYPE, errbuf));
4317 }

--- 914 unchanged lines hidden ---