M1: make mount/unmount idempotent
mount now detects already-unlocked and already-mounted devices, returning the existing mount point instead of failing. unmount handles already-locked devices gracefully and skips unmount if not mounted before locking. Adds IsMounted helper to udisks client. Updates PLAN.md with refined v1.0.0 milestones. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -97,6 +97,18 @@ func (c *Client) MountPoint(dev *BlockDevice) (string, error) {
|
||||
return string(bytes.TrimRight(mountPoints[0], "\x00")), nil
|
||||
}
|
||||
|
||||
// IsMounted returns the mount point and true if the device is mounted.
|
||||
func (c *Client) IsMounted(dev *BlockDevice) (string, bool) {
|
||||
if !dev.HasFilesystem {
|
||||
return "", false
|
||||
}
|
||||
mp, err := c.MountPoint(dev)
|
||||
if err != nil || mp == "" {
|
||||
return "", false
|
||||
}
|
||||
return mp, true
|
||||
}
|
||||
|
||||
// DeviceAtPath returns the block device at the given D-Bus object path.
|
||||
func (c *Client) DeviceAtPath(path dbus.ObjectPath) (*BlockDevice, error) {
|
||||
devices, err := c.listBlockDevices()
|
||||
|
||||
Reference in New Issue
Block a user