virFileLinkPointsTo;
virFileLock;
virFileMakePath;
+virFileMakePathWithMode;
virFileMatchesNameSuffix;
virFileOpenAs;
virFileOpenTty;
}
#endif /* WIN32 */
-static int virFileMakePathHelper(char *path)
+static int virFileMakePathHelper(char *path, mode_t mode)
{
struct stat st;
char *p;
if (p != path) {
*p = '\0';
- if (virFileMakePathHelper(path) < 0)
+ if (virFileMakePathHelper(path, mode) < 0)
return -1;
*p = '/';
}
- if (mkdir(path, 0777) < 0 && errno != EEXIST)
+ if (mkdir(path, mode) < 0 && errno != EEXIST)
return -1;
return 0;
* is set appropriately).
*/
int virFileMakePath(const char *path)
+{
+ return virFileMakePathWithMode(path, 0777);
+}
+
+int
+virFileMakePathWithMode(const char *path,
+ mode_t mode)
{
int ret = -1;
char *tmp;
if ((tmp = strdup(path)) == NULL)
goto cleanup;
- ret = virFileMakePathHelper(tmp);
+ ret = virFileMakePathHelper(tmp, mode);
cleanup:
VIR_FREE(tmp);
int virDirCreate(const char *path, mode_t mode, uid_t uid, gid_t gid,
unsigned int flags) ATTRIBUTE_RETURN_CHECK;
int virFileMakePath(const char *path) ATTRIBUTE_RETURN_CHECK;
+int virFileMakePathWithMode(const char *path,
+ mode_t mode) ATTRIBUTE_RETURN_CHECK;
char *virFileBuildPath(const char *dir,
const char *name,
vshReadlineDeinit (vshControl *ctl)
{
if (ctl->historyfile != NULL) {
- if (mkdir(ctl->historydir, 0755) < 0 && errno != EEXIST) {
+ if (virFileMakePathWithMode(ctl->historydir, 0755) < 0 &&
+ errno != EEXIST) {
char ebuf[1024];
vshError(ctl, _("Failed to create '%s': %s"),
ctl->historydir, virStrerror(errno, ebuf, sizeof(ebuf)));