diff options
author | aldot <aldot@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-04-12 07:35:12 +0000 |
---|---|---|
committer | aldot <aldot@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-04-12 07:35:12 +0000 |
commit | 721e61dc4ddec000c9917f004b6c0a68ea40a565 (patch) | |
tree | 4459d66dd948b019c4a96730eea224f79520ad8c /libbb | |
parent | ab8d64334188e25031953f21fe92fb7839ffa806 (diff) | |
download | busybox-w32-721e61dc4ddec000c9917f004b6c0a68ea40a565.tar.gz busybox-w32-721e61dc4ddec000c9917f004b6c0a68ea40a565.tar.bz2 busybox-w32-721e61dc4ddec000c9917f004b6c0a68ea40a565.zip |
- 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
git-svn-id: svn://busybox.net/trunk/busybox@14830 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/Makefile.in | 10 | ||||
-rw-r--r-- | libbb/copy_file.c | 3 | ||||
-rw-r--r-- | libbb/opendir.c | 37 | ||||
-rw-r--r-- | libbb/procps.c | 4 | ||||
-rw-r--r-- | libbb/recursive_action.c | 17 | ||||
-rw-r--r-- | libbb/remove_file.c | 17 | ||||
-rw-r--r-- | libbb/run_parts.c | 9 |
7 files changed, 53 insertions, 44 deletions
diff --git a/libbb/Makefile.in b/libbb/Makefile.in index 2d9a1745d..de511fc9b 100644 --- a/libbb/Makefile.in +++ b/libbb/Makefile.in | |||
@@ -105,12 +105,18 @@ LIBBB_MOBJ6:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ6)) | |||
105 | $(LIBBB_MOBJ6):$(LIBBB_MSRC6) | 105 | $(LIBBB_MOBJ6):$(LIBBB_MSRC6) |
106 | $(compile.c) -DL_$(notdir $*) | 106 | $(compile.c) -DL_$(notdir $*) |
107 | 107 | ||
108 | LIBBB_MSRC7:=$(srcdir)/opendir.c | ||
109 | LIBBB_MOBJ7:=bb_opendir.o bb_xopendir.o | ||
110 | LIBBB_MOBJ7:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ7)) | ||
111 | $(LIBBB_MOBJ7):$(LIBBB_MSRC7) | ||
112 | $(compile.c) -DL_$(notdir $*) | ||
108 | 113 | ||
109 | # We need the names of the object files built from MSRC for the L_ defines | 114 | # We need the names of the object files built from MSRC for the L_ defines |
110 | LIBBB_ALL_MOBJ:=$(LIBBB_MOBJ0) $(LIBBB_MOBJ1) $(LIBBB_MOBJ2) $(LIBBB_MOBJ3) $(LIBBB_MOBJ4) $(LIBBB_MOBJ5) $(LIBBB_MOBJ6) | 115 | LIBBB_ALL_MOBJ:=$(LIBBB_MOBJ0) $(LIBBB_MOBJ1) $(LIBBB_MOBJ2) $(LIBBB_MOBJ3) \ |
116 | $(LIBBB_MOBJ4) $(LIBBB_MOBJ5) $(LIBBB_MOBJ6) $(LIBBB_MOBJ7) | ||
111 | 117 | ||
112 | LIBBB_ALL_MSRC:=$(LIBBB_MSRC0) $(LIBBB_MSRC1) $(LIBBB_MSRC2) $(LIBBB_MSRC3) \ | 118 | LIBBB_ALL_MSRC:=$(LIBBB_MSRC0) $(LIBBB_MSRC1) $(LIBBB_MSRC2) $(LIBBB_MSRC3) \ |
113 | $(LIBBB_MSRC4) $(LIBBB_MSRC5) $(LIBBB_MSRC6) | 119 | $(LIBBB_MSRC4) $(LIBBB_MSRC5) $(LIBBB_MSRC6) $(LIBBB_MSRC7) |
114 | 120 | ||
115 | LIBBB-y:=$(sort $(LIBBB-y) $(LIBBB_ALL_MSRC)) | 121 | LIBBB-y:=$(sort $(LIBBB-y) $(LIBBB_ALL_MSRC)) |
116 | 122 | ||
diff --git a/libbb/copy_file.c b/libbb/copy_file.c index 3b172ffe4..2f7514628 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) | |||
92 | } | 92 | } |
93 | 93 | ||
94 | /* Recursively copy files in SOURCE. */ | 94 | /* Recursively copy files in SOURCE. */ |
95 | if ((dp = opendir(source)) == NULL) { | 95 | if ((dp = bb_opendir(source)) == NULL) { |
96 | bb_perror_msg("unable to open directory `%s'", source); | ||
97 | status = -1; | 96 | status = -1; |
98 | goto preserve_status; | 97 | goto preserve_status; |
99 | } | 98 | } |
diff --git a/libbb/opendir.c b/libbb/opendir.c new file mode 100644 index 000000000..e284db0db --- /dev/null +++ b/libbb/opendir.c | |||
@@ -0,0 +1,37 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * wrapper for opendir() | ||
4 | * | ||
5 | * Copyright (C) 2006 Bernhard Fischer <busybox@busybox.net> | ||
6 | * | ||
7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | ||
8 | */ | ||
9 | |||
10 | #include <sys/types.h> | ||
11 | #include <dirent.h> | ||
12 | #include "libbb.h" | ||
13 | |||
14 | #ifdef L_bb_opendir | ||
15 | DIR *bb_opendir(const char *path) | ||
16 | { | ||
17 | DIR *dp; | ||
18 | |||
19 | if ((dp = opendir(path)) == NULL) { | ||
20 | bb_perror_msg("unable to open `%s'", path); | ||
21 | return NULL; | ||
22 | } | ||
23 | return dp; | ||
24 | } | ||
25 | #endif | ||
26 | |||
27 | #ifdef L_bb_xopendir | ||
28 | DIR *bb_xopendir(const char *path) | ||
29 | { | ||
30 | DIR *dp; | ||
31 | |||
32 | if ((dp = opendir(path)) == NULL) { | ||
33 | bb_perror_msg_and_die("unable to open `%s'", path); | ||
34 | } | ||
35 | return dp; | ||
36 | } | ||
37 | #endif | ||
diff --git a/libbb/procps.c b/libbb/procps.c index e73c0dc64..25f42ffc8 100644 --- a/libbb/procps.c +++ b/libbb/procps.c | |||
@@ -50,9 +50,7 @@ procps_status_t * procps_scan(int save_user_arg0) | |||
50 | struct stat sb; | 50 | struct stat sb; |
51 | 51 | ||
52 | if (!dir) { | 52 | if (!dir) { |
53 | dir = opendir("/proc"); | 53 | dir = bb_xopendir("/proc"); |
54 | if(!dir) | ||
55 | bb_error_msg_and_die("Can't open /proc"); | ||
56 | } | 54 | } |
57 | for(;;) { | 55 | for(;;) { |
58 | if((entry = readdir(dir)) == NULL) { | 56 | if((entry = readdir(dir)) == NULL) { |
diff --git a/libbb/recursive_action.c b/libbb/recursive_action.c index d27629829..6b005e22d 100644 --- a/libbb/recursive_action.c +++ b/libbb/recursive_action.c | |||
@@ -4,19 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> | 5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | 8 | */ |
21 | 9 | ||
22 | #include <stdio.h> | 10 | #include <stdio.h> |
@@ -94,9 +82,8 @@ int recursive_action(const char *fileName, | |||
94 | } else if (status == SKIP) | 82 | } else if (status == SKIP) |
95 | return TRUE; | 83 | return TRUE; |
96 | } | 84 | } |
97 | dir = opendir(fileName); | 85 | dir = bb_opendir(fileName); |
98 | if (!dir) { | 86 | if (!dir) { |
99 | bb_perror_msg("%s", fileName); | ||
100 | return FALSE; | 87 | return FALSE; |
101 | } | 88 | } |
102 | status = TRUE; | 89 | status = TRUE; |
diff --git a/libbb/remove_file.c b/libbb/remove_file.c index ee1aaa5cd..2fa6596ee 100644 --- a/libbb/remove_file.c +++ b/libbb/remove_file.c | |||
@@ -4,19 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (C) 2001 Matt Kraai <kraai@alumni.carnegiemellon.edu> | 5 | * Copyright (C) 2001 Matt Kraai <kraai@alumni.carnegiemellon.edu> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | 8 | */ |
21 | 9 | ||
22 | #include <stdio.h> | 10 | #include <stdio.h> |
@@ -71,8 +59,7 @@ int remove_file(const char *path, int flags) | |||
71 | return 0; | 59 | return 0; |
72 | } | 60 | } |
73 | 61 | ||
74 | if ((dp = opendir(path)) == NULL) { | 62 | if ((dp = bb_opendir(path)) == NULL) { |
75 | bb_perror_msg("unable to open `%s'", path); | ||
76 | return -1; | 63 | return -1; |
77 | } | 64 | } |
78 | 65 | ||
diff --git a/libbb/run_parts.c b/libbb/run_parts.c index 864460d0d..7bdae5b38 100644 --- a/libbb/run_parts.c +++ b/libbb/run_parts.c | |||
@@ -7,12 +7,7 @@ | |||
7 | * rewrite to vfork usage by | 7 | * rewrite to vfork usage by |
8 | * Copyright (C) 2002 by Vladimir Oleynik <dzo@simtreas.ru> | 8 | * Copyright (C) 2002 by Vladimir Oleynik <dzo@simtreas.ru> |
9 | * | 9 | * |
10 | * This program is free software; you can redistribute it and/or modify | 10 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * | ||
16 | */ | 11 | */ |
17 | 12 | ||
18 | 13 | ||
@@ -69,7 +64,7 @@ int run_parts(char **args, const unsigned char test_mode, char **env) | |||
69 | if (test_mode & 2) { | 64 | if (test_mode & 2) { |
70 | return(2); | 65 | return(2); |
71 | } | 66 | } |
72 | bb_perror_msg_and_die("failed to open directory %s", arg0); | 67 | bb_perror_msg_and_die("unable to open `%s'", arg0); |
73 | } | 68 | } |
74 | 69 | ||
75 | for (i = 0; i < entries; i++) { | 70 | for (i = 0; i < entries; i++) { |