diff options
-rw-r--r-- | doc/gensquashfs.1 | 6 | ||||
-rw-r--r-- | include/fstree.h | 2 | ||||
-rw-r--r-- | lib/fstree/fstree_from_dir.c | 16 | ||||
-rw-r--r-- | mkfs/mkfs.c | 3 | ||||
-rw-r--r-- | mkfs/mkfs.h | 1 | ||||
-rw-r--r-- | mkfs/options.c | 11 |
6 files changed, 33 insertions, 6 deletions
diff --git a/doc/gensquashfs.1 b/doc/gensquashfs.1 index ab729d7..fca45cd 100644 --- a/doc/gensquashfs.1 +++ b/doc/gensquashfs.1 @@ -38,10 +38,14 @@ Device block size to padd the image to. Defaults to 4096. .TP \fB\-\-keep\-time\fR, \fB\-k\fR -Whe using \fB\-\-pack\-dir\fR only, use the timestamps from the input files +When using \fB\-\-pack\-dir\fR only, use the timestamps from the input files instead of setting defaults on all input paths. The root inode and the modification time on the SquashFS image itself will still be set to defaults. .TP +\fB\-\-one\-file\-system\fR, \fB\-o\fR +When using \fB\-\-pack\-dir\fR only, stay in local filesystem and do not cross +mount points. +.TP \fB\-\-defaults\fR, \fB\-d\fR <options> A comma seperated list of default values for implicitly created directories. diff --git a/include/fstree.h b/include/fstree.h index a6fbd3e..9f47f76 100644 --- a/include/fstree.h +++ b/include/fstree.h @@ -37,6 +37,8 @@ enum { enum { DIR_SCAN_KEEP_TIME = 0x01, + + DIR_SCAN_ONE_FILESYSTEM = 0x02, }; /* Encapsulates a set of key-value pairs attached to a tree_node_t */ diff --git a/lib/fstree/fstree_from_dir.c b/lib/fstree/fstree_from_dir.c index 0c56148..7301d91 100644 --- a/lib/fstree/fstree_from_dir.c +++ b/lib/fstree/fstree_from_dir.c @@ -52,7 +52,8 @@ fail: return NULL; } -static int populate_dir(fstree_t *fs, tree_node_t *root, unsigned int flags) +static int populate_dir(fstree_t *fs, tree_node_t *root, dev_t devstart, + unsigned int flags) { char *extra = NULL; struct dirent *ent; @@ -86,6 +87,9 @@ static int populate_dir(fstree_t *fs, tree_node_t *root, unsigned int flags) goto fail; } + if ((flags & DIR_SCAN_ONE_FILESYSTEM) && sb.st_dev != devstart) + continue; + if (S_ISLNK(sb.st_mode)) { extra = calloc(1, sb.st_size + 1); if (extra == NULL) @@ -122,7 +126,7 @@ static int populate_dir(fstree_t *fs, tree_node_t *root, unsigned int flags) if (pushd(n->name)) return -1; - if (populate_dir(fs, n, flags)) + if (populate_dir(fs, n, devstart, flags)) return -1; if (popd()) @@ -141,12 +145,18 @@ fail: int fstree_from_dir(fstree_t *fs, const char *path, unsigned int flags) { + struct stat sb; int ret; + if (stat(path, &sb)) { + perror(path); + return -1; + } + if (pushd(path)) return -1; - ret = populate_dir(fs, fs->root, flags); + ret = populate_dir(fs, fs->root, sb.st_dev, flags); if (popd()) ret = -1; diff --git a/mkfs/mkfs.c b/mkfs/mkfs.c index 8b8ecc3..f0d1e73 100644 --- a/mkfs/mkfs.c +++ b/mkfs/mkfs.c @@ -78,6 +78,9 @@ static int read_fstree(fstree_t *fs, options_t *opt) if (opt->keep_time) flags |= DIR_SCAN_KEEP_TIME; + if (opt->one_filesystem) + flags |= DIR_SCAN_ONE_FILESYSTEM; + return fstree_from_dir(fs, opt->packdir, flags); } diff --git a/mkfs/mkfs.h b/mkfs/mkfs.h index e6e1517..c7c327c 100644 --- a/mkfs/mkfs.h +++ b/mkfs/mkfs.h @@ -36,6 +36,7 @@ typedef struct { int blksz; int devblksz; bool keep_time; + bool one_filesystem; bool exportable; bool quiet; const char *infile; diff --git a/mkfs/options.c b/mkfs/options.c index 471844f..01727fa 100644 --- a/mkfs/options.c +++ b/mkfs/options.c @@ -15,6 +15,7 @@ static struct option long_opts[] = { { "pack-file", required_argument, NULL, 'F' }, { "pack-dir", required_argument, NULL, 'D' }, { "keep-time", required_argument, NULL, 'k' }, + { "one-file-system", no_argument, NULL, 'o' }, { "exportable", no_argument, NULL, 'e' }, { "force", no_argument, NULL, 'f' }, { "quiet", no_argument, NULL, 'q' }, @@ -26,9 +27,9 @@ static struct option long_opts[] = { }; #ifdef WITH_SELINUX -static const char *short_opts = "s:F:D:X:c:b:B:d:kefqhV"; +static const char *short_opts = "s:F:D:X:c:b:B:d:koefqhV"; #else -static const char *short_opts = "F:D:X:c:b:B:d:kefqhV"; +static const char *short_opts = "F:D:X:c:b:B:d:koefqhV"; #endif extern char *__progname; @@ -76,6 +77,8 @@ static const char *help_string = " --keep-time, -k When using --pack-dir only, use the timestamps\n" " from the input files instead of setting\n" " defaults on all input paths.\n" +" --one-file-system, -o When using --pack-dir only, stay in local file\n" +" system and do not cross mount points.\n" " --exportable, -e Generate an export table for NFS support.\n" " --force, -f Overwrite the output file if it exists.\n" " --quiet, -q Do not print out progress reports.\n" @@ -135,6 +138,7 @@ void process_command_line(options_t *opt, int argc, char **argv) opt->blksz = SQFS_DEFAULT_BLOCK_SIZE; opt->devblksz = SQFS_DEVBLK_SIZE; opt->keep_time = false; + opt->one_filesystem = false; opt->exportable = false; opt->quiet = false; opt->infile = NULL; @@ -182,6 +186,9 @@ void process_command_line(options_t *opt, int argc, char **argv) case 'k': opt->keep_time = true; break; + case 'o': + opt->one_filesystem = true; + break; case 'e': opt->exportable = true; break; |