forked from enlightenment/efl
parent
6e1be20e6c
commit
8c29186b5a
|
@ -10,7 +10,7 @@ main(void)
|
|||
{
|
||||
Eina_List *disks;
|
||||
const char *syspath;
|
||||
|
||||
|
||||
eeze_init();
|
||||
eeze_disk_function();
|
||||
|
||||
|
@ -25,7 +25,7 @@ main(void)
|
|||
eeze_disk_free(disk);
|
||||
eina_stringshare_del(syspath);
|
||||
}
|
||||
|
||||
|
||||
disks = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_REMOVABLE, NULL);
|
||||
printf("Found the following removable drives:\n");
|
||||
EINA_LIST_FREE(disks, syspath)
|
||||
|
|
|
@ -54,14 +54,14 @@ main(int argc, char *argv[])
|
|||
Eeze_Disk *disk;
|
||||
|
||||
Ecore_Getopt_Value values[] =
|
||||
{
|
||||
{
|
||||
ECORE_GETOPT_VALUE_BOOL(verbose),
|
||||
ECORE_GETOPT_VALUE_BOOL(exit_option),
|
||||
ECORE_GETOPT_VALUE_BOOL(exit_option),
|
||||
ECORE_GETOPT_VALUE_BOOL(exit_option),
|
||||
ECORE_GETOPT_VALUE_BOOL(exit_option)
|
||||
};
|
||||
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
printf("Insufficient args specified!\n");
|
||||
|
|
|
@ -15,7 +15,7 @@ static const Ecore_Getopt opts =
|
|||
"LGPL",
|
||||
"unmount a disk using either its /sys/ path or its /dev/ path\n\n",
|
||||
1,
|
||||
{
|
||||
{
|
||||
ECORE_GETOPT_STORE_TRUE('v', "verbose", "Enable debug output"),
|
||||
ECORE_GETOPT_VERSION('V', "version"),
|
||||
ECORE_GETOPT_COPYRIGHT('R', "copyright"),
|
||||
|
@ -54,14 +54,14 @@ main(int argc, char *argv[])
|
|||
Eeze_Disk *disk;
|
||||
|
||||
Ecore_Getopt_Value values[] =
|
||||
{
|
||||
{
|
||||
ECORE_GETOPT_VALUE_BOOL(verbose),
|
||||
ECORE_GETOPT_VALUE_BOOL(exit_option),
|
||||
ECORE_GETOPT_VALUE_BOOL(exit_option),
|
||||
ECORE_GETOPT_VALUE_BOOL(exit_option),
|
||||
ECORE_GETOPT_VALUE_BOOL(exit_option)
|
||||
};
|
||||
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
printf("Insufficient args specified!\n");
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
/**
|
||||
* @file Eeze.h
|
||||
* @brief Easy device manipulation.
|
||||
*
|
||||
*
|
||||
* Eeze is a library for manipulating devices through udev with a simple and fast
|
||||
* api. It interfaces directly with libudev, avoiding such middleman daemons as
|
||||
* udisks/upower or hal, to immediately gather device information the instant it
|
||||
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
/**
|
||||
* @addtogroup udev
|
||||
*
|
||||
*
|
||||
* These are the device subsystems of udev:
|
||||
* @li ac97
|
||||
* @li acpi
|
||||
|
@ -134,10 +134,10 @@ typedef enum
|
|||
* @typedef Eeze_Udev_Type Eeze_Udev_Type
|
||||
* @enum Eeze_Udev_Type
|
||||
* @brief Convenience types to simplify udev access.
|
||||
*
|
||||
*
|
||||
* These types allow easy access to certain udev device types. They
|
||||
* may only be used in specified functions.
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*FIXME: these probably need to be bitmasks with categories*/
|
||||
|
@ -200,7 +200,7 @@ typedef void(*Eeze_Udev_Watch_Cb)(const char *, Eeze_Udev_Event, void *, Eeze_Ud
|
|||
EAPI Eina_List *eeze_udev_find_by_sysattr(const char *sysattr, const char *value);
|
||||
EAPI Eina_List *eeze_udev_find_by_type(Eeze_Udev_Type type, const char *name);
|
||||
EAPI Eina_List *eeze_udev_find_by_filter(const char *subsystem, const char *type, const char *name);
|
||||
|
||||
|
||||
EAPI const char *eeze_udev_devpath_get_syspath(const char *devpath);
|
||||
EAPI const char *eeze_udev_syspath_get_parent(const char *syspath);
|
||||
EAPI Eina_List *eeze_udev_syspath_get_parents(const char *syspath);
|
||||
|
@ -208,11 +208,11 @@ typedef void(*Eeze_Udev_Watch_Cb)(const char *, Eeze_Udev_Event, void *, Eeze_Ud
|
|||
EAPI const char *eeze_udev_syspath_get_subsystem(const char *syspath);
|
||||
EAPI const char *eeze_udev_syspath_get_property(const char *syspath, const char *property);
|
||||
EAPI const char *eeze_udev_syspath_get_sysattr(const char *syspath, const char *sysattr);
|
||||
|
||||
|
||||
EAPI Eina_Bool eeze_udev_syspath_is_mouse(const char *syspath);
|
||||
EAPI Eina_Bool eeze_udev_syspath_is_kbd(const char *syspath);
|
||||
EAPI Eina_Bool eeze_udev_syspath_is_touchpad(const char *syspath);
|
||||
|
||||
|
||||
EAPI Eina_Bool eeze_udev_walk_check_sysattr(const char *syspath, const char *sysattr, const char *value);
|
||||
EAPI const char *eeze_udev_walk_get_sysattr(const char *syspath, const char *sysattr);
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ _eeze_disk_device_from_property(const char *prop, Eina_Bool uuid)
|
|||
}
|
||||
udev_enumerate_unref(en);
|
||||
return device;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,7 +92,7 @@ eeze_disk_new(const char *path)
|
|||
_udev_device *dev;
|
||||
const char *syspath;
|
||||
Eina_Bool is_dev = EINA_FALSE;
|
||||
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
|
||||
|
||||
if (!strncmp(path, "/dev/", 5))
|
||||
|
@ -110,12 +110,12 @@ eeze_disk_new(const char *path)
|
|||
}
|
||||
else if (!(dev = _new_device(path)))
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
if (!(disk = calloc(1, sizeof(Eeze_Disk))))
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
if (is_dev)
|
||||
{
|
||||
disk->devpath = eina_stringshare_add(path);
|
||||
|
@ -123,13 +123,13 @@ eeze_disk_new(const char *path)
|
|||
}
|
||||
else
|
||||
disk->syspath = eina_stringshare_add(udev_device_get_syspath(dev));
|
||||
|
||||
|
||||
|
||||
disk->device = dev;
|
||||
disk->mount_opts = EEZE_DISK_MOUNTOPT_DEFAULTS;
|
||||
disk->mount_cmd_changed = EINA_TRUE;
|
||||
disk->unmount_cmd_changed = EINA_TRUE;
|
||||
|
||||
|
||||
return disk;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ eeze_disk_new_from_mount(const char *mount_point)
|
|||
Eeze_Disk *disk = NULL;
|
||||
_udev_device *dev = NULL;
|
||||
const char *syspath = NULL, *source, *uuid = NULL, *label = NULL, *devpath = NULL;
|
||||
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(mount_point, NULL);
|
||||
|
||||
if (!(source = eeze_disk_libmount_mp_find_source(mount_point)))
|
||||
|
@ -195,7 +195,7 @@ eeze_disk_new_from_mount(const char *mount_point)
|
|||
else
|
||||
disk->devpath = devpath;
|
||||
disk->mount_point = eina_stringshare_add(mount_point);
|
||||
|
||||
|
||||
return disk;
|
||||
error:
|
||||
if (uuid)
|
||||
|
@ -222,7 +222,7 @@ eeze_disk_free(Eeze_Disk *disk)
|
|||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN(disk);
|
||||
|
||||
|
||||
|
||||
udev_device_unref(disk->device);
|
||||
if (disk->mount_cmd)
|
||||
eina_strbuf_free(disk->mount_cmd);
|
||||
|
@ -245,7 +245,7 @@ eeze_disk_scan(Eeze_Disk *disk)
|
|||
EINA_SAFETY_ON_NULL_RETURN(disk);
|
||||
/* never rescan; if these values change then something is seriously wrong */
|
||||
if (disk->cache.filled) return;
|
||||
|
||||
|
||||
if (!disk->cache.vendor)
|
||||
disk->cache.vendor = udev_device_get_property_value(disk->device, "ID_VENDOR");
|
||||
if (!disk->cache.model)
|
||||
|
@ -275,7 +275,7 @@ EAPI void
|
|||
eeze_disk_data_set(Eeze_Disk *disk, void *data)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN(disk);
|
||||
|
||||
|
||||
disk->data = data;
|
||||
}
|
||||
|
||||
|
@ -292,7 +292,7 @@ EAPI void *
|
|||
eeze_disk_data_get(Eeze_Disk *disk)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(disk, NULL);
|
||||
|
||||
|
||||
return disk->data;
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,7 @@ EAPI const char *
|
|||
eeze_disk_syspath_get(Eeze_Disk *disk)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(disk, NULL);
|
||||
|
||||
|
||||
return disk->syspath;
|
||||
}
|
||||
|
||||
|
@ -322,7 +322,7 @@ EAPI const char *
|
|||
eeze_disk_devpath_get(Eeze_Disk *disk)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(disk, NULL);
|
||||
|
||||
|
||||
if (disk->devpath)
|
||||
return disk->devpath;
|
||||
disk->devpath = udev_device_get_devnode(disk->device);
|
||||
|
@ -340,7 +340,7 @@ EAPI const char *
|
|||
eeze_disk_fstype_get(Eeze_Disk *disk)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(disk, NULL);
|
||||
|
||||
|
||||
return disk->fstype;
|
||||
}
|
||||
|
||||
|
@ -355,10 +355,10 @@ EAPI const char *
|
|||
eeze_disk_vendor_get(Eeze_Disk *disk)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(disk, NULL);
|
||||
|
||||
|
||||
if (disk->cache.vendor)
|
||||
return disk->cache.vendor;
|
||||
|
||||
|
||||
disk->cache.vendor = udev_device_get_property_value(disk->device, "ID_VENDOR");
|
||||
return disk->cache.vendor;
|
||||
}
|
||||
|
@ -374,10 +374,10 @@ EAPI const char *
|
|||
eeze_disk_model_get(Eeze_Disk *disk)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(disk, NULL);
|
||||
|
||||
|
||||
if (disk->cache.model)
|
||||
return disk->cache.model;
|
||||
|
||||
|
||||
disk->cache.model = udev_device_get_property_value(disk->device, "ID_MODEL");
|
||||
return disk->cache.model;
|
||||
}
|
||||
|
@ -393,7 +393,7 @@ EAPI const char *
|
|||
eeze_disk_serial_get(Eeze_Disk *disk)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(disk, NULL);
|
||||
|
||||
|
||||
if (disk->cache.serial)
|
||||
return disk->cache.serial;
|
||||
disk->cache.serial = udev_device_get_property_value(disk->device, "ID_SERIAL_SHORT");
|
||||
|
@ -413,7 +413,7 @@ EAPI const char *
|
|||
eeze_disk_uuid_get(Eeze_Disk *disk)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(disk, NULL);
|
||||
|
||||
|
||||
if (disk->cache.uuid)
|
||||
return disk->cache.uuid;
|
||||
disk->cache.uuid = udev_device_get_property_value(disk->device, "ID_FS_UUID");
|
||||
|
@ -431,7 +431,7 @@ EAPI const char *
|
|||
eeze_disk_label_get(Eeze_Disk *disk)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(disk, NULL);
|
||||
|
||||
|
||||
if (disk->cache.label)
|
||||
return disk->cache.label;
|
||||
disk->cache.label = udev_device_get_property_value(disk->device, "ID_FS_LABEL");
|
||||
|
@ -450,7 +450,7 @@ EAPI Eeze_Disk_Type
|
|||
eeze_disk_type_get(Eeze_Disk *disk)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(disk, EEZE_DISK_TYPE_UNKNOWN);
|
||||
|
||||
|
||||
if (disk->cache.type)
|
||||
return disk->cache.type;
|
||||
disk->cache.type = _eeze_disk_type_find(disk);
|
||||
|
|
|
@ -95,7 +95,7 @@ _eeze_mount_tab_parse(const char *filename)
|
|||
|
||||
if (!mnt_table_parse_file(tab, filename))
|
||||
return tab;
|
||||
|
||||
|
||||
mnt_free_table(tab);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ eeze_disk_libmount_opts_get(Eeze_Disk *disk)
|
|||
libmnt_fs *mnt;
|
||||
const char *opts;
|
||||
unsigned long f = 0;
|
||||
|
||||
|
||||
if (!eeze_mount_mtab_scan() || !eeze_mount_fstab_scan())
|
||||
return 0;
|
||||
|
||||
|
@ -191,7 +191,7 @@ Eina_Bool
|
|||
eeze_disk_libmount_mounted_get(Eeze_Disk *disk)
|
||||
{
|
||||
libmnt_fs *mnt;
|
||||
|
||||
|
||||
if (!disk)
|
||||
return EINA_FALSE;
|
||||
|
||||
|
@ -214,7 +214,7 @@ const char *
|
|||
eeze_disk_libmount_mp_find_source(const char *mount_point)
|
||||
{
|
||||
libmnt_fs *mnt;
|
||||
|
||||
|
||||
if (!mount_point)
|
||||
return NULL;
|
||||
|
||||
|
@ -238,7 +238,7 @@ const char *
|
|||
eeze_disk_libmount_mp_lookup_by_uuid(const char *uuid)
|
||||
{
|
||||
libmnt_fs *mnt;
|
||||
|
||||
|
||||
if (!uuid)
|
||||
return NULL;
|
||||
|
||||
|
@ -260,7 +260,7 @@ const char *
|
|||
eeze_disk_libmount_mp_lookup_by_label(const char *label)
|
||||
{
|
||||
libmnt_fs *mnt;
|
||||
|
||||
|
||||
if (!label)
|
||||
return NULL;
|
||||
|
||||
|
@ -282,7 +282,7 @@ const char *
|
|||
eeze_disk_libmount_mp_lookup_by_devpath(const char *devpath)
|
||||
{
|
||||
libmnt_fs *mnt;
|
||||
|
||||
|
||||
if (!devpath)
|
||||
return NULL;
|
||||
|
||||
|
@ -319,7 +319,7 @@ EAPI Eina_Bool
|
|||
eeze_mount_tabs_watch(void)
|
||||
{
|
||||
libmnt_table *bak;
|
||||
|
||||
|
||||
if (_watching)
|
||||
return EINA_TRUE;
|
||||
|
||||
|
@ -338,7 +338,7 @@ eeze_mount_tabs_watch(void)
|
|||
|
||||
mnt_free_table(_eeze_mount_fstab);
|
||||
_eeze_mount_fstab = bak;
|
||||
|
||||
|
||||
_mtab_mon = ecore_file_monitor_add("/etc/mtab", _eeze_mount_tab_watcher, (void*)1);
|
||||
_fstab_mon = ecore_file_monitor_add("/etc/fstab", _eeze_mount_tab_watcher, NULL);
|
||||
_watching = EINA_TRUE;
|
||||
|
@ -387,7 +387,7 @@ EAPI Eina_Bool
|
|||
eeze_mount_mtab_scan(void)
|
||||
{
|
||||
libmnt_table *bak;
|
||||
|
||||
|
||||
if (_watching)
|
||||
return EINA_TRUE;
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ Eina_Bool
|
|||
eeze_disk_libmount_mounted_get(Eeze_Disk *disk)
|
||||
{
|
||||
mnt_fs *mnt;
|
||||
|
||||
|
||||
if (!disk)
|
||||
return EINA_FALSE;
|
||||
|
||||
|
@ -178,7 +178,7 @@ const char *
|
|||
eeze_disk_libmount_mp_find_source(const char *mount_point)
|
||||
{
|
||||
mnt_fs *mnt;
|
||||
|
||||
|
||||
if (!mount_point)
|
||||
return NULL;
|
||||
|
||||
|
@ -202,7 +202,7 @@ const char *
|
|||
eeze_disk_libmount_mp_lookup_by_uuid(const char *uuid)
|
||||
{
|
||||
mnt_fs *mnt;
|
||||
|
||||
|
||||
if (!uuid)
|
||||
return NULL;
|
||||
|
||||
|
@ -224,7 +224,7 @@ const char *
|
|||
eeze_disk_libmount_mp_lookup_by_label(const char *label)
|
||||
{
|
||||
mnt_fs *mnt;
|
||||
|
||||
|
||||
if (!label)
|
||||
return NULL;
|
||||
|
||||
|
@ -246,7 +246,7 @@ const char *
|
|||
eeze_disk_libmount_mp_lookup_by_devpath(const char *devpath)
|
||||
{
|
||||
mnt_fs *mnt;
|
||||
|
||||
|
||||
if (!devpath)
|
||||
return NULL;
|
||||
|
||||
|
@ -283,7 +283,7 @@ EAPI Eina_Bool
|
|||
eeze_mount_tabs_watch(void)
|
||||
{
|
||||
mnt_tab *bak;
|
||||
|
||||
|
||||
if (_watching)
|
||||
return EINA_TRUE;
|
||||
|
||||
|
@ -302,7 +302,7 @@ eeze_mount_tabs_watch(void)
|
|||
|
||||
mnt_free_tab(_eeze_mount_fstab);
|
||||
_eeze_mount_fstab = bak;
|
||||
|
||||
|
||||
_mtab_mon = ecore_file_monitor_add("/etc/mtab", _eeze_mount_tab_watcher, (void*)1);
|
||||
_fstab_mon = ecore_file_monitor_add("/etc/fstab", _eeze_mount_tab_watcher, NULL);
|
||||
_watching = EINA_TRUE;
|
||||
|
@ -351,7 +351,7 @@ EAPI Eina_Bool
|
|||
eeze_mount_mtab_scan(void)
|
||||
{
|
||||
mnt_tab *bak;
|
||||
|
||||
|
||||
if (_watching)
|
||||
return EINA_TRUE;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ static void
|
|||
_eeze_disk_mount_error_handler(Eeze_Disk *disk, const char *error)
|
||||
{
|
||||
Eeze_Event_Disk_Error *de;
|
||||
|
||||
|
||||
ERR("%s", error);
|
||||
if (!(de = calloc(1, sizeof(Eeze_Event_Disk_Error))))
|
||||
return;
|
||||
|
@ -67,7 +67,7 @@ _eeze_disk_mount_result_handler(void *data __UNUSED__, int type __UNUSED__, Ecor
|
|||
|
||||
if ((!disk) || (!eeze_events) || (!(l = eina_list_data_find(eeze_events, disk))))
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
|
||||
|
||||
eeze_events = eina_list_remove_list(eeze_events, l);
|
||||
if (disk->mount_status == EEZE_DISK_MOUNTING)
|
||||
switch (ev->exit_code)
|
||||
|
@ -122,7 +122,7 @@ _eeze_disk_mount_result_handler(void *data __UNUSED__, int type __UNUSED__, Ecor
|
|||
eeze_events = eina_list_append(eeze_events, disk);
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
|
@ -314,7 +314,7 @@ eeze_disk_mount(Eeze_Disk *disk)
|
|||
* 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.
|
||||
*/
|
||||
EAPI Eina_Bool
|
||||
|
|
|
@ -48,13 +48,13 @@ struct _Eeze_Disk
|
|||
Eina_Bool mount_cmd_changed : 1;
|
||||
Eina_Bool unmount_cmd_changed : 1;
|
||||
Ecore_Exe *mounter;
|
||||
|
||||
|
||||
const char *syspath;
|
||||
const char *devpath;
|
||||
const char *fstype;
|
||||
const char *mount_point;
|
||||
unsigned long mount_opts;
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
Eeze_Disk_Type type;
|
||||
|
|
Loading…
Reference in New Issue