Exclude snap /dev/loop file system image mounts (#129)

On Ubuntu the gparted shell wrapper still attempts to mask lots of
non-block device based file systems.  Remove the --quiet option from the
systemctl --runtime mask command to see:
    $ gparted
    Created symlink /run/systemd/system/snap-gnome\x2d3\x2d34\x2d1804-66.mount -> /dev/null.
    Created symlink /run/systemd/system/snap-core-10583.mount -> /dev/null.
    Created symlink /run/systemd/system/boot-efi.mount -> /dev/null.
    Created symlink /run/systemd/system/snap-gtk\x2dcommon\x2dthemes-1514.mount -> /dev/null.
    Created symlink /run/systemd/system/snap-core-10577.mount -> /dev/null.
    Created symlink /run/systemd/system/snap-core18-1944.mount -> /dev/null.
    Created symlink /run/systemd/system/run-user-1000-doc.mount -> /dev/null.
    Created symlink /run/systemd/system/snap-gtk\x2dcommon\x2dthemes-1506.mount -> /dev/null.
    Created symlink /run/systemd/system/snap-gnome\x2d3\x2d28\x2d1804-128.mount -> /dev/null.
    Created symlink /run/systemd/system/snap-snap\x2dstore-518.mount -> /dev/null.
    Created symlink /run/systemd/system/snap-gnome\x2d3\x2d28\x2d1804-145.mount -> /dev/null.
    Created symlink /run/systemd/system/snap-core18-1932.mount -> /dev/null.
    Created symlink /run/systemd/system/snap-snap\x2dstore-467.mount -> /dev/null.
    Created symlink /run/systemd/system/snap-gnome\x2d3\x2d34\x2d1804-60.mount -> /dev/null.
    Created symlink /run/systemd/system/-.mount -> /dev/null.
    GParted 1.0.0
    configuration --enable-libparted-dmraid --enable-online-resize
    libparted 3.3

The gparted shell wrapper is currently looking for non-masked Systemd
mount units where the 'What' property starts "/dev/".  However Ubuntu
also uses snap packages which are mounted file images via loop devices:
    $ grep '^/dev/' /proc/mounts | sort
    /dev/fuse /run/user/1000/doc fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=1000 0 0
    /dev/loop0 /snap/core/10583 squashfs ro,nodev,relatime 0 0
    /dev/loop10 /snap/snap-store/518 squashfs ro,nodev,relatime 0 0
    /dev/loop11 /snap/snap-store/467 squashfs ro,nodev,relatime 0 0
    /dev/loop12 /snap/gtk-common-themes/1506 squashfs ro,nodev,relatime 0 0
    /dev/loop1 /snap/core/10577 squashfs ro,nodev,relatime 0 0
    /dev/loop3 /snap/core18/1944 squashfs ro,nodev,relatime 0 0
    /dev/loop4 /snap/core18/1932 squashfs ro,nodev,relatime 0 0
    /dev/loop5 /snap/gnome-3-34-1804/66 squashfs ro,nodev,relatime 0 0
    /dev/loop6 /snap/gnome-3-28-1804/128 squashfs ro,nodev,relatime 0 0
    /dev/loop7 /snap/gnome-3-34-1804/60 squashfs ro,nodev,relatime 0 0
    /dev/loop8 /snap/gnome-3-28-1804/145 squashfs ro,nodev,relatime 0 0
    /dev/loop9 /snap/gtk-common-themes/1514 squashfs ro,nodev,relatime 0 0
    /dev/sda1 /boot/efi vfat rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 0
    /dev/sda5 / ext4 rw,relatime,errors=remount-ro 0 0

Fix by excluding:
1. Device name "/dev/fuse" because it's a character not a block device
   and the mount point is associated with snap,
2. Device names starting "/dev/loop" and where the mount point starts
   "/snap/" [1].  This is to allow for use of GParted with explicitly
   named loop devices.

[1] The system /snap directory
    https://snapcraft.io/docs/system-snap-directory

Closes #129 - Unit \xe2\x97\x8f.service does not exist, proceeding
              anyway
This commit is contained in:
Mike Fleetwood 2021-01-10 16:42:54 +00:00 committed by Curtis Gedak
parent 1a5614b3dd
commit 56fb026658
1 changed files with 9 additions and 3 deletions

View File

@ -144,16 +144,22 @@ done
# Use systemctl to prevent automount by masking currently unmasked mount points
#
if test "x$HAVE_SYSTEMCTL" = "xyes"; then
MOUNTLIST=`systemctl show --all --property=What,Id,LoadState '*.mount' | \
MOUNTLIST=`systemctl show --all --property=Where,What,Id,LoadState '*.mount' | \
awk '
function clear_properties() {
what = ""; id = ""; loadstate = ""
where = ""; what = ""; id = ""; loadstate = ""
}
function process_unit() {
if (substr(what,1,5) == "/dev/" && loadstate != "masked")
if (substr(what,1,5) == "/dev/" &&
loadstate != "masked" &&
what != "/dev/fuse" &&
! (substr(what,1,9) == "/dev/loop" && substr(where,1,6) == "/snap/"))
{
print id
}
clear_properties()
}
/^Where=/ { where = substr($0,7) }
/^What=/ { what = substr($0,6) }
/^Id=/ { id = substr($0,4) }
/^LoadState=/ { loadstate = substr($0,11) }