Skip to content

List drives that aren't mounted yet, and mount them on a click or as they're plugged in - #22

Open
AyushKr2003 wants to merge 11 commits into
omacom:mainfrom
AyushKr2003:unmounted-drives
Open

AyushKr2003 wants to merge 11 commits into
omacom:mainfrom
AyushKr2003:unmounted-drives

Conversation

@AyushKr2003

@AyushKr2003 AyushKr2003 commented Nov 11, 2026 •

Copy link
Copy Markdown

Devices lists only drives that are already mounted. On a machine that also has Windows and another Linux install, none of those partitions show until they're mounted by hand, while Nautilus lists them all and mounts one on a click.

Letting go of a drive is now main's own (Places::eject and leave, the eject button and the drive menu, from #32 and #53), so this branch is merged with main and builds on that rather than adding a second way to eject.

What changes

  • Devices lists GIO's volumes, the same list Nautilus shows. udisks leaves out the system's own and hidden partitions (EFI, MSR, recovery), so on a dual-boot laptop it reads Acer (Windows), 53 GB Volume, ryoku (another Arch). A mounted volume is the row physicalDrives already makes for it (free space, Eject or Unmount), with its volume id added; mounted drives GIO doesn't know (an fstab mount under /mnt) follow, as before, and a mounted volume physicalDrives leaves out (the system's own) stays out. The list follows plugging, mounting and unmounting at once via GVolumeMonitor, instead of waiting for the 15-second poll.
  • A click on a drive that isn't mounted mounts it and opens it (g_volume_mount), and so do ⏎ and the drive menu's Mount. udisks asks the session's polkit agent where it needs permission. An encrypted drive's passphrase is asked for in the window through the mount prompt, which then reads "Unlock" and shows only a Passphrase field. The passphrase isn't saved. A drive's questions go to the user, as an unverified server's do.
  • Drives plugged in mount by themselves when udisks marks them to (removable media; internal partitions aren't). This respects GNOME's org.gnome.desktop.media-handling automount when that schema is installed. A desktop automounter (udiskie, a shell) gets two seconds' head start, so a drive isn't mounted twice and an encrypted one isn't asked for its passphrase twice. The mount goes through the last window used, so it can ask for a passphrase. "TESTSTICK is mounted" shows as a notice.
  • A drive unmounted from anywhere (another app, a terminal, pulled out) is left at once through Places::leave, so panes go home and previews close, as they do for main's own eject.
  • An encrypted drive that unlocks with nothing mountable inside (no filesystem, LVM) says so, and one that's still not mounted a minute after its passphrase is given up on. GVfs reports both as "cancelled", which used to look like nothing happening.

The GIO code lives in a new Drives class (drives.h/.cpp). Mounter gains mountVolume() alongside mount(), sharing its prompt, and Places::devicesFrom puts the two lists together. Unmounted rows have no path and no release, so the eject button and Format stay away from them.

Tested

  • Builds clean after the merge with main. bin/test: 194 passed, including the reworked placesListDrivesNotMountedYet and englishCatalogMatchesTheSources (the new strings are in en.json). The one failure, previewerPicksAViewerForEachType (CR2 → image), depends on the Qt image plugins installed here and fails the same way on main.
  • Before the merge, on Omarchy (Hyprland, Qt 6.12, gvfs 1.62, udisks 2.11), dual boot with Windows and a second Arch:
    • Devices listed the two NTFS partitions and the second Arch's btrfs, and not EFI/MSR/recovery.
    • Clicking the btrfs partition mounted it at /run/media/<user>/ryoku through the polkit agent and opened it. Unmounting it from a terminal (gio mount -u) sent the pane home.
    • A FAT image attached with udisksctl loop-setup (udiskie paused) was mounted by Folio after the delay, with the notice. With udiskie running, udiskie mounted it and Folio left it alone.
    • A LUKS2 image showed the Unlock prompt. The passphrase unlocked it, and since it holds no filesystem, the window said so.

@greptile-apps

greptile-apps Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge with two non-blocking edge cases around stalled reads and mount cleanup.

Findings

  1. P2 Stalled reads hide new drives ▶
  2. P2 Closed windows leave mounts running ▶

Summary

This PR adds unmounted drives to Devices, mounts them when opened or plugged in, and reuses the existing drive-release flow.

  • Devices lists drives before they are mounted.
  • Clicking an unmounted drive mounts it and opens its folder.
  • Eligible plugged-in drives mount after a short wait, while removed mounts clear the panes.
  • Git leaves local package-build files out of source changes.

Two non-blocking edge cases remain: stalled filesystem reads delay new drive rows, and closing a window can leave a stalled mount request running.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    G[GIO drive events] --> D[Drives]
    D --> P[Places updates Devices]
    D --> A[Delayed automatic mount]
    S[User opens an unmounted drive] --> B[Backend]
    A --> B
    B --> M[Mounter]
    M --> Q[Ask for passphrase if needed]
    Q --> M
    M --> R[Open drive or show notice]
    D --> U[Mount removed]
    U --> L[Places leaves drive and panes go home]
Loading

Reviews (11) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Comment thread src/drives.cpp Resolved
Comment thread src/windows.cpp Resolved
Comment thread src/mounter.cpp Resolved
Comment thread src/Sidebar.qml Resolved
Comment thread src/mounter.cpp Resolved
Devices listed only what was already mounted, so another system's
partitions and a stick that nothing had mounted never showed. It now
lists GIO's volumes, as Nautilus does: udisks leaves out the system's own
and hidden partitions (EFI, recovery), and the list follows plugging,
mounting and unmounting at once instead of on the 15-second poll.

- A click on one that isn't mounted mounts it and opens it. udisks asks
  the session's polkit agent where it needs permission, and an encrypted
  drive's passphrase is asked for in the window, kept for no session.
- A drive plugged in that udisks marks to mount by itself is mounted,
  unless GNOME's automount setting is off. A desktop automounter (udiskie,
  a shell) gets two seconds' head start, so nothing is mounted, or asked
  for its passphrase, twice.
- A mounted drive has an eject button: removable ones are ejected, others
  unmounted. Panes in a drive that goes away, from here or elsewhere, go
  home first.
- An encrypted drive that unlocks with nothing mountable inside says so,
  instead of nothing happening.
A wrong passphrase and a retry left the first reply's timer running, so
it could cancel the corrected attempt early. A new request now stops the
last reply's timer, and each reply starts its own.
An encrypted drive that unlocked but was slow to mount its filesystem
still read as "nothing on it that can be mounted" once the minute ran
out. Now that's said only when nothing inside the unlocked device is a
filesystem, by udev's record of it; otherwise it's reported as timed out.
Main now lets go of mounted drives itself (Places::eject and leave, the
drive menu and its eject button), so the branch keeps only what main
lacks: GIO's unmounted volumes in Devices, mounting one with its
passphrase put in the window, and mounting a drive as it's plugged in.
A drive's questions go to the user, as an unverified server's do, and an
unmount from anywhere is left through Places::leave.
Comment thread src/places.cpp Resolved
@AyushKr2003 AyushKr2003 changed the title List drives that aren't mounted yet, and mount and eject them List drives that aren't mounted yet, and mount them on a click or as they're plugged in Nov 12, 2026
@amagdy46

Copy link
Copy Markdown

I built much the same thing locally before finding this, so I'll leave drives to this PR. Two things from mine that might be worth folding in:

  • A mounted drive with no label is named after its mount folder, which for udisks is the UUID (8CAE187EAE18634E). g_mount_get_name gives "1.0 TB Volume", matching the unmounted rows.
  • The eject button is easy to miss when it only appears on hover. Keeping it at the end of every row that can be let go of, as Nautilus does, made it discoverable.

@omarchybot omarchybot added the enhancement New feature or request label Nov 15, 2026
# Conflicts:
#	src/main.cpp
Comment thread src/backend.cpp Resolved
Comment thread src/drives.cpp Resolved
@greptile-apps

greptile-apps Bot commented Nov 17, 2026

Copy link
Copy Markdown

Want your agent to iterate on Greptile's feedback? Try greploops.

# Conflicts:
#	src/Sidebar.qml
#	src/i18n/en.json
Comment thread src/places.cpp
}
const QVariantList devices = physicalDrives(mounts, m_systemDevice);
const QVariantList physical = physicalDrives(mounts, m_systemDevice);
const QVariantList devices = m_drives ? devicesFrom(m_drives->volumes(), physical, mounts) : physical;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Stalled reads hide new drives. The new GIO rows are published only from mountsRead(). If an existing NFS mount stops answering during readMounts(), every drive event returns from refreshDevices() without updating Devices. Even an unmounted drive, which needs no filesystem read, stays missing until that unrelated read finishes.

Update the GIO rows from the last completed mount data while a new read runs, then fill in free space when it finishes.

Knowledge Base Used: Storage discovery and mounts

Comment thread src/mounter.cpp
Comment on lines +326 to +328
if (m_cancellable) {
g_object_unref(m_cancellable);
m_cancellable = nullptr;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Closed windows leave mounts running. After a passphrase is submitted, m_asking is false. Closing that window makes the destructor’s cancel() return without stopping the mount. This new cleanup code only drops the reference to m_cancellable; it does not cancel the request. The window’s destruction also removes the minute-long timer.

For the supported case where an unlocked drive has nothing mountable inside, the request can therefore remain pending indefinitely. Cancel the active m_cancellable during teardown before dropping it.

Knowledge Base Used: Mounting workflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants