Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
vaeth committed Nov 30, 2019
1 parent 6b80e2d commit 68066db
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 28 deletions.
6 changes: 5 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# ChangeLog for squashmount

*squashmount-21.0:
Martin Väth <martin at mvath.de>:
- Support https://github.com/containers/fuse-overlayfs

*squashmount-20.0:
Martin Väth <martin at mvath.de>:
- Support https://github.com/AgentD/squashfs-tools-ng
- Support https://github.com/AgentD/squashfs-tools-ng (--tar2sqfs)
BEWARE: For me, this new tool does not work for unknown reasons:
tar2sqfs produces files unreadable by the kernel or by unsquashfs
(no matter whether squashfs-root is a parent directory), and
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ available):
- overlayfs, a variant for older linux kernels, see
http://git.kernel.org/?p=linux/kernel/git/mszeredi/vfs.git
- aufs, see http://aufs.sourceforge.net
- fuse-overlayfs, see https://github.com/containers/fuse-overlayfs
- unionfs-fuse, see http://podgorny.cz/moin/UnionFsFuse
(unionfs-fuse-0.25 or newer is required)
- unionfs, see http://www.fsl.cs.sunysb.edu/project-unionfs.html
Expand Down
86 changes: 60 additions & 26 deletions bin/squashmount
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
BEGIN { require 5.022 }
package Squashmount v20.0.0;
package Squashmount v21.0.0;

use strict;
use warnings;
Expand Down Expand Up @@ -269,9 +269,9 @@ Output the mtime of the squash-file.

Output the tool actually used for mounting.
Possible output is C<overlay>, C<overlayfs>, C<overlayfs-obsolete>, C<aufs>,
C<unionfs-fuse>, C<unionfs>, C<funionfs>, C<bind>, C<readonly>, or the
empty string (for not mounted or incompletely mounted; you can check
the details with B<print-squashtype>).
C<fuse-overlayfs>, C<unionfs-fuse>, C<unionfs>, C<funionfs>, C<bind>,
C<readonly>, or the empty string (for not mounted or incompletely mounted;
you can check the details with B<print-squashtype>).
For usage in scripts, combine this with B<-q> and pass a tag.

=item B<print-squashtype>
Expand Down Expand Up @@ -462,7 +462,8 @@ differently (for examples, see the description of B<@umount> and B<UMOUNT>).

Add option I<opt> to the default B<@fumount> array (see also B<--umount>).
If this option is repeated, all passed options are added to the array.
By default, this means that the option are used in the call to B<fusermount -u DIR>.
By default, this means that the option are used in the call to
B<fusermount -u DIR>.
There might be code in B</etc/squashmount.pl> which treats this array value
differently.

Expand Down Expand Up @@ -494,7 +495,7 @@ You can avoid/change the effect by specifying B<--rundir>.

You can avoid this effect by specifying B<--allow>

=item Use default @order = qw(unionfs-fuse!! funionfs!!)
=item Use default @order = qw(fuse-overlayfs!! unionfs-fuse!! funionfs!!)

You can avoid this effect by specifying B<--order>

Expand Down Expand Up @@ -732,7 +733,7 @@ configured (without actually changing the configuration, of course).

=item B<--tar2sqfs> or B<--tar>

Use tar -> tar2sqfs for compression instead of squashfs.
Use tar -> tar2sqfs from squashfs-tools-ng for compression instead of squashfs.

=item B<--no-tar2sqfs>, B<--notar2sqfs>, B<--no-tar>, or B<--notar>

Expand Down Expand Up @@ -866,16 +867,16 @@ configuration file F</etc/squashmount.pl>

=item B<--allow>

Use the option C<-o allow_other> for B<MOUNT_UNIONFS_FUSE>,
B<MOUNT_FUNIONFS>, and B<MOUNT_SQUASHFUSE> as default if these variables
are not specified.
Use the option C<-o allow_other> for B<MOUNT_FUSE_OVERLAYFS>,
B<MOUNT_UNIONFS_FUSE>, B<MOUNT_FUNIONFS>, and B<MOUNT_SQUASHFUSE>
as default if these variables are not specified.
This is the default unless B<--user> is in use.

=item B<--no-allow> or B<--noallow>

Do not use the option C<-o allow_other> for B<MOUNT_UNIONFS_FUSE>,
B<MOUNT_FUNIONFS>, and B<MOUNT_SQUASHFUSE> as default if these variables
are not specified.
Do not use the option C<-o allow_other> for B<MOUNT_FUSE_OVERLAYFS>,
B<MOUNT_UNIONFS_FUSE>, B<MOUNT_FUNIONFS>, and B<MOUNT_SQUASHFUSE>
as default if these variables are not specified.
This overrides the setting of B<--user>.

=item B<--locking>
Expand Down Expand Up @@ -1054,7 +1055,7 @@ see the remarks at the end of this manpage.)

=item $obsolete_overlayfs = undef; # no fallback: require >=kernel-3.15

=item @order = qw(overlay? overlayfs? aufs! unionfs-fuse! unionfs??# funionfs??#);
=item @order = qw(overlay? overlayfs? aufs! fuse-overlayfs! unionfs-fuse! unionfs??# funionfs??#);

=item # The main task is to set B<@mounts>. Use one of

Expand Down Expand Up @@ -1399,7 +1400,7 @@ The content of this array should be strings with one of the texts

=over 16

=item B<overlay>, B<overlayfs>, B<aufs>, B<unionfs-fuse>, B<unionfs>, B<funionfs>, B<bind>
=item B<overlay>, B<overlayfs>, B<aufs>, B<fuse-overlayfs>, B<unionfs-fuse>, B<unionfs>, B<funionfs>, B<bind>

=back

Expand All @@ -1426,8 +1427,8 @@ in case of B<!!> the modprobe is not even attempted.
In particular you should use this if it might happen (or you know) that the
corresponding tool is compiled directly into the kernel.
Note that B<overlayfs>, B<aufs>, B<unionfs> have their own kernel modules
while B<unionfs-fuse> and B<funionfs> both require the B<fuse> module and
need special user space binaries.
while B<fuse-overlayfs>, B<unionfs-fuse> and B<funionfs> all require the
B<fuse> module and need special user space binaries.

=item B<?> or B<??>

Expand All @@ -1445,10 +1446,11 @@ B<??> variant is used, the tool is considered as unavailable.

If this flag is used, it is checked whether the binary
(B<mount> in case of B<overlay>, B<overlayfs>, B<aufs>, or B<unionfs>
or the special user space binary for B<unionfs-fuse> or B<funionfs>,
respectively) is available in your path. If it is unavailable, the tool is
tacitly skipped. This flag is ignored if neither B<File::Which> nor the
B<which> program are available.
or the special user space binary for B<fuse-overlayfs>, B<unionfs-fuse>,
or B<funionfs>, respectively) is available in your path.
If it is unavailable, the tool is tacitly skipped.
This flag is ignored if neither B<File::Which> nor the B<which> program are
available.

=back

Expand All @@ -1457,7 +1459,7 @@ If B<squashmount> is used with a command for which the order is possibly needed

=over 16

=item qw(overlay!? overlayfs!? aufs! unionfs-fuse! unionfs! funionfs!)
=item qw(overlay!? overlayfs!? aufs! fuse-overlayfs! unionfs-fuse! unionfs! funionfs!)

=back

Expand Down Expand Up @@ -1715,6 +1717,13 @@ This should be a (possibly empty) string or a reference to an array of strings:
These strings are used as additional options when mounting with aufs.
The default is B<['-o', 'noatime']>.

=item B<MOUNT_FUSE_OVERLAYFS>

This should be a (possibly empty) string or a reference to an array of strings:
These strings are used as additional options when mounting with fuse-overlayfs.
The default is B<['-o', 'allow_other', '-o', 'use_ino', '-o', 'nonempty',
'-o', 'noatime']>.

=item B<MOUNT_UNIONFS_FUSE>

This should be a (possibly empty) string or a reference to an array of strings:
Expand Down Expand Up @@ -2580,6 +2589,7 @@ my $titleopt = undef;

my $title = undef;
my $funionfs = undef;
my $fuse_overlayfs = undef;
my $unionfs_fuse = undef;
my $squashfuse = undef;
my $mksquashfs = undef;
Expand Down Expand Up @@ -3254,7 +3264,9 @@ sub mount_rw {
my $probemod = (($i =~ m{\!}) ? (($i =~ m{\!\!}) ? '' : -1) : 1);
my $check_bin = ($i =~ m{\#});
my $check_gz = (($i =~ m{\?}) ? (($i =~ m{\?\?}) ? -1 : 1) : '');
if ($i =~ m{overlayfs}i) {
if ($i =~ m{fuse}i && $i =~ m{over}i) {
return 'fuse-overlayfs' if (&mount_fuse_overlayfs($probemod, $check_gz, $check_bin, $ro, $rw, $changes))
} elsif ($i =~ m{overlayfs}i) {
my $type = &mount_overlayfs($probemod, $check_gz, $check_bin, $ro, $rw, $changes);
return $type if ($type ne '')
} elsif ($i =~ m{overlay}i) {
Expand Down Expand Up @@ -3355,6 +3367,28 @@ sub mount_aufs {
''
}

# Mount with fuse-overlayfs

sub mount_fuse_overlayfs {
my ($probemod, $check_gz, $check_bin, $ro, $rw, $changes) = @_;
&push_ref(\my @options, $user_config->{'MOUNT_FUSE_OVERLAYFS'},
[@allow_other, '-o', 'use_ino', '-o', 'nonempty',
'-o', 'noatime']);
my $workdir = &create_workdir();
return '' if ($workdir eq '');
my $tool = 'fuse-overlayfs';
unless (&which_store(\$fuse_overlayfs, $tool)) {
return '' if ($check_bin)
}
return '' unless (&kernelprobe($probemod, $check_gz, 'fuse'));
return 1 if (&my_system('', \$fuse_overlayfs, $tool, @options,
'-o', "upperdir\=${changes}", '-o', "lowerdir\=${ro}",
'-o', "workdir\=${workdir}", # '--', # -- breaks fuse-overlayfs
$rw) == 0);
&warning('fuse-overlayfs failed') unless ($quiet > 1);
''
}

# Mount with unionfs-fuse

sub mount_unionfs_fuse {
Expand Down Expand Up @@ -4413,7 +4447,7 @@ sub is_workdir_type {
sub is_fuse_type {
my $type = (@_ ? $_[0] : $current->{'TYPE'});
return undef unless (&is_nonempty($type));
(($type eq 'unionfs-fuse') || ($type eq 'funionfs'))
(($type eq 'fuse-overlayfs') || ($type eq 'unionfs-fuse') || ($type eq 'funionfs'))
}

# Test if READONLY has valid type for fusermount;
Expand Down Expand Up @@ -5521,10 +5555,10 @@ my $action = (shift(@ARGV) // '');
$CFG::storing = $CFG::locking = !$run_ro;
if ($order_needed) {
if ($opt_user) {
@CFG::order = qw(unionfs-fuse!! funionfs!!);
@CFG::order = qw(fuse-overlayfs!! unionfs-fuse!! funionfs!!);
@CFG::squashorder = qw(squashfuse!!)
} else {
@CFG::order = qw(overlay!? overlayfs!? aufs! unionfs-fuse! unionfs! funionfs!);
@CFG::order = qw(overlay!? overlayfs!? aufs! fuse-overlayfs! unionfs-fuse! unionfs! funionfs!);
@CFG::squashorder = qw(squashfs!? squashfuse!)
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/squashmount.pl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
# if compiled into the kernel. Use "overlay? overlayfs?" instead
# if you want a more reliable check for that case.

@order = qw(overlay overlayfs aufs! unionfs-fuse! unionfs??# funionfs??#);
@order = qw(overlay overlayfs aufs! fuse-overlayfs! unionfs-fuse! unionfs??# funionfs??#);

# The tool to mount squash files (currently: kernel or user-space squashfuse)
# is determined according to squashorder. The following is the default
Expand Down
2 changes: 2 additions & 0 deletions zsh/_squashmount
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ _arguments -C -s -S : \
'(--color -F '{'--no-color --nocolor)-C','--nocolor -C)--no-color','--no-color -E)--nocolor'}'[non-colored output]' \
'(--no-star --nostar)--star[print stars for info commands]' \
'(--star '{'--nostar)--no-star','--no-star)--nostar'}'[do not print stars]' \
'(--no-tar2sqfs --notar2sqfs --no-tar --notar '{'--tar)--tar2sqfs','--tar2sqfs)--tar'}'[use tar2sqfs]' \
'(--tar2sqfs --tar '{'--notar2sqfs --no-tar --notar)--no-tar2sqfs','--no-tar2sqfs --no-tar --notar)--notar2sqfs','--no-tar2sqfs --notar2sqfs --notar --notar)--no-tar','--no-tar2sqfs --notar2sqfs --no-tar)--notar'}'[do not use tar2sqfs]' \
'(--no-locking --nolocking)--locking[use file locking]' \
'(--locking '{'--nolocking)--no-locking','--no-locking)--nolocking'}'[do not use file locking]' \
'(--no-fatal --nofatal)--fatal[return nonzero on every failure]' \
Expand Down

0 comments on commit 68066db

Please sign in to comment.