Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] portable mechanism to determine noatime



Bart wrote:
> On Dec 10, 12:48am, Bart Schaefer wrote:

> - Why don't we grep "mount" output for "noatime" FIRST, and THEN test
>    whether [[ $(df .) = $(df $atimeFS) ]] 

Seems reasonable but after playing with the idea I've found it won't
work for btrfs subvolumes: they have the same device but can be mounted
with different options. I created this state:
# mount |grep /dev/sda6
/dev/sda6 on /var/lib/docker type btrfs (rw,relatime,space_cache)
/dev/sda6 on /mnt type btrfs (rw,noatime,space_cache)
df /dev/sda6 only shows one: whichever was mounted second I think.

> Oops, exactly as written that runs df with no arguments if there are no
> filesystems with noatime, so tweak it a little:
>
> df ${$(mount || /sbin/mount | awk '/noatime/ {print $1, $3}'):-""}

I needed some tweaks to make that work for me. I need -- after df
because of automounter entries such as -hosts being interpreted as
options. Braces around the two mount bits seem to be needed. And it
doesn't work to fgrep for the full output of $(df .) - just the first
word on the last line.

df -k -- ${$({mount || /sbin/mount} >&/dev/null | awk '/noatime/ {print $1, $3}'):-""} >&/dev/null |fgrep $(df -k .|tail -1|cut -d' ' -f1) >/dev/null

Oliver



Messages sorted by: Reverse Date, Date, Thread, Author