[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 44/70: mount: handle -t auto
From: |
Samuel Thibault |
Subject: |
[hurd] 44/70: mount: handle -t auto |
Date: |
Mon, 16 Sep 2013 07:41:42 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 96f54b8bc892bc6feee6b9a3878b23e8dcbb2004
Author: Justus Winter <address@hidden>
Date: Mon Sep 2 10:55:24 2013 +0200
mount: handle -t auto
Use libblkid to detect the filesystem type if "auto" is given as
type. Remove the translator localization from main, this is also done
in do_mount and any errors are propagated properly. This way "auto" is
handled correctly if given on the command line or used as filesystem
type in the fstab.
* configure.ac: Add check for libblkid.
* config.make.in: Make libblkid specific values available.
* utils/Makefile: Use libblkid specific values.
* utils/mount.c (DEFAULT_FSTYPE): Use "auto" as default type.
(do_mount): Detect type using libblkid.
(main): Drop translator localization.
---
config.make.in | 5 +++++
configure.ac | 6 ++++++
utils/Makefile | 2 ++
utils/mount.c | 35 +++++++++++++++++++++++++++--------
4 files changed, 40 insertions(+), 8 deletions(-)
diff --git a/config.make.in b/config.make.in
index edb74c0..4d2abcc 100644
--- a/config.make.in
+++ b/config.make.in
@@ -85,6 +85,11 @@ HAVE_DAEMON = @HAVE_DAEMON@
libdaemon_CFLAGS = @libdaemon_CFLAGS@
libdaemon_LIBS = @libdaemon_LIBS@
+# How to compile and link against libblkid.
+HAVE_BLKID = @HAVE_BLKID@
+libblkid_CFLAGS = @libblkid_CFLAGS@
+libblkid_LIBS = @libblkid_LIBS@
+
# Whether Sun RPC support is available.
HAVE_SUN_RPC = @HAVE_SUN_RPC@
diff --git a/configure.ac b/configure.ac
index d40c01f..5340b50 100644
--- a/configure.ac
+++ b/configure.ac
@@ -303,6 +303,12 @@ PKG_CHECK_MODULES([libdaemon], [libdaemon],
AC_SUBST([libdaemon_LIBS])
AC_SUBST([libdaemon_CFLAGS])
+PKG_CHECK_MODULES([libblkid], [blkid],
+ [AC_DEFINE([HAVE_BLKID], [1], [Use libblkid])],
+ [true])
+AC_SUBST([libblkid_LIBS])
+AC_SUBST([libblkid_CFLAGS])
+
AC_CONFIG_FILES([config.make ${makefiles}])
AC_OUTPUT
diff --git a/utils/Makefile b/utils/Makefile
index 8e8591f..acc8a70 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -39,6 +39,8 @@ LDLIBS += -lpthread
login-LDLIBS = -lutil $(LIBCRYPT)
addauth-LDLIBS = $(LIBCRYPT)
setauth-LDLIBS = $(LIBCRYPT)
+mount-LDLIBS = $(libblkid-LIBS)
+mount-CPPFLAGS = $(libblkid-CFLAGS)
INSTALL-login-ops = -o root -m 4755
INSTALL-ids-ops = -o root -m 4755
diff --git a/utils/mount.c b/utils/mount.c
index 77b2138..04519da 100644
--- a/utils/mount.c
+++ b/utils/mount.c
@@ -28,11 +28,14 @@
#include <hurd/fsys.h>
#include <hurd/fshelp.h>
#include <hurd/paths.h>
+#ifdef HAVE_BLKID
+#include <blkid/blkid.h>
+#endif
#include "match-options.h"
#define SEARCH_FMTS _HURD "%sfs\0" _HURD "%s"
-#define DEFAULT_FSTYPE "ext2"
+#define DEFAULT_FSTYPE "auto"
static char *fstype = DEFAULT_FSTYPE;
static char *device, *mountpoint;
@@ -338,6 +341,29 @@ do_mount (struct fs *fs, int remount)
return EBUSY;
}
+ if (strcmp (fs->mntent.mnt_type, "auto") == 0)
+ {
+#if HAVE_BLKID
+ char *type =
+ blkid_get_tag_value (NULL, "TYPE", fs->mntent.mnt_fsname);
+ if (! type)
+ {
+ error (0, 0, "failed to detect file system type");
+ return EFTYPE;
+ }
+ else
+ {
+ fs->mntent.mnt_type = strdup (type);
+ if (! fs->mntent.mnt_type)
+ error (3, ENOMEM, "failed to allocate memory");
+ }
+#else
+ fs->mntent.mnt_type = strdup ("ext2");
+ if (! fs->mntent.mnt_type)
+ error (3, ENOMEM, "failed to allocate memory");
+#endif
+ }
+
err = fs_type (fs, &type);
if (err)
{
@@ -579,13 +605,6 @@ main (int argc, char **argv)
mnt_opts: 0,
mnt_freq: 0, mnt_passno: 0
};
- struct fstype *fst;
-
- err = fstypes_get (fstab->types, fstype, &fst);
- if (err)
- error (106, err, "cannot initialize type %s", fstype);
- if (fst->program == 0)
- error (2, 0, "filesystem type %s not recognized", fstype);
err = fstab_add_mntent (fstab, &m, &fs);
if (err)
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 54/70: libfshelp: add translator-list.c, (continued)
- [hurd] 54/70: libfshelp: add translator-list.c, Samuel Thibault, 2013/09/16
- [hurd] 70/70: Merge remote-tracking branch 'upstream/master' into upstream, Samuel Thibault, 2013/09/16
- [hurd] 53/70: libnetfs: track file name in struct peropen, Samuel Thibault, 2013/09/16
- [hurd] 48/70: exec: keep track of the range where executable segments are mapped, Samuel Thibault, 2013/09/16
- [hurd] 64/70: hurd: add fsys_get_source, Samuel Thibault, 2013/09/16
- [hurd] 59/70: hurd: add fsys_get_children, Samuel Thibault, 2013/09/16
- [hurd] 68/70: Handle notification on page eviction, Samuel Thibault, 2013/09/16
- [hurd] 65/70: trans: add mtab translator, Samuel Thibault, 2013/09/16
- [hurd] 49/70: proc: remove unused file exc-reply.defs, Samuel Thibault, 2013/09/16
- [hurd] 47/70: hurd: add proc_{get,set}_code, Samuel Thibault, 2013/09/16
- [hurd] 44/70: mount: handle -t auto,
Samuel Thibault <=
- [hurd] 55/70: libdiskfs: add fsys_get_children, Samuel Thibault, 2013/09/16
- [hurd] 18/70: libshouldbeinlibc: Add nullauth.{c,h}, Samuel Thibault, 2013/09/16
- [hurd] 39/70: libnetfs: register libnetfs-based translators as important, Samuel Thibault, 2013/09/16
- [hurd] 51/70: libihash: add HURD_IHASH_ITERATE_ITEMS macro, Samuel Thibault, 2013/09/16
- [hurd] 15/70: Define and use symbolic names for important processes, Samuel Thibault, 2013/09/16
- [hurd] 52/70: libdiskfs: track file name in struct peropen, Samuel Thibault, 2013/09/16
- [hurd] 50/70: proc: Remove unused declaration of zombie_list, Samuel Thibault, 2013/09/16
- [hurd] 31/70: Merge branch 'master-merge2' into master-merge, Samuel Thibault, 2013/09/16
- [hurd] 12/70: umount: add a umount utility, Samuel Thibault, 2013/09/16
- [hurd] 10/70: sutils: allow multiple entries for the device "none", Samuel Thibault, 2013/09/16