diff options
| author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-03-01 07:50:04 +0000 |
|---|---|---|
| committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-03-01 07:50:04 +0000 |
| commit | fb1b47533947ce20746168c231e34e01334e5d01 (patch) | |
| tree | b07ee09c54df47e3809f6433ee2cf24eb3abe5d5 /util-linux | |
| parent | 778dff541991d12b740084b5c20c2651c8061766 (diff) | |
| download | busybox-w32-fb1b47533947ce20746168c231e34e01334e5d01.tar.gz busybox-w32-fb1b47533947ce20746168c231e34e01334e5d01.tar.bz2 busybox-w32-fb1b47533947ce20746168c231e34e01334e5d01.zip | |
Reduce the size of mount (and bypass /proc/filesystems) by using the sysfs
system call, based on work done by Glenn McGrath in December.
-Erik
git-svn-id: svn://busybox.net/trunk/busybox@1947 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'util-linux')
| -rw-r--r-- | util-linux/mount.c | 75 |
1 files changed, 14 insertions, 61 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c index 76cab7d79..2353a8ac2 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
| @@ -83,6 +83,7 @@ extern int mount (__const char *__special_file, __const char *__dir, | |||
| 83 | __const void *__data); | 83 | __const void *__data); |
| 84 | extern int umount (__const char *__special_file); | 84 | extern int umount (__const char *__special_file); |
| 85 | extern int umount2 (__const char *__special_file, int __flags); | 85 | extern int umount2 (__const char *__special_file, int __flags); |
| 86 | static _syscall3(int, sysfs, int, option, unsigned int, fs_index, char *, buf); | ||
| 86 | 87 | ||
| 87 | 88 | ||
| 88 | extern const char mtab_file[]; /* Defined in utility.c */ | 89 | extern const char mtab_file[]; /* Defined in utility.c */ |
| @@ -233,72 +234,24 @@ mount_one(char *blockDevice, char *directory, char *filesystemType, | |||
| 233 | { | 234 | { |
| 234 | int status = 0; | 235 | int status = 0; |
| 235 | 236 | ||
| 236 | char buf[255]; | ||
| 237 | if (strcmp(filesystemType, "auto") == 0) { | 237 | if (strcmp(filesystemType, "auto") == 0) { |
| 238 | FILE *f = xfopen("/proc/filesystems", "r"); | 238 | int i=0; |
| 239 | 239 | const int num_of_filesystems = sysfs(3, 0, 0); | |
| 240 | while (fgets(buf, sizeof(buf), f) != NULL) { | 240 | char buf[255]; |
| 241 | filesystemType = buf; | 241 | filesystemType=buf; |
| 242 | if (*filesystemType == '\t') { // Not a nodev filesystem | 242 | |
| 243 | 243 | while(i < num_of_filesystems) { | |
| 244 | // Add NULL termination to each line | 244 | sysfs(2, i++, filesystemType); |
| 245 | while (*filesystemType && *filesystemType != '\n') | 245 | status = do_mount(blockDevice, directory, filesystemType, |
| 246 | filesystemType++; | 246 | flags | MS_MGC_VAL, string_flags, |
| 247 | *filesystemType = '\0'; | 247 | useMtab, fakeIt, mtab_opts); |
| 248 | |||
| 249 | filesystemType = buf; | ||
| 250 | filesystemType++; // hop past tab | ||
| 251 | |||
| 252 | status = do_mount(blockDevice, directory, filesystemType, | ||
| 253 | flags | MS_MGC_VAL, string_flags, | ||
| 254 | useMtab, fakeIt, mtab_opts); | ||
| 255 | if (status == TRUE) | ||
| 256 | break; | ||
| 257 | } | ||
| 258 | } | ||
| 259 | fclose(f); | ||
| 260 | } else | ||
| 261 | #if defined BB_FEATURE_USE_DEVPS_PATCH | ||
| 262 | if (strcmp(filesystemType, "auto") == 0) { | ||
| 263 | int fd, i, numfilesystems; | ||
| 264 | char device[] = "/dev/mtab"; | ||
| 265 | struct k_fstype *fslist; | ||
| 266 | |||
| 267 | /* open device */ | ||
| 268 | fd = open(device, O_RDONLY); | ||
| 269 | if (fd < 0) | ||
| 270 | perror_msg_and_die("open failed for `%s'", device); | ||
| 271 | |||
| 272 | /* How many filesystems? We need to know to allocate enough space */ | ||
| 273 | numfilesystems = ioctl (fd, DEVMTAB_COUNT_FILESYSTEMS); | ||
| 274 | if (numfilesystems<0) | ||
| 275 | perror_msg_and_die("\nDEVMTAB_COUNT_FILESYSTEMS"); | ||
| 276 | fslist = (struct k_fstype *) xcalloc ( numfilesystems, sizeof(struct k_fstype)); | ||
| 277 | |||
| 278 | /* Grab the list of available filesystems */ | ||
| 279 | status = ioctl (fd, DEVMTAB_GET_FILESYSTEMS, fslist); | ||
| 280 | if (status<0) | ||
| 281 | perror_msg_and_die("\nDEVMTAB_GET_FILESYSTEMS"); | ||
| 282 | |||
| 283 | /* Walk the list trying to mount filesystems | ||
| 284 | * that do not claim to be nodev filesystems */ | ||
| 285 | for( i = 0 ; i < numfilesystems ; i++) { | ||
| 286 | if (fslist[i].mnt_nodev) | ||
| 287 | continue; | ||
| 288 | status = do_mount(blockDevice, directory, fslist[i].mnt_type, | ||
| 289 | flags | MS_MGC_VAL, string_flags, | ||
| 290 | useMtab, fakeIt, mtab_opts); | ||
| 291 | if (status == TRUE) | 248 | if (status == TRUE) |
| 292 | break; | 249 | break; |
| 293 | } | 250 | } |
| 294 | free( fslist); | 251 | } else { |
| 295 | close(fd); | ||
| 296 | } else | ||
| 297 | #endif | ||
| 298 | { | ||
| 299 | status = do_mount(blockDevice, directory, filesystemType, | 252 | status = do_mount(blockDevice, directory, filesystemType, |
| 300 | flags | MS_MGC_VAL, string_flags, useMtab, | 253 | flags | MS_MGC_VAL, string_flags, useMtab, |
| 301 | fakeIt, mtab_opts); | 254 | fakeIt, mtab_opts); |
| 302 | } | 255 | } |
| 303 | 256 | ||
| 304 | if (status == FALSE) { | 257 | if (status == FALSE) { |
