This refactors the path check routine used in virDomainSave into util > Matt McCowan > diff -ur libvirt.orig/src/util.h libvirt-0.6.1.1/src/util.h --- libvirt.orig/src/util.h 2009-02-27 01:27:51.000000000 +0900 +++ libvirt-0.6.1.1/src/util.h 2009-03-05 11:44:42.000000000 +0900 @@ -111,6 +111,8 @@ int virFileDeletePid(const char *dir, const char *name); +char *virFileAbsPath(const char *str); + char *virArgvToString(const char *const *argv); int virStrToLong_i(char const *s, --- libvirt.orig/src/util.c 2009-03-03 21:03:44.000000000 +0900 +++ libvirt-0.6.1.1/src/util.c 2009-03-09 14:17:17.000000000 +0900 @@ -136,6 +136,28 @@ return 1; } + +char * +virFileAbsPath(const char *str) +{ + char filepath[4096]; + char *ret; + unsigned int len, t; + + t = strlen(str); + if (getcwd(filepath, sizeof(filepath) - (t + 3)) == NULL) + return NULL; + len = strlen(filepath); + /* that should be covered by getcwd() semantic, but be 100% sure */ + if (len > sizeof(filepath) - (t + 3)) + return NULL; + filepath[len] = '/'; + strcpy(&filepath[len + 1], str); + ret = &filepath[0]; + + return ret; +} + char * virArgvToString(const char *const *argv) { -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list