summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer2006-04-12 07:35:12 +0000
committerBernhard Reutner-Fischer2006-04-12 07:35:12 +0000
commitcb44816ba32a3bbf598aab6d7cb1eabfd6619f5f (patch)
tree4459d66dd948b019c4a96730eea224f79520ad8c /libbb
parentd0ea52ee041ca4d8d00cc5212d54328689b1a3c4 (diff)
downloadbusybox-cb44816ba32a3bbf598aab6d7cb1eabfd6619f5f.zip
busybox-cb44816ba32a3bbf598aab6d7cb1eabfd6619f5f.tar.gz
- add and use bb_opendir(), bb_xopendir().
text data bss dec hex filename 889445 9392 1035784 1934621 1d851d busybox.gcc-4.2.orig 889297 9392 1035784 1934473 1d8489 busybox.gcc-4.2 889009 9820 1037860 1936689 1d8d31 busybox.gcc-4.1.orig 888817 9820 1037860 1936497 1d8c71 busybox.gcc-4.1
Diffstat (limited to 'libbb')
-rw-r--r--libbb/Makefile.in10
-rw-r--r--libbb/copy_file.c3
-rw-r--r--libbb/opendir.c37
-rw-r--r--libbb/procps.c4
-rw-r--r--libbb/recursive_action.c17
-rw-r--r--libbb/remove_file.c17
-rw-r--r--libbb/run_parts.c9
7 files changed, 53 insertions, 44 deletions
diff --git a/libbb/Makefile.in b/libbb/Makefile.in
index 2d9a174..de511fc 100644
--- a/libbb/Makefile.in
+++ b/libbb/Makefile.in
@@ -105,12 +105,18 @@ LIBBB_MOBJ6:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ6))
$(LIBBB_MOBJ6):$(LIBBB_MSRC6)
$(compile.c) -DL_$(notdir $*)
+LIBBB_MSRC7:=$(srcdir)/opendir.c
+LIBBB_MOBJ7:=bb_opendir.o bb_xopendir.o
+LIBBB_MOBJ7:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ7))
+$(LIBBB_MOBJ7):$(LIBBB_MSRC7)
+ $(compile.c) -DL_$(notdir $*)
# We need the names of the object files built from MSRC for the L_ defines
-LIBBB_ALL_MOBJ:=$(LIBBB_MOBJ0) $(LIBBB_MOBJ1) $(LIBBB_MOBJ2) $(LIBBB_MOBJ3) $(LIBBB_MOBJ4) $(LIBBB_MOBJ5) $(LIBBB_MOBJ6)
+LIBBB_ALL_MOBJ:=$(LIBBB_MOBJ0) $(LIBBB_MOBJ1) $(LIBBB_MOBJ2) $(LIBBB_MOBJ3) \
+ $(LIBBB_MOBJ4) $(LIBBB_MOBJ5) $(LIBBB_MOBJ6) $(LIBBB_MOBJ7)
LIBBB_ALL_MSRC:=$(LIBBB_MSRC0) $(LIBBB_MSRC1) $(LIBBB_MSRC2) $(LIBBB_MSRC3) \
- $(LIBBB_MSRC4) $(LIBBB_MSRC5) $(LIBBB_MSRC6)
+ $(LIBBB_MSRC4) $(LIBBB_MSRC5) $(LIBBB_MSRC6) $(LIBBB_MSRC7)
LIBBB-y:=$(sort $(LIBBB-y) $(LIBBB_ALL_MSRC))
diff --git a/libbb/copy_file.c b/libbb/copy_file.c
index 3b172ff..2f75146 100644
--- a/libbb/copy_file.c
+++ b/libbb/copy_file.c
@@ -92,8 +92,7 @@ int copy_file(const char *source, const char *dest, int flags)
}
/* Recursively copy files in SOURCE. */
- if ((dp = opendir(source)) == NULL) {
- bb_perror_msg("unable to open directory `%s'", source);
+ if ((dp = bb_opendir(source)) == NULL) {
status = -1;
goto preserve_status;
}
diff --git a/libbb/opendir.c b/libbb/opendir.c
new file mode 100644
index 0000000..e284db0
--- /dev/null
+++ b/libbb/opendir.c
@@ -0,0 +1,37 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * wrapper for opendir()
+ *
+ * Copyright (C) 2006 Bernhard Fischer <busybox@busybox.net>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ */
+
+#include <sys/types.h>
+#include <dirent.h>
+#include "libbb.h"
+
+#ifdef L_bb_opendir
+DIR *bb_opendir(const char *path)
+{
+ DIR *dp;
+
+ if ((dp = opendir(path)) == NULL) {
+ bb_perror_msg("unable to open `%s'", path);
+ return NULL;
+ }
+ return dp;
+}
+#endif
+
+#ifdef L_bb_xopendir
+DIR *bb_xopendir(const char *path)
+{
+ DIR *dp;
+
+ if ((dp = opendir(path)) == NULL) {
+ bb_perror_msg_and_die("unable to open `%s'", path);
+ }
+ return dp;
+}
+#endif
diff --git a/libbb/procps.c b/libbb/procps.c
index e73c0dc..25f42ff 100644
--- a/libbb/procps.c
+++ b/libbb/procps.c
@@ -50,9 +50,7 @@ procps_status_t * procps_scan(int save_user_arg0)
struct stat sb;
if (!dir) {
- dir = opendir("/proc");
- if(!dir)
- bb_error_msg_and_die("Can't open /proc");
+ dir = bb_xopendir("/proc");
}
for(;;) {
if((entry = readdir(dir)) == NULL) {
diff --git a/libbb/recursive_action.c b/libbb/recursive_action.c
index d276298..6b005e2 100644
--- a/libbb/recursive_action.c
+++ b/libbb/recursive_action.c
@@ -4,19 +4,7 @@
*
* Copyright (C) 1999-2004 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
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * 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
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdio.h>
@@ -94,9 +82,8 @@ int recursive_action(const char *fileName,
} else if (status == SKIP)
return TRUE;
}
- dir = opendir(fileName);
+ dir = bb_opendir(fileName);
if (!dir) {
- bb_perror_msg("%s", fileName);
return FALSE;
}
status = TRUE;
diff --git a/libbb/remove_file.c b/libbb/remove_file.c
index ee1aaa5..2fa6596 100644
--- a/libbb/remove_file.c
+++ b/libbb/remove_file.c
@@ -4,19 +4,7 @@
*
* Copyright (C) 2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
- * 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
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * 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
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdio.h>
@@ -71,8 +59,7 @@ int remove_file(const char *path, int flags)
return 0;
}
- if ((dp = opendir(path)) == NULL) {
- bb_perror_msg("unable to open `%s'", path);
+ if ((dp = bb_opendir(path)) == NULL) {
return -1;
}
diff --git a/libbb/run_parts.c b/libbb/run_parts.c
index 864460d..7bdae5b 100644
--- a/libbb/run_parts.c
+++ b/libbb/run_parts.c
@@ -7,12 +7,7 @@
* rewrite to vfork usage by
* Copyright (C) 2002 by Vladimir Oleynik <dzo@simtreas.ru>
*
- * 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
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
@@ -69,7 +64,7 @@ int run_parts(char **args, const unsigned char test_mode, char **env)
if (test_mode & 2) {
return(2);
}
- bb_perror_msg_and_die("failed to open directory %s", arg0);
+ bb_perror_msg_and_die("unable to open `%s'", arg0);
}
for (i = 0; i < entries; i++) {