]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
eject: remove unnecessary function
authorKarel Zak <kzak@redhat.com>
Tue, 27 Mar 2012 12:08:02 +0000 (14:08 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 27 Mar 2012 12:08:02 +0000 (14:08 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/eject.c

index 7a847bf28f829662f65327b5e8f38a34be94c414..cc877b63a19aafc76450bc302ede684367492553 100644 (file)
@@ -229,20 +229,6 @@ static void parse_args(int argc, char **argv, char **device)
                *device = xstrdup(argv[optind]);
 }
 
-/* Return 1 if file/device exists, 0 otherwise. */
-static int file_exists(const char *name) {
-    /*
-    * access() uses the UID, not the EUID. This way a normal user
-    * cannot find out if a file (say, /root/fubar) exists or not, even
-    * if eject is SUID root
-   */
-   if (access (name, F_OK) == 0) {
-       return 1;
-   } else {
-       return 0;
-   }
-}
-
 /*
  * Given name, such as foo, see if any of the following exist:
  *
@@ -259,13 +245,13 @@ static char *find_device(const char *name) {
 
        if ((name[0] == '.') || (name[0] == '/')) {
                strcpy(buf, name);
-               if (file_exists(buf))
+               if (access(buf, F_OK) == 0)
                        return buf;
        }
 
        strcpy(buf, "/dev/");
        strcat(buf, name);
-       if (file_exists(buf))
+       if (access (name, F_OK) == 0)
                return buf;
 
        free(buf);