storage: Auto-mount disks, notify of failing disks
-
Remove freedombox-udiskie.service file. Don't run udiskie anymore. Use our own implementation of auto-mounting.
-
Schedule disk failure checking to 3 seconds after application initialization. Also perform auto-mounting at that time.
-
Listen to new filesystems added and auto-mount them.
-
Listen to disk failing attribute and report to user via a notification.
-
Add rules to polkit-1 to allow plinth user to mount drives.
-
Add simple abstractions over DBusProxy objects make accessing properties simpler.
-
Replicate udiskie's approach to mounting disks.
Udiskie analysis:
- On device added, media added, perform auto_add
- On device changed and is addable and old state is not addable or removeable
- Automount condition:
- Matches configuration
- Not ignored
- is_filesystem and not mounted -> mount
- crypto device -> try unlock -> if success, mount
- is partition table
- Get all non-ignored devices, if partition then mount
- Mount condition:
- Is not ignored
- Is filesystem
- Find device with path
- Get options from configuration
- Is ntfs and executable ntfs-3g is not available
- Call mount
- No support for udisks1
- Built-in rules
- {'symlinks': '/dev/mapper/docker-*', 'ignore': True}
- {'symlinks': '/dev/disk/by-id/dm-name-docker-*', 'ignore': True}
- {'is_loop': True, 'is_ignored': False, 'loop_file': '/*', 'ignore': False}
- {'is_block': False, 'ignore': True}
- {'is_external': False, 'is_toplevel': True, 'ignore': True}
- {'is_ignored': True, 'ignore': True}
Tests performed:
- Create a CDROM in VM, inject media. Disk should get mounted.
- Create a temp file. mkfs.ext4 it at top level. losetup it. It should not get auto mounted as it is a top level internal device.
- Create a temp file. Create two partitions and format the partitions. kpartx -a on it. Both the file systems should get mounted.
- Create a temp file. luksformat it. Create a filesystem. luksopen the file. It should get auto mounted.
- Checking for disk space repeatedly happens every 3 minutes.
- Drives are checked for healthy status only once, 3 seconds after FreedomBox is started.
- FreedomBox is able to mount disks while running as 'plinth' user with policykit-1 version 0.105-26.
- FreedomBox is able to mount disks while running as 'plinth' user with policykit-1 version 0.116-2 from experimental.
- Temporarily flip the is_failing condition in report_failing_drive. When FreedomBox is restarted, notification about drives failing show up. When the condition is reverted to normal, the notification is withdrawn.
Signed-off-by: Sunil Mohan Adapa sunil@medhas.org