* [LTP] [PATCH v2 1/1] ver_linux: Print filesystems
@ 2021-10-27 7:56 Petr Vorel
2021-11-03 14:36 ` Cyril Hrubis
0 siblings, 1 reply; 8+ messages in thread
From: Petr Vorel @ 2021-10-27 7:56 UTC (permalink / raw)
To: ltp
both available and mounted.
check for options as aosp toybox does not support -h,
-T option requires IF_FEATURE_HUMAN_READABLE on busybox.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
changes v1->v2:
properly check options
ver_linux | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/ver_linux b/ver_linux
index 824c39510..82b7468a6 100755
--- a/ver_linux
+++ b/ver_linux
@@ -138,6 +138,21 @@ echo
echo 'cpuinfo:'
tst_cmd_run lscpu || cat /proc/cpuinfo
+echo
+echo 'available filesystems:'
+echo $(cut -f2 /proc/filesystems | sort -u)
+
+echo
+echo 'mounted filesystems (/proc/mounts):'
+cat /proc/mounts
+
+echo
+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
+df $df_opt
+
echo
if is_enabled /sys/module/apparmor/parameters/enabled; then
echo 'AppArmor enabled'
--
2.33.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH v2 1/1] ver_linux: Print filesystems
2021-10-27 7:56 [LTP] [PATCH v2 1/1] ver_linux: Print filesystems Petr Vorel
@ 2021-11-03 14:36 ` Cyril Hrubis
2021-11-03 14:48 ` Petr Vorel
0 siblings, 1 reply; 8+ messages in thread
From: Cyril Hrubis @ 2021-11-03 14:36 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
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?
> +df $df_opt
> +
> echo
> if is_enabled /sys/module/apparmor/parameters/enabled; then
> echo 'AppArmor enabled'
> --
> 2.33.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH v2 1/1] ver_linux: Print filesystems
2021-11-03 14:36 ` Cyril Hrubis
@ 2021-11-03 14:48 ` Petr Vorel
2021-11-03 15:03 ` Cyril Hrubis
0 siblings, 1 reply; 8+ messages in thread
From: Petr Vorel @ 2021-11-03 14:48 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH v2 1/1] ver_linux: Print filesystems
2021-11-03 14:48 ` Petr Vorel
@ 2021-11-03 15:03 ` Cyril Hrubis
2021-11-03 15:17 ` Petr Vorel
0 siblings, 1 reply; 8+ messages in thread
From: Cyril Hrubis @ 2021-11-03 15:03 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi!
> If you want simpler form, I suggest
> df -hT 2>/dev/null || df
Looks good.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH v2 1/1] ver_linux: Print filesystems
2021-11-03 15:03 ` Cyril Hrubis
@ 2021-11-03 15:17 ` Petr Vorel
2021-11-03 15:38 ` Cyril Hrubis
0 siblings, 1 reply; 8+ messages in thread
From: Petr Vorel @ 2021-11-03 15:17 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
> Hi!
> > If you want simpler form, I suggest
> > df -hT 2>/dev/null || df
> Looks good.
Ah, sorry, I see why I checked it more complicated way:
with simply checking exit code you have output twice:
df -hT 2>/dev/null || df
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 16G 8,0K 16G 1% /dev
tmpfs tmpfs 16G 91M 16G 1% /dev/shm
tmpfs tmpfs 6,2G 4,1M 6,2G 1% /run
...
df: /run/user/1000/doc: Operation not permitted
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 16G 8,0K 16G 1% /dev
tmpfs tmpfs 16G 91M 16G 1% /dev/shm
tmpfs tmpfs 6,2G 4,1M 6,2G 1% /run
...
=> which is IMHO nogo. I could redirect to a file and cut it after, but in that
case v2 is IMHO much better.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH v2 1/1] ver_linux: Print filesystems
2021-11-03 15:17 ` Petr Vorel
@ 2021-11-03 15:38 ` Cyril Hrubis
2021-11-03 16:10 ` Petr Vorel
2021-11-03 16:20 ` Petr Vorel
0 siblings, 2 replies; 8+ messages in thread
From: Cyril Hrubis @ 2021-11-03 15:38 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi!
> Ah, sorry, I see why I checked it more complicated way:
> with simply checking exit code you have output twice:
>
> df -hT 2>/dev/null || df
> Filesystem Type Size Used Avail Use% Mounted on
> devtmpfs devtmpfs 16G 8,0K 16G 1% /dev
> tmpfs tmpfs 16G 91M 16G 1% /dev/shm
> tmpfs tmpfs 6,2G 4,1M 6,2G 1% /run
> ...
> df: /run/user/1000/doc: Operation not permitted
> Filesystem Type Size Used Avail Use% Mounted on
> devtmpfs devtmpfs 16G 8,0K 16G 1% /dev
> tmpfs tmpfs 16G 91M 16G 1% /dev/shm
> tmpfs tmpfs 6,2G 4,1M 6,2G 1% /run
> ...
>
> => which is IMHO nogo. I could redirect to a file and cut it after, but in that
> case v2 is IMHO much better.
But still we don't need that grep part, right?
So it should be something as:
if `df -hT 2>/dev/null >/dev/null`; then
df -hT
else
df
fi
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH v2 1/1] ver_linux: Print filesystems
2021-11-03 15:38 ` Cyril Hrubis
@ 2021-11-03 16:10 ` Petr Vorel
2021-11-03 16:20 ` Petr Vorel
1 sibling, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2021-11-03 16:10 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
> Hi!
> > Ah, sorry, I see why I checked it more complicated way:
> > with simply checking exit code you have output twice:
> > df -hT 2>/dev/null || df
> > Filesystem Type Size Used Avail Use% Mounted on
> > devtmpfs devtmpfs 16G 8,0K 16G 1% /dev
> > tmpfs tmpfs 16G 91M 16G 1% /dev/shm
> > tmpfs tmpfs 6,2G 4,1M 6,2G 1% /run
> > ...
> > df: /run/user/1000/doc: Operation not permitted
> > Filesystem Type Size Used Avail Use% Mounted on
> > devtmpfs devtmpfs 16G 8,0K 16G 1% /dev
> > tmpfs tmpfs 16G 91M 16G 1% /dev/shm
> > tmpfs tmpfs 6,2G 4,1M 6,2G 1% /run
> > ...
> > => which is IMHO nogo. I could redirect to a file and cut it after, but in that
> > case v2 is IMHO much better.
> But still we don't need that grep part, right?
> So it should be something as:
> if `df -hT 2>/dev/null >/dev/null`; then
> df -hT
> else
> df
> fi
Yep, how simple, thanks!
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH v2 1/1] ver_linux: Print filesystems
2021-11-03 15:38 ` Cyril Hrubis
2021-11-03 16:10 ` Petr Vorel
@ 2021-11-03 16:20 ` Petr Vorel
1 sibling, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2021-11-03 16:20 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
> > => which is IMHO nogo. I could redirect to a file and cut it after, but in that
> > case v2 is IMHO much better.
> But still we don't need that grep part, right?
> So it should be something as:
> if `df -hT 2>/dev/null >/dev/null`; then
> df -hT
> else
> df
> fi
Merged this version, thanks!
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-11-03 16:20 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-27 7:56 [LTP] [PATCH v2 1/1] ver_linux: Print filesystems Petr Vorel
2021-11-03 14:36 ` Cyril Hrubis
2021-11-03 14:48 ` Petr Vorel
2021-11-03 15:03 ` Cyril Hrubis
2021-11-03 15:17 ` Petr Vorel
2021-11-03 15:38 ` Cyril Hrubis
2021-11-03 16:10 ` Petr Vorel
2021-11-03 16:20 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).