Index: /trunk/include/iprt/fs.h
===================================================================
--- /trunk/include/iprt/fs.h	(revision 30253)
+++ /trunk/include/iprt/fs.h	(revision 30254)
@@ -180,4 +180,20 @@
 
 
+/** @name Filesystem type IDs. Used by RTFsQueryType. */
+#define RTFS_FS_TYPE_UNKNOWN            0
+#define RTFS_FS_TYPE_EXT                1
+#define RTFS_FS_TYPE_EXT2               2
+#define RTFS_FS_TYPE_EXT3               3
+#define RTFS_FS_TYPE_EXT4               4
+#define RTFS_FS_TYPE_TMPFS              5
+#define RTFS_FS_TYPE_JFS                6
+#define RTFS_FS_TYPE_NFS                7
+#define RTFS_FS_TYPE_HFS                8
+#define RTFS_FS_TYPE_CIFS               9
+#define RTFS_FS_TYPE_FAT               10
+#define RTFS_FS_TYPE_NTFS              11
+#define RTFS_FS_TYPE_ZFS               12
+
+
 /**
  * The available additional information in a RTFSOBJATTR object.
@@ -385,4 +401,14 @@
 RTR3DECL(int) RTFsQueryDriver(const char *pszFsPath, char *pszFsDriver, size_t cbFsDriver);
 
+/**
+ * Query the name of the filesystem the file is located on.
+ *
+ * @returns iprt status code.
+ * @param   pszFsPath       Path within the mounted filesystem.
+ * @param   pu32Type        Where to store the filesystem type.
+ *                          See RTFS_FS_TYPE_xxx constants.
+ */
+RTR3DECL(int) RTFsQueryType(const char *pszFsPath, uint32_t *pu32Type);
+
 #endif /* IN_RING3 */
 
Index: /trunk/src/VBox/Runtime/r3/posix/fs-posix.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/posix/fs-posix.cpp	(revision 30253)
+++ /trunk/src/VBox/Runtime/r3/posix/fs-posix.cpp	(revision 30254)
@@ -32,4 +32,8 @@
 #include <sys/statvfs.h>
 #include <errno.h>
+#include <stdio.h>
+#ifdef RT_OS_LINUX
+# include <mntent.h>
+#endif
 
 #include <iprt/fs.h>
@@ -163,2 +167,72 @@
 }
 
+
+RTR3DECL(int) RTFsQueryType(const char *pszFsPath, uint32_t *pu32Type)
+{
+    /*
+     * Validate input.
+     */
+    AssertMsgReturn(VALID_PTR(pszFsPath) && *pszFsPath, ("%p", pszFsPath), VERR_INVALID_PARAMETER);
+
+    /*
+     * Convert the path and query the stats.
+     * We're simply return the device id.
+     */
+    char const *pszNativeFsPath;
+    int rc = rtPathToNative(&pszNativeFsPath, pszFsPath, NULL);
+    if (RT_SUCCESS(rc))
+    {
+        *pu32Type = RTFS_FS_TYPE_UNKNOWN;
+
+        struct stat Stat;
+        if (!stat(pszNativeFsPath, &Stat))
+        {
+#if defined(RT_OS_LINUX)
+            FILE *mounted = setmntent("/proc/mounts", "r");
+            if (!mounted)
+                mounted = setmntent("/etc/mtab", "r");
+            if (mounted)
+            {
+                char szBuf[1024];
+                struct stat mntStat;
+                struct mntent mntEnt;
+                while (getmntent_r(mounted, &mntEnt, szBuf, sizeof(szBuf)))
+                {
+                    if (!stat(mntEnt.mnt_dir, &mntStat))
+                    {
+                        if (mntStat.st_dev == Stat.st_dev)
+                        {
+                            if (!strcmp("ext4", mntEnt.mnt_type))
+                                *pu32Type = RTFS_FS_TYPE_EXT4;
+                            else if (!strcmp("ext3", mntEnt.mnt_type))
+                                *pu32Type = RTFS_FS_TYPE_EXT3;
+                            else if (!strcmp("ext2", mntEnt.mnt_type))
+                                *pu32Type = RTFS_FS_TYPE_EXT2;
+                            else if (   !strcmp("vfat", mntEnt.mnt_type)
+                                     || !strcmp("msdos", mntEnt.mnt_type))
+                                *pu32Type = RTFS_FS_TYPE_FAT;
+                            else if (!strcmp("tmpfs", mntEnt.mnt_type))
+                                *pu32Type = RTFS_FS_TYPE_TMPFS;
+                            else
+                            {
+                                /* sometimes there are more than one entry for the same partition */
+                                continue;
+                            }
+                            break;
+                        }
+                    }
+                }
+                endmntent(mounted);
+            }
+#elif defined(RT_OS_SOLARIS)
+            if (!strcmp("zfs", Stat.st_fstype))
+                *pu32Type = RTFS_FS_TYPE_ZFS;
+#endif
+        }
+        else
+            rc = RTErrConvertFromErrno(errno);
+        rtPathFreeNative(pszNativeFsPath, pszFsPath);
+    }
+
+    return rc;
+}
