diff options
Diffstat (limited to 'mount.c')
-rw-r--r-- | mount.c | 71 |
1 files changed, 0 insertions, 71 deletions
@@ -51,8 +51,6 @@ | |||
51 | #include <sys/ioctl.h> | 51 | #include <sys/ioctl.h> |
52 | #include <linux/loop.h> | 52 | #include <linux/loop.h> |
53 | 53 | ||
54 | static int set_loop(const char *device, const char *file, int offset, int *loopro); | ||
55 | static char *find_unused_loop_device (void); | ||
56 | 54 | ||
57 | static int use_loop = 0; | 55 | static int use_loop = 0; |
58 | #endif | 56 | #endif |
@@ -177,75 +175,6 @@ extern void whine_if_fstab_is_missing() | |||
177 | #endif | 175 | #endif |
178 | 176 | ||
179 | 177 | ||
180 | #if defined BB_FEATURE_MOUNT_LOOP | ||
181 | static int set_loop(const char *device, const char *file, int offset, int *loopro) | ||
182 | { | ||
183 | struct loop_info loopinfo; | ||
184 | int fd, ffd, mode; | ||
185 | |||
186 | mode = *loopro ? O_RDONLY : O_RDWR; | ||
187 | if ((ffd = open (file, mode)) < 0 && !*loopro | ||
188 | && (errno != EROFS || (ffd = open (file, mode = O_RDONLY)) < 0)) { | ||
189 | perror (file); | ||
190 | return 1; | ||
191 | } | ||
192 | if ((fd = open (device, mode)) < 0) { | ||
193 | close(ffd); | ||
194 | perror (device); | ||
195 | return 1; | ||
196 | } | ||
197 | *loopro = (mode == O_RDONLY); | ||
198 | |||
199 | memset(&loopinfo, 0, sizeof(loopinfo)); | ||
200 | strncpy(loopinfo.lo_name, file, LO_NAME_SIZE); | ||
201 | loopinfo.lo_name[LO_NAME_SIZE-1] = 0; | ||
202 | |||
203 | loopinfo.lo_offset = offset; | ||
204 | |||
205 | loopinfo.lo_encrypt_key_size = 0; | ||
206 | if (ioctl(fd, LOOP_SET_FD, ffd) < 0) { | ||
207 | perror("ioctl: LOOP_SET_FD"); | ||
208 | close(fd); | ||
209 | close(ffd); | ||
210 | return 1; | ||
211 | } | ||
212 | if (ioctl(fd, LOOP_SET_STATUS, &loopinfo) < 0) { | ||
213 | (void) ioctl(fd, LOOP_CLR_FD, 0); | ||
214 | perror("ioctl: LOOP_SET_STATUS"); | ||
215 | close(fd); | ||
216 | close(ffd); | ||
217 | return 1; | ||
218 | } | ||
219 | close(fd); | ||
220 | close(ffd); | ||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | char *find_unused_loop_device (void) | ||
225 | { | ||
226 | char dev[20]; | ||
227 | int i, fd; | ||
228 | struct stat statbuf; | ||
229 | struct loop_info loopinfo; | ||
230 | |||
231 | for(i = 0; i <= 7; i++) { | ||
232 | sprintf(dev, "/dev/loop%d", i); | ||
233 | if (stat (dev, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)) { | ||
234 | if ((fd = open (dev, O_RDONLY)) >= 0) { | ||
235 | if(ioctl (fd, LOOP_GET_STATUS, &loopinfo) == -1) { | ||
236 | if (errno == ENXIO) { /* probably free */ | ||
237 | close (fd); | ||
238 | return strdup(dev); | ||
239 | } | ||
240 | } | ||
241 | close (fd); | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | return NULL; | ||
246 | } | ||
247 | #endif /* BB_FEATURE_MOUNT_LOOP */ | ||
248 | |||
249 | /* Seperate standard mount options from the nonstandard string options */ | 178 | /* Seperate standard mount options from the nonstandard string options */ |
250 | static void | 179 | static void |
251 | parse_mount_options ( char *options, unsigned long *flags, char *strflags) | 180 | parse_mount_options ( char *options, unsigned long *flags, char *strflags) |