Split out the portion of virFileGetFSFtype that makes the statfs call
in order to return the "f_type" field
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/util/virfile.c | 34 ++++++++++++++++++++++++----------
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 9863fd0..7612007 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -2841,14 +2841,16 @@ int virFilePrintf(FILE *fp, const char *msg, ...)
# define HUGETLBFS_MAGIC 0x958458f6
# endif
-int
-virFileIsSharedFSType(const char *path,
- int fstypes)
+static int
+virFileGetFSFtype(const char *path,
+ long long int *ret_ftype)
{
char *dirpath, *p;
struct statfs sb;
int statfs_ret;
+ *ret_ftype = 0;
+
if (VIR_STRDUP(dirpath, path) < 0)
return -1;
@@ -2886,28 +2888,40 @@ virFileIsSharedFSType(const char *path,
path);
return -1;
}
+ *ret_ftype = sb.f_type;
+ return 0;
+}
+
+int
+virFileIsSharedFSType(const char *path,
+ int fstypes)
+{
+ long long int f_type;
+
+ if (virFileGetFSFtype(path, &f_type) < 0)
+ return -1;
VIR_DEBUG("Check if path %s with FS magic %lld is shared",
- path, (long long int)sb.f_type);
+ path, f_type);
if ((fstypes & VIR_FILE_SHFS_NFS) &&
- (sb.f_type == NFS_SUPER_MAGIC))
+ (f_type == NFS_SUPER_MAGIC))
return 1;
if ((fstypes & VIR_FILE_SHFS_GFS2) &&
- (sb.f_type == GFS2_MAGIC))
+ (f_type == GFS2_MAGIC))
return 1;
if ((fstypes & VIR_FILE_SHFS_OCFS) &&
- (sb.f_type == OCFS2_SUPER_MAGIC))
+ (f_type == OCFS2_SUPER_MAGIC))
return 1;
if ((fstypes & VIR_FILE_SHFS_AFS) &&
- (sb.f_type == AFS_FS_MAGIC))
+ (f_type == AFS_FS_MAGIC))
return 1;
if ((fstypes & VIR_FILE_SHFS_SMB) &&
- (sb.f_type == SMB_SUPER_MAGIC))
+ (f_type == SMB_SUPER_MAGIC))
return 1;
if ((fstypes & VIR_FILE_SHFS_CIFS) &&
- (sb.f_type == CIFS_SUPER_MAGIC))
+ (f_type == CIFS_SUPER_MAGIC))
return 1;
return 0;
--
1.9.3