We will need to traverse the symlinks one step at the time.
Therefore we need to see where a symlink is pointing to.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
virFileReadBufQuiet;
virFileReadHeaderFD;
virFileReadLimFD;
+virFileReadLink;
virFileRelLinkPointsTo;
virFileRemove;
virFileRemoveLastComponent;
#include "virutil.h"
#include "c-ctype.h"
+#include "areadlink.h"
#define VIR_FROM_THIS VIR_FROM_NONE
return S_ISLNK(st.st_mode) != 0;
}
+/*
+ * Read where symlink is pointing to.
+ *
+ * Returns 0 on success (@linkpath is a successfully read link),
+ * -1 with errno set upon error.
+ */
+int
+virFileReadLink(const char *linkpath, char **resultpath)
+{
+ return (*resultpath = areadlink(linkpath)) ? 0 : -1;
+}
/*
* Finds a requested executable file in the PATH env. e.g.:
int virFileIsLink(const char *linkpath)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
+int virFileReadLink(const char *linkpath, char **resultpath)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
+
char *virFindFileInPath(const char *file);
char *virFileFindResource(const char *filename,