Scan and query information about disks. More...
Data Structures | |
struct | _Eeze_Event_Disk |
struct | _Eeze_Event_Disk_Error |
Typedefs | |
typedef struct _Eeze_Event_Disk | Eeze_Event_Disk_Mount |
typedef struct _Eeze_Event_Disk | Eeze_Event_Disk_Unmount |
typedef struct _Eeze_Event_Disk | Eeze_Event_Disk_Eject |
typedef struct _Eeze_Disk | Eeze_Disk |
typedef struct _Eeze_Event_Disk_Error | Eeze_Event_Disk_Error |
Enumerations | |
enum | Eeze_Disk_Type { EEZE_DISK_TYPE_UNKNOWN = 0 , EEZE_DISK_TYPE_INTERNAL = (1 << 0) , EEZE_DISK_TYPE_CDROM = (1 << 1) , EEZE_DISK_TYPE_USB = (1 << 2) , EEZE_DISK_TYPE_FLASH = (1 << 3) } |
enum | Eeze_Mount_Opts { EEZE_DISK_MOUNTOPT_LOOP = (1 << 1) , EEZE_DISK_MOUNTOPT_UTF8 = (1 << 2) , EEZE_DISK_MOUNTOPT_NOEXEC = (1 << 3) , EEZE_DISK_MOUNTOPT_NOSUID = (1 << 4) , EEZE_DISK_MOUNTOPT_REMOUNT = (1 << 5) , EEZE_DISK_MOUNTOPT_UID = (1 << 6) , EEZE_DISK_MOUNTOPT_NODEV = (1 << 7) } |
Functions | |
EAPI void | eeze_disk_function (void) |
Use this function to determine whether your eeze is disk-capable. More... | |
EAPI Eina_Bool | eeze_disk_can_mount (void) |
Return whether mount support is available in eeze. More... | |
EAPI Eina_Bool | eeze_disk_can_unmount (void) |
Return whether unmount support is available in eeze. More... | |
EAPI Eina_Bool | eeze_disk_can_eject (void) |
Return whether eject support is available in eeze. More... | |
EAPI Eeze_Disk * | eeze_disk_new (const char *path) |
Create a new disk object from a /sys/ path or /dev/ path. More... | |
EAPI Eeze_Disk * | eeze_disk_new_from_mount (const char *mount_point) |
Create a new disk object from a mount point. More... | |
EAPI void | eeze_disk_free (Eeze_Disk *disk) |
Frees a disk object. More... | |
EAPI void | eeze_disk_scan (Eeze_Disk *disk) |
Retrieve all disk information. More... | |
EAPI void | eeze_disk_data_set (Eeze_Disk *disk, void *data) |
Associate data with a disk. More... | |
EAPI void * | eeze_disk_data_get (Eeze_Disk *disk) |
Retrieve data previously associated with a disk. More... | |
EAPI const char * | eeze_disk_syspath_get (Eeze_Disk *disk) |
Return the /sys/ path of a disk. More... | |
EAPI const char * | eeze_disk_devpath_get (Eeze_Disk *disk) |
Return the /dev/ path of a disk. More... | |
EAPI const char * | eeze_disk_fstype_get (Eeze_Disk *disk) |
Return the filesystem of the disk (if known) More... | |
EAPI const char * | eeze_disk_vendor_get (Eeze_Disk *disk) |
Return the manufacturing vendor of the disk. More... | |
EAPI const char * | eeze_disk_model_get (Eeze_Disk *disk) |
Return the model of the disk. More... | |
EAPI const char * | eeze_disk_serial_get (Eeze_Disk *disk) |
Return the serial number of the disk. More... | |
EAPI const char * | eeze_disk_uuid_get (Eeze_Disk *disk) |
Return the UUID of the disk. More... | |
EAPI const char * | eeze_disk_label_get (Eeze_Disk *disk) |
Return the label of the disk. More... | |
EAPI Eeze_Disk_Type | eeze_disk_type_get (Eeze_Disk *disk) |
Return the Eeze_Disk_Type of the disk. More... | |
EAPI Eina_Bool | eeze_disk_removable_get (Eeze_Disk *disk) |
Return whether the disk is removable. More... | |
EAPI Eina_Bool | eeze_disk_mounted_get (Eeze_Disk *disk) |
Return the mount state of a disk. More... | |
EAPI const char * | eeze_disk_mount_wrapper_get (Eeze_Disk *disk) |
Get the previously set mount wrapper for a disk. More... | |
EAPI Eina_Bool | eeze_disk_mount_wrapper_set (Eeze_Disk *disk, const char *wrapper) |
Set a wrapper to run mount commands with. More... | |
EAPI Eina_Bool | eeze_disk_mount (Eeze_Disk *disk) |
Begin a mount operation on the disk. More... | |
EAPI Eina_Bool | eeze_disk_unmount (Eeze_Disk *disk) |
Begin an unmount operation on the disk. More... | |
EAPI Eina_Bool | eeze_disk_eject (Eeze_Disk *disk) |
Begin an eject operation on the disk. More... | |
EAPI void | eeze_disk_cancel (Eeze_Disk *disk) |
Cancel a pending operation on the disk. More... | |
EAPI const char * | eeze_disk_mount_point_get (Eeze_Disk *disk) |
Return the mount point of a disk. More... | |
EAPI Eina_Bool | eeze_disk_mount_point_set (Eeze_Disk *disk, const char *mount_point) |
Set the mount point of a disk. More... | |
EAPI Eina_Bool | eeze_disk_mountopts_set (Eeze_Disk *disk, unsigned long opts) |
Set the mount options using flags. More... | |
EAPI unsigned long | eeze_disk_mountopts_get (Eeze_Disk *disk) |
Get the flags of a disk's current mount options. More... | |
EAPI Eina_Bool | eeze_mount_tabs_watch (void) |
Begin watching mtab and fstab. More... | |
EAPI void | eeze_mount_tabs_unwatch (void) |
Stop watching /etc/fstab and /etc/mtab. More... | |
EAPI Eina_Bool | eeze_mount_mtab_scan (void) |
Scan /etc/mtab a single time. More... | |
EAPI Eina_Bool | eeze_mount_fstab_scan (void) |
Scan /etc/fstab a single time. More... | |
EAPI const char * | eeze_disk_udev_get_property (Eeze_Disk *disk, const char *property) |
Get the property value of a disk. More... | |
EAPI const char * | eeze_disk_udev_get_sysattr (Eeze_Disk *disk, const char *sysattr) |
Get the sysattr value of a disk. More... | |
EAPI const char * | eeze_disk_udev_get_parent (Eeze_Disk *disk) |
Find the root device of a disk. More... | |
EAPI Eina_Bool | eeze_disk_udev_walk_check_sysattr (Eeze_Disk *disk, const char *sysattr, const char *value) |
Walks up the device chain using the device from disk , checking each device for sysattr with (optional) value . More... | |
EAPI const char * | eeze_disk_udev_walk_get_sysattr (Eeze_Disk *disk, const char *sysattr) |
Walks up the device chain of disk checking each device for sysattr and returns the value if found. More... | |
Variables | |
EAPI int | EEZE_EVENT_DISK_MOUNT |
EAPI int | EEZE_EVENT_DISK_UNMOUNT |
EAPI int | EEZE_EVENT_DISK_EJECT |
EAPI int | EEZE_EVENT_DISK_ERROR |
Scan and query information about disks.
Manipulate them with moun, unmount and eject.
Handle for an Eeze Disk.
Contains the human readable error message.
enum Eeze_Disk_Type |
enum Eeze_Mount_Opts |
EAPI void eeze_disk_function | ( | void | ) |
Use this function to determine whether your eeze is disk-capable.
Since applications will die if they run/compile against a function that doesn't exist, if your application successfully runs/compiles with this function then you have eeze_disk.
Return whether mount support is available in eeze.
Use this function to determine whether your Eeze library was compiled with a mount binary available.
References EINA_FALSE.
Return whether unmount support is available in eeze.
Use this function to determine whether your Eeze library was compiled with an unmount binary available.
References EINA_FALSE.
Return whether eject support is available in eeze.
Use this function to determine whether your Eeze library was compiled with an eject binary available.
References EINA_FALSE.
Create a new disk object from a /sys/ path or /dev/ path.
path | The /sys/ or /dev path of the disk; CANNOT be NULL . |
This function creates a new Eeze_Disk from path
. Note that this function does the minimal amount of work in order to save memory, and udev info about the disk is not retrieved in this call.
References eeze_udev_devpath_get_syspath(), EINA_FALSE, EINA_SAFETY_ON_NULL_RETURN_VAL, eina_stringshare_add(), eina_stringshare_del(), and EINA_TRUE.
Create a new disk object from a mount point.
mount_point | The mount point of the disk; CANNOT be NULL |
This function creates a new Eeze_Disk from mount_point
. Note that this function does the minimal amount of work in order to save memory, and udev info about the disk is not retrieved in this call. If the disk is not currently mounted, it must have an entry in /etc/fstab.
References eeze_udev_devpath_get_syspath(), EINA_FALSE, eina_list_append(), EINA_SAFETY_ON_NULL_RETURN_VAL, eina_stringshare_add(), eina_stringshare_del(), and EINA_TRUE.
Frees a disk object.
disk | The disk object to free |
This call frees an Eeze_Disk. Once freed, the disk can no longer be used.
References ecore_exe_kill(), eina_list_remove(), EINA_SAFETY_ON_NULL_RETURN, and eina_strbuf_free().
Retrieve all disk information.
disk |
Use this function to retrieve all of a disk's information at once, then use a "get" function to retrieve the value. Data retrieved in this call is cached, meaning that subsequent calls will return immediately without performing any work.
References EINA_FALSE, EINA_SAFETY_ON_NULL_RETURN, eina_stringshare_del(), and EINA_TRUE.
Associate data with a disk.
disk | The disk |
data | The data |
Data can be associated with disk
with this function.
References EINA_SAFETY_ON_NULL_RETURN.
Retrieve data previously associated with a disk.
disk | The disk |
Data that has been previously associated with disk
is returned with this function.
References EINA_SAFETY_ON_NULL_RETURN_VAL.
Return the /sys/ path of a disk.
disk | The disk |
This retrieves the /sys/ path that udev associates with disk
.
References EINA_SAFETY_ON_NULL_RETURN_VAL.
Return the /dev/ path of a disk.
disk | The disk |
This retrieves the /dev/ path that udev has created a device node at for disk
.
References EINA_SAFETY_ON_NULL_RETURN_VAL.
Referenced by eeze_disk_eject(), eeze_disk_mount(), eeze_disk_mount_point_get(), and eeze_disk_unmount().
Return the filesystem of the disk (if known)
disk | The disk |
This retrieves the filesystem that the disk is using, or NULL
if unknown.
References EINA_SAFETY_ON_NULL_RETURN_VAL.
Return the manufacturing vendor of the disk.
disk | The disk |
This retrieves the vendor which manufactured the disk, or NULL
if unknown.
References EINA_SAFETY_ON_NULL_RETURN_VAL.
Return the model of the disk.
disk | The disk |
This retrieves the model of the disk, or NULL
if unknown.
References EINA_SAFETY_ON_NULL_RETURN_VAL.
Return the serial number of the disk.
disk | The disk |
This retrieves the serial number the disk, or NULL
if unknown.
References EINA_SAFETY_ON_NULL_RETURN_VAL.
Return the UUID of the disk.
disk | The disk |
This retrieves the UUID of the disk, or NULL
if unknown. A UUID is a 36 character (hopefully) unique identifier which can be used to store persistent information about a disk.
References EINA_SAFETY_ON_NULL_RETURN_VAL.
Referenced by eeze_disk_mount(), and eeze_disk_mount_point_get().
Return the label of the disk.
disk | The disk |
This retrieves the label (name) of the disk, or NULL
if unknown.
References EINA_SAFETY_ON_NULL_RETURN_VAL.
Referenced by eeze_disk_mount_point_get().
EAPI Eeze_Disk_Type eeze_disk_type_get | ( | Eeze_Disk * | disk | ) |
Return the Eeze_Disk_Type of the disk.
disk | The disk |
This retrieves the Eeze_Disk_Type of the disk. This call is useful for determining the bus that the disk is connected through.
References EEZE_DISK_TYPE_UNKNOWN, and EINA_SAFETY_ON_NULL_RETURN_VAL.
Return whether the disk is removable.
disk | The disk |
EINA_TRUE
if removable, EINA_FALSE
otherwise. References EINA_FALSE, EINA_SAFETY_ON_NULL_RETURN_VAL, and eina_stringshare_del().
Return the mount state of a disk.
disk | The disk |
This returns the mounted state of the disk. EINA_TRUE
if mounted, EINA_FALSE
otherwise.
References EINA_FALSE, and EINA_SAFETY_ON_NULL_RETURN_VAL.
Get the previously set mount wrapper for a disk.
disk | The disk |
NULL
on failure.This returns the wrapper previously set with eeze_disk_mount_wrapper_set
References EINA_SAFETY_ON_NULL_RETURN_VAL.
Set a wrapper to run mount commands with.
disk | The disk to wrap mount commands for |
wrapper | The wrapper executable |
EINA_TRUE
on success, EINA_FALSE
otherwise.Use this function to set up a wrapper for running mount/umount commands. The wrapper must NOT use any of the standard mount/umount error code return values, and it must return 0 on success. Note that this function will call stat() on wrapper
if not NULL
to test for existence.
References EINA_FALSE, EINA_SAFETY_ON_NULL_RETURN_VAL, EINA_SAFETY_ON_TRUE_RETURN_VAL, eina_stringshare_del(), eina_stringshare_replace(), and EINA_TRUE.
Begin a mount operation on the disk.
disk | The disk |
EINA_TRUE
if the operation was started, EINA_FALSE
otherwise.This call is used to begin a mount operation on disk
. The operation will run asynchronously in a pipe, emitting an EEZE_EVENT_DISK_MOUNT event with the disk object as its event on completion. If any errors are encountered, they will automatically logged to the eeze_disk domain and an EEZE_EVENT_DISK_ERROR event will be generated with an Eeze_Event_Disk_Error struct as its event.
NOTE: The return value of this function does not in any way reflect the mount state of a disk.
References eeze_disk_devpath_get(), eeze_disk_mount_point_set(), eeze_disk_uuid_get(), EINA_FALSE, EINA_SAFETY_ON_NULL_RETURN_VAL, eina_strbuf_append_printf(), eina_strbuf_new(), eina_strbuf_string_free(), and eina_stringshare_del().
Begin an unmount operation on the disk.
disk | The disk |
EINA_TRUE
if the operation was started, EINA_FALSE
otherwise.This call is used to begin an unmount operation on disk
. The operation will run asynchronously in a pipe, emitting an EEZE_EVENT_DISK_UNMOUNT event with the disk object as its event on completion. If any errors are encountered, they will automatically logged to the eeze_disk domain and an EEZE_EVENT_DISK_ERROR event will be generated with an Eeze_Event_Disk_Error struct as its event.
NOTE: The return value of this function does not in any way reflect the mount state of a disk.
References ecore_exe_run(), eeze_disk_devpath_get(), EINA_FALSE, eina_list_append(), EINA_SAFETY_ON_NULL_RETURN_VAL, eina_strbuf_append_printf(), eina_strbuf_new(), eina_strbuf_string_free(), eina_strbuf_string_get(), EINA_TRUE, and INF.
Referenced by eeze_disk_eject().
Begin an eject operation on the disk.
disk | The disk |
EINA_TRUE
if the operation was started, EINA_FALSE
otherwise.This call is used to begin an eject operation on disk
. The operation will run asynchronously in a pipe, emitting an EEZE_EVENT_DISK_EJECT event with the disk object as its event on completion. If any errors are encountered, they will automatically logged to the eeze_disk domain and an EEZE_EVENT_DISK_ERROR event will be generated with an Eeze_Event_Disk_Error struct as its event.
NOTE: The return value of this function does not in any way reflect the mount state of a disk.
References ecore_exe_run(), eeze_disk_devpath_get(), eeze_disk_unmount(), EINA_FALSE, eina_list_append(), EINA_SAFETY_ON_NULL_RETURN_VAL, eina_strbuf_append_printf(), eina_strbuf_new(), eina_strbuf_string_get(), EINA_TRUE, and INF.
Cancel a pending operation on the disk.
disk | The disk |
This function cancels the current pending operation on disk
which was previously started with eeze_disk_mount or eeze_disk_unmount.
References ecore_exe_kill(), and EINA_SAFETY_ON_NULL_RETURN.
Return the mount point of a disk.
disk | The disk |
This function returns the mount point associated with disk
. Note that to determine whether the disk is actually mounted, eeze_disk_mounted_get should be used.
References eeze_disk_devpath_get(), eeze_disk_label_get(), eeze_disk_uuid_get(), EINA_SAFETY_ON_NULL_RETURN_VAL, and eina_stringshare_add().
Set the mount point of a disk.
disk | The disk |
mount_point | The mount point |
EINA_TRUE
on success, EINA_FALSE
otherwise.This function sets the mount point associated with disk
. Note that to determine whether the disk is actually mounted, eeze_disk_mounted_get should be used. Also note that this function cannot be used while the disk is mounted to avoid losing the current mount point.
References EINA_FALSE, EINA_SAFETY_ON_NULL_RETURN_VAL, eina_stringshare_replace(), and EINA_TRUE.
Referenced by eeze_disk_mount().
Set the mount options using flags.
disk | The disk |
opts | An ORed set of Eeze_Mount_Opts |
EINA_TRUE
on success, EINA_FALSE
otherwise.This function replaces the current mount opts of a disk with the ones in opts
.
References EEZE_DISK_MOUNTOPT_UID, EINA_FALSE, EINA_SAFETY_ON_NULL_RETURN_VAL, and EINA_TRUE.
Get the flags of a disk's current mount options.
disk | The disk |
This function returns the current mount opts of a disk.
References EINA_SAFETY_ON_NULL_RETURN_VAL.
Begin watching mtab and fstab.
EINA_TRUE
if watching was started, EINA_FALSE
otherwise.This function creates inotify watches on /etc/mtab and /etc/fstab and watches them for changes. This function should be used when expecting a lot of disk mounting/unmounting while you need disk data since it will automatically update certain necessary data instead of waiting.
References ECORE_FD_ERROR, ecore_file_monitor_add(), ecore_main_fd_handler_file_add(), EINA_FALSE, EINA_SAFETY_ON_NULL_GOTO, EINA_TRUE, ERR, and fcntl().
EAPI void eeze_mount_tabs_unwatch | ( | void | ) |
Stop watching /etc/fstab and /etc/mtab.
This function stops watching fstab and mtab. Data obtained previously will be saved.
References ecore_file_monitor_del(), ecore_main_fd_handler_del(), and EINA_FALSE.
Scan /etc/mtab a single time.
EINA_TRUE
if mtab could be scanned, EINA_FALSE
otherwise.This function is used to perform a single scan on /etc/mtab. It is used to gather information about mounted filesystems which can then be used with your Eeze_Disk objects where appropriate. These files will automatically be scanned any time a mount point or mount state is requested unless eeze_mount_tabs_watch has been called previously, in which case data is stored for use. If this function is called after eeze_mount_tabs_watch, EINA_TRUE
will be returned.
References EINA_FALSE, and EINA_TRUE.
Scan /etc/fstab a single time.
EINA_TRUE
if mtab could be scanned, EINA_FALSE
otherwise.This function is used to perform a single scan on /etc/fstab. It is used to gather information about mounted filesystems which can then be used with your Eeze_Disk objects where appropriate. These files will automatically be scanned any time a mount point or mount state is requested unless eeze_mount_tabs_watch has been called previously, in which case data is stored for use. If this function is called after eeze_mount_tabs_watch, EINA_TRUE
will be returned.
References EINA_FALSE, and EINA_TRUE.
Get the property value of a disk.
disk | The disk |
property | The property to get; full list of these is a FIXME |
NULL
on failure. References EINA_SAFETY_ON_NULL_RETURN_VAL, EINA_SAFETY_ON_TRUE_RETURN_VAL, and eina_stringshare_add().
Get the sysattr value of a disk.
disk | The disk |
sysattr | The sysattr to get; full list of these is a FIXME |
NULL
on failure. References EINA_SAFETY_ON_NULL_RETURN_VAL, EINA_SAFETY_ON_TRUE_RETURN_VAL, and eina_stringshare_add().
Find the root device of a disk.
disk | The disk |
Return a stringshared syspath (/sys/$syspath) for the parent device.
References EINA_SAFETY_ON_NULL_RETURN_VAL, and eina_stringshare_add().
EAPI Eina_Bool eeze_disk_udev_walk_check_sysattr | ( | Eeze_Disk * | disk, |
const char * | sysattr, | ||
const char * | value | ||
) |
Walks up the device chain using the device from disk
, checking each device for sysattr
with (optional) value
.
disk | The disk to walk |
sysattr | The attribute to find |
value | OPTIONAL: The value that sysattr should have, or NULL . |
EINA_TRUE
, EINA_FALSE
otherwise. References EINA_FALSE, EINA_SAFETY_ON_NULL_RETURN_VAL, EINA_SAFETY_ON_TRUE_RETURN_VAL, and EINA_TRUE.
Walks up the device chain of disk
checking each device for sysattr
and returns the value if found.
disk | The disk |
sysattr | The attribute to find |
sysattr
if found, or NULL
. References EINA_SAFETY_ON_NULL_RETURN_VAL, EINA_SAFETY_ON_TRUE_RETURN_VAL, and eina_stringshare_add().