svn commit: trunk/busybox: coreutils debianutils include libbb proc etc...

aldot at busybox.net aldot at busybox.net
Wed Apr 12 07:35:15 UTC 2006


Author: aldot
Date: 2006-04-12 00:35:12 -0700 (Wed, 12 Apr 2006)
New Revision: 14830

Log:
- 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


Added:
   trunk/busybox/libbb/opendir.c

Modified:
   trunk/busybox/coreutils/diff.c
   trunk/busybox/coreutils/du.c
   trunk/busybox/coreutils/ls.c
   trunk/busybox/debianutils/start_stop_daemon.c
   trunk/busybox/include/libbb.h
   trunk/busybox/libbb/Makefile.in
   trunk/busybox/libbb/copy_file.c
   trunk/busybox/libbb/procps.c
   trunk/busybox/libbb/recursive_action.c
   trunk/busybox/libbb/remove_file.c
   trunk/busybox/libbb/run_parts.c
   trunk/busybox/procps/sysctl.c


Changeset:
Modified: trunk/busybox/coreutils/diff.c
===================================================================
--- trunk/busybox/coreutils/diff.c	2006-04-12 03:47:16 UTC (rev 14829)
+++ trunk/busybox/coreutils/diff.c	2006-04-12 07:35:12 UTC (rev 14830)
@@ -1114,8 +1114,8 @@
 	else {
 		DIR *dp;
 		struct dirent *ep;
-		if ((dp = opendir(path)) == NULL)
-			bb_error_msg("Error reading directory");
+
+		dp = bb_opendir(path);
 		while ((ep = readdir(dp))) {
 			if ((!strcmp(ep->d_name, "..")) || (!strcmp(ep->d_name, ".")))
 				continue;

Modified: trunk/busybox/coreutils/du.c
===================================================================
--- trunk/busybox/coreutils/du.c	2006-04-12 03:47:16 UTC (rev 14829)
+++ trunk/busybox/coreutils/du.c	2006-04-12 07:35:12 UTC (rev 14830)
@@ -6,20 +6,7 @@
  * Copyright (C) 1999,2000,2001 by John Beppu <beppu at codepoet.org>
  * Copyright (C) 2002  Edward Betts <edward at debian.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.
  */
 
 /* BB_AUDIT SUSv3 compliant (unless default blocksize set to 1k) */
@@ -134,9 +121,8 @@
 		struct dirent *entry;
 		char *newfile;
 
-		dir = opendir(filename);
+		dir = bb_opendir(filename);
 		if (!dir) {
-			bb_perror_msg("%s", filename);
 			status = EXIT_FAILURE;
 			return sum;
 		}

Modified: trunk/busybox/coreutils/ls.c
===================================================================
--- trunk/busybox/coreutils/ls.c	2006-04-12 03:47:16 UTC (rev 14829)
+++ trunk/busybox/coreutils/ls.c	2006-04-12 07:35:12 UTC (rev 14830)
@@ -3,19 +3,7 @@
  * tiny-ls.c version 0.1.0: A minimalist 'ls'
  * Copyright (C) 1996 Brian Candler <B.Candler at pobox.com>
  *
- *  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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  */
 
 /*
@@ -592,9 +580,8 @@
 
 	dn = NULL;
 	nfiles = 0;
-	dir = opendir(path);
+	dir = bb_opendir(path);
 	if (dir == NULL) {
-		bb_perror_msg("%s", path);
 		status = EXIT_FAILURE;
 		return (NULL);	/* could not open the dir */
 	}

Modified: trunk/busybox/debianutils/start_stop_daemon.c
===================================================================
--- trunk/busybox/debianutils/start_stop_daemon.c	2006-04-12 03:47:16 UTC (rev 14829)
+++ trunk/busybox/debianutils/start_stop_daemon.c	2006-04-12 07:35:12 UTC (rev 14830)
@@ -143,9 +143,7 @@
 		return;
 	}
 
-	procdir = opendir("/proc");
-	if (!procdir)
-		bb_perror_msg_and_die ("opendir /proc");
+	procdir = bb_xopendir("/proc");
 
 	foundany = 0;
 	while ((entry = readdir(procdir)) != NULL) {

Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h	2006-04-12 03:47:16 UTC (rev 14829)
+++ trunk/busybox/include/libbb.h	2006-04-12 07:35:12 UTC (rev 14830)
@@ -17,6 +17,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <termios.h>
+#include <dirent.h>
 #include <stdint.h>
 
 #include <netinet/in.h>
@@ -98,6 +99,8 @@
 
 extern const char *bb_mode_string(int mode);
 extern int is_directory(const char *name, int followLinks, struct stat *statBuf);
+extern DIR *bb_opendir(const char *path);
+extern DIR *bb_xopendir(const char *path);
 
 extern int remove_file(const char *path, int flags);
 extern int copy_file(const char *source, const char *dest, int flags);

Modified: trunk/busybox/libbb/Makefile.in
===================================================================
--- trunk/busybox/libbb/Makefile.in	2006-04-12 03:47:16 UTC (rev 14829)
+++ trunk/busybox/libbb/Makefile.in	2006-04-12 07:35:12 UTC (rev 14830)
@@ -105,12 +105,18 @@
 $(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))
 

