lineedit: in !EDITING config, return -1 on fgets error
[oweals/busybox.git] / libbb / find_root_device.c
index 9779f7e82d190d064782fdd38aba50522ca74e66..8436cd664fcb28091299126baf82dfc5e3a59c4d 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
 
 #include "libbb.h"
@@ -29,14 +29,15 @@ static char *find_block_device_in_dir(struct arena *ap)
        char *retpath = NULL;
        int len, rem;
 
-       dir = opendir(ap->devpath);
-       if (!dir)
-               return NULL;
-
        len = strlen(ap->devpath);
        rem = DEVNAME_MAX-2 - len;
        if (rem <= 0)
                return NULL;
+
+       dir = opendir(ap->devpath);
+       if (!dir)
+               return NULL;
+
        ap->devpath[len++] = '/';
 
        while ((entry = readdir(dir)) != NULL) {
@@ -62,7 +63,7 @@ static char *find_block_device_in_dir(struct arena *ap)
        return retpath;
 }
 
-char *find_block_device(const char *path)
+char* FAST_FUNC find_block_device(const char *path)
 {
        struct arena a;