2 * Copyright (C) 2012-2020 all contributors <cmogstored-public@yhbt.net>
3 * License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
5 #include "cmogstored.h"
8 * "path" is the pathname for a file (not a directory)
9 * returns -1 on error, sets errno to EACCES on invalid paths
11 int mog_mkpath_for(struct mog_svc
*svc
, char *path
)
14 char *c
= strchr(tip
, '/');
18 /* refuse to create files at the top-level */
24 for (i
= 0; c
!= NULL
; i
++) {
27 rc
= mog_mkdir(svc
, path
, svc
->mkcol_perms
);
31 if (rc
!= 0 && errno
!= EEXIST
)