-
Notifications
You must be signed in to change notification settings - Fork 35
add zstd compression #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hchunhui
wants to merge
3
commits into
AppImageCommunity:master
Choose a base branch
from
hchunhui:zstd-v2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add zstd compression #158
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,10 +2,6 @@ | |
| #include <appimage/appimage.h> | ||
|
|
||
| extern "C" { | ||
| ssize_t appimage_get_elf_size(const char* fname) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Limit the changes in files to the PR intention. |
||
| return appimage_get_payload_offset(fname); | ||
| } | ||
|
|
||
| int appimage_type1_is_terminal_app(const char* path) { | ||
| return appimage_is_terminal_app(path); | ||
| } ; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,6 +117,41 @@ static off_t read_elf64(FILE* fd) | |
| return sht_end > last_section_end ? sht_end : last_section_end; | ||
| } | ||
|
|
||
| ssize_t appimage_get_elf_size(const char* fname) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Limit the changes in files to the PR intention. |
||
| off_t ret; | ||
| FILE* fd = NULL; | ||
| off_t size = -1; | ||
|
|
||
| fd = fopen(fname, "rb"); | ||
| if (fd == NULL) { | ||
| fprintf(stderr, "Cannot open %s: %s\n", | ||
| fname, strerror(errno)); | ||
| return -1; | ||
| } | ||
| ret = fread(ehdr.e_ident, 1, EI_NIDENT, fd); | ||
| if (ret != EI_NIDENT) { | ||
| fprintf(stderr, "Read of e_ident from %s failed: %s\n", | ||
| fname, strerror(errno)); | ||
| return -1; | ||
| } | ||
| if ((ehdr.e_ident[EI_DATA] != ELFDATA2LSB) && | ||
| (ehdr.e_ident[EI_DATA] != ELFDATA2MSB)) { | ||
| fprintf(stderr, "Unkown ELF data order %u\n", | ||
| ehdr.e_ident[EI_DATA]); | ||
| return -1; | ||
| } | ||
| if (ehdr.e_ident[EI_CLASS] == ELFCLASS32) { | ||
| size = read_elf32(fd); | ||
| } else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64) { | ||
| size = read_elf64(fd); | ||
| } else { | ||
| fprintf(stderr, "Unknown ELF class %u\n", ehdr.e_ident[EI_CLASS]); | ||
| return -1; | ||
| } | ||
|
|
||
| fclose(fd); | ||
| return size; | ||
| } | ||
|
|
||
| /* Return the offset, and the length of an ELF section with a given name in a given ELF file */ | ||
| bool appimage_get_elf_section_offset_and_length(const char* fname, const char* section_name, unsigned long* offset, unsigned long* length) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| From 5986f1d2b002d4f7f7144239a2c39b8aa39ac874 Mon Sep 17 00:00:00 2001 | ||
| From: Sean Purcell <me@seanp.xyz> | ||
| Date: Mon, 27 Mar 2017 14:42:40 -0700 | ||
| Subject: [PATCH] Add zstd compression support | ||
|
|
||
| --- | ||
| CONFIGURATION | 1 + | ||
| Makefile.am | 4 ++-- | ||
| configure.ac | 1 + | ||
| decompress.c | 21 ++++++++++++++++++++- | ||
| squashfs_fs.h | 1 + | ||
| 5 files changed, 25 insertions(+), 3 deletions(-) | ||
|
|
||
| diff --git a/CONFIGURATION b/CONFIGURATION | ||
| index c172c3e..044c67a 100644 | ||
| --- a/CONFIGURATION | ||
| +++ b/CONFIGURATION | ||
| @@ -14,5 +14,6 @@ These are the most useful options to ./configure: | ||
| --with-xz=PREFIX | ||
| --with-lzo=PREFIX | ||
| --with-lz4=PREFIX | ||
| + --with-zstd=PREFIX | ||
|
|
||
| More options are available in `./configure --help' | ||
| diff --git a/Makefile.am b/Makefile.am | ||
| index e84534e..8e61e21 100644 | ||
| --- a/Makefile.am | ||
| +++ b/Makefile.am | ||
| @@ -1,4 +1,4 @@ | ||
| -COMPRESSION_LIBS = $(ZLIB_LIBS) $(XZ_LIBS) $(LZO_LIBS) $(LZ4_LIBS) | ||
| +COMPRESSION_LIBS = $(ZLIB_LIBS) $(XZ_LIBS) $(LZO_LIBS) $(LZ4_LIBS) $(ZSTD_LIBS) | ||
|
|
||
| ACLOCAL_AMFLAGS = -I m4 --install | ||
|
|
||
| @@ -23,2 +23,2 @@ | ||
| libsquashfuse_la_CPPFLAGS = $(ZLIB_CPPFLAGS) $(XZ_CPPFLAGS) $(LZO_CPPFLAGS) \ | ||
| - $(LZ4_CPPFLAGS) | ||
| + $(LZ4_CPPFLAGS) $(ZSTD_CPPFLAGS) | ||
| diff --git a/configure.ac b/configure.ac | ||
| index 36ffb51..f3b55eb 100644 | ||
| --- a/configure.ac | ||
| +++ b/configure.ac | ||
| @@ -31,6 +31,7 @@ SQ_CHECK_DECOMPRESS([ZLIB],[z],[uncompress],[zlib.h]) | ||
| SQ_CHECK_DECOMPRESS([XZ],[lzma],[lzma_stream_buffer_decode],[lzma.h],[liblzma]) | ||
| SQ_CHECK_DECOMPRESS([LZO],[lzo2],[lzo1x_decompress_safe],[lzo/lzo1x.h]) | ||
| SQ_CHECK_DECOMPRESS([LZ4],[lz4],[LZ4_decompress_safe],[lz4.h]) | ||
| +SQ_CHECK_DECOMPRESS([ZSTD],[zstd],[ZSTD_decompress],[zstd.h]) | ||
| AS_IF([test "x$sq_decompressors" = x], | ||
| [AC_MSG_FAILURE([At least one decompression library must exist])]) | ||
|
|
||
| diff --git a/decompress.c b/decompress.c | ||
| index d8a677e..80344f0 100644 | ||
| --- a/decompress.c | ||
| +++ b/decompress.c | ||
| @@ -98,6 +98,19 @@ static sqfs_err sqfs_decompressor_lz4(void *in, size_t insz, | ||
| #endif | ||
|
|
||
|
|
||
| +#ifdef HAVE_ZSTD_H | ||
| +#include <zstd.h> | ||
| +static sqfs_err sqfs_decompressor_zstd(void *in, size_t insz, | ||
| + void *out, size_t *outsz) { | ||
| + const size_t zstdout = ZSTD_decompress(out, *outsz, in, insz); | ||
| + if (ZSTD_isError(zstdout)) | ||
| + return SQFS_ERR; | ||
| + *outsz = zstdout; | ||
| + return SQFS_OK; | ||
| +} | ||
| +#define CAN_DECOMPRESS_ZSTD 1 | ||
| +#endif | ||
| + | ||
| sqfs_decompressor sqfs_decompressor_get(sqfs_compression_type type) { | ||
| switch (type) { | ||
| #ifdef CAN_DECOMPRESS_ZLIB | ||
| @@ -111,13 +124,16 @@ sqfs_decompressor sqfs_decompressor_get(sqfs_compression_type type) { | ||
| #endif | ||
| #ifdef CAN_DECOMPRESS_LZ4 | ||
| case LZ4_COMPRESSION: return &sqfs_decompressor_lz4; | ||
| +#endif | ||
| +#ifdef CAN_DECOMPRESS_ZSTD | ||
| + case ZSTD_COMPRESSION: return &sqfs_decompressor_zstd; | ||
| #endif | ||
| default: return NULL; | ||
| } | ||
| } | ||
|
|
||
| static char *const sqfs_compression_names[SQFS_COMP_MAX] = { | ||
| - NULL, "zlib", "lzma", "lzo", "xz", "lz4", | ||
| + NULL, "zlib", "lzma", "lzo", "xz", "lz4", "zstd", | ||
| }; | ||
|
|
||
| char *sqfs_compression_name(sqfs_compression_type type) { | ||
| @@ -141,4 +157,7 @@ void sqfs_compression_supported(sqfs_compression_type *types) { | ||
| #ifdef CAN_DECOMPRESS_LZ4 | ||
| types[i++] = LZ4_COMPRESSION; | ||
| #endif | ||
| +#ifdef CAN_DECOMPRESS_ZSTD | ||
| + types[i++] = ZSTD_COMPRESSION; | ||
| +#endif | ||
| } | ||
| diff --git a/squashfs_fs.h b/squashfs_fs.h | ||
| index 7269c1f..e0ab1f4 100644 | ||
| --- a/squashfs_fs.h | ||
| +++ b/squashfs_fs.h | ||
| @@ -126,6 +126,7 @@ | ||
| #define LZO_COMPRESSION 3 | ||
| #define XZ_COMPRESSION 4 | ||
| #define LZ4_COMPRESSION 5 | ||
| +#define ZSTD_COMPRESSION 6 | ||
|
|
||
| struct squashfs_super_block { | ||
| __le32 s_magic; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.