[Gluster-devel] Weirdness in glfs_mkdir()?

Justin Clift jclift at redhat.com
Tue Oct 29 09:54:57 UTC 2013

On 29/10/2013, at 4:51 AM, Anand Avati wrote:
> On Mon, Oct 28, 2013 at 6:28 PM, Jay Vyas <jayunit100 at gmail.com> wrote:
> wow.  im surprised.  this caught my eye, checked into the mode: 
> glfs_mkdir (struct glfs *fs, const char *path, mode_t mode)
> So, somehow, the python API is capable of sending a "mode" which doesnt correspond to anything enumerated as part of the mode_t, but the C method still manages to write the file with a "garbage mode" ?  
> That sounds like a bug not in python.  Not in gluster... but in C ! :)  [if im understanding this correctyle, which i might not be]
> Not sure whether its a bug or feature of C. C runtime is typeless. Python ctypes uses dlopen/dlsym which do symbol lookups - doesn't care whether the looked up symbol is a data structure or a function name - let alone do type matching!

Thanks guys.  Armed with this "it's a bug, nor a feature"
info, it turned out to be a simple fix.  Added a new mode
parameter to the Gluster Libgfapi mkdir() call works,
passing it straight through to the C glfs_mkdir() call.

New dirs are now created as expected: :)

  >>> vol.mkdir("foobar", 0o750)
  >>> vol.mkdir("foobar/111", 0o750)
  >>> vol.mkdir("foobar/112", 0o750)
  >>> vol.mkdir("foobar/113", 0o750)

  $ sudo ls -la /export/brick/brick1/foobar/
  total 0
  drwxr-x---. 8 root root 65 Oct 29 09:42 .
  drwxr-xr-x. 8 root root 87 Oct 29 09:41 ..
  drwxr-x---. 2 root root  6 Oct 29 09:42 111
  drwxr-x---. 2 root root  6 Oct 29 09:42 112
  drwxr-x---. 2 root root  6 Oct 29 09:42 113

This fix is in Gerrit for review, along with newly
added chmod() and chown() calls, plus some docstrings
for the existing functions.


Please review if you have a few minutes. :)

Note - I'm not sure about the format of the docstrings.
Mostly copied the layout of the C comments, but am
happy to adjust things if theres a better docstring

+ Justin

Open Source and Standards @ Red Hat


More information about the Gluster-devel mailing list