forked from enlightenment/efl
on feedback from kay sievers, use open() to check for removable media presence
SVN revision: 55895
This commit is contained in:
parent
f3df2fcce9
commit
d47e3516da
|
@ -2,6 +2,11 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include <Eeze.h>
|
#include <Eeze.h>
|
||||||
#include "eeze_udev_private.h"
|
#include "eeze_udev_private.h"
|
||||||
|
|
||||||
|
@ -208,7 +213,6 @@ eeze_udev_find_by_type(Eeze_Udev_Type etype, const char *name)
|
||||||
case EEZE_UDEV_TYPE_DRIVE_MOUNTABLE:
|
case EEZE_UDEV_TYPE_DRIVE_MOUNTABLE:
|
||||||
udev_enumerate_add_match_subsystem(en, "block");
|
udev_enumerate_add_match_subsystem(en, "block");
|
||||||
udev_enumerate_add_match_property(en, "ID_FS_USAGE", "filesystem");
|
udev_enumerate_add_match_property(en, "ID_FS_USAGE", "filesystem");
|
||||||
udev_enumerate_add_nomatch_sysattr(en, "capability", "52");
|
|
||||||
/* parent node */
|
/* parent node */
|
||||||
udev_enumerate_add_nomatch_sysattr(en, "capability", "50");
|
udev_enumerate_add_nomatch_sysattr(en, "capability", "50");
|
||||||
break;
|
break;
|
||||||
|
@ -285,6 +289,19 @@ eeze_udev_find_by_type(Eeze_Udev_Type etype, const char *name)
|
||||||
if (!(test = udev_device_get_property_value(device, "ID_USB_DRIVER")))
|
if (!(test = udev_device_get_property_value(device, "ID_USB_DRIVER")))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
else if (etype == EEZE_UDEV_TYPE_DRIVE_MOUNTABLE)
|
||||||
|
{
|
||||||
|
int devcheck;
|
||||||
|
|
||||||
|
devcheck = open(udev_device_get_devnode(device), O_EXCL);
|
||||||
|
if (errno)
|
||||||
|
{
|
||||||
|
if (devcheck >= 0) close(devcheck);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
if (devcheck < 0) goto out;
|
||||||
|
close(devcheck);
|
||||||
|
}
|
||||||
|
|
||||||
if (name && (!strstr(devname, name)))
|
if (name && (!strstr(devname, name)))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
@ -2,6 +2,11 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include <Ecore.h>
|
#include <Ecore.h>
|
||||||
#include <Eeze.h>
|
#include <Eeze.h>
|
||||||
#include "eeze_udev_private.h"
|
#include "eeze_udev_private.h"
|
||||||
|
@ -128,11 +133,18 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler * fd_handler)
|
||||||
test = udev_device_get_sysattr_value(device, "capability");
|
test = udev_device_get_sysattr_value(device, "capability");
|
||||||
|
|
||||||
if (test)
|
if (test)
|
||||||
cap = atoi(test);
|
cap = strtol(test, NULL, 10);
|
||||||
|
|
||||||
if (!(test = (udev_device_get_property_value(device, "ID_FS_USAGE"))) ||
|
if (!(test = (udev_device_get_property_value(device, "ID_FS_USAGE"))) ||
|
||||||
(strcmp("filesystem", test)) || (cap == 52) || (cap == 50))
|
(strcmp("filesystem", test)) || (cap == 50))
|
||||||
goto error;
|
goto error;
|
||||||
|
{
|
||||||
|
int devcheck;
|
||||||
|
|
||||||
|
devcheck = open(udev_device_get_devnode(device), O_EXCL);
|
||||||
|
if ((devcheck < 0) || errno) goto error;
|
||||||
|
close(devcheck);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case EEZE_UDEV_TYPE_DRIVE_INTERNAL:
|
case EEZE_UDEV_TYPE_DRIVE_INTERNAL:
|
||||||
|
@ -144,7 +156,7 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler * fd_handler)
|
||||||
if (!(test = udev_device_get_property_value(device, "ID_BUS"))
|
if (!(test = udev_device_get_property_value(device, "ID_BUS"))
|
||||||
|| (strcmp("ata", test))
|
|| (strcmp("ata", test))
|
||||||
|| !(test = udev_device_get_sysattr_value(device, "removable"))
|
|| !(test = udev_device_get_sysattr_value(device, "removable"))
|
||||||
|| (atoi(test)))
|
|| (strtol(test, NULL, 10)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -155,9 +167,9 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler * fd_handler)
|
||||||
goto error;
|
goto error;
|
||||||
#endif
|
#endif
|
||||||
if ((!(test = udev_device_get_sysattr_value(device, "removable"))
|
if ((!(test = udev_device_get_sysattr_value(device, "removable"))
|
||||||
|| (!atoi(test)))
|
|| (!strtol(test, NULL, 10)))
|
||||||
&& (!(test = udev_device_get_sysattr_value(device, "capability"))
|
&& (!(test = udev_device_get_sysattr_value(device, "capability"))
|
||||||
|| (atoi(test) != 10)))
|
|| (strtol(test, NULL, 10) != 10)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue