- char string_flags_buf[1024] = "";
- char *string_flags = string_flags_buf;
- char *extra_opts = string_flags_buf;
- int flags = 0;
- char *filesystemType = "auto";
- char *device = NULL;
- char *directory = NULL;
- int all = FALSE;
- int fakeIt = FALSE;
- int useMtab = TRUE;
- int i;
- int rc = FALSE;
- int fstabmount = FALSE;
-
-#if defined BB_FEATURE_USE_DEVPS_PATCH
- if (argc == 1) {
- int fd, i, numfilesystems;
- char device[] = "/dev/mtab";
- struct k_mntent *mntentlist;
-
- /* open device */
- fd = open(device, O_RDONLY);
- if (fd < 0)
- fatalError("open failed for `%s': %s\n", device, strerror (errno));
-
- /* How many mounted filesystems? We need to know to
- * allocate enough space for later... */
- numfilesystems = ioctl (fd, DEVMTAB_COUNT_MOUNTS);
- if (numfilesystems<0)
- fatalError( "\nDEVMTAB_COUNT_MOUNTS: %s\n", strerror (errno));
- mntentlist = (struct k_mntent *) xcalloc ( numfilesystems, sizeof(struct k_mntent));
-
- /* Grab the list of mounted filesystems */
- if (ioctl (fd, DEVMTAB_GET_MOUNTS, mntentlist)<0)
- fatalError( "\nDEVMTAB_GET_MOUNTS: %s\n", strerror (errno));
-
- for( i = 0 ; i < numfilesystems ; i++) {
- fprintf( stdout, "%s %s %s %s %d %d\n", mntentlist[i].mnt_fsname,
- mntentlist[i].mnt_dir, mntentlist[i].mnt_type,
- mntentlist[i].mnt_opts, mntentlist[i].mnt_freq,
- mntentlist[i].mnt_passno);
- }
-#ifdef BB_FEATURE_CLEAN_UP
- /* Don't bother to close files or free memory. Exit
- * does that automagically, so we can save a few bytes */
- free( mntentlist);
- close(fd);
-#endif
- exit(TRUE);
+ char *cmdopts = xstrdup(""), *fstabname, *fstype=0, *storage_path=0;
+ FILE *fstab;
+ int i, opt, all = FALSE, rc = 0;
+ struct mntent mtpair[2], *mtcur = mtpair;
+
+ /* parse long options, like --bind and --move. Note that -o option
+ * and --option are synonymous. Yes, this means --remount,rw works. */
+
+ for (i = opt = 0; i < argc; i++) {
+ if (argv[i][0] == '-' && argv[i][1] == '-') {
+ append_mount_options(&cmdopts,argv[i]+2);
+ } else argv[opt++] = argv[i];