man_MANS = fstab.5 mount.8 swapoff.8 swapon.8 umount.8 losetup.8
MNTHDRS = fstab.h linux_fs.h mount_mntent.h mount_constants.h my_dev_t.h \
- mount_paths.h lomount.h fsprobe.h \
- mount_guess_fstype.h realpath.h xmalloc.h \
+ mount_paths.h lomount.h fsprobe.h realpath.h xmalloc.h \
getusername.h loop.h sundries.h
mount_common = fstab.c sundries.c xmalloc.c realpath.c mount_mntent.c \
- getusername.c lomount.c $(MNTHDRS) ../lib/env.c
+ fsprobe.c getusername.c lomount.c $(MNTHDRS) ../lib/env.c
-mount_SOURCES = mount.c $(mount_common) ../lib/setproctitle.c \
- mount_guess_fstype.c
+mount_SOURCES = mount.c $(mount_common) ../lib/setproctitle.c
mount_CFLAGS = $(SUID_CFLAGS) $(AM_CFLAGS)
mount_LDFLAGS = $(SUID_LDFLAGS) $(AM_LDFLAGS)
-/*
- * Thu Jul 14 07:32:40 1994: faith@cs.unc.edu added changes from Adam
- * J. Richter (adam@adam.yggdrasil.com) so that /proc/filesystems is used
- * if no -t option is given. I modified his patches so that, if
- * /proc/filesystems is not available, the behavior of mount is the same as
- * it was previously.
- *
- * Wed Feb 8 09:23:18 1995: Mike Grupenhoff <kashmir@umiacs.UMD.EDU> added
- * a probe of the superblock for the type before /proc/filesystems is
- * checked.
- *
- * Fri Apr 5 01:13:33 1996: quinlan@bucknell.edu, fixed up iso9660 autodetect
- *
- * Wed Nov 11 11:33:55 1998: K.Garloff@ping.de, try /etc/filesystems before
- * /proc/filesystems
- * [This was mainly in order to specify vfat before fat; these days we often
- * detect *fat and then assume vfat, so perhaps /etc/filesystems isnt
- * so useful anymore.]
- *
- * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
- * added Native Language Support
- *
- * 2000-12-01 Sepp Wijnands <mrrazz@garbage-coderz.net>
- * added probes for cramfs, hfs, hpfs and adfs.
- *
- * 2001-10-26 Tim Launchbury
- * added sysv magic.
- *
- * aeb - many changes.
- *
- */
-
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include "mount_paths.h"
#include "linux_fs.h"
#include "fsprobe.h"
-#include "mount_guess_fstype.h"
#include "sundries.h" /* for xstrdup */
#include "nls.h"
-#define ETC_FILESYSTEMS "/etc/filesystems"
-#define PROC_FILESYSTEMS "/proc/filesystems"
-
-char *
-do_guess_fstype(const char *device)
-{
- return blkid_get_tag_value(blkid, "TYPE", device);
-}
-
-static int
-known_fstype(const char *fstype)
-{
- return blkid_known_fstype(fstype);
-}
-
-
+/* list of already tested filesystems by fsprobe_procfsloop_mount() */
static struct tried {
struct tried *next;
char *type;
was_tested(const char *fstype) {
struct tried *t;
- if (known_fstype(fstype))
+ if (fsprobe_known_fstype(fstype))
return 1;
for (t = tried; t; t = t->next) {
if (!strcmp(t->type, fstype))
tried = NULL;
}
-char *
-guess_fstype(const char *spec) {
- char *type = do_guess_fstype(spec);
- if (verbose) {
- printf (_("mount: you didn't specify a filesystem type for %s\n"),
- spec);
- if (!type)
- printf (_(" I will try all types mentioned in %s or %s\n"),
- ETC_FILESYSTEMS, PROC_FILESYSTEMS);
- else if (!strcmp(type, "swap"))
- printf (_(" and it looks like this is swapspace\n"));
- else
- printf (_(" I will try type %s\n"), type);
- }
- return type;
-}
-
static char *
procfsnext(FILE *procfs) {
char line[100];
the kernel knows about, so /etc/filesystems is irrelevant.
Return: 1: yes, 0: no, -1: cannot open procfs */
int
-is_in_procfs(const char *type) {
+fsprobe_known_fstype_in_procfs(const char *type)
+{
FILE *procfs;
char *fsname;
int ret = -1;
/* when 0 or -1 is returned, *types contains the type used */
/* when 1 is returned, *types is NULL */
int
-procfsloop(int (*mount_fn)(struct mountargs *), struct mountargs *args,
- const char **types) {
+fsprobe_procfsloop_mount( int (*mount_fn)(struct mountargs *),
+ struct mountargs *args,
+ const char **types)
+{
char *files[2] = { ETC_FILESYSTEMS, PROC_FILESYSTEMS };
FILE *procfs;
char *fsname;
ret = 0;
break;
} else if (errno != EINVAL &&
- is_in_procfs(fsname) == 1) {
+ fsprobe_known_fstype_in_procfs(fsname) == 1) {
*types = "guess";
ret = -1;
errsv = errno;
extern const char *mount_get_volume_label_by_spec(const char *spec);
extern const char *mount_get_devname(const char *spec);
extern const char *mount_get_devname_for_mounting(const char *spec);
+extern int fsprobe_known_fstype(const char *fstype);
+extern const char *fsprobe_get_fstype_by_devname(const char *devname);
+
+struct mountargs {
+ const char *spec;
+ const char *node;
+ const char *type;
+ int flags;
+ void *data;
+};
+
+extern int fsprobe_known_fstype_in_procfs(const char *type);
+
+extern int fsprobe_procfsloop_mount(int (*mount_fn)(struct mountargs *),
+ struct mountargs *args,
+ const char **types);
+
return blkid_get_devname(blkid, spec, 0);
}
+int
+fsprobe_known_fstype(const char *fstype)
+{
+ return blkid_known_fstype(fstype);
+}
+
+const char *
+fsprobe_get_fstype_by_devname(const char *devname) {
+ return blkid_get_tag_value(blkid, "TYPE", devname);
+}
+
#endif
#include "lomount.h"
#include "loop.h"
#include "linux_fs.h" /* for BLKGETSIZE */
-#include "mount_guess_fstype.h"
#include "getusername.h"
#include "mount_paths.h"
#include "env.h"
return 0;
}
+
+static const char *
+guess_fstype_by_devname(const char *devname)
+{
+ const char *type = fsprobe_get_fstype_by_devname(devname);
+
+ if (verbose) {
+ printf (_("mount: you didn't specify a filesystem type for %s\n"), devname);
+
+ if (!type)
+ printf (_(" I will try all types mentioned in %s or %s\n"),
+ ETC_FILESYSTEMS, PROC_FILESYSTEMS);
+ else if (!strcmp(type, "swap"))
+ printf (_(" and it looks like this is swapspace\n"));
+ else
+ printf (_(" I will try type %s\n"), type);
+ }
+ return type;
+}
+
/*
* guess_fstype_and_mount()
* Mount a single file system. Guess the type when unknown.
*types = "none"; /* random, but not "bind" */
if (!*types && !(flags & MS_REMOUNT)) {
- *types = guess_fstype(spec);
+ *types = guess_fstype_by_devname(spec);
if (*types) {
if (!strcmp(*types, "swap")) {
error(_("%s looks like swapspace - not mounted"), spec);
return do_mount_syscall (&args);
}
- return procfsloop(do_mount_syscall, &args, types);
+ return fsprobe_procfsloop_mount(do_mount_syscall, &args, types);
}
/*
case EIO:
error (_("mount: %s: can't read superblock"), spec); break;
case ENODEV:
- { int pfs;
- if ((pfs = is_in_procfs(types)) == 1 || !strcmp(types, "guess"))
+ {
+ int pfs = fsprobe_known_fstype_in_procfs(types);
+
+ if (pfs == 1 || !strcmp(types, "guess"))
error(_("mount: %s: unknown device"), spec);
else if (pfs == 0) {
char *lowtype, *p;
u++;
}
}
- if (u && is_in_procfs(lowtype) == 1)
+ if (u && fsprobe_known_fstype_in_procfs(lowtype) == 1)
error (_("mount: probably you meant %s"), lowtype);
- else if (!strncmp(lowtype, "iso", 3) && is_in_procfs("iso9660") == 1)
+ else if (!strncmp(lowtype, "iso", 3) &&
+ fsprobe_known_fstype_in_procfs("iso9660") == 1)
error (_("mount: maybe you meant 'iso9660'?"));
- else if (!strncmp(lowtype, "fat", 3) && is_in_procfs("vfat") == 1)
+ else if (!strncmp(lowtype, "fat", 3) &&
+ fsprobe_known_fstype_in_procfs("vfat") == 1)
error (_("mount: maybe you meant 'vfat'?"));
free(lowtype);
} else
use only for testing purposes -
the guessing is not reliable at all */
{
- char *fstype;
- fstype = do_guess_fstype(optarg);
+ const char *fstype;
+ fstype = fsprobe_get_fstype_by_devname(optarg);
printf("%s\n", fstype ? fstype : "unknown");
exit(fstype ? 0 : EX_FAIL);
}
+++ /dev/null
-struct mountargs {
- const char *spec;
- const char *node;
- const char *type;
- int flags;
- void *data;
-};
-
-extern int verbose;
-
-char *guess_fstype(const char *device);
-char *do_guess_fstype(const char *device);
-int procfsloop(int (*mount_fn)(struct mountargs *), struct mountargs *args,
- const char **type);
-int is_in_procfs(const char *fstype);
-
#endif
#define LOCK_TIMEOUT 10
+#define ETC_FILESYSTEMS "/etc/filesystems"
+#define PROC_FILESYSTEMS "/proc/filesystems"
+
#endif /* MOUNT_PATHS_H */