Merged. Ivana ----- Original Message ----- > From: "Jan Safranek" <jsafr...@redhat.com> > To: "Peter Schiffer" <pschi...@redhat.com> > Cc: "Ivana Varekova" <varek...@redhat.com>, libcg-devel@lists.sourceforge.net > Sent: Monday, May 13, 2013 1:55:55 PM > Subject: Re: [Libcg-devel] [PATCH] Make cg_mkdir_p() function compatible with > read-only fs > > 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; > > } > >
------------------------------------------------------------------------------ AlienVault Unified Security Management (USM) platform delivers complete security visibility with the essential security capabilities. Easily and efficiently configure, manage, and operate all of your security controls from a single console and one unified framework. Download a free trial. http://p.sf.net/sfu/alienvault_d2d _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel