lineedit: do not hang on error, but return error indicator.
[oweals/busybox.git] / libbb / find_root_device.c
index 7182102c71962feb894511cf126f7761f6211ff5..32c86cea8e1de22f9262a74b91c24653e27fd416 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"
@@ -41,7 +41,8 @@ static char *find_block_device_in_dir(struct arena *ap)
 
        while ((entry = readdir(dir)) != NULL) {
                safe_strncpy(ap->devpath + len, entry->d_name, rem);
-               if (stat(ap->devpath, &ap->st) != 0)
+               /* lstat: do not follow links */
+               if (lstat(ap->devpath, &ap->st) != 0)
                        continue;
                if (S_ISBLK(ap->st.st_mode) && ap->st.st_rdev == ap->dev) {
                        retpath = xstrdup(ap->devpath);
@@ -61,7 +62,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;