From: Jiri Denemark <jdene...@redhat.com> The function is called by virFileIsSharedFSOverride which is not Linux specific and thus building on anything but Linux failes.
Fixes: 94fb348d670f612c0b58901c9829b4eec81faa50 Signed-off-by: Jiri Denemark <jdene...@redhat.com> --- src/util/virfile.c | 55 +++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index d79a60baee..1b3f37db7a 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -3444,6 +3444,34 @@ virFileRemoveLastComponent(char *path) path[0] = '\0'; } + +static char * +virFileGetExistingParent(const char *path) +{ + g_autofree char *dirpath = g_strdup(path); + char *p = NULL; + + /* Try less and less of the path until we get to a directory we can stat. + * Even if we don't have 'x' permission on any directory in the path on the + * NFS server (assuming it's NFS), we will be able to stat the mount point. + */ + while (!virFileExists(dirpath) && p != dirpath) { + if (!(p = strrchr(dirpath, '/'))) { + virReportSystemError(EINVAL, + _("Invalid relative path '%1$s'"), path); + return NULL; + } + + if (p == dirpath) + *(p + 1) = '\0'; + else + *p = '\0'; + } + + return g_steal_pointer(&dirpath); +} + + #ifdef __linux__ # ifndef NFS_SUPER_MAGIC @@ -3557,33 +3585,6 @@ virFileIsSharedFsFUSE(const char *path, } -static char * -virFileGetExistingParent(const char *path) -{ - g_autofree char *dirpath = g_strdup(path); - char *p = NULL; - - /* Try less and less of the path until we get to a directory we can stat. - * Even if we don't have 'x' permission on any directory in the path on the - * NFS server (assuming it's NFS), we will be able to stat the mount point. - */ - while (!virFileExists(dirpath) && p != dirpath) { - if (!(p = strrchr(dirpath, '/'))) { - virReportSystemError(EINVAL, - _("Invalid relative path '%1$s'"), path); - return NULL; - } - - if (p == dirpath) - *(p + 1) = '\0'; - else - *p = '\0'; - } - - return g_steal_pointer(&dirpath); -} - - static const struct virFileSharedFsData virFileSharedFs[] = { { .fstype = VIR_FILE_SHFS_NFS, .magic = NFS_SUPER_MAGIC }, { .fstype = VIR_FILE_SHFS_GFS2, .magic = GFS2_MAGIC }, -- 2.49.0