Re: [PATCH] dracut: dmsquash-live: overlay module can be built-in the kernel

Federico Vaga <[email protected]> Tue, 26 Apr 2022 10:40:05 +0200
Newsgroups org.kernel.vger.initramfs
Message-ID <[email protected]>
On Fri, Apr 22, 2022 at 01:04:45PM +0200, German Maglione wrote:
>On Wed, Apr 20, 2022 at 9:17 AM Federico Vaga <[email protected]> wrote:
>>
>> The dmsquash-live module assumes that `overlay` is always a module.
>> Therefore, when `overlay` is built-in the kernel, this module will fail
>> to detect the presence of such a feature.
>>
>> This patch adds a fallback mechanism to check also `/proc/filesystem`.
>> This is also what happens with the dracut NSF module when loading the
>> kernel module `rpc_pipefs`.
>>
>> Signed-off-by: Federico Vaga <[email protected]>
>> ---
>>  modules.d/90dmsquash-live/dmsquash-live-root.sh | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh
>> index fd8a858a..b4a44e92 100755
>> --- a/modules.d/90dmsquash-live/dmsquash-live-root.sh
>> +++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh
>> @@ -170,7 +170,7 @@ do_live_overlay() {
>>          fi
>>      fi
>>      if [ -n "$overlayfs" ]; then
>> -        if ! modprobe overlay; then
>> +        if ! (modprobe overlay || strstr "$(cat /proc/filesystems)" overlay); then
>
>if ! { modprobe overlay || strstr "$(cat /proc/filesystems)" overlay; }; then
>
>I recently made the same mistake of using a subshell.

For my understanding:

Why do you think it's a mistake to use a subshell?

Are you thinking about execution performance, or some locale variable
that do not get exported to the subshell?


Then, why curly brackets and not double square brackets?

I see the latter is far more used among modules; even if it is
enforcing a dependency on bash (or whatever supports `[[`)

Thanks in advance for the clarifications :)

>>              if [ "$overlayfs" = required ]; then
>>                  die "OverlayFS is required but not available."
>>                  exit 1
>> --
>> 2.27.0
>>
>
>
>-- 
>German
>