AsahiLinux / asahi-scripts

Miscellaneous admin scripts for the Asahi Linux reference distro
MIT License
45 stars 32 forks source link

functions.sh: be more precise while reading /proc/mount #34

Closed MingcongBai closed 5 months ago

MingcongBai commented 10 months ago

The /proc/mount file is a space-separated table of all devices mounted. The current implementation only greps for a matching pattern without taking this into account. This may cause a misreading of /proc/mount when, say, the ESP was mounted at /efi (AOSC OS default).

For instance:

$ grep /efi /proc/mounts 
efivarfs /sys/firmware/efi/efivars efivarfs rw,nosuid,nodev,noexec,relatime 0 0
systemd-1 /efi autofs rw,relatime,fd=50,pgrp=1,timeout=120,minproto=5,maxproto=5,direct,pipe_ino=21868 0 0

Also match the spaces on either end of the mount path to avoid this issue.