Skip to content

Commit

Permalink
Add a "zstream decompress" subcommand
Browse files Browse the repository at this point in the history
It can be used to repair a ZFS file system corrupted by ZFS bug 12762.
Use it like this:
zfs send -c <DS> | zstream decompress <OBJECT>,<OFFSET>[,<COMPRESSION_ALGO>] ... | zfs recv <DST_DS>

Workaround for #12762
Sponsored-by:   Axcient
Signed-off-by:  Alan Somers <[email protected]>
  • Loading branch information
asomers committed Jun 23, 2022
1 parent deb1213 commit 43f3195
Show file tree
Hide file tree
Showing 7 changed files with 424 additions and 5 deletions.
2 changes: 2 additions & 0 deletions cmd/zstream/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ CPPCHECKTARGETS += zstream
zstream_SOURCES = \
%D%/zstream.c \
%D%/zstream.h \
%D%/zstream_decompress.c \
%D%/zstream_dump.c \
%D%/zstream_redup.c \
%D%/zstream_token.c

zstream_LDADD = \
libzfs.la \
libzfs_core.la \
libzpool.la \
libnvpair.la

PHONY += install-exec-hook
Expand Down
4 changes: 4 additions & 0 deletions cmd/zstream/zstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ zstream_usage(void)
"\tzstream dump [-vCd] FILE\n"
"\t... | zstream dump [-vCd]\n"
"\n"
"\tzstream decompress [-v] [OBJECT,OFFSET[,TYPE]] ...\n"
"\n"
"\tzstream token resume_token\n"
"\n"
"\tzstream redup [-v] FILE | ...\n");
Expand All @@ -61,6 +63,8 @@ main(int argc, char *argv[])

if (strcmp(subcommand, "dump") == 0) {
return (zstream_do_dump(argc - 1, argv + 1));
} else if (strcmp(subcommand, "decompress") == 0) {
return (zstream_do_decompress(argc - 1, argv + 1));
} else if (strcmp(subcommand, "token") == 0) {
return (zstream_do_token(argc - 1, argv + 1));
} else if (strcmp(subcommand, "redup") == 0) {
Expand Down
4 changes: 4 additions & 0 deletions cmd/zstream/zstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@
extern "C" {
#endif

extern void *safe_calloc(size_t n);
extern int sfread(void *buf, size_t size, FILE *fp);
extern void *safe_malloc(size_t size);
extern int zstream_do_redup(int, char *[]);
extern int zstream_do_dump(int, char *[]);
extern int zstream_do_decompress(int argc, char *argv[]);
extern int zstream_do_token(int, char *[]);
extern void zstream_usage(void);

Expand Down
Loading

0 comments on commit 43f3195

Please sign in to comment.