Loop

Loop — plugin for operations with loop devices

Functions

gboolean bd_loop_init ()
void bd_loop_close ()
GQuark bd_loop_error_quark ()
BDLoopInfo * bd_loop_info ()
BDLoopInfo * bd_loop_info_copy ()
void bd_loop_info_free ()
gchar * bd_loop_get_loop_name ()
gboolean bd_loop_setup ()
gboolean bd_loop_setup_from_fd ()
gboolean bd_loop_teardown ()
gboolean bd_loop_set_autoclear ()
gboolean bd_loop_set_capacity ()
gboolean bd_loop_is_tech_avail ()

Types and Values

Includes

#include <loop.h>

Description

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

Functions

bd_loop_init ()

gboolean
bd_loop_init (void);

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


bd_loop_close ()

void
bd_loop_close (void);

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);

[skip]


bd_loop_info ()

BDLoopInfo *
bd_loop_info (const gchar *loop,
              GError **error);

Parameters

loop

name of the loop device to get information about (e.g. "loop0")

 

error

place to store error (if any).

[out][optional]

Returns

information about the loop device or NULL in case of error

Tech category: BD_LOOP_TECH_LOOP-BD_LOOP_TECH_MODE_QUERY.

[transfer full]


bd_loop_info_copy ()

BDLoopInfo *
bd_loop_info_copy (BDLoopInfo *info);

Creates a new copy of info .

[skip]

Parameters

info

BDLoopInfo to copy.

[nullable]

bd_loop_info_free ()

void
bd_loop_info_free (BDLoopInfo *info);

Frees info .

[skip]

Parameters

info

BDLoopInfo to free.

[nullable]

bd_loop_get_loop_name ()

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

Parameters

file

path of the backing file to get loop name for

 

error

place to store error (if any).

[out][optional]

Returns

name of the loop device associated with the given file

Tech category: BD_LOOP_TECH_LOOP-BD_LOOP_TECH_MODE_QUERY.

[transfer full]


bd_loop_setup ()

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

Parameters

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

 

sector_size

logical sector size for the loop device in bytes (or 0 for default)

 

loop_name

if not NULL, it is used to store the name of the loop device.

[optional][out]

error

place to store error (if any).

[out][optional]

Returns

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

Tech category: BD_LOOP_TECH_LOOP-BD_LOOP_TECH_MODE_CREATE


bd_loop_setup_from_fd ()

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

Parameters

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

 

sector_size

logical sector size for the loop device in bytes (or 0 for default)

 

loop_name

if not NULL, it is used to store the name of the loop device.

[optional][out]

error

place to store error (if any).

[out][optional]

Returns

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

Tech category: BD_LOOP_TECH_LOOP-BD_LOOP_TECH_MODE_CREATE


bd_loop_teardown ()

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

Parameters

loop

path or name of the loop device to tear down

 

error

place to store error (if any).

[out][optional]

Returns

whether the loop device was successfully torn down or not

Tech category: BD_LOOP_TECH_LOOP-BD_LOOP_TECH_MODE_DESTROY


bd_loop_set_autoclear ()

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

Parameters

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][optional]

Returns

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

Tech category: BD_LOOP_TECH_LOOP-BD_LOOP_TECH_MODE_MODIFY


bd_loop_set_capacity ()

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

Force the loop driver to reread the size of the file associated with the specified loop device.

Parameters

loop

path or name of the loop device

 

error

place to store error (if any).

[out][optional]

Returns

whether the LOOP_SET_CAPACITY ioctl was successfully issued or not.

Tech category: BD_LOOP_TECH_LOOP-BD_LOOP_TECH_MODE_MODIFY


bd_loop_is_tech_avail ()

gboolean
bd_loop_is_tech_avail (BDLoopTech tech,
                       guint64 mode,
                       GError **error);

Parameters

tech

the queried tech

 

mode

a bit mask of queried modes of operation (BDLoopTechMode) for tech

 

error

place to store error (details about why the tech -mode combination is not available).

[out][optional]

Returns

whether the tech -mode combination is available -- supported by the plugin implementation and having all the runtime dependencies available

Types and Values

BD_LOOP_ERROR

#define             BD_LOOP_ERROR

enum BDLoopError

Members

BD_LOOP_ERROR_TECH_UNAVAIL

   

BD_LOOP_ERROR_FAIL

   

BD_LOOP_ERROR_DEVICE

   

BDLoopInfo

typedef struct {
    gchar *backing_file;
    guint64 offset;
    gboolean autoclear;
    gboolean direct_io;
    gboolean part_scan;
    gboolean read_only;
} BDLoopInfo;

Members

gchar *backing_file;

backing file for the give loop device;

 

guint64 offset;

offset of the start of the device (in backing_file );

 

gboolean autoclear;

whether the autoclear flag is set or not;

 

gboolean direct_io;

whether direct IO is enabled or not;

 

gboolean part_scan;

whether the partition scan is enforced or not;

 

gboolean read_only;

whether the device is read-only or not;

 

enum BDLoopTech

Members

BD_LOOP_TECH_LOOP

   

enum BDLoopTechMode

Members

BD_LOOP_TECH_MODE_CREATE

   

BD_LOOP_TECH_MODE_DESTROY

   

BD_LOOP_TECH_MODE_MODIFY

   

BD_LOOP_TECH_MODE_QUERY