Modified: trunk/busybox/libbb/copy_file.c
===================================================================
--- trunk/busybox/libbb/copy_file.c	2006-04-12 03:47:16 UTC (rev 14829)
+++ trunk/busybox/libbb/copy_file.c	2006-04-12 07:35:12 UTC (rev 14830)
@@ -92,8 +92,7 @@
 		}
 
 		/* 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;
 		}

Added: trunk/busybox/libbb/opendir.c
===================================================================
--- trunk/busybox/libbb/opendir.c	2006-04-12 03:47:16 UTC (rev 14829)
+++ trunk/busybox/libbb/opendir.c	2006-04-12 07:35:12 UTC (rev 14830)
@@ -0,0 +1,37 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * wrapper for opendir()
+ *
+ * Copyright (C) 2006 Bernhard Fischer <busybox at 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

Modified: trunk/busybox/libbb/procps.c
===================================================================
--- trunk/busybox/libbb/procps.c	2006-04-12 03:47:16 UTC (rev 14829)
+++ trunk/busybox/libbb/procps.c	2006-04-12 07:35:12 UTC (rev 14830)
@@ -50,9 +50,7 @@
 	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) {

Modified: trunk/busybox/libbb/recursive_action.c
===================================================================
--- trunk/busybox/libbb/recursive_action.c	2006-04-12 03:47:16 UTC (rev 14829)
+++ trunk/busybox/libbb/recursive_action.c	2006-04-12 07:35:12 UTC (rev 14830)
@@ -4,19 +4,7 @@
  *
  * Copyright (C) 1999-2004 by Erik Andersen <andersen at 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 @@
 			} else if (status == SKIP)
 				return TRUE;
 		}
-		dir = opendir(fileName);
+		dir = bb_opendir(fileName);
 		if (!dir) {
-			bb_perror_msg("%s", fileName);
 			return FALSE;
 		}
 		status = TRUE;

Modified: trunk/busybox/libbb/remove_file.c
===================================================================
--- trunk/busybox/libbb/remove_file.c	2006-04-12 03:47:16 UTC (rev 14829)
+++ trunk/busybox/libbb/remove_file.c	2006-04-12 07:35:12 UTC (rev 14830)
@@ -4,19 +4,7 @@
  *
  * Copyright (C) 2001 Matt Kraai <kraai at 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 @@
 				return 0;
 		}
 
-		if ((dp = opendir(path)) == NULL) {
-			bb_perror_msg("unable to open `%s'", path);
+		if ((dp = bb_opendir(path)) == NULL) {
 			return -1;
 		}
 

Modified: trunk/busybox/libbb/run_parts.c
===================================================================
--- trunk/busybox/libbb/run_parts.c	2006-04-12 03:47:16 UTC (rev 14829)
+++ trunk/busybox/libbb/run_parts.c	2006-04-12 07:35:12 UTC (rev 14830)
@@ -7,12 +7,7 @@
  * rewrite to vfork usage by
  * Copyright (C) 2002 by Vladimir Oleynik <dzo at 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 @@
 		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++) {

Modified: trunk/busybox/procps/sysctl.c
===================================================================
--- trunk/busybox/procps/sysctl.c	2006-04-12 03:47:16 UTC (rev 14829)
+++ trunk/busybox/procps/sysctl.c	2006-04-12 07:35:12 UTC (rev 14830)
@@ -4,14 +4,9 @@
  *
  *
  * "Copyright 1999 George Staikos
- * This file may be used subject to the terms and conditions of the
- * GNU General Public License Version 2, or any later version
- * at your option, as published by the Free Software Foundation.
- * 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."
  *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ *
  * Changelog:
  *	v1.01:
  *		- added -p <preload> to preload values from a file
@@ -57,7 +52,6 @@
 	"error: unknown error %d reading key '%s'\n";
 static const char ERR_PERMISSION_DENIED[] =
 	"error: permission denied on key '%s'\n";
-static const char ERR_OPENING_DIR[] = "error: unable to open directory '%s'\n";
 static const char ERR_PRELOAD_FILE[] =
 	"error: unable to open preload file '%s'\n";
 static const char WARN_BAD_LINE[] =
@@ -316,8 +310,7 @@
 	char *tmpdir;
 	struct stat ts;
 
-	if (!(dp = opendir(path))) {
-		bb_perror_msg(ERR_OPENING_DIR, path);
+	if (!(dp = bb_opendir(path))) {
 		retval = -1;
 	} else {
 		while ((de = readdir(dp)) != NULL) {




More information about the busybox-cvs mailing list