[LTP] [PATCH v2 1/1] ver_linux: Print filesystems

Petr Vorel pvorel@suse.cz
Wed Nov 3 15:48:14 CET 2021


Hi Cyril,

> Hi!
> > +echo 'mounted filesystems (df):'
> > +df_opt=
> > +if ! (df -h 2>&1 | grep -i -q -e 'unknown option' -e 'invalid option'); then df_opt="$df_opt -h"; fi
> > +if ! (df -T 2>&1 | grep -i -q -e 'unknown option' -e 'invalid option'); then df_opt="$df_opt -T"; fi

> Uff that's ugly, can't we simply depend on df returning non-zero on
> invalid option?

On real HW (2 laptops with different linux distros) it fails for something else:
$ df -hT; echo $?
df: /run/user/1000/doc: Operation not permitted
1

If you want simpler form, I suggest
df -hT 2>/dev/null || df

instead of:
df -hT 2>/dev/null || df -h

Which version should I merge?

Kind regards,
Petr


More information about the ltp mailing list