getfs_by_devdir (const char *dev, const char *dir) {
	struct mntentchn *mc, *mc0;

	mc0 = fstab_head();

	for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) {
		int ok = 1;

		/* dir */
		if (!streq(mc->m.mnt_dir, dir)) {
			char *dr = canonicalize(mc->m.mnt_dir);
			ok = streq(dr, dir);
			my_free(dr);
		}

		/* spec */
		if (ok && !streq(mc->m.mnt_fsname, dev)) {
			const char *fs = mc->m.mnt_fsname;

			if (strncmp (fs, "LABEL=", 6) == 0) {
				ok = has_label(dev, fs + 6);
			} else if (strncmp (fs, "UUID=", 5) == 0) {
				ok = has_uuid(dev, fs + 5);
			} else {
				fs = canonicalize_spec(mc->m.mnt_fsname);
				ok = streq(fs, dev);
				my_free(fs);
			}
		}
		if (ok)
			return mc;
	}

	return NULL;
}
getfs_by_devdir (const char *dev, const char *dir) {
	struct mntentchn *mc, *mc0;

	mc0 = fstab_head();

	for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) {
		int ok = 1;

		 
		if (!streq(mc->m.mnt_dir, dir)) {
			char *dr = canonicalize(mc->m.mnt_dir);
			ok = streq(dr, dir);
			my_free(dr);
		}

		 
		if (ok && !streq(mc->m.mnt_fsname, dev)) {
			const char *fs = mc->m.mnt_fsname;

			if (strncmp (fs, "LABEL=", 6) == 0) {
				ok = has_label(dev, fs + 6);
			} else if (strncmp (fs, "UUID=", 5) == 0) {
				ok = has_uuid(dev, fs + 5);
			} else {
				fs = canonicalize_spec(mc->m.mnt_fsname);
				ok = streq(fs, dev);
				my_free(fs);
			}
		}
		if (ok)
			return mc;
	}

	return NULL;
}