- char string_flags_buf[1024]="";
- char *string_flags = string_flags_buf;
- char *extra_opts = string_flags_buf;
- unsigned long flags = 0;
- char *filesystemType = "auto";
- char *device = NULL;
- char *directory = NULL;
- int all = FALSE;
- int fakeIt = FALSE;
- int useMtab = TRUE;
- int i;
-
- /* Only compiled in if BB_MTAB is not defined */
- whine_if_fstab_is_missing();
-
- if (argc == 1) {
- FILE *mountTable = setmntent (mtab_file, "r");
- if (mountTable) {
- struct mntent *m;
- while ((m = getmntent (mountTable)) != 0) {
- struct fstab* fstabItem;
- char *blockDevice = m->mnt_fsname;
- /* Note that if /etc/fstab is missing, libc can't fix up /dev/root for us */
- if (strcmp (blockDevice, "/dev/root") == 0) {
- fstabItem = getfsfile ("/");
- if (fstabItem != NULL)
- blockDevice = fstabItem->fs_spec;
+ 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 = EXIT_FAILURE;
+ 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)
+ perror_msg_and_die("open failed for `%s'", device);
+
+ /* How many mounted filesystems? We need to know to
+ * allocate enough space for later... */
+ numfilesystems = ioctl (fd, DEVMTAB_COUNT_MOUNTS);
+ if (numfilesystems<0)
+ perror_msg_and_die( "\nDEVMTAB_COUNT_MOUNTS");
+ mntentlist = (struct k_mntent *) xcalloc ( numfilesystems, sizeof(struct k_mntent));
+
+ /* Grab the list of mounted filesystems */
+ if (ioctl (fd, DEVMTAB_GET_MOUNTS, mntentlist)<0)
+ perror_msg_and_die( "\nDEVMTAB_GET_MOUNTS");
+
+ for( i = 0 ; i < numfilesystems ; i++) {
+ printf( "%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);