aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-06-01 21:47:15 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-06-01 21:47:15 +0000
commita95fa3cae0e63dd7d3bbe8672a81a0ffd5c4de67 (patch)
treec833c8f3a72637660af61b061b90d69d987fed25 /libbb
parent36bc4bcd564d935828df0cb4c8b88ab245fc3b69 (diff)
downloadbusybox-w32-a95fa3cae0e63dd7d3bbe8672a81a0ffd5c4de67.tar.gz
busybox-w32-a95fa3cae0e63dd7d3bbe8672a81a0ffd5c4de67.tar.bz2
busybox-w32-a95fa3cae0e63dd7d3bbe8672a81a0ffd5c4de67.zip
Vladimir's last_patch13, containing several bugfixes.
git-svn-id: svn://busybox.net/trunk/busybox@2779 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r--libbb/find_root_device.c67
-rw-r--r--libbb/interface.c45
-rw-r--r--libbb/libbb.h10
3 files changed, 71 insertions, 51 deletions
diff --git a/libbb/find_root_device.c b/libbb/find_root_device.c
index edfd7085a..f8f68464d 100644
--- a/libbb/find_root_device.c
+++ b/libbb/find_root_device.c
@@ -1,10 +1,9 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * Utility routines. 3 * Copyright (C) 2000,2001 by Lineo, inc.
4 * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
4 * 5 *
5 * Copyright (C) tons of folks. Tracking down who wrote what 6 * Patched by a bunch of people. Feel free to acknowledge your work.
6 * isn't something I'm going to worry about... If you wrote something
7 * here, please feel free to acknowledge your work.
8 * 7 *
9 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -20,9 +19,6 @@
20 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * 21 *
23 * Based in part on code from sash, Copyright (c) 1999 by David I. Bell
24 * Permission has been granted to redistribute this code under the GPL.
25 *
26 */ 22 */
27 23
28#include <stdio.h> 24#include <stdio.h>
@@ -38,45 +34,42 @@ extern char *find_real_root_device_name(const char* name)
38 DIR *dir; 34 DIR *dir;
39 struct dirent *entry; 35 struct dirent *entry;
40 struct stat statBuf, rootStat; 36 struct stat statBuf, rootStat;
41 char *fileName; 37 char *fileName = NULL;
42 dev_t dev; 38 dev_t dev;
43 39
44 if (stat("/", &rootStat) != 0) { 40 if (stat("/", &rootStat) != 0)
45 perror_msg("could not stat '/'"); 41 perror_msg("could not stat '/'");
46 return NULL; 42 else {
47 } 43 if ((dev = rootStat.st_rdev)==0)
48 if ((dev = rootStat.st_rdev)==0) dev=rootStat.st_dev; 44 dev=rootStat.st_dev;
49 45
50 dir = opendir("/dev"); 46 dir = opendir("/dev");
51 if (!dir) { 47 if (!dir)
52 perror_msg("could not open '/dev'"); 48 perror_msg("could not open '/dev'");
53 goto fallback; 49 else {
54 } 50 while((entry = readdir(dir)) != NULL) {
55 51
56 while((entry = readdir(dir)) != NULL) { 52 /* Must skip ".." since that is "/", and so we
53 * would get a false positive on ".." */
54 if (strcmp(entry->d_name, "..") == 0)
55 continue;
57 56
58 /* Must skip ".." since that is "/", and so we 57 fileName = concat_path_file("/dev", entry->d_name);
59 * would get a false positive on ".." */
60 if (strcmp(entry->d_name, "..") == 0)
61 continue;
62 58
63 fileName = concat_path_file("/dev/", entry->d_name); 59 /* Some char devices have the same dev_t as block
64 60 * devices, so make sure this is a block device */
65 /* Some char devices have the same dev_t as block 61 if (stat(fileName, &statBuf) == 0 &&
66 * devices, so make sure this is a block device */ 62 S_ISBLK(statBuf.st_mode)!=0 &&
67 if (stat(fileName, &statBuf) == 0 && 63 statBuf.st_rdev == dev)
68 S_ISBLK(statBuf.st_mode)!=0 && 64 break;
69 statBuf.st_rdev == dev) { 65 free(fileName);
70 return fileName; 66 fileName=NULL;
67 }
68 closedir(dir);
71 } 69 }
72 free(fileName);
73 } 70 }
74 closedir(dir); 71 if(fileName==NULL)
75 72 fileName=xstrdup("/dev/root");
76fallback:
77 /* don't use stack space, caller expects to free() result */
78 fileName=xmalloc(20);
79 sprintf(fileName,"(rdev %u)",(unsigned int) rootStat.st_rdev);
80 return fileName; 73 return fileName;
81} 74}
82 75
diff --git a/libbb/interface.c b/libbb/interface.c
index 1d36c13bb..8eb03a61c 100644
--- a/libbb/interface.c
+++ b/libbb/interface.c
@@ -3,7 +3,7 @@
3 * that either displays or sets the characteristics of 3 * that either displays or sets the characteristics of
4 * one or more of the system's networking interfaces. 4 * one or more of the system's networking interfaces.
5 * 5 *
6 * Version: $Id: interface.c,v 1.2 2001/05/05 03:19:12 bug1 Exp $ 6 * Version: $Id: interface.c,v 1.3 2001/06/01 21:47:15 andersen Exp $
7 * 7 *
8 * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> 8 * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
9 * and others. Copyright 1993 MicroWalt Corporation 9 * and others. Copyright 1993 MicroWalt Corporation
@@ -49,6 +49,7 @@
49#undef HAVE_AFNETROM 49#undef HAVE_AFNETROM
50#undef HAVE_AFX25 50#undef HAVE_AFX25
51#undef HAVE_AFECONET 51#undef HAVE_AFECONET
52#undef HAVE_AFASH
52 53
53/* 54/*
54 * 55 *
@@ -83,7 +84,7 @@
83#define _(x) x 84#define _(x) x
84#define _PATH_PROCNET_DEV "/proc/net/dev" 85#define _PATH_PROCNET_DEV "/proc/net/dev"
85#define new(p) ((p) = xcalloc(1,sizeof(*(p)))) 86#define new(p) ((p) = xcalloc(1,sizeof(*(p))))
86#define KRELEASE(maj,min,patch) ((maj) * 10000 + (min)*1000 + (patch)) 87#define KRELEASE(maj,min,patch) ((maj) * 65536 + (min)*256 + (patch))
87 88
88static int procnetdev_vsn = 1; 89static int procnetdev_vsn = 1;
89 90
@@ -174,15 +175,31 @@ static struct aftype *aftypes[];
174#ifdef KEEP_UNUSED 175#ifdef KEEP_UNUSED
175 176
176static int flag_unx; 177static int flag_unx;
178#ifdef HAVE_AFIPX
177static int flag_ipx; 179static int flag_ipx;
180#endif
181#ifdef HAVE_AFX25
178static int flag_ax25; 182static int flag_ax25;
183#endif
184#ifdef HAVE_AFATALK
179static int flag_ddp; 185static int flag_ddp;
186#endif
187#ifdef HAVE_AFNETROM
180static int flag_netrom; 188static int flag_netrom;
189#endif
181static int flag_inet; 190static int flag_inet;
191#ifdef HAVE_AFINET6
182static int flag_inet6; 192static int flag_inet6;
193#endif
194#ifdef HAVE_AFECONET
183static int flag_econet; 195static int flag_econet;
196#endif
197#ifdef HAVE_AFX25
184static int flag_x25 = 0; 198static int flag_x25 = 0;
199#endif
200#ifdef HAVE_AFASH
185static int flag_ash; 201static int flag_ash;
202#endif
186 203
187 204
188static struct aftrans_t { 205static struct aftrans_t {
@@ -191,48 +208,68 @@ static struct aftrans_t {
191 int *flag; 208 int *flag;
192} aftrans[] = { 209} aftrans[] = {
193 210
211#ifdef HAVE_AFX25
194 { 212 {
195 "ax25", "ax25", &flag_ax25 213 "ax25", "ax25", &flag_ax25
196 }, 214 },
215#endif
197 { 216 {
198 "ip", "inet", &flag_inet 217 "ip", "inet", &flag_inet
199 }, 218 },
219#ifdef HAVE_AFINET6
200 { 220 {
201 "ip6", "inet6", &flag_inet6 221 "ip6", "inet6", &flag_inet6
202 }, 222 },
223#endif
224#ifdef HAVE_AFIPX
203 { 225 {
204 "ipx", "ipx", &flag_ipx 226 "ipx", "ipx", &flag_ipx
205 }, 227 },
228#endif
229#ifdef HAVE_AFATALK
206 { 230 {
207 "appletalk", "ddp", &flag_ddp 231 "appletalk", "ddp", &flag_ddp
208 }, 232 },
233#endif
234#ifdef HAVE_AFNETROM
209 { 235 {
210 "netrom", "netrom", &flag_netrom 236 "netrom", "netrom", &flag_netrom
211 }, 237 },
238#endif
212 { 239 {
213 "inet", "inet", &flag_inet 240 "inet", "inet", &flag_inet
214 }, 241 },
242#ifdef HAVE_AFINET6
215 { 243 {
216 "inet6", "inet6", &flag_inet6 244 "inet6", "inet6", &flag_inet6
217 }, 245 },
246#endif
247#ifdef HAVE_AFATALK
218 { 248 {
219 "ddp", "ddp", &flag_ddp 249 "ddp", "ddp", &flag_ddp
220 }, 250 },
251#endif
221 { 252 {
222 "unix", "unix", &flag_unx 253 "unix", "unix", &flag_unx
223 }, 254 },
224 { 255 {
225 "tcpip", "inet", &flag_inet 256 "tcpip", "inet", &flag_inet
226 }, 257 },
258#ifdef HAVE_AFECONET
227 { 259 {
228 "econet", "ec", &flag_econet 260 "econet", "ec", &flag_econet
229 }, 261 },
262#endif
263#ifdef HAVE_AFX25
230 { 264 {
231 "x25", "x25", &flag_x25 265 "x25", "x25", &flag_x25
232 }, 266 },
267#endif
268#ifdef HAVE_AFASH
233 { 269 {
234 "ash", "ash", &flag_ash 270 "ash", "ash", &flag_ash
235 }, 271 },
272#endif
236 { 273 {
237 0, 0, 0 274 0, 0, 0
238 } 275 }
@@ -694,7 +731,7 @@ static int aftrans_opt(const char *arg)
694 731
695 while (tmp1) { 732 while (tmp1) {
696 733
697 tmp2 = index(tmp1, ','); 734 tmp2 = strchr(tmp1, ',');
698 735
699 if (tmp2) 736 if (tmp2)
700 *(tmp2++) = '\0'; 737 *(tmp2++) = '\0';
@@ -777,7 +814,7 @@ static struct aftype *get_aftype(const char *name)
777 return (*afp); 814 return (*afp);
778 afp++; 815 afp++;
779 } 816 }
780 if (index(name, ',')) 817 if (strchr(name, ','))
781 fprintf(stderr, _("Please don't supply more than one address family.\n")); 818 fprintf(stderr, _("Please don't supply more than one address family.\n"));
782 return (NULL); 819 return (NULL);
783} 820}
diff --git a/libbb/libbb.h b/libbb/libbb.h
index 4e324bf86..31bd97f2e 100644
--- a/libbb/libbb.h
+++ b/libbb/libbb.h
@@ -92,16 +92,6 @@ const char *time_string(time_t timeVal);
92int is_directory(const char *name, int followLinks, struct stat *statBuf); 92int is_directory(const char *name, int followLinks, struct stat *statBuf);
93int isDevice(const char *name); 93int isDevice(const char *name);
94 94
95typedef struct ino_dev_hash_bucket_struct {
96 struct ino_dev_hash_bucket_struct *next;
97 ino_t ino;
98 dev_t dev;
99 char name[1];
100} ino_dev_hashtable_bucket_t;
101int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name);
102void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
103void reset_ino_dev_hashtable(void);
104
105int remove_file(const char *path, int flags); 95int remove_file(const char *path, int flags);
106int copy_file(const char *source, const char *dest, int flags); 96int copy_file(const char *source, const char *dest, int flags);
107int copy_file_chunk(FILE *src_file, FILE *dst_file, unsigned long long chunksize); 97int copy_file_chunk(FILE *src_file, FILE *dst_file, unsigned long long chunksize);