X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=libbb%2Ffind_root_device.c;h=c595321dfe832f0197e2363047a387f997664edf;hb=1dc0ccafddf9b5f540008b7cabbf3ab1f4f53ee3;hp=b12d392a23630dd59a52e5cf09f2cbcb34e48b0c;hpb=393183dccc4d100366972bdbbdc6e03a77839120;p=oweals%2Fbusybox.git diff --git a/libbb/find_root_device.c b/libbb/find_root_device.c index b12d392a2..c595321df 100644 --- a/libbb/find_root_device.c +++ b/libbb/find_root_device.c @@ -2,9 +2,7 @@ /* * Utility routines. * - * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen - * Copyright (C) 1999,2000,2001 by Erik Andersen - * Patched by a bunch of people. Feel free to acknowledge your work. + * Copyright (C) 1999-2003 by Erik Andersen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -48,11 +46,14 @@ extern char *find_real_root_device_name(const char* name) bb_perror_msg("could not open '/dev'"); else { while((entry = readdir(dir)) != NULL) { - - fileName = concat_subpath_file("/dev", entry->d_name); - if(fileName == NULL) + const char *myname = entry->d_name; + /* Must skip ".." since that is "/", and so we + * would get a false positive on ".." */ + if (myname[0] == '.' && myname[1] == '.' && !myname[2]) continue; + fileName = concat_path_file("/dev", myname); + /* Some char devices have the same dev_t as block * devices, so make sure this is a block device */ if (stat(fileName, &statBuf) == 0 && @@ -66,7 +67,7 @@ extern char *find_real_root_device_name(const char* name) } } if(fileName==NULL) - fileName=bb_xstrdup("/dev/root"); + fileName = bb_xstrdup("/dev/root"); return fileName; }