On 05/13/2013 01:49 PM, Peter Schiffer wrote: > > There is updated version of this patch, which shouldn't be racy, see > below. I can confirm that mkdir() returns EROFS on read-only fs even > when the directory exists.
Acked-By: Jan Safranek <jsafr...@redhat.com> > > peter > > > diff --git a/src/api.c b/src/api.c > index 11cd1b4..b5bbb74 100644 > --- a/src/api.c > +++ b/src/api.c > @@ -1270,7 +1270,8 @@ int cg_mkdir_p(const char *path) > char *real_path = NULL; > int i = 0; > char pos; > - int ret = 0; > + int ret = 0, stat_ret; > + struct stat st; > > real_path = strdup(path); > if (!real_path) { > @@ -1298,6 +1299,14 @@ int cg_mkdir_p(const char *path) > ret = ECGROUPNOTOWNER; > goto done; > default: > + /* Check if path exists */ > + real_path[i] = '\0'; > + stat_ret = stat(real_path, &st); > + real_path[i] = pos; > + if (stat_ret == 0) { > + ret = 0; /* Path exists */ > + break; > + } > ret = ECGROUPNOTALLOWED; > goto done; > } ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. This 200-page book is written by three acclaimed leaders in the field. The early access version is available now. Download your free book today! http://p.sf.net/sfu/neotech_d2d_may _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel