diff options
author | "Vladimir N. Oleynik" <dzo@simtreas.ru> | 2005-10-12 12:11:42 +0000 |
---|---|---|
committer | "Vladimir N. Oleynik" <dzo@simtreas.ru> | 2005-10-12 12:11:42 +0000 |
commit | ab57f76e13c00830fb8c3fe32dc210158abc5e91 (patch) | |
tree | f91ad789cad64c33d51c40981eca0e1dae1f259d /e2fsprogs/fsck.c | |
parent | 1c275de6a2b332d49355d02d3d8650aea33f1b87 (diff) | |
download | busybox-w32-ab57f76e13c00830fb8c3fe32dc210158abc5e91.tar.gz busybox-w32-ab57f76e13c00830fb8c3fe32dc210158abc5e91.tar.bz2 busybox-w32-ab57f76e13c00830fb8c3fe32dc210158abc5e91.zip |
more busyboxes, remove 1 extern function (mainstream also have for one fsck)
Diffstat (limited to 'e2fsprogs/fsck.c')
-rw-r--r-- | e2fsprogs/fsck.c | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/e2fsprogs/fsck.c b/e2fsprogs/fsck.c index 93514a391..ec0c38b0b 100644 --- a/e2fsprogs/fsck.c +++ b/e2fsprogs/fsck.c | |||
@@ -47,10 +47,147 @@ | |||
47 | 47 | ||
48 | #include "e2fsbb.h" | 48 | #include "e2fsbb.h" |
49 | 49 | ||
50 | #include "busybox.h" | ||
51 | |||
50 | #ifndef _PATH_MNTTAB | 52 | #ifndef _PATH_MNTTAB |
51 | #define _PATH_MNTTAB "/etc/fstab" | 53 | #define _PATH_MNTTAB "/etc/fstab" |
52 | #endif | 54 | #endif |
53 | 55 | ||
56 | /* | ||
57 | * base_device.c | ||
58 | * | ||
59 | * Return the "base device" given a particular device; this is used to | ||
60 | * assure that we only fsck one partition on a particular drive at any | ||
61 | * one time. Otherwise, the disk heads will be seeking all over the | ||
62 | * place. If the base device can not be determined, return NULL. | ||
63 | * | ||
64 | * The base_device() function returns an allocated string which must | ||
65 | * be freed. | ||
66 | * | ||
67 | */ | ||
68 | |||
69 | |||
70 | #ifdef CONFIG_FEATURE_DEVFS | ||
71 | /* | ||
72 | * Required for the uber-silly devfs /dev/ide/host1/bus2/target3/lun3 | ||
73 | * pathames. | ||
74 | */ | ||
75 | static const char *devfs_hier[] = { | ||
76 | "host", "bus", "target", "lun", 0 | ||
77 | }; | ||
78 | #endif | ||
79 | |||
80 | static char *base_device(const char *device) | ||
81 | { | ||
82 | char *str, *cp; | ||
83 | #ifdef CONFIG_FEATURE_DEVFS | ||
84 | const char **hier, *disk; | ||
85 | int len; | ||
86 | #endif | ||
87 | |||
88 | cp = str = bb_xstrdup(device); | ||
89 | |||
90 | /* Skip over /dev/; if it's not present, give up. */ | ||
91 | if (strncmp(cp, "/dev/", 5) != 0) | ||
92 | goto errout; | ||
93 | cp += 5; | ||
94 | |||
95 | #if 0 /* this is for old stuff no one uses anymore ? */ | ||
96 | /* Skip over /dev/dsk/... */ | ||
97 | if (strncmp(cp, "dsk/", 4) == 0) | ||
98 | cp += 4; | ||
99 | #endif | ||
100 | |||
101 | /* | ||
102 | * For md devices, we treat them all as if they were all | ||
103 | * on one disk, since we don't know how to parallelize them. | ||
104 | */ | ||
105 | if (cp[0] == 'm' && cp[1] == 'd') { | ||
106 | *(cp+2) = 0; | ||
107 | return str; | ||
108 | } | ||
109 | |||
110 | /* Handle DAC 960 devices */ | ||
111 | if (strncmp(cp, "rd/", 3) == 0) { | ||
112 | cp += 3; | ||
113 | if (cp[0] != 'c' || cp[2] != 'd' || | ||
114 | !isdigit(cp[1]) || !isdigit(cp[3])) | ||
115 | goto errout; | ||
116 | *(cp+4) = 0; | ||
117 | return str; | ||
118 | } | ||
119 | |||
120 | /* Now let's handle /dev/hd* and /dev/sd* devices.... */ | ||
121 | if ((cp[0] == 'h' || cp[0] == 's') && (cp[1] == 'd')) { | ||
122 | cp += 2; | ||
123 | /* If there's a single number after /dev/hd, skip it */ | ||
124 | if (isdigit(*cp)) | ||
125 | cp++; | ||
126 | /* What follows must be an alpha char, or give up */ | ||
127 | if (!isalpha(*cp)) | ||
128 | goto errout; | ||
129 | *(cp + 1) = 0; | ||
130 | return str; | ||
131 | } | ||
132 | |||
133 | #ifdef CONFIG_FEATURE_DEVFS | ||
134 | /* Now let's handle devfs (ugh) names */ | ||
135 | len = 0; | ||
136 | if (strncmp(cp, "ide/", 4) == 0) | ||
137 | len = 4; | ||
138 | if (strncmp(cp, "scsi/", 5) == 0) | ||
139 | len = 5; | ||
140 | if (len) { | ||
141 | cp += len; | ||
142 | /* | ||
143 | * Now we proceed down the expected devfs hierarchy. | ||
144 | * i.e., .../host1/bus2/target3/lun4/... | ||
145 | * If we don't find the expected token, followed by | ||
146 | * some number of digits at each level, abort. | ||
147 | */ | ||
148 | for (hier = devfs_hier; *hier; hier++) { | ||
149 | len = strlen(*hier); | ||
150 | if (strncmp(cp, *hier, len) != 0) | ||
151 | goto errout; | ||
152 | cp += len; | ||
153 | while (*cp != '/' && *cp != 0) { | ||
154 | if (!isdigit(*cp)) | ||
155 | goto errout; | ||
156 | cp++; | ||
157 | } | ||
158 | cp++; | ||
159 | } | ||
160 | *(cp - 1) = 0; | ||
161 | return str; | ||
162 | } | ||
163 | |||
164 | /* Now handle devfs /dev/disc or /dev/disk names */ | ||
165 | disk = 0; | ||
166 | if (strncmp(cp, "discs/", 6) == 0) | ||
167 | disk = "disc"; | ||
168 | else if (strncmp(cp, "disks/", 6) == 0) | ||
169 | disk = "disk"; | ||
170 | if (disk) { | ||
171 | cp += 6; | ||
172 | if (strncmp(cp, disk, 4) != 0) | ||
173 | goto errout; | ||
174 | cp += 4; | ||
175 | while (*cp != '/' && *cp != 0) { | ||
176 | if (!isdigit(*cp)) | ||
177 | goto errout; | ||
178 | cp++; | ||
179 | } | ||
180 | *cp = 0; | ||
181 | return str; | ||
182 | } | ||
183 | #endif | ||
184 | |||
185 | errout: | ||
186 | free(str); | ||
187 | return NULL; | ||
188 | } | ||
189 | |||
190 | |||
54 | static const char * const ignored_types[] = { | 191 | static const char * const ignored_types[] = { |
55 | "ignore", | 192 | "ignore", |
56 | "iso9660", | 193 | "iso9660", |