/* Find the device SPEC in fstab. */ struct mntentchn * getfsspec (const char *spec) { struct mntentchn *mc, *mc0; mc0 = fstab_head(); for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) if (streq(mc->m.mnt_fsname, spec)) return mc; return NULL; }
/* Find the dir FILE in fstab. */ struct mntentchn * getfsfile (const char *file) { struct mntentchn *mc, *mc0; mc0 = fstab_head(); for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) if (streq(mc->m.mnt_dir, file)) return mc; return NULL; }
/* Find the device SPEC in fstab. */ struct mntentchn *getfsspec(const char *spec) { struct mntentchn *mc; for (mc = fstab_head()->nxt; mc; mc = mc->nxt) if (streq(mc->mnt_fsname, spec)) break; return mc; }
/* Find the dir FILE in fstab. */ struct mntentchn *getfsfile(const char *file) { struct mntentchn *mc; for (mc = fstab_head()->nxt; mc; mc = mc->nxt) if (streq(mc->mnt_dir, file)) break; return mc; }
/* Find the label LABEL in fstab. */ struct mntentchn * getfsvolspec (const char *label) { struct mntentchn *mc, *mc0; mc0 = fstab_head(); for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) if (strncmp (mc->m.mnt_fsname, "LABEL=", 6) == 0 && streq(mc->m.mnt_fsname + 6, label)) return mc; return NULL; }
/* Find the uuid UUID in fstab. */ struct mntentchn * getfsuuidspec (const char *uuid) { struct mntentchn *mc, *mc0; mc0 = fstab_head(); for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) if (strncmp (mc->m.mnt_fsname, "UUID=", 5) == 0 && streq(mc->m.mnt_fsname + 5, uuid)) return mc; return NULL; }
/* Find the entry (SPEC,FILE) in fstab */ struct mntentchn * getfsspecfile (const char *spec, const char *file) { struct mntentchn *mc, *mc0; mc0 = fstab_head(); /* first attempt: names occur precisely as given */ for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) if (streq(mc->m.mnt_dir, file) && streq(mc->m.mnt_fsname, spec)) return mc; /* second attempt: names found after symlink resolution */ for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) if ((streq(mc->m.mnt_dir, file) || streq(canonicalize(mc->m.mnt_dir), file)) && (streq(mc->m.mnt_fsname, spec) || streq(canonicalize(mc->m.mnt_fsname), spec))) return mc; /* third attempt: names found after LABEL= or UUID= resolution */ for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) { if (!strncmp (mc->m.mnt_fsname, "LABEL=", 6) && (streq(mc->m.mnt_dir, file) || streq(canonicalize(mc->m.mnt_dir), file))) { if (has_label(spec, mc->m.mnt_fsname+6)) return mc; } if (!strncmp (mc->m.mnt_fsname, "UUID=", 5) && (streq(mc->m.mnt_dir, file) || streq(canonicalize(mc->m.mnt_dir), file))) { if (has_uuid(spec, mc->m.mnt_fsname+5)) return mc; } } return NULL; }