summaryrefslogtreecommitdiffstats
path: root/shlibs/mount/src/context.c
diff options
context:
space:
mode:
authorKarel Zak2010-09-28 01:26:31 +0200
committerKarel Zak2011-01-03 12:28:43 +0100
commit8485e7093bf506e3a4e13ffbe59ba83ef6853a32 (patch)
tree249f48e342df6956b2a0f2a5ff2e4cc977dbf4ef /shlibs/mount/src/context.c
parentlibmount: better permissions and optstr evaliation (diff)
downloadkernel-qcow2-util-linux-8485e7093bf506e3a4e13ffbe59ba83ef6853a32.tar.gz
kernel-qcow2-util-linux-8485e7093bf506e3a4e13ffbe59ba83ef6853a32.tar.xz
kernel-qcow2-util-linux-8485e7093bf506e3a4e13ffbe59ba83ef6853a32.zip
libmount: add FS detection
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/mount/src/context.c')
-rw-r--r--shlibs/mount/src/context.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/shlibs/mount/src/context.c b/shlibs/mount/src/context.c
index 61b5d26fc..664ef9182 100644
--- a/shlibs/mount/src/context.c
+++ b/shlibs/mount/src/context.c
@@ -1090,7 +1090,41 @@ static int mnt_context_prepare_srcpath(mnt_context *cxt)
static int mnt_context_detect_fstype(mnt_context *cxt)
{
- return 0; /* TODO */
+ char *type = NULL;
+
+ if (!cxt || !cxt->fs)
+ return -EINVAL;
+
+ if (cxt->mountflags & (MS_BIND | MS_MOVE | MS_PROPAGATION)) {
+ mnt_fs_set_fstype(cxt->fs, "none");
+ return 0;
+ }
+
+ type = (char *) mnt_fs_get_fstype(cxt->fs);
+ if (type && !strcmp(type, "auto")) {
+ mnt_fs_set_fstype(cxt->fs, NULL);
+ type = NULL;
+ }
+
+ if (!type && !(cxt->flags & MS_REMOUNT)) {
+ mnt_cache *cache;
+ const char *dev = mnt_fs_get_srcpath(cxt->fs);
+
+ if (!dev)
+ return -EINVAL;
+
+ cache = mnt_context_get_cache(cxt);
+ type = mnt_get_fstype(dev, cache);
+
+ if (!type)
+ return -EINVAL;
+ mnt_fs_set_fstype(cxt->fs, type);
+ if (!cache)
+ free(type); /* type is not cached */
+ return 0;
+ }
+
+ return 0;
}
static int mnt_context_merge_mountflags(mnt_context *cxt)