aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorprobonopd <probonopd@users.noreply.github.com>2016-09-15 21:09:52 +0200
committerPhillip Lougher <phillip@squashfs.org.uk>2017-07-31 19:20:59 +0100
commite4a57ef479e0abbc4c96fec5593635cf14aed05c (patch)
treefa4030db9a708919b13e9ea99537f126f07415d7
parent0d654504832b872daf70fad8be6463f4e12ecc6c (diff)
downloadsquashfs-tools-e4a57ef479e0abbc4c96fec5593635cf14aed05c.tar.gz
Add -offset function to skip n bytes at the beginning of the squashfs file
-rw-r--r--squashfs-tools/mksquashfs.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
index 1ccbb28..4808ae9 100644
--- a/squashfs-tools/mksquashfs.c
+++ b/squashfs-tools/mksquashfs.c
@@ -99,6 +99,7 @@ int old_exclude = TRUE;
int use_regex = FALSE;
int nopad = FALSE;
int exit_on_error = FALSE;
+static off_t squashfs_start_offset = 0;
long long global_uid = -1, global_gid = -1;
@@ -517,9 +518,9 @@ int read_fs_bytes(int fd, long long byte, int bytes, void *buff)
pthread_cleanup_push((void *) pthread_mutex_unlock, &pos_mutex);
pthread_mutex_lock(&pos_mutex);
- if(lseek(fd, off, SEEK_SET) == -1) {
+ if(lseek(fd, off+squashfs_start_offset, SEEK_SET) == -1) {
ERROR("read_fs_bytes: Lseek on destination failed because %s, "
- "offset=0x%llx\n", strerror(errno), off);
+ "offset=0x%llx\n", strerror(errno), off+squashfs_start_offset);
res = 0;
} else if(read_bytes(fd, buff, bytes) < bytes) {
ERROR("Read on destination failed\n");
@@ -558,10 +559,10 @@ void write_destination(int fd, long long byte, int bytes, void *buff)
pthread_cleanup_push((void *) pthread_mutex_unlock, &pos_mutex);
pthread_mutex_lock(&pos_mutex);
- if(lseek(fd, off, SEEK_SET) == -1) {
+ if(lseek(fd, off+squashfs_start_offset, SEEK_SET) == -1) {
ERROR("write_destination: Lseek on destination "
"failed because %s, offset=0x%llx\n", strerror(errno),
- off);
+ off+squashfs_start_offset);
BAD_ERROR("Probably out of space on output %s\n",
block_device ? "block device" : "filesystem");
}
@@ -2317,9 +2318,9 @@ void *writer(void *arg)
pthread_cleanup_push((void *) pthread_mutex_unlock, &pos_mutex);
pthread_mutex_lock(&pos_mutex);
- if(lseek(fd, off, SEEK_SET) == -1) {
+ if(lseek(fd, off+squashfs_start_offset, SEEK_SET) == -1) {
ERROR("writer: Lseek on destination failed because "
- "%s, offset=0x%llx\n", strerror(errno), off);
+ "%s, offset=0x%llx\n", strerror(errno), off+squashfs_start_offset);
BAD_ERROR("Probably out of space on output "
"%s\n", block_device ? "block device" :
"filesystem");
@@ -5352,6 +5353,15 @@ print_compressor_options:
force_progress = TRUE;
else if(strcmp(argv[i], "-no-exports") == 0)
exportable = FALSE;
+ else if(strcmp(argv[i], "-offset") == 0 ||
+ strcmp(argv[i], "-o") ==0) {
+ if(++i == argc) {
+ ERROR("%s: %s offset missing argument\n", argv[0],
+ argv[i - 1]);
+ exit(1);
+ }
+ squashfs_start_offset = (off_t)atol(argv[i]);
+ }
else if(strcmp(argv[i], "-processors") == 0) {
if((++i == argc) || !parse_num(argv[i], &processors)) {
ERROR("%s: -processors missing or invalid "
@@ -5656,6 +5666,9 @@ printOptions:
ERROR("\nMiscellaneous options:\n");
ERROR("-root-owned\t\talternative name for -all-root"
"\n");
+ ERROR("-o <offset>\t\tSkip <offset> bytes at the "
+ "beginning of the file.\n\t\t\t"
+ "Default 0 bytes\n");
ERROR("-noInodeCompression\talternative name for -noI"
"\n");
ERROR("-noDataCompression\talternative name for -noD"