From 68066db160e65f2fd03f0b85e82cd2b9305940c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20V=C3=A4th?= Date: Sat, 30 Nov 2019 11:01:27 +0100 Subject: [PATCH] Support https://github.com/containers/fuse-overlayfs --- ChangeLog | 6 +++- README.md | 1 + bin/squashmount | 86 ++++++++++++++++++++++++++++++++-------------- lib/squashmount.pl | 2 +- zsh/_squashmount | 2 ++ 5 files changed, 69 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index fbca82a..4dafafb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,12 @@ # ChangeLog for squashmount +*squashmount-21.0: + Martin Väth : + - Support https://github.com/containers/fuse-overlayfs + *squashmount-20.0: Martin Väth : - - 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 diff --git a/README.md b/README.md index c8cbb8c..086b590 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bin/squashmount b/bin/squashmount index 12e7f9e..cd42c7c 100755 --- a/bin/squashmount +++ b/bin/squashmount @@ -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; @@ -269,9 +269,9 @@ Output the mtime of the squash-file. Output the tool actually used for mounting. Possible output is C, C, C, C, -C, C, C, C, C, or the -empty string (for not mounted or incompletely mounted; you can check -the details with B). +C, C, C, C, C, +C, or the empty string (for not mounted or incompletely mounted; +you can check the details with B). For usage in scripts, combine this with B<-q> and pass a tag. =item B @@ -462,7 +462,8 @@ differently (for examples, see the description of B<@umount> and B). Add option I 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. +By default, this means that the option are used in the call to +B. There might be code in B which treats this array value differently. @@ -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> @@ -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> @@ -866,16 +867,16 @@ configuration file F =item B<--allow> -Use the option C<-o allow_other> for B, -B, and B as default if these variables -are not specified. +Use the option C<-o allow_other> for B, +B, B, and B +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, -B, and B as default if these variables -are not specified. +Do not use the option C<-o allow_other> for B, +B, B, and B +as default if these variables are not specified. This overrides the setting of B<--user>. =item B<--locking> @@ -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 @@ -1399,7 +1400,7 @@ The content of this array should be strings with one of the texts =over 16 -=item B, B, B, B, B, B, B +=item B, B, B, B, B, B, B, B =back @@ -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, B, B have their own kernel modules -while B and B both require the B module and -need special user space binaries. +while B, B and B all require the +B module and need special user space binaries. =item B or B @@ -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 in case of B, B, B, or B -or the special user space binary for B or B, -respectively) is available in your path. If it is unavailable, the tool is -tacitly skipped. This flag is ignored if neither B nor the -B program are available. +or the special user space binary for B, B, +or B, respectively) is available in your path. +If it is unavailable, the tool is tacitly skipped. +This flag is ignored if neither B nor the B program are +available. =back @@ -1457,7 +1459,7 @@ If B 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 @@ -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 + +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 This should be a (possibly empty) string or a reference to an array of strings: @@ -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; @@ -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) { @@ -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 { @@ -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; @@ -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!) } } diff --git a/lib/squashmount.pl b/lib/squashmount.pl index c6aaa1a..9892bde 100644 --- a/lib/squashmount.pl +++ b/lib/squashmount.pl @@ -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 diff --git a/zsh/_squashmount b/zsh/_squashmount index 0419da6..3bc858a 100644 --- a/zsh/_squashmount +++ b/zsh/_squashmount @@ -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]' \