forked from enlightenment/efl
new functions for applying a wrapper for (u)mount
SVN revision: 59422
This commit is contained in:
parent
4139d9282e
commit
58c89b619b
|
@ -1,4 +1,8 @@
|
||||||
2011-05-15 Mike Blumenkrantz (discomfitor/zmike)
|
2011-05-15 Mike Blumenkrantz (discomfitor/zmike)
|
||||||
|
+eeze_disk_mount_wrapper_set
|
||||||
|
+eeze_disk_mount_wrapper_get
|
||||||
|
Allow use of wrapper exes for mount commands (such as sudo)
|
||||||
|
---------------------------------------
|
||||||
+eeze_disk_udev_get_property
|
+eeze_disk_udev_get_property
|
||||||
+eeze_disk_udev_get_sysattr
|
+eeze_disk_udev_get_sysattr
|
||||||
+eeze_disk_udev_walk_check_sysattr
|
+eeze_disk_udev_walk_check_sysattr
|
||||||
|
|
|
@ -249,6 +249,27 @@ EAPI Eina_Bool eeze_disk_removable_get(Eeze_Disk *disk);
|
||||||
*/
|
*/
|
||||||
EAPI Eina_Bool eeze_disk_mounted_get(Eeze_Disk *disk);
|
EAPI Eina_Bool eeze_disk_mounted_get(Eeze_Disk *disk);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the previously set mount wrapper for a disk
|
||||||
|
* @param disk The disk
|
||||||
|
* @return The wrapper, or NULL on failure
|
||||||
|
*
|
||||||
|
* This returns the wrapper previously set with eeze_disk_mount_wrapper_set
|
||||||
|
*/
|
||||||
|
EAPI const char *eeze_disk_mount_wrapper_get(Eeze_Disk *disk);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set a wrapper to run mount commands with
|
||||||
|
* @param disk The disk to wrap mount commands for
|
||||||
|
* @param wrapper The wrapper executable
|
||||||
|
* @return EINA_TRUE on success, else EINA_FALSE
|
||||||
|
*
|
||||||
|
* 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 @p wrapper if not NULL to test for existence.
|
||||||
|
*/
|
||||||
|
EAPI Eina_Bool eeze_disk_mount_wrapper_set(Eeze_Disk *disk, const char *wrapper);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Begin a mount operation on the disk
|
* @brief Begin a mount operation on the disk
|
||||||
* @param disk The disk
|
* @param disk The disk
|
||||||
|
|
|
@ -168,6 +168,33 @@ eeze_disk_mountopts_get(Eeze_Disk *disk)
|
||||||
return disk->mount_opts;
|
return disk->mount_opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI Eina_Bool
|
||||||
|
eeze_disk_mount_wrapper_set(Eeze_Disk *disk, const char *wrapper)
|
||||||
|
{
|
||||||
|
struct stat s;
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(disk, EINA_FALSE);
|
||||||
|
if (wrapper) EINA_SAFETY_ON_TRUE_RETURN_VAL(!*wrapper, EINA_FALSE);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eina_stringshare_del(disk->mount_wrapper);
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
if ((!stat(wrapper, &s)) && S_ISREG(s.st_mode))
|
||||||
|
{
|
||||||
|
eina_stringshare_replace(&disk->mount_wrapper, wrapper);
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
ERR("%s does not exist!", wrapper);
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI const char *
|
||||||
|
eeze_disk_mount_wrapper_get(Eeze_Disk *disk)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(disk, NULL);
|
||||||
|
return disk->mount_wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
eeze_disk_mount(Eeze_Disk *disk)
|
eeze_disk_mount(Eeze_Disk *disk)
|
||||||
{
|
{
|
||||||
|
@ -218,6 +245,8 @@ eeze_disk_mount(Eeze_Disk *disk)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!disk->mount_point) || (!disk->mount_point[0])) return EINA_FALSE;
|
if ((!disk->mount_point) || (!disk->mount_point[0])) return EINA_FALSE;
|
||||||
|
if (disk->mount_wrapper)
|
||||||
|
eina_strbuf_append_printf(disk->mount_cmd, "%s ", disk->mount_wrapper);
|
||||||
if (disk->mount_opts == EEZE_DISK_MOUNTOPT_DEFAULTS)
|
if (disk->mount_opts == EEZE_DISK_MOUNTOPT_DEFAULTS)
|
||||||
eina_strbuf_append_printf(disk->mount_cmd, EEZE_MOUNT_BIN" -o "EEZE_MOUNT_DEFAULT_OPTS" UUID=%s %s", disk->cache.uuid, disk->mount_point);
|
eina_strbuf_append_printf(disk->mount_cmd, EEZE_MOUNT_BIN" -o "EEZE_MOUNT_DEFAULT_OPTS" UUID=%s %s", disk->cache.uuid, disk->mount_point);
|
||||||
else if (!disk->mount_opts)
|
else if (!disk->mount_opts)
|
||||||
|
|
|
@ -53,6 +53,7 @@ struct _Eeze_Disk
|
||||||
const char *devpath;
|
const char *devpath;
|
||||||
const char *fstype;
|
const char *fstype;
|
||||||
const char *mount_point;
|
const char *mount_point;
|
||||||
|
const char *mount_wrapper;
|
||||||
unsigned long mount_opts;
|
unsigned long mount_opts;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
|
|
Loading…
Reference in New Issue