[lxc-devel] [PATCH] replace redundant creat() with open()

Serge Hallyn serge.hallyn at ubuntu.com
Fri Nov 8 22:20:52 UTC 2013


Quoting S.Çağlar Onur (caglar at 10ur.org):
> Hey Serge,
> 
> On Fri, Nov 8, 2013 at 4:06 PM, Serge Hallyn <serge.hallyn at ubuntu.com> wrote:
> > Quoting S.Çağlar Onur (caglar at 10ur.org):
> >> creat() is equivalent to open() with flags equal to O_CREAT|O_WRONLY|O_TRUNC
> >
> > Hi,
> >
> > I'm confused - what is redundant in the use of creat()?  If there is an
> > improvement here then I don't understand what it is.  Otherwise I'd
> > argue creat() is more concise and clearer about its intent.
> 
> There is no improvement other than a syntactic change (assuming
> creat() is also protected by glibc like open()). I saw them while
> trying to come up with a list of functions protected by process_lock
> and replaced them with open() without checking what glibc does. If you
> think creat is also protected than please feel free to drop this :)

int
__libc_creat (file, mode)
     const char *file;
     mode_t mode;
{
  return __open (file, O_WRONLY|O_CREAT|O_TRUNC, mode);
}

:)




More information about the lxc-devel mailing list