StoragedMountMonitor

StoragedMountMonitor — Monitors mounted filesystems or in-use swap devices

Synopsis

                    StoragedMount;
enum                StoragedMountType;
dev_t               storaged_mount_get_dev              (StoragedMount *mount);
StoragedMountType   storaged_mount_get_mount_type       (StoragedMount *mount);
const gchar *       storaged_mount_get_mount_path       (StoragedMount *mount);
gint                storaged_mount_compare              (StoragedMount *mount,
                                                         StoragedMount *other_mount);
                    StoragedMountMonitor;
StoragedMountMonitor * storaged_mount_monitor_new       (void);
GList *             storaged_mount_monitor_get_mounts_for_dev
                                                        (StoragedMountMonitor *monitor,
                                                         dev_t dev);
gboolean            storaged_mount_monitor_is_dev_in_use
                                                        (StoragedMountMonitor *monitor,
                                                         dev_t dev,
                                                         StoragedMountType *out_type);

Object Hierarchy

  GObject
   +----StoragedMount
  GObject
   +----StoragedMountMonitor

Signals

  "mount-added"                                    : Has Details
  "mount-removed"                                  : Has Details

Description

This type is used for monitoring mounted devices and swap devices in use. On Linux, this is done by inspecting and monitoring the /proc/self/mountinfo and /proc/swaps files.

Details

StoragedMount

typedef struct _StoragedMount StoragedMount;

The StoragedMount structure contains only private data and should only be accessed using the provided API.


enum StoragedMountType

typedef enum {
  STORAGED_MOUNT_TYPE_FILESYSTEM,
  STORAGED_MOUNT_TYPE_SWAP
} StoragedMountType;

Types of a mount.

STORAGED_MOUNT_TYPE_FILESYSTEM

Object correspond to a mounted filesystem.

STORAGED_MOUNT_TYPE_SWAP

Object correspond to an in-use swap device.

storaged_mount_get_dev ()

dev_t               storaged_mount_get_dev              (StoragedMount *mount);

Gets the device number for mount.

mount :

A StoragedMount.

Returns :

A dev_t.

storaged_mount_get_mount_type ()

StoragedMountType   storaged_mount_get_mount_type       (StoragedMount *mount);

Gets the StoragedMountType for mount.

mount :

A StoragedMount.

Returns :

A value from the StoragedMountType enumeration.

storaged_mount_get_mount_path ()

const gchar *       storaged_mount_get_mount_path       (StoragedMount *mount);

Gets the mount path for a STORAGED_MOUNT_TYPE_FILESYSTEM-type mount.

It is a programming error to call this on any other type of StoragedMount.

mount :

A StoragedMount

Returns :

A string owned by mount. Do not free.

storaged_mount_compare ()

gint                storaged_mount_compare              (StoragedMount *mount,
                                                         StoragedMount *other_mount);

Comparison function for comparing two StoragedMount objects.

mount :

A StoragedMount

other_mount :

Another StoragedMount.

Returns :

Negative value if mount < other_mount; zero if mount = other_mount; positive value if mount > other_mount.

StoragedMountMonitor

typedef struct _StoragedMountMonitor StoragedMountMonitor;

The StoragedMountMonitor structure contains only private data and should only be accessed using the provided API.


storaged_mount_monitor_new ()

StoragedMountMonitor * storaged_mount_monitor_new       (void);

Creates a new StoragedMountMonitor object.

Signals are emitted in the thread-default main loop that this function is called from.

Returns :

A StoragedMountMonitor. Free with g_object_unref().

storaged_mount_monitor_get_mounts_for_dev ()

GList *             storaged_mount_monitor_get_mounts_for_dev
                                                        (StoragedMountMonitor *monitor,
                                                         dev_t dev);

Gets all StoragedMount objects for dev.

monitor :

A StoragedMountMonitor.

dev :

A dev_t device number.

Returns :

A GList of StoragedMount objects. The returned list must be freed with g_list_free() after each element has been freed with g_object_unref().

storaged_mount_monitor_is_dev_in_use ()

gboolean            storaged_mount_monitor_is_dev_in_use
                                                        (StoragedMountMonitor *monitor,
                                                         dev_t dev,
                                                         StoragedMountType *out_type);

Checks if dev is in use (e.g. mounted or swap-area in-use).

monitor :

A StoragedMountMonitor.

dev :

A dev_t device number.

out_type :

Return location for mount type, if in use or NULL. [out allow-none]

Returns :

TRUE if in use, FALSE otherwise.

Signal Details

The "mount-added" signal

void                user_function                      (StoragedMountMonitor *monitor,
                                                        StoragedMount        *mount,
                                                        gpointer              user_data)      : Has Details

Emitted when a mount is added.

This signal is emitted in the thread-default main loop that monitor was created in.

monitor :

A StoragedMountMonitor.

mount :

The StoragedMount that was added.

user_data :

user data set when the signal handler was connected.

The "mount-removed" signal

void                user_function                      (StoragedMountMonitor *monitor,
                                                        StoragedMount        *mount,
                                                        gpointer              user_data)      : Has Details

Emitted when a mount is removed.

This signal is emitted in the thread-default main loop that monitor was created in.

monitor :

A StoragedMountMonitor.

mount :

The StoragedMount that was removed.

user_data :

user data set when the signal handler was connected.