Documentation
¶
Index ¶
- Constants
- type MountDetector
- type MountEvent
- type Reader
- func (*Reader) CancelWrite()
- func (*Reader) Capabilities() []readers.Capability
- func (r *Reader) Close() error
- func (r *Reader) Connected() bool
- func (*Reader) Detect(_ []string) string
- func (*Reader) IDs() []string
- func (r *Reader) Info() string
- func (*Reader) Metadata() readers.DriverMetadata
- func (*Reader) OnMediaChange(*models.ActiveMedia) error
- func (r *Reader) Open(device config.ReadersConnect, iq chan<- readers.Scan) error
- func (r *Reader) Path() string
- func (r *Reader) ReaderID() string
- func (*Reader) Write(_ string) (*tokens.Token, error)
Constants ¶
View Source
const ( DriverID = "externaldrive" TokenType = "externaldrive" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MountDetector ¶
type MountDetector interface {
// Events returns a channel that emits MountEvent when a removable device is mounted.
// The channel is closed when Stop() is called.
Events() <-chan MountEvent
// Unmounts returns a channel that emits the DeviceID when a removable device is unmounted.
// The channel is closed when Stop() is called.
Unmounts() <-chan string
// Start begins monitoring for mount/unmount events.
// Returns an error if the platform-specific monitoring service cannot be initialized.
Start() error
// Stop terminates the mount detector and releases all resources.
// After Stop() is called, the Events() and Unmounts() channels are closed.
Stop()
// Forget removes a device from internal tracking, allowing it to be
// re-detected on the next scan. Used when a mount is detected as stale
// (e.g., block device no longer exists after USB was yanked).
Forget(deviceID string)
}
MountDetector provides platform-specific mount event detection for removable storage devices. Implementations must be event-driven (not polling-based) and should filter for removable devices only, excluding internal hard drives and system partitions.
func NewMountDetector ¶
func NewMountDetector() (MountDetector, error)
NewMountDetector creates a new Linux mount detector. It tries D-Bus/UDisks2 first, and falls back to inotify if D-Bus is unavailable.
type MountEvent ¶
type MountEvent struct {
// DeviceID is a unique and stable identifier for the device, such as a volume UUID
// or serial number. This is used to track the device across mount/unmount cycles.
DeviceID string
// DeviceNode is the block device path (e.g., "/dev/sda1", "/dev/mmcblk0p1").
// Used for safety checks when detecting stale mounts. May be empty if unavailable.
DeviceNode string
// MountPath is the filesystem path where the volume is mounted.
// Examples: "E:\", "/media/user/USB_DRIVE", "/Volumes/MyUSB"
MountPath string
// VolumeLabel is the user-facing volume label for the device.
// Examples: "MyUSB", "SD_CARD"
VolumeLabel string
// DeviceType indicates the type of removable device.
// Examples: "USB", "SD", "removable"
DeviceType string
}
MountEvent represents a filesystem mount event for a removable storage device.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader implements the readers.Reader interface for external drive devices.
func (*Reader) CancelWrite ¶
func (*Reader) CancelWrite()
func (*Reader) Capabilities ¶
func (*Reader) Capabilities() []readers.Capability
func (*Reader) Metadata ¶
func (*Reader) Metadata() readers.DriverMetadata
func (*Reader) OnMediaChange ¶
func (*Reader) OnMediaChange(*models.ActiveMedia) error
Click to show internal directories.
Click to hide internal directories.