## Mount Points

Mount Points — Functions to query active and configured mount points

## Synopsis

    #include <exo/exo.h>

    enum                ExoMountPointFlags;
                        ExoMountPoint;
    ExoMountPoint *     exo_mount_point_dup                 (const ExoMountPoint *mount_point);
    void                exo_mount_point_free                (ExoMountPoint *mount_point);
    enum                ExoMountPointMatchMask;
    GSList *            exo_mount_point_list_matched        (ExoMountPointMatchMask mask,
                                                             const gchar *device,
                                                             const gchar *folder,
                                                             const gchar *fstype,
                                                             GError **error);
    #define             exo_mount_point_list_active         (error)
    #define             exo_mount_point_list_configured     (error)

## Description

This module provides functions to query active and configured mount points from the system. This is commonly required in file and volume management, and hence it was added to the library. For example, exo-mount, Thunar and thunar-volman make use of this.

## Details

### enum ExoMountPointFlags

    typedef enum /*< flags >*/
    {
      EXO_MOUNT_POINT_READ_ONLY = (1L << 0),
    } ExoMountPointFlags;

Identifies options of ExoMountPoints.

Since 0.3.1.13

### ExoMountPoint

    typedef struct {
      ExoMountPointFlags flags;
      gchar             *device;
      gchar             *folder;
      gchar             *fstype;
    } ExoMountPoint;

Structure to represent a mount point, which can be either an active mount point, queried from the kernel's internal mount table, or a configured mount point queried from the file system table (usually `/etc/fstab` or `/etc/vfstab`).

ExoMountPointFlags `flags`; | see ExoMountPointFlags.
gchar *`device`; | the device file path.
gchar *`folder`; | the folder where the device is mounted (or may be mounted).
gchar *`fstype`; | the type of the file system used for the device.

### exo_mount_point_dup ()

    ExoMountPoint *     exo_mount_point_dup                 (const ExoMountPoint *mount_point);

Duplicates the specified `mount_point` and returns the duplicate. If `mount_point` is `NULL`, this simply returns `NULL`.

The caller is responsible to free the returned mount point using `exo_mount_point_free()` when no longer needed.

`mount_point` : | an ExoMountPoint.
Returns : | a copy of the specified `mount_point`.

Since 0.3.1.13

### exo_mount_point_free ()

    void                exo_mount_point_free                (ExoMountPoint *mount_point);

Frees the resources allocated to the specified `mount_point`. If `mount_point` is `NULL`, this function does nothing.

`mount_point` : | an ExoMountPoint.

Since 0.3.1.13

### enum ExoMountPointMatchMask

    typedef enum /*< skip >*/
    {
      EXO_MOUNT_POINT_MATCH_ACTIVE      = (0L << 0),
      EXO_MOUNT_POINT_MATCH_CONFIGURED  = (1L << 0),
      EXO_MOUNT_POINT_MATCH_DEVICE      = (1L << 1),
      EXO_MOUNT_POINT_MATCH_FOLDER      = (1L << 2),
      EXO_MOUNT_POINT_MATCH_FSTYPE      = (1L << 3),
    } ExoMountPointMatchMask;

Flags for `exo_mount_point_list_matched()`, that control which mount points will be returned. The fewer match options are specified, the more mount points will usually match (surprising, eh?).

Since 0.3.1.13

### exo_mount_point_list_matched ()

    GSList *            exo_mount_point_list_matched        (ExoMountPointMatchMask mask,
                                                             const gchar *device,
                                                             const gchar *folder,
                                                             const gchar *fstype,
                                                             GError **error);

Lists mount points matching the given `mask` and optionally the parameters `device`, `folder` and `fstype`. If an error occurrs and `error` is non-`NULL`, the `error` will be set to point to a GError describing the problem, and `NULL` will be returned. Note, however, that `NULL` may also be returned if no mount points match.

If `mask` includes `EXO_MOUNT_POINT_MATCH_ACTIVE`, the currently active mount points will be matched, that is, the currently mounted file systems, queried from the kernel. Otherwise if `EXO_MOUNT_POINT_MATCH_CONFIGURED` is specified, the configured mount points from the file system table (usually `/etc/fstab` or `/etc/vfstab`) will be matched.

The caller is responsible to free the returned list using

    g_slist_foreach (list, (GFunc) exo_mount_point_free, NULL);
    g_slist_free (list);

when no longer needed.

`mask` : | the mask of flags that have to match for a mount point to be returned.
`device` : | the device file to match if `EXO_MOUNT_POINT_MATCH_DEVICE` is specified.
`folder` : | the folder to match if `EXO_MOUNT_POINT_MATCH_FOLDER` is specified.
`fstype` : | the file system type to match if `EXO_MOUNT_POINT_MATCH_FSTYPE` is specified.
`error` : | return location for errors or `NULL`.
Returns : | the list of matching ExoMountPoints.

Since 0.3.1.13

### exo_mount_point_list_active()

    #define             exo_mount_point_list_active(error)

Convenience wrapper for `exo_mount_point_list_matched()`, that returns the currently active mount points, or `NULL` in case of an error.

The caller is responsible to free the returned list using

    g_slist_foreach (list, (GFunc) exo_mount_point_free, NULL);
    g_slist_free (list);

when no longer needed.

`error` : | return location for errors or `NULL`.

Since 0.3.1.13

### exo_mount_point_list_configured()

    #define             exo_mount_point_list_configured(error)

Convenience wrapper for `exo_mount_point_list_matched()`, that returns the configured mount points, i.e. the entries from the file system table (which is usually specified in `/etc/fstab`).

The caller is responsible to free the returned list using

    g_slist_foreach (list, (GFunc) exo_mount_point_free, NULL);
    g_slist_free (list);

when no longer needed.

`error` : | return location for errors or `NULL`.

Since 0.3.1.13