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.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or https://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
25 * Copyright (c) 2015, 2018 by Delphix. All rights reserved.
26 * Copyright 2016 Joyent, Inc.
27 * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
37 #include <sys/types.h>
45 #include <sys/zfs_ioctl.h>
48 #include "libzfs_impl.h"
50 #define ZDIFF_SNAPDIR "/.zfs/snapshot/"
51 #define ZDIFF_PREFIX "zfs-diff-%d"
53 #define ZDIFF_ADDED '+'
54 #define ZDIFF_MODIFIED "M"
55 #define ZDIFF_REMOVED '-'
56 #define ZDIFF_RENAMED "R"
58 #define ZDIFF_ADDED_COLOR ANSI_GREEN
59 #define ZDIFF_MODIFIED_COLOR ANSI_YELLOW
60 #define ZDIFF_REMOVED_COLOR ANSI_RED
61 #define ZDIFF_RENAMED_COLOR ANSI_BOLD_BLUE
64 * Given a {dsname, object id}, get the object path
67 get_stats_for_obj(differ_info_t
*di
, const char *dsname
, uint64_t obj
,
68 char *pn
, int maxlen
, zfs_stat_t
*sb
)
70 zfs_cmd_t zc
= {"\0"};
73 (void) strlcpy(zc
.zc_name
, dsname
, sizeof (zc
.zc_name
));
77 error
= zfs_ioctl(di
->zhp
->zfs_hdl
, ZFS_IOC_OBJ_TO_STATS
, &zc
);
80 /* we can get stats even if we failed to get a path */
81 (void) memcpy(sb
, &zc
.zc_stat
, sizeof (zfs_stat_t
));
83 ASSERT(di
->zerr
== 0);
84 (void) strlcpy(pn
, zc
.zc_value
, maxlen
);
88 if (di
->zerr
== ESTALE
) {
89 (void) snprintf(pn
, maxlen
, "(on_delete_queue)");
91 } else if (di
->zerr
== EPERM
) {
92 (void) snprintf(di
->errbuf
, sizeof (di
->errbuf
),
94 "The sys_config privilege or diff delegated permission "
95 "is needed\nto discover path names"));
97 } else if (di
->zerr
== EACCES
) {
98 (void) snprintf(di
->errbuf
, sizeof (di
->errbuf
),
100 "Key must be loaded to discover path names"));
103 (void) snprintf(di
->errbuf
, sizeof (di
->errbuf
),
104 dgettext(TEXT_DOMAIN
,
105 "Unable to determine path or stats for "
106 "object %lld in %s"), (longlong_t
)obj
, dsname
);
114 * Prints a file name out a character at a time. If the character is
115 * not in the range of what we consider "printable" ASCII, display it
116 * as an escaped 4-digit octal value. ASCII values less than a space
117 * are all control characters and we declare the upper end as the
118 * DELete character. This also is the last 7-bit ASCII character.
119 * We choose to treat all 8-bit ASCII as not printable for this
123 stream_bytes(FILE *fp
, const char *string
)
127 while ((c
= *string
++) != '\0') {
128 if (c
> ' ' && c
!= '\\' && c
< '\177') {
131 (void) fprintf(fp
, "\\%04hho", (uint8_t)c
);
137 * Takes the type of change (like `print_file`), outputs the appropriate color
140 type_to_color(char type
)
143 return (ZDIFF_ADDED_COLOR
);
144 else if (type
== '-')
145 return (ZDIFF_REMOVED_COLOR
);
146 else if (type
== 'M')
147 return (ZDIFF_MODIFIED_COLOR
);
148 else if (type
== 'R')
149 return (ZDIFF_RENAMED_COLOR
);
156 get_what(mode_t what
)
158 switch (what
& S_IFMT
) {
187 print_cmn(FILE *fp
, differ_info_t
*di
, const char *file
)
189 if (!di
->no_mangle
) {
190 stream_bytes(fp
, di
->dsmnt
);
191 stream_bytes(fp
, file
);
193 (void) fputs(di
->dsmnt
, fp
);
194 (void) fputs(file
, fp
);
199 print_rename(FILE *fp
, differ_info_t
*di
, const char *old
, const char *new,
202 if (isatty(fileno(fp
)))
203 color_start(ZDIFF_RENAMED_COLOR
);
205 (void) fprintf(fp
, "%10lld.%09lld\t",
206 (longlong_t
)isb
->zs_ctime
[0],
207 (longlong_t
)isb
->zs_ctime
[1]);
208 (void) fputs(ZDIFF_RENAMED
"\t", fp
);
210 (void) fprintf(fp
, "%c\t", get_what(isb
->zs_mode
));
211 print_cmn(fp
, di
, old
);
212 (void) fputs(di
->scripted
? "\t" : " -> ", fp
);
213 print_cmn(fp
, di
, new);
214 (void) fputc('\n', fp
);
216 if (isatty(fileno(fp
)))
221 print_link_change(FILE *fp
, differ_info_t
*di
, int delta
, const char *file
,
224 if (isatty(fileno(fp
)))
225 color_start(ZDIFF_MODIFIED_COLOR
);
228 (void) fprintf(fp
, "%10lld.%09lld\t",
229 (longlong_t
)isb
->zs_ctime
[0],
230 (longlong_t
)isb
->zs_ctime
[1]);
231 (void) fputs(ZDIFF_MODIFIED
"\t", fp
);
233 (void) fprintf(fp
, "%c\t", get_what(isb
->zs_mode
));
234 print_cmn(fp
, di
, file
);
235 (void) fprintf(fp
, "\t(%+d)\n", delta
);
236 if (isatty(fileno(fp
)))
241 print_file(FILE *fp
, differ_info_t
*di
, char type
, const char *file
,
244 if (isatty(fileno(fp
)))
245 color_start(type_to_color(type
));
248 (void) fprintf(fp
, "%10lld.%09lld\t",
249 (longlong_t
)isb
->zs_ctime
[0],
250 (longlong_t
)isb
->zs_ctime
[1]);
251 (void) fprintf(fp
, "%c\t", type
);
253 (void) fprintf(fp
, "%c\t", get_what(isb
->zs_mode
));
254 print_cmn(fp
, di
, file
);
255 (void) fputc('\n', fp
);
257 if (isatty(fileno(fp
)))
262 write_inuse_diffs_one(FILE *fp
, differ_info_t
*di
, uint64_t dobj
)
264 struct zfs_stat fsb
, tsb
;
266 char fobjname
[MAXPATHLEN
], tobjname
[MAXPATHLEN
];
267 boolean_t already_logged
= B_FALSE
;
268 int fobjerr
, tobjerr
;
271 if (dobj
== di
->shares
)
275 * Check the from and to snapshots for info on the object. If
276 * we get ENOENT, then the object just didn't exist in that
277 * snapshot. If we get ENOTSUP, then we tried to get
278 * info on a non-ZPL object, which we don't care about anyway.
279 * For any other error we print a warning which includes the
280 * errno and continue.
283 fobjerr
= get_stats_for_obj(di
, di
->fromsnap
, dobj
, fobjname
,
285 if (fobjerr
&& di
->zerr
!= ENOTSUP
&& di
->zerr
!= ENOENT
) {
286 zfs_error_aux(di
->zhp
->zfs_hdl
, "%s", zfs_strerror(di
->zerr
));
287 zfs_error(di
->zhp
->zfs_hdl
, di
->zerr
, di
->errbuf
);
289 * Let's not print an error for the same object more than
290 * once if it happens in both snapshots
292 already_logged
= B_TRUE
;
295 tobjerr
= get_stats_for_obj(di
, di
->tosnap
, dobj
, tobjname
,
298 if (tobjerr
&& di
->zerr
!= ENOTSUP
&& di
->zerr
!= ENOENT
) {
299 if (!already_logged
) {
300 zfs_error_aux(di
->zhp
->zfs_hdl
,
301 "%s", zfs_strerror(di
->zerr
));
302 zfs_error(di
->zhp
->zfs_hdl
, di
->zerr
, di
->errbuf
);
306 * Unallocated object sharing the same meta dnode block
308 if (fobjerr
&& tobjerr
) {
313 di
->zerr
= 0; /* negate get_stats_for_obj() from side that failed */
314 fmode
= fsb
.zs_mode
& S_IFMT
;
315 tmode
= tsb
.zs_mode
& S_IFMT
;
316 if (fmode
== S_IFDIR
|| tmode
== S_IFDIR
|| fsb
.zs_links
== 0 ||
320 change
= tsb
.zs_links
- fsb
.zs_links
;
324 print_link_change(fp
, di
, change
, tobjname
, &tsb
);
327 print_file(fp
, di
, ZDIFF_ADDED
, tobjname
, &tsb
);
329 } else if (tobjerr
) {
331 print_link_change(fp
, di
, change
, fobjname
, &fsb
);
334 print_file(fp
, di
, ZDIFF_REMOVED
, fobjname
, &fsb
);
338 if (fmode
!= tmode
&& fsb
.zs_gen
== tsb
.zs_gen
)
339 tsb
.zs_gen
++; /* Force a generational difference */
341 /* Simple modification or no change */
342 if (fsb
.zs_gen
== tsb
.zs_gen
) {
343 /* No apparent changes. Could we assert !this? */
344 if (fsb
.zs_ctime
[0] == tsb
.zs_ctime
[0] &&
345 fsb
.zs_ctime
[1] == tsb
.zs_ctime
[1])
348 print_link_change(fp
, di
, change
,
349 change
> 0 ? fobjname
: tobjname
, &tsb
);
350 } else if (strcmp(fobjname
, tobjname
) == 0) {
351 print_file(fp
, di
, *ZDIFF_MODIFIED
, fobjname
, &tsb
);
353 print_rename(fp
, di
, fobjname
, tobjname
, &tsb
);
357 /* file re-created or object re-used */
358 print_file(fp
, di
, ZDIFF_REMOVED
, fobjname
, &fsb
);
359 print_file(fp
, di
, ZDIFF_ADDED
, tobjname
, &tsb
);
365 write_inuse_diffs(FILE *fp
, differ_info_t
*di
, dmu_diff_record_t
*dr
)
370 for (o
= dr
->ddr_first
; o
<= dr
->ddr_last
; o
++) {
371 if ((err
= write_inuse_diffs_one(fp
, di
, o
)) != 0)
378 describe_free(FILE *fp
, differ_info_t
*di
, uint64_t object
, char *namebuf
,
383 (void) get_stats_for_obj(di
, di
->fromsnap
, object
, namebuf
,
386 /* Don't print if in the delete queue on from side */
387 if (di
->zerr
== ESTALE
|| di
->zerr
== ENOENT
) {
392 print_file(fp
, di
, ZDIFF_REMOVED
, namebuf
, &sb
);
397 write_free_diffs(FILE *fp
, differ_info_t
*di
, dmu_diff_record_t
*dr
)
399 zfs_cmd_t zc
= {"\0"};
400 libzfs_handle_t
*lhdl
= di
->zhp
->zfs_hdl
;
401 char fobjname
[MAXPATHLEN
];
403 (void) strlcpy(zc
.zc_name
, di
->fromsnap
, sizeof (zc
.zc_name
));
404 zc
.zc_obj
= dr
->ddr_first
- 1;
406 ASSERT(di
->zerr
== 0);
408 while (zc
.zc_obj
< dr
->ddr_last
) {
411 err
= zfs_ioctl(lhdl
, ZFS_IOC_NEXT_OBJ
, &zc
);
413 if (zc
.zc_obj
== di
->shares
) {
417 if (zc
.zc_obj
> dr
->ddr_last
) {
420 (void) describe_free(fp
, di
, zc
.zc_obj
, fobjname
,
422 } else if (errno
== ESRCH
) {
425 (void) snprintf(di
->errbuf
, sizeof (di
->errbuf
),
426 dgettext(TEXT_DOMAIN
,
427 "next allocated object (> %lld) find failure"),
428 (longlong_t
)zc
.zc_obj
);
441 differ_info_t
*di
= arg
;
442 dmu_diff_record_t dr
;
446 if ((ofp
= fdopen(di
->outputfd
, "w")) == NULL
) {
448 strlcpy(di
->errbuf
, zfs_strerror(errno
), sizeof (di
->errbuf
));
449 (void) close(di
->datafd
);
454 char *cp
= (char *)&dr
;
455 int len
= sizeof (dr
);
459 rv
= read(di
->datafd
, cp
, len
);
462 } while (len
> 0 && rv
> 0);
464 if (rv
< 0 || (rv
== 0 && len
!= sizeof (dr
))) {
467 } else if (rv
== 0) {
468 /* end of file at a natural breaking point */
472 switch (dr
.ddr_type
) {
474 err
= write_free_diffs(ofp
, di
, &dr
);
477 err
= write_inuse_diffs(ofp
, di
, &dr
);
489 (void) close(di
->datafd
);
493 ASSERT(di
->zerr
== EPIPE
);
494 (void) snprintf(di
->errbuf
, sizeof (di
->errbuf
),
495 dgettext(TEXT_DOMAIN
,
496 "Internal error: bad data from diff IOCTL"));
503 make_temp_snapshot(differ_info_t
*di
)
505 libzfs_handle_t
*hdl
= di
->zhp
->zfs_hdl
;
506 zfs_cmd_t zc
= {"\0"};
508 (void) snprintf(zc
.zc_value
, sizeof (zc
.zc_value
),
509 ZDIFF_PREFIX
, getpid());
510 (void) strlcpy(zc
.zc_name
, di
->ds
, sizeof (zc
.zc_name
));
511 zc
.zc_cleanup_fd
= di
->cleanupfd
;
513 if (zfs_ioctl(hdl
, ZFS_IOC_TMP_SNAPSHOT
, &zc
) != 0) {
516 (void) snprintf(di
->errbuf
, sizeof (di
->errbuf
),
517 dgettext(TEXT_DOMAIN
, "The diff delegated "
518 "permission is needed in order\nto create a "
519 "just-in-time snapshot for diffing\n"));
520 return (zfs_error(hdl
, EZFS_DIFF
, di
->errbuf
));
522 (void) snprintf(di
->errbuf
, sizeof (di
->errbuf
),
523 dgettext(TEXT_DOMAIN
, "Cannot create just-in-time "
524 "snapshot of '%s'"), zc
.zc_name
);
525 return (zfs_standard_error(hdl
, err
, di
->errbuf
));
529 di
->tmpsnap
= zfs_strdup(hdl
, zc
.zc_value
);
530 di
->tosnap
= zfs_asprintf(hdl
, "%s@%s", di
->ds
, di
->tmpsnap
);
535 teardown_differ_info(differ_info_t
*di
)
544 (void) close(di
->cleanupfd
);
548 get_snapshot_names(differ_info_t
*di
, const char *fromsnap
,
551 libzfs_handle_t
*hdl
= di
->zhp
->zfs_hdl
;
559 * fdslen fsnlen tdslen tsnlen
561 * 0. dataset@snap1 dataset@snap2 >0 >1 >0 >1
562 * 1. dataset@snap1 @snap2 >0 >1 ==0 >1
563 * 2. dataset@snap1 dataset >0 >1 >0 ==0
564 * 3. @snap1 dataset@snap2 ==0 >1 >0 >1
565 * 4. @snap1 dataset ==0 >1 >0 ==0
567 if (tosnap
== NULL
) {
568 /* only a from snapshot given, must be valid */
569 (void) snprintf(di
->errbuf
, sizeof (di
->errbuf
),
570 dgettext(TEXT_DOMAIN
,
571 "Badly formed snapshot name %s"), fromsnap
);
573 if (!zfs_validate_name(hdl
, fromsnap
, ZFS_TYPE_SNAPSHOT
,
575 return (zfs_error(hdl
, EZFS_INVALIDNAME
,
579 atptrf
= strchr(fromsnap
, '@');
580 ASSERT(atptrf
!= NULL
);
581 fdslen
= atptrf
- fromsnap
;
583 di
->fromsnap
= zfs_strdup(hdl
, fromsnap
);
584 di
->ds
= zfs_strdup(hdl
, fromsnap
);
585 di
->ds
[fdslen
] = '\0';
587 /* the to snap will be a just-in-time snap of the head */
588 return (make_temp_snapshot(di
));
591 (void) snprintf(di
->errbuf
, sizeof (di
->errbuf
),
592 dgettext(TEXT_DOMAIN
,
593 "Unable to determine which snapshots to compare"));
595 atptrf
= strchr(fromsnap
, '@');
596 atptrt
= strchr(tosnap
, '@');
597 fdslen
= atptrf
? atptrf
- fromsnap
: strlen(fromsnap
);
598 tdslen
= atptrt
? atptrt
- tosnap
: strlen(tosnap
);
599 fsnlen
= strlen(fromsnap
) - fdslen
; /* includes @ sign */
600 tsnlen
= strlen(tosnap
) - tdslen
; /* includes @ sign */
602 if (fsnlen
<= 1 || tsnlen
== 1 || (fdslen
== 0 && tdslen
== 0)) {
603 return (zfs_error(hdl
, EZFS_INVALIDNAME
, di
->errbuf
));
604 } else if ((fdslen
> 0 && tdslen
> 0) &&
605 ((tdslen
!= fdslen
|| strncmp(fromsnap
, tosnap
, fdslen
) != 0))) {
607 * not the same dataset name, might be okay if
608 * tosnap is a clone of a fromsnap descendant.
610 char origin
[ZFS_MAX_DATASET_NAME_LEN
];
614 di
->ds
= zfs_alloc(di
->zhp
->zfs_hdl
, tdslen
+ 1);
615 (void) strlcpy(di
->ds
, tosnap
, tdslen
+ 1);
617 zhp
= zfs_open(hdl
, di
->ds
, ZFS_TYPE_FILESYSTEM
);
618 while (zhp
!= NULL
) {
619 if (zfs_prop_get(zhp
, ZFS_PROP_ORIGIN
, origin
,
620 sizeof (origin
), &src
, NULL
, 0, B_FALSE
) != 0) {
621 (void) zfs_close(zhp
);
625 if (strncmp(origin
, fromsnap
, fsnlen
) == 0)
628 (void) zfs_close(zhp
);
629 zhp
= zfs_open(hdl
, origin
, ZFS_TYPE_FILESYSTEM
);
633 (void) snprintf(di
->errbuf
, sizeof (di
->errbuf
),
634 dgettext(TEXT_DOMAIN
,
635 "Not an earlier snapshot from the same fs"));
636 return (zfs_error(hdl
, EZFS_INVALIDNAME
, di
->errbuf
));
638 (void) zfs_close(zhp
);
641 di
->isclone
= B_TRUE
;
642 di
->fromsnap
= zfs_strdup(hdl
, fromsnap
);
644 di
->tosnap
= zfs_strdup(hdl
, tosnap
);
646 return (make_temp_snapshot(di
));
648 int dslen
= fdslen
? fdslen
: tdslen
;
650 di
->ds
= zfs_alloc(hdl
, dslen
+ 1);
651 (void) strlcpy(di
->ds
, fdslen
? fromsnap
: tosnap
, dslen
+ 1);
653 di
->fromsnap
= zfs_asprintf(hdl
, "%s%s", di
->ds
, atptrf
);
655 di
->tosnap
= zfs_asprintf(hdl
, "%s%s", di
->ds
, atptrt
);
657 return (make_temp_snapshot(di
));
664 get_mountpoint(differ_info_t
*di
, char *dsnm
, char **mntpt
)
668 mounted
= is_mounted(di
->zhp
->zfs_hdl
, dsnm
, mntpt
);
669 if (mounted
== B_FALSE
) {
670 (void) snprintf(di
->errbuf
, sizeof (di
->errbuf
),
671 dgettext(TEXT_DOMAIN
,
672 "Cannot diff an unmounted snapshot"));
673 return (zfs_error(di
->zhp
->zfs_hdl
, EZFS_BADTYPE
, di
->errbuf
));
676 /* Avoid a double slash at the beginning of root-mounted datasets */
677 if (**mntpt
== '/' && *(*mntpt
+ 1) == '\0')
683 get_mountpoints(differ_info_t
*di
)
689 * first get the mountpoint for the parent dataset
691 if (get_mountpoint(di
, di
->ds
, &di
->dsmnt
) != 0)
694 strptr
= strchr(di
->tosnap
, '@');
695 ASSERT3P(strptr
, !=, NULL
);
696 di
->tomnt
= zfs_asprintf(di
->zhp
->zfs_hdl
, "%s%s%s", di
->dsmnt
,
697 ZDIFF_SNAPDIR
, ++strptr
);
699 strptr
= strchr(di
->fromsnap
, '@');
700 ASSERT3P(strptr
, !=, NULL
);
702 frommntpt
= di
->dsmnt
;
708 err
= get_mountpoint(di
, di
->fromsnap
, &mntpt
);
715 di
->frommnt
= zfs_asprintf(di
->zhp
->zfs_hdl
, "%s%s%s", frommntpt
,
716 ZDIFF_SNAPDIR
, ++strptr
);
725 setup_differ_info(zfs_handle_t
*zhp
, const char *fromsnap
,
726 const char *tosnap
, differ_info_t
*di
)
730 di
->cleanupfd
= open(ZFS_DEV
, O_RDWR
| O_CLOEXEC
);
731 VERIFY(di
->cleanupfd
>= 0);
733 if (get_snapshot_names(di
, fromsnap
, tosnap
) != 0)
736 if (get_mountpoints(di
) != 0)
739 if (find_shares_object(di
) != 0)
746 zfs_show_diffs(zfs_handle_t
*zhp
, int outfd
, const char *fromsnap
,
747 const char *tosnap
, int flags
)
749 zfs_cmd_t zc
= {"\0"};
750 char errbuf
[ERRBUFLEN
];
751 differ_info_t di
= { 0 };
756 (void) snprintf(errbuf
, sizeof (errbuf
),
757 dgettext(TEXT_DOMAIN
, "zfs diff failed"));
759 if (setup_differ_info(zhp
, fromsnap
, tosnap
, &di
)) {
760 teardown_differ_info(&di
);
764 if (pipe2(pipefd
, O_CLOEXEC
)) {
765 zfs_error_aux(zhp
->zfs_hdl
, "%s", zfs_strerror(errno
));
766 teardown_differ_info(&di
);
767 return (zfs_error(zhp
->zfs_hdl
, EZFS_PIPEFAILED
, errbuf
));
770 di
.scripted
= (flags
& ZFS_DIFF_PARSEABLE
);
771 di
.classify
= (flags
& ZFS_DIFF_CLASSIFY
);
772 di
.timestamped
= (flags
& ZFS_DIFF_TIMESTAMP
);
773 di
.no_mangle
= (flags
& ZFS_DIFF_NO_MANGLE
);
776 di
.datafd
= pipefd
[0];
778 if (pthread_create(&tid
, NULL
, differ
, &di
)) {
779 zfs_error_aux(zhp
->zfs_hdl
, "%s", zfs_strerror(errno
));
780 (void) close(pipefd
[0]);
781 (void) close(pipefd
[1]);
782 teardown_differ_info(&di
);
783 return (zfs_error(zhp
->zfs_hdl
,
784 EZFS_THREADCREATEFAILED
, errbuf
));
788 (void) strlcpy(zc
.zc_value
, di
.fromsnap
, strlen(di
.fromsnap
) + 1);
789 (void) strlcpy(zc
.zc_name
, di
.tosnap
, strlen(di
.tosnap
) + 1);
790 zc
.zc_cookie
= pipefd
[1];
792 iocerr
= zfs_ioctl(zhp
->zfs_hdl
, ZFS_IOC_DIFF
, &zc
);
794 (void) snprintf(errbuf
, sizeof (errbuf
),
795 dgettext(TEXT_DOMAIN
, "Unable to obtain diffs"));
796 if (errno
== EPERM
) {
797 zfs_error_aux(zhp
->zfs_hdl
, dgettext(TEXT_DOMAIN
,
798 "\n The sys_mount privilege or diff delegated "
799 "permission is needed\n to execute the "
801 } else if (errno
== EXDEV
) {
802 zfs_error_aux(zhp
->zfs_hdl
, dgettext(TEXT_DOMAIN
,
803 "\n Not an earlier snapshot from the same fs"));
804 } else if (errno
!= EPIPE
|| di
.zerr
== 0) {
805 zfs_error_aux(zhp
->zfs_hdl
, "%s", zfs_strerror(errno
));
807 (void) close(pipefd
[1]);
808 (void) pthread_cancel(tid
);
809 (void) pthread_join(tid
, NULL
);
810 teardown_differ_info(&di
);
811 if (di
.zerr
!= 0 && di
.zerr
!= EPIPE
) {
812 zfs_error_aux(zhp
->zfs_hdl
, "%s",
813 zfs_strerror(di
.zerr
));
814 return (zfs_error(zhp
->zfs_hdl
, EZFS_DIFF
, di
.errbuf
));
816 return (zfs_error(zhp
->zfs_hdl
, EZFS_DIFFDATA
, errbuf
));
820 (void) close(pipefd
[1]);
821 (void) pthread_join(tid
, NULL
);
824 zfs_error_aux(zhp
->zfs_hdl
, "%s", zfs_strerror(di
.zerr
));
825 return (zfs_error(zhp
->zfs_hdl
, EZFS_DIFF
, di
.errbuf
));
827 teardown_differ_info(&di
);