If the filesystem wasn't determined to be a shared one via the
type check, try comparing it with the additional paths that
have been configured by the local admin.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/util/virfile.c | 86 ++++++++++++++++++++++++++++++++++++++--------
1 file changed, 72 insertions(+), 14 deletions(-)
diff --git a/src/util/virfile.c b/src/util/virfile.c
index a6a7de9829..ac9b5a77a6 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -3795,22 +3795,80 @@ virFileGetDefaultHugepage(virHugeTLBFS *fs,
return NULL;
}
+static int
+virFileIsSharedFSOverrideCompare(const char *path,
+ char *const *overrides)
+{
+ char *const *iter = overrides;
+
+ while (*iter != NULL) {
+ if (STREQ(path, *iter))
+ return 1;
+ iter++;
+ }
+
+ return 0;
+}
+
+static int
+virFileIsSharedFSOverride(const char *path,
+ char *const *overrides)
+{
+ g_autofree char *dirpath = NULL;
+ char *p = NULL;
+ int ret = 0;
+
+ if (!path || path[0] != '/' || !overrides)
+ return ret;
+
+ dirpath = g_strdup(path);
+
+ ret = virFileIsSharedFSOverrideCompare(dirpath, overrides);
+
+ /* Continue until we've scanned the entire path or found a match */
+ while (p != dirpath && ret == 0) {
+
+ /* Find the last slash */
+ if ((p = strrchr(dirpath, '/')) == NULL)
+ break;
+
+ /* Truncate the path by overwriting the slash that we've just
+ * found with a null byte. If it is the very first slash in
+ * the path, we need to handle things slightly differently */
+ if (p == dirpath)
+ *(p+1) = '\0';
+ else
+ *p = '\0';
+
+ ret = virFileIsSharedFSOverrideCompare(dirpath, overrides);
+ }
+
+ return ret;
+}
+
int virFileIsSharedFS(const char *path,
- char *const *overrides G_GNUC_UNUSED)
+ char *const *overrides)
{
- return virFileIsSharedFSType(path,
- VIR_FILE_SHFS_NFS |
- VIR_FILE_SHFS_GFS2 |
- VIR_FILE_SHFS_OCFS |
- VIR_FILE_SHFS_AFS |
- VIR_FILE_SHFS_SMB |
- VIR_FILE_SHFS_CIFS |
- VIR_FILE_SHFS_CEPH |
- VIR_FILE_SHFS_GPFS|
- VIR_FILE_SHFS_QB |
- VIR_FILE_SHFS_ACFS |
- VIR_FILE_SHFS_GLUSTERFS |
- VIR_FILE_SHFS_BEEGFS);
+ int ret;
+
+ ret = virFileIsSharedFSType(path,
+ VIR_FILE_SHFS_NFS |
+ VIR_FILE_SHFS_GFS2 |
+ VIR_FILE_SHFS_OCFS |
+ VIR_FILE_SHFS_AFS |
+ VIR_FILE_SHFS_SMB |
+ VIR_FILE_SHFS_CIFS |
+ VIR_FILE_SHFS_CEPH |
+ VIR_FILE_SHFS_GPFS|
+ VIR_FILE_SHFS_QB |
+ VIR_FILE_SHFS_ACFS |
+ VIR_FILE_SHFS_GLUSTERFS |
+ VIR_FILE_SHFS_BEEGFS);
+
+ if (ret == 0)
+ ret = virFileIsSharedFSOverride(path, overrides);
+
+ return ret;
}
--
2.44.0