## UDisksMountMonitor UDisksMountMonitor — Monitors mounted filesystems or in-use swap devices |

## Synopsis

                        UDisksMount;
    enum                UDisksMountType;
    dev_t               udisks_mount_get_dev                (UDisksMount *mount);
    UDisksMountType     udisks_mount_get_mount_type         (UDisksMount *mount);
    const gchar *       udisks_mount_get_mount_path         (UDisksMount *mount);
    gint                udisks_mount_compare                (UDisksMount *mount,
                                                             UDisksMount *other_mount);
                        UDisksMountMonitor;
    UDisksMountMonitor * udisks_mount_monitor_new           (void);
    GList *             udisks_mount_monitor_get_mounts_for_dev
                                                            (UDisksMountMonitor *monitor,
                                                             dev_t dev);
    gboolean            udisks_mount_monitor_is_dev_in_use  (UDisksMountMonitor *monitor,
                                                             dev_t dev,
                                                             UDisksMountType *out_type);

## Object Hierarchy

      GObject
       +----UDisksMount

      GObject
       +----UDisksMountMonitor

## 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

### UDisksMount

    typedef struct _UDisksMount UDisksMount;

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

### enum UDisksMountType

    typedef enum {
      UDISKS_MOUNT_TYPE_FILESYSTEM,
      UDISKS_MOUNT_TYPE_SWAP
    } UDisksMountType;

Types of a mount.

`UDISKS_MOUNT_TYPE_FILESYSTEM` | Object correspond to a mounted filesystem.
`UDISKS_MOUNT_TYPE_SWAP` | Object correspond to an in-use swap device.

### udisks_mount_get_dev ()

    dev_t               udisks_mount_get_dev                (UDisksMount *mount);

Gets the device number for `mount`.

`mount` : | A UDisksMount.
Returns : | A dev_t.

### udisks_mount_get_mount_type ()

    UDisksMountType     udisks_mount_get_mount_type         (UDisksMount *mount);

Gets the UDisksMountType for `mount`.

`mount` : | A UDisksMount.
Returns : | A value from the UDisksMountType enumeration.

### udisks_mount_get_mount_path ()

    const gchar *       udisks_mount_get_mount_path         (UDisksMount *mount);

Gets the mount path for a UDISKS_MOUNT_TYPE_FILESYSTEM-type mount.

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

`mount` : | A UDisksMount
Returns : | A string owned by `mount`. Do not free.

### udisks_mount_compare ()

    gint                udisks_mount_compare                (UDisksMount *mount,
                                                             UDisksMount *other_mount);

Comparison function for comparing two UDisksMount objects.

`mount` : | A UDisksMount
`other_mount` : | Another UDisksMount.
Returns : | Negative value if `mount` < `other_mount`; zero if `mount` = `other_mount`; positive value if `mount` > `other_mount`.

### UDisksMountMonitor

    typedef struct _UDisksMountMonitor UDisksMountMonitor;

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

### udisks_mount_monitor_new ()

    UDisksMountMonitor * udisks_mount_monitor_new           (void);

Creates a new UDisksMountMonitor object.

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

Returns : | A UDisksMountMonitor. Free with `g_object_unref()`.

### udisks_mount_monitor_get_mounts_for_dev ()

    GList *             udisks_mount_monitor_get_mounts_for_dev
                                                            (UDisksMountMonitor *monitor,
                                                             dev_t dev);

Gets all UDisksMount objects for `dev`.

`monitor` : | A UDisksMountMonitor.
`dev` : | A dev_t device number.
Returns : | A GList of UDisksMount objects. The returned list must be freed with `g_list_free()` after each element has been freed with `g_object_unref()`.

### udisks_mount_monitor_is_dev_in_use ()

    gboolean            udisks_mount_monitor_is_dev_in_use  (UDisksMountMonitor *monitor,
                                                             dev_t dev,
                                                             UDisksMountType *out_type);

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

`monitor` : | A UDisksMountMonitor.
`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                      (UDisksMountMonitor *monitor,
                                                            UDisksMount        *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 UDisksMountMonitor.
`mount` : | The UDisksMount that was added.
`user_data` : | user data set when the signal handler was connected.

### The `"mount-removed"` signal

    void                user_function                      (UDisksMountMonitor *monitor,
                                                            UDisksMount        *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 UDisksMountMonitor.
`mount` : | The UDisksMount that was removed.
`user_data` : | user data set when the signal handler was connected.