- if (strlen(fs->fs_file) > 1 && fs->fs_file[strlen(fs->fs_file) - 1] == '/')
- fs->fs_file[strlen(fs->fs_file) - 1] = '\0';
- if ((new->fs_file = strdup(fs->fs_file)) == NULL ||
- (new->fs_type = strdup(fs->fs_type)) == NULL ||
- (new->fs_vfstype = strdup(fs->fs_vfstype)) == NULL ||
- (new->fs_spec = strdup(fs->fs_spec)) == NULL)
+
+ /* Translade UUID=, LABEL= ... */
+ disk = get_device_name(fs->mnt_fsname);
+ if (disk == NULL)
+ disk = strdup(fs->mnt_fsname);
+
+ /* Discard non block devices */
+ if (stat(disk, &buf) != 0 || !S_ISBLK(buf.st_mode)) {
+ free(new);
+ return NULL;
+ }
+
+ /* Discard same major/minor devices */
+ for (tabpf = table; tabpf != NULL; tabpf = tabpf->pf_next) {
+ tabfs = tabpf->pf_mntent;
+ if (stat(tabfs->mnt_fsname, &tabbuf) != 0)
+ /* should not happen */
+ quit("Cannot access %s\n", tabfs->mnt_fsname);
+ if (tabbuf.st_rdev == buf.st_rdev) {
+ free(new);
+ /* Copy passno and freq from /etc/fstab because
+ * /etc/mtab does always have them as 0 0 */
+ if (!tabfs->mnt_passno)
+ tabfs->mnt_passno = fs->mnt_passno;
+ if (!tabfs->mnt_freq)
+ tabfs->mnt_freq = fs->mnt_freq;
+ return NULL;
+ }
+ }
+
+ if (strlen(fs->mnt_dir) > 1 && fs->mnt_dir[strlen(fs->mnt_dir) - 1] == '/')
+ fs->mnt_dir[strlen(fs->mnt_dir) - 1] = '\0';
+ if ((new->mnt_dir = strdup(fs->mnt_dir)) == NULL ||
+ (new->mnt_type = strdup(fs->mnt_type)) == NULL ||
+ (new->mnt_opts = strdup(fs->mnt_opts)) == NULL ||
+ (new->mnt_fsname = strdup(disk)) == NULL)