Files
mcde/include/Mcde
lotherk f4ec4a1da1 MCDE: the disk-removed warning through the kernel's device events (t0093)
A medium that is pulled while it is still mounted now gets the reference's
one-button "Disk Not Ejected" warning: Motif's error dialog, the device and
its stale mountpoint in the text, the Warning sound.  The desktop (dtwm,
WmMcdeDesktop.c) owns the event descriptor already; it reads each event,
asks what it says, and checks the mount table before it shows anything.

McdeSys:
- mcde_sys_disk_event_info() parses both shapes the read gives: Linux's
  uevent with its NULs turned into spaces ("remove@/... ACTION=remove
  DEVNAME=sdb1 ...") and NetBSD's "device-detach sd0"; 1 when the device
  went away, 0 for add/change/attach, -1 on bad arguments.
- mcde_sys_disk_detached(name, mountpoint, len): looks in the mount table
  for a partition of NAME (sdb takes sdb1, sd0 takes sd0a), copies the
  mountpoint and unmounts it the forced way -- "umount -l" on Linux,
  "umount -f" on NetBSD (disk_linux.c, disk_netbsd.c) -- but never what the
  computer runs from.  0 when nothing of NAME was mounted.
- test_disk_events.c: the uevent and drvctl shapes, add/change/attach,
  missing DEVNAME, the bad arguments.  make check: 8/8 PASS (the seven
  before and this one).

Measured under Xvfb :79 with a real ext4 loop mount at /tmp/opencode/mnt:
- start of dtwm with MCDE_DESK_TEST_DEVICE="remove@/... DEVNAME=loop0":
  log "desktop: loop0 (remove)", "umount: /tmp/opencode/mnt: must be
  superuser to unmount.", "desktop: loop0 was mounted at
  /tmp/opencode/mnt"; the dialog is 354x167 at (335,300), OK as the only
  button (docs/screenshots/leopard/Device-Removal-mcde.png).
- sudo umount /tmp/opencode/mnt, the same event again: log "desktop: loop0
  (remove)" and no "was mounted"; zero dialog windows -- a device that was
  put away stays quiet.
- make mcde-linux MCDE_DIRS="install lib/McdeSys programs/dtwm" exit=0;
  MCDE_DIRS=plist "mcde-plist-check: ok".

MCDE_DESK_TEST_DEVICE is the test hook: one event line through the same
handler a real event takes, without a kernel.  The NetBSD drvctl branch is
unchanged (t0272); the force unmount there is written for it but was not
run.  Still open in t0093: the Eject item in dtfile (Selected menu,
Command+E) and the qemu device_del test in a VM.
2026-11-16 13:56:06 +00:00
..