Deleted Added
full compact
dsl_dataset.c (223623) dsl_dataset.c (226676)
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

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

2456 if (strlen(oldname) + delta >= MAXNAMELEN)
2457 return (ENAMETOOLONG);
2458
2459 return (0);
2460}
2461
2462#pragma weak dmu_objset_rename = dsl_dataset_rename
2463int
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

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

2456 if (strlen(oldname) + delta >= MAXNAMELEN)
2457 return (ENAMETOOLONG);
2458
2459 return (0);
2460}
2461
2462#pragma weak dmu_objset_rename = dsl_dataset_rename
2463int
2464dsl_dataset_rename(char *oldname, const char *newname, boolean_t recursive)
2464dsl_dataset_rename(char *oldname, const char *newname, int flags)
2465{
2466 dsl_dir_t *dd;
2467 dsl_dataset_t *ds;
2468 const char *tail;
2469 int err;
2470
2471 err = dsl_dir_open(oldname, FTAG, &dd, &tail);
2472 if (err)
2473 return (err);
2474
2475 if (tail == NULL) {
2476 int delta = strlen(newname) - strlen(oldname);
2477
2478 /* if we're growing, validate child name lengths */
2479 if (delta > 0)
2480 err = dmu_objset_find(oldname, dsl_valid_rename,
2481 &delta, DS_FIND_CHILDREN | DS_FIND_SNAPSHOTS);
2482
2483 if (err == 0)
2465{
2466 dsl_dir_t *dd;
2467 dsl_dataset_t *ds;
2468 const char *tail;
2469 int err;
2470
2471 err = dsl_dir_open(oldname, FTAG, &dd, &tail);
2472 if (err)
2473 return (err);
2474
2475 if (tail == NULL) {
2476 int delta = strlen(newname) - strlen(oldname);
2477
2478 /* if we're growing, validate child name lengths */
2479 if (delta > 0)
2480 err = dmu_objset_find(oldname, dsl_valid_rename,
2481 &delta, DS_FIND_CHILDREN | DS_FIND_SNAPSHOTS);
2482
2483 if (err == 0)
2484 err = dsl_dir_rename(dd, newname);
2484 err = dsl_dir_rename(dd, newname, flags);
2485 dsl_dir_close(dd, FTAG);
2486 return (err);
2487 }
2488
2489 if (tail[0] != '@') {
2490 /* the name ended in a nonexistent component */
2491 dsl_dir_close(dd, FTAG);
2492 return (ENOENT);

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

2497 /* new name must be snapshot in same filesystem */
2498 tail = strchr(newname, '@');
2499 if (tail == NULL)
2500 return (EINVAL);
2501 tail++;
2502 if (strncmp(oldname, newname, tail - newname) != 0)
2503 return (EXDEV);
2504
2485 dsl_dir_close(dd, FTAG);
2486 return (err);
2487 }
2488
2489 if (tail[0] != '@') {
2490 /* the name ended in a nonexistent component */
2491 dsl_dir_close(dd, FTAG);
2492 return (ENOENT);

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

2497 /* new name must be snapshot in same filesystem */
2498 tail = strchr(newname, '@');
2499 if (tail == NULL)
2500 return (EINVAL);
2501 tail++;
2502 if (strncmp(oldname, newname, tail - newname) != 0)
2503 return (EXDEV);
2504
2505 if (recursive) {
2505 if (flags & ZFS_RENAME_RECURSIVE) {
2506 err = dsl_recursive_rename(oldname, newname);
2507 } else {
2508 err = dsl_dataset_hold(oldname, FTAG, &ds);
2509 if (err)
2510 return (err);
2511
2512 err = dsl_sync_task_do(ds->ds_dir->dd_pool,
2513 dsl_dataset_snapshot_rename_check,

--- 1531 unchanged lines hidden ---
2506 err = dsl_recursive_rename(oldname, newname);
2507 } else {
2508 err = dsl_dataset_hold(oldname, FTAG, &ds);
2509 if (err)
2510 return (err);
2511
2512 err = dsl_sync_task_do(ds->ds_dir->dd_pool,
2513 dsl_dataset_snapshot_rename_check,

--- 1531 unchanged lines hidden ---