/* vi: set sw=4 ts=4: */
/*
- * Copyright (C) 2000,2001 by Lineo, inc.
- * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
+ * Utility routines.
*
- * Patched by a bunch of people. Feel free to acknowledge your work.
+ * Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
*
* 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
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
*/
#include <stdio.h>
dev_t dev;
if (stat("/", &rootStat) != 0)
- perror_msg("could not stat '/'");
+ bb_perror_msg("could not stat '/'");
else {
if ((dev = rootStat.st_rdev)==0)
dev=rootStat.st_dev;
dir = opendir("/dev");
if (!dir)
- perror_msg("could not open '/dev'");
+ bb_perror_msg("could not open '/dev'");
else {
while((entry = readdir(dir)) != NULL) {
-
- /* Must skip ".." since that is "/", and so we
+ const char *myname = entry->d_name;
+ /* Must skip ".." since that is "/", and so we
* would get a false positive on ".." */
- if (strcmp(entry->d_name, "..") == 0)
+ if (myname[0] == '.' && myname[1] == '.' && !myname[2])
continue;
- fileName = concat_path_file("/dev", entry->d_name);
+ 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(fileName==NULL)
- fileName=xstrdup("/dev/root");
+ fileName = bb_xstrdup("/dev/root");
return fileName;
}