![]() |
![]() |
![]() |
Disk Utility Library Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces |
GduDriveClass; GduDrivePrivate; enum GduCreateVolumeFlags; GduDrive; gboolean gdu_drive_is_active (GduDrive *drive
); gboolean gdu_drive_is_activatable (GduDrive *drive
); gboolean gdu_drive_can_deactivate (GduDrive *drive
); gboolean gdu_drive_can_activate (GduDrive *drive
,gboolean *out_degraded
); void gdu_drive_activate (GduDrive *drive
,GduDriveActivateFunc callback
,gpointer user_data
); void gdu_drive_deactivate (GduDrive *drive
,GduDriveDeactivateFunc callback
,gpointer user_data
); gboolean gdu_drive_can_create_volume (GduDrive *drive
,gboolean *out_is_uninitialized
,guint64 *out_largest_contiguous_free_segment
,guint64 *out_total_free
,GduPresentable **out_presentable
); void gdu_drive_create_volume (GduDrive *drive
,guint64 size
,const gchar *name
,GduCreateVolumeFlags flags
,GAsyncReadyCallback callback
,gpointer user_data
); GduVolume * gdu_drive_create_volume_finish (GduDrive *drive
,GAsyncResult *res
,GError **error
); gboolean gdu_drive_count_mbr_partitions (GduDrive *drive
,guint *out_num_primary_partitions
,gboolean *out_has_extended_partition
); GList * gdu_drive_get_volumes (GduDrive *drive
);
The GduDrive class represents drives attached to the system. Normally, objects of this class corresponds 1:1 to physical drives (hard disks, optical drives, card readers etc.) attached to the system. However, it can also relate to software abstractions such as a Linux md Software RAID array and similar things.
See the documentation for GduPresentable for the big picture.
typedef struct { GObjectClass parent_class; /* VTable */ gboolean (*is_active) (GduDrive *drive); gboolean (*is_activatable) (GduDrive *drive); gboolean (*can_deactivate) (GduDrive *drive); gboolean (*can_activate) (GduDrive *drive, gboolean *out_degraded); void (*activate) (GduDrive *drive, GduDriveActivateFunc callback, gpointer user_data); void (*deactivate) (GduDrive *drive, GduDriveDeactivateFunc callback, gpointer user_data); gboolean (*can_create_volume) (GduDrive *drive, gboolean *out_is_uninitialized, guint64 *out_largest_contiguous_free_segment, guint64 *out_total_free, GduPresentable **out_presentable); void (*create_volume) (GduDrive *drive, guint64 size, const gchar *name, GduCreateVolumeFlags flags, GAsyncReadyCallback callback, gpointer user_data); GduVolume *(*create_volume_finish) (GduDrive *drive, GAsyncResult *res, GError **error); } GduDriveClass;
typedef enum { GDU_CREATE_VOLUME_FLAGS_NONE = 0x00, GDU_CREATE_VOLUME_FLAGS_LINUX_MD = (1<<0), GDU_CREATE_VOLUME_FLAGS_LINUX_LVM2 = (1<<1) } GduCreateVolumeFlags;
Flags used in gdu_drive_create_volume()
.
gboolean gdu_drive_can_activate (GduDrive *drive
,gboolean *out_degraded
);
Checks if drive
can be activated. If this function returns TRUE
,
out_degraded
will be set to whether the drive will be started in
degraded mode (e.g. starting a mirror RAID array with only one
component available).
|
A GduDrive. |
|
NULL or return location for whether the drive will be degraded if activated.
|
Returns : |
TRUE if drive can be activated (and out_degraded will be set), FALSE otherwise.
|
void gdu_drive_activate (GduDrive *drive
,GduDriveActivateFunc callback
,gpointer user_data
);
|
|
|
|
|
void gdu_drive_deactivate (GduDrive *drive
,GduDriveDeactivateFunc callback
,gpointer user_data
);
|
|
|
|
|
gboolean gdu_drive_can_create_volume (GduDrive *drive
,gboolean *out_is_uninitialized
,guint64 *out_largest_contiguous_free_segment
,guint64 *out_total_free
,GduPresentable **out_presentable
);
This method checks if a new volume can be created on drive
.
If drive
uses removable media and there is no media inserted,
FALSE
is returned.
If drive
appears to be completely uninitialized (such as a hard
disk full of zeros), out_is_unitialized
is set to TRUE
, the size
of the media/disk is returned in out_largest_segment
and TRUE
is
returned. Note that this can also happen if drive
contains
signatures unknown to the operating system so be careful and always
prompt the user.
If the disk is partitioned and unallocated space exists but no more
partitions can be created (due to e.g. four primary partitions on a
MBR partitioned disk), this method returns FALSE
but
out_largest_segment
will be set to a non-zero value.
Additionally, out_presentable
will be set to either a
GduVolumeHole (if the disk is partitioned and has free space) or
the GduDrive (if the disk is uninitialized).
You can use gdu_drive_create_volume()
to create a volume.
|
A GduDrive. |
|
Return location for whether drive is uninitialized or NULL .
|
|
|
|
Return location for total amount of free space on drive or NULL .
|
|
Return location for the presentable that represents free space or NULL . Free
with g_object_unref() .
|
Returns : |
TRUE if drive has unallocated space, FALSE otherwise.
|
void gdu_drive_create_volume (GduDrive *drive
,guint64 size
,const gchar *name
,GduCreateVolumeFlags flags
,GAsyncReadyCallback callback
,gpointer user_data
);
High-level method for creating a new volume on drive
of size size
using name
and flags
as influential hints.
Depending on the actual type of drive
, different things may happen
- if drive
represents a partitioned drive, then a new partition
will be created (and if the partitioning scheme supports partition
labels name
will be used as the label). If drive
is completely
uninitialized, it may (or may not) be partitioned.
If drive
represents a LVM2 volume group, a logical volume may be
created (with name
being used as LV name).
This is an asynchronous operation. When the result of the operation
is ready, callback
will be invoked.
|
A GduDrive. |
|
The size of the volume to create. |
|
A name for the volume. |
|
Flags describing what kind of volume to create |
|
Function to call when the result is ready. |
|
User data to pass to callback .
|
GduVolume * gdu_drive_create_volume_finish (GduDrive *drive
,GAsyncResult *res
,GError **error
);
Finishes an operation started with gdu_drive_create_volume()
.
gboolean gdu_drive_count_mbr_partitions (GduDrive *drive
,guint *out_num_primary_partitions
,gboolean *out_has_extended_partition
);
Counts the number of primary partitions and figures out if there's an extended partition.
|
A GduDrive. |
|
Return location for number of primary partitions. |
|
Return location for number of extended partitions. |
Returns : |
TRUE if out_num_logical_partitions and out_has_extended_partition is set, FALSE otherwise.
|