Loop

Loop — plugin for operations with loop devices

Synopsis

#include <loop.h>

gboolean            bd_loop_check_deps                  ();
gboolean            bd_loop_init                        ();
void                bd_loop_close                       ();
GQuark              bd_loop_error_quark                 (void);
#define             BD_LOOP_ERROR
enum                BDLoopError;
gchar *             bd_loop_get_backing_file            (const gchar *dev_name,
                                                         GError **error);
gchar *             bd_loop_get_loop_name               (const gchar *file,
                                                         GError **error);
gboolean            bd_loop_setup                       (const gchar *file,
                                                         guint64 offset,
                                                         guint64 size,
                                                         gboolean read_only,
                                                         gboolean part_scan,
                                                         const gchar **loop_name,
                                                         GError **error);
gboolean            bd_loop_setup_from_fd               (gint fd,
                                                         guint64 offset,
                                                         guint64 size,
                                                         gboolean read_only,
                                                         gboolean part_scan,
                                                         const gchar **loop_name,
                                                         GError **error);
gboolean            bd_loop_teardown                    (const gchar *loop,
                                                         GError **error);
gboolean            bd_loop_get_autoclear               (const gchar *loop,
                                                         GError **error);
gboolean            bd_loop_set_autoclear               (const gchar *loop,
                                                         gboolean autoclear,
                                                         GError **error);

Description

A plugin for operations with loop devices. All sizes passed in/out to/from the functions are in bytes.

Details

bd_loop_check_deps ()

gboolean            bd_loop_check_deps                  ();

Returns :

whether the plugin's runtime dependencies are satisfied or not Function checking plugin's runtime dependencies.

bd_loop_init ()

gboolean            bd_loop_init                        ();

Initializes the plugin. **This function is called automatically by the library's initialization functions.**


bd_loop_close ()

void                bd_loop_close                       ();

Cleans up after the plugin. **This function is called automatically by the library's functions that unload it.**


bd_loop_error_quark ()

GQuark              bd_loop_error_quark                 (void);

BD_LOOP_ERROR

#define             BD_LOOP_ERROR

enum BDLoopError

typedef enum {
    BD_LOOP_ERROR_DEVICE,
    BD_LOOP_ERROR_FAIL,
} BDLoopError;

BD_LOOP_ERROR_DEVICE

BD_LOOP_ERROR_FAIL


bd_loop_get_backing_file ()

gchar *             bd_loop_get_backing_file            (const gchar *dev_name,
                                                         GError **error);

dev_name :

name of the loop device to get backing file for (e.g. "loop0")

error :

place to store error (if any). [out]

Returns :

path of the device's backing file or NULL if none is found. [transfer full]

bd_loop_get_loop_name ()

gchar *             bd_loop_get_loop_name               (const gchar *file,
                                                         GError **error);

file :

path of the backing file to get loop name for

error :

place to store error (if any). [out]

Returns :

name of the loop device associated with the given file. [transfer full]

bd_loop_setup ()

gboolean            bd_loop_setup                       (const gchar *file,
                                                         guint64 offset,
                                                         guint64 size,
                                                         gboolean read_only,
                                                         gboolean part_scan,
                                                         const gchar **loop_name,
                                                         GError **error);

file :

file to setup as a loop device

offset :

offset of the start of the device (in file)

size :

maximum size of the device (or 0 to leave unspecified)

read_only :

whether to setup as read-only (TRUE) or read-write (FALSE)

part_scan :

whether to enforce partition scan on the newly created device or not

loop_name :

if not NULL, it is used to store the name of the loop device. [allow-none][out]

error :

place to store error (if any). [out]

Returns :

whether the file was successfully setup as a loop device or not

bd_loop_setup_from_fd ()

gboolean            bd_loop_setup_from_fd               (gint fd,
                                                         guint64 offset,
                                                         guint64 size,
                                                         gboolean read_only,
                                                         gboolean part_scan,
                                                         const gchar **loop_name,
                                                         GError **error);

fd :

file descriptor for a file to setup as a new loop device

offset :

offset of the start of the device (in file given by fd)

size :

maximum size of the device (or 0 to leave unspecified)

read_only :

whether to setup as read-only (TRUE) or read-write (FALSE)

part_scan :

whether to enforce partition scan on the newly created device or not

loop_name :

if not NULL, it is used to store the name of the loop device. [allow-none][out]

error :

place to store error (if any). [out]

Returns :

whether an new loop device was successfully setup for fd or not

bd_loop_teardown ()

gboolean            bd_loop_teardown                    (const gchar *loop,
                                                         GError **error);

loop :

path or name of the loop device to tear down

error :

place to store error (if any). [out]

Returns :

whether the loop device was successfully torn down or not

bd_loop_get_autoclear ()

gboolean            bd_loop_get_autoclear               (const gchar *loop,
                                                         GError **error);

loop :

path or name of the loop device

error :

place to store error (if any). [out]

Returns :

whether the autoclear flag is set on the loop device or not (if FALSE, error may be set)

bd_loop_set_autoclear ()

gboolean            bd_loop_set_autoclear               (const gchar *loop,
                                                         gboolean autoclear,
                                                         GError **error);

loop :

path or name of the loop device

autoclear :

whether to set or unset the autoclear flag

error :

place to store error (if any). [out]

Returns :

whether the autoclear flag was successfully set on the loop device or not