return ret;
}
-/* Find the entry (SPEC,FILE) in fstab */
+/* Find the entry (SPEC,DIR) in fstab */
struct mntentchn *
-getfsspecfile (const char *spec, const char *file) {
+getfs_by_specdir (const char *spec, const char *dir) {
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) &&
+ if (streq(mc->m.mnt_dir, dir) &&
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))
+ if ((streq(mc->m.mnt_dir, dir) ||
+ streq(canonicalize(mc->m.mnt_dir), dir))
&& (streq(mc->m.mnt_fsname, spec) ||
- streq(canonicalize(mc->m.mnt_fsname), spec)))
+ streq(canonicalize(mc->m.mnt_fsname), dir)))
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))) {
+ (streq(mc->m.mnt_dir, dir) ||
+ streq(canonicalize(mc->m.mnt_dir), dir))) {
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))) {
+ (streq(mc->m.mnt_dir, dir) ||
+ streq(canonicalize(mc->m.mnt_dir), dir))) {
if (has_uuid(spec, mc->m.mnt_fsname+5))
return mc;
}
return NULL;
}
-/* Find the dir FILE in fstab. */
+/* Find the dir DIR in fstab. */
struct mntentchn *
-getfsfile (const char *file) {
+getfs_by_dir (const char *dir) {
struct mntentchn *mc, *mc0;
mc0 = fstab_head();
for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt)
- if (streq(mc->m.mnt_dir, file))
+ if (streq(mc->m.mnt_dir, dir))
return mc;
return NULL;
}
/* Find the device SPEC in fstab. */
struct mntentchn *
-getfsspec (const char *spec) {
+getfs_by_spec (const char *spec) {
+ return getfs_by_devname(spec);
+}
+
+/* Find the device in fstab. */
+struct mntentchn *
+getfs_by_devname (const char *devname) {
struct mntentchn *mc, *mc0;
mc0 = fstab_head();
for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt)
- if (streq(mc->m.mnt_fsname, spec))
+ if (streq(mc->m.mnt_fsname, devname))
return mc;
return NULL;
}
+
/* Find the uuid UUID in fstab. */
struct mntentchn *
-getfsuuidspec (const char *uuid) {
+getfs_by_uuid (const char *uuid) {
struct mntentchn *mc, *mc0;
mc0 = fstab_head();
/* Find the label LABEL in fstab. */
struct mntentchn *
-getfsvolspec (const char *label) {
+getfs_by_label (const char *label) {
struct mntentchn *mc, *mc0;
mc0 = fstab_head();
+#ifndef MOUNT_FSTAB_H
+#define MOUNT_FSTAB_H
+
#include "mount_mntent.h"
int mtab_is_writable(void);
int mtab_does_not_exist(void);
struct mntentchn *getmntdevbackward (const char *dev, struct mntentchn *mc);
struct mntentchn *fstab_head (void);
-struct mntentchn *getfsfile (const char *file);
-struct mntentchn *getfsspec (const char *spec);
-struct mntentchn *getfsspecfile (const char *spec, const char *file);
-struct mntentchn *getfsuuidspec (const char *uuid);
-struct mntentchn *getfsvolspec (const char *label);
+struct mntentchn *getfs_by_dir (const char *dir);
+struct mntentchn *getfs_by_spec (const char *spec);
+struct mntentchn *getfs_by_devname (const char *devname);
+struct mntentchn *getfs_by_specdir (const char *spec, const char *dir);
+struct mntentchn *getfs_by_uuid (const char *uuid);
+struct mntentchn *getfs_by_label (const char *label);
void lock_mtab (void);
void unlock_mtab (void);
void update_mtab (const char *special, struct my_mntent *with);
+
+#endif /* MOUNT_FSTAB_H */
}
/* Find the root entry by looking it up in fstab */
- if ((fstab = getfsfile ("/")) || (fstab = getfsfile ("root"))) {
+ if ((fstab = getfs_by_dir ("/")) || (fstab = getfs_by_dir ("root"))) {
char *extra_opts;
parse_opts (fstab->m.mnt_opts, &flags, &extra_opts);
mnt.mnt_dir = "/";
usage (stderr, EX_USAGE);
if (specseen) {
/* We know the device. Where shall we mount it? */
- mc = (uuid ? getfsuuidspec (uuid)
- : getfsvolspec (volumelabel));
+ mc = (uuid ? getfs_by_uuid (uuid)
+ : getfs_by_label (volumelabel));
if (mc == NULL)
- mc = getfsspec (spec);
+ mc = getfs_by_spec (spec);
if (mc == NULL)
die (EX_USAGE,
_("mount: cannot find %s in %s"),
} else {
/* Try to find the other pathname in fstab. */
spec = canonicalize (*argv);
- if ((mc = getfsspec (spec)) == NULL &&
- (mc = getfsfile (spec)) == NULL &&
+ if ((mc = getfs_by_spec (spec)) == NULL &&
+ (mc = getfs_by_dir (spec)) == NULL &&
/* Try noncanonical name in fstab
perhaps /dev/cdrom or /dos is a symlink */
- (mc = getfsspec (*argv)) == NULL &&
- (mc = getfsfile (*argv)) == NULL &&
+ (mc = getfs_by_spec (*argv)) == NULL &&
+ (mc = getfs_by_dir (*argv)) == NULL &&
/* Try mtab - maybe this was a remount */
(mc = getmntfile (spec)) == NULL)
die (EX_USAGE,