Skip to content

Commit

Permalink
Mksquashfs: create mount point when using -one-file-system
Browse files Browse the repository at this point in the history
This fixes #189

If a directory crosses the filesystem boundary, create an
empty directory, rather than ignoring it.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
  • Loading branch information
plougher committed Aug 11, 2022
1 parent 8994a80 commit f25f465
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions squashfs-tools/mksquashfs.c
Expand Up @@ -3655,6 +3655,7 @@ static struct dir_info *dir_scan1(char *filename, char *subpath,
char *filename = pathname(dir_ent);
char *subpath = NULL;
char *dir_name = dir_ent->name;
int create_empty_directory = FALSE;

if(strcmp(dir_name, ".") == 0 || strcmp(dir_name, "..") == 0) {
free_dir_entry(dir_ent);
Expand All @@ -3671,9 +3672,13 @@ static struct dir_info *dir_scan1(char *filename, char *subpath,

if(one_file_system) {
if(buf.st_dev != cur_dev) {
ERROR("%s is on a different filesystem, ignored\n", filename);
free_dir_entry(dir_ent);
continue;
if(!S_ISDIR(buf.st_mode)) {
ERROR("%s is on a different filesystem, ignored\n", filename);
free_dir_entry(dir_ent);
continue;
}

create_empty_directory = TRUE;
}
}

Expand Down Expand Up @@ -3719,8 +3724,12 @@ static struct dir_info *dir_scan1(char *filename, char *subpath,
if(subpath == NULL)
subpath = subpathname(dir_ent);

sub_dir = dir_scan1(filename, subpath, new,
scan1_readdir, depth + 1);
if(create_empty_directory) {
ERROR("%s is on a different filesystem, creating empty directory\n", filename);
sub_dir = create_dir(filename, subpath, depth + 1);
} else
sub_dir = dir_scan1(filename, subpath, new,
scan1_readdir, depth + 1);
if(sub_dir) {
dir->directory_count ++;
add_dir_entry(dir_ent, sub_dir,
Expand Down

0 comments on commit f25f465

Please sign in to comment.