- char string_flags[1024]="";
- unsigned long flags = 0;
- char *filesystemType = "auto";
- char *device = NULL;
- char *directory = NULL;
- int all = 0;
- int i;
-
- if (argc == 1) {
- FILE *mountTable;
- if ((mountTable = setmntent ("/proc/mounts", "r"))) {
- struct mntent *m;
- while ((m = getmntent (mountTable)) != 0) {
- char *blockDevice = m->mnt_fsname;
- if (strcmp (blockDevice, "/dev/root") == 0)
- blockDevice = (getfsfile ("/"))->fs_spec;
- printf ("%s on %s type %s (%s)\n", blockDevice, m->mnt_dir,
- m->mnt_type, m->mnt_opts);
- }
- endmntent (mountTable);
- }
- return( TRUE);
- }
-
-
- /* Parse options */
- i = --argc;
- argv++;
- while (i > 0 && **argv) {
- if (**argv == '-') {
- while (i>0 && *++(*argv)) switch (**argv) {
- case 'o':
- if (--i == 0) {
- fprintf (stderr, "%s\n", mount_usage);
- return( FALSE);
- }
- parse_mount_options (*(++argv), &flags, string_flags);
- --i;
- ++argv;
- break;
- case 'r':
- flags |= MS_RDONLY;
- break;
- case 't':
- if (--i == 0) {
- fprintf (stderr, "%s\n", mount_usage);
- return( FALSE);
+ 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;
+
+#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 *) calloc ( 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);