On Wed, Jan 5, 2011 at 4:42 PM, Enlightenment SVN <
[email protected]> wrote:
> Log:
> on feedback from kay sievers, use open() to check for removable media
presence
>
>
> Author:       discomfitor
> Date:         2011-01-05 10:42:49 -0800 (Wed, 05 Jan 2011)
> New Revision: 55895
> Trac:         http://trac.enlightenment.org/e/changeset/55895
>
> Modified:
>  trunk/eeze/src/lib/eeze_udev_find.c trunk/eeze/src/lib/eeze_udev_watch.c
>
> Modified: trunk/eeze/src/lib/eeze_udev_find.c
> ===================================================================
> --- trunk/eeze/src/lib/eeze_udev_find.c 2011-01-05 18:06:05 UTC (rev
55894)
> +++ trunk/eeze/src/lib/eeze_udev_find.c 2011-01-05 18:42:49 UTC (rev
55895)
> @@ -2,6 +2,11 @@
>  #include "config.h"
>  #endif
>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +#include <errno.h>
> +
>  #include <Eeze.h>
>  #include "eeze_udev_private.h"
>
> @@ -208,7 +213,6 @@
>         case EEZE_UDEV_TYPE_DRIVE_MOUNTABLE:
>           udev_enumerate_add_match_subsystem(en, "block");
>           udev_enumerate_add_match_property(en, "ID_FS_USAGE",
"filesystem");
> -          udev_enumerate_add_nomatch_sysattr(en, "capability", "52");
>           /* parent node */
>           udev_enumerate_add_nomatch_sysattr(en, "capability", "50");
>           break;
> @@ -285,7 +289,20 @@
>                 if (!(test = udev_device_get_property_value(device,
"ID_USB_DRIVER")))
>                   goto out;
>              }
> +         else if (etype == EEZE_UDEV_TYPE_DRIVE_MOUNTABLE)
> +           {
> +              int devcheck;
>
> +              devcheck = open(udev_device_get_devnode(device), O_EXCL);
> +              if (errno)

This is bad... you have to either zero errno before calling open() or check
the return value before. Since open() will not zero errno in case of
succees, doing like you did you're actually carrying whatever value errno
had.

Looking only this diff, it seems that you have only to check for `!devcheck'

> +                {
> +                   if (devcheck >= 0) close(devcheck);
> +                   goto out;
> +                }
> +              if (devcheck < 0) goto out;
> +              close(devcheck);
> +           }
> +
>         if (name && (!strstr(devname, name)))
>            goto out;
>
>
> Modified: trunk/eeze/src/lib/eeze_udev_watch.c
> ===================================================================
> --- trunk/eeze/src/lib/eeze_udev_watch.c        2011-01-05 18:06:05 UTC
(rev 55894)
> +++ trunk/eeze/src/lib/eeze_udev_watch.c        2011-01-05 18:42:49 UTC
(rev 55895)
> @@ -2,6 +2,11 @@
>  #include "config.h"
>  #endif
>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +#include <errno.h>
> +
>  #include <Ecore.h>
>  #include <Eeze.h>
>  #include "eeze_udev_private.h"
> @@ -128,12 +133,19 @@
>           test = udev_device_get_sysattr_value(device, "capability");
>
>           if
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to