[issue14702] os.makedirs breaks under autofs directories

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[issue14702] os.makedirs breaks under autofs directories

STINNER Victor

New submission from Andrew McNabb <[hidden email]>:

When a os.makedirs is used under an autofs directory, it crashes. For example, on my machine, `os.makedirs('/net/prodigy/tmp')` crashes with the following traceback:

Traceback (most recent call last):
  ...
  File "/usr/lib64/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/net/prodigy/tmp'

In this case, '/net' is an autofs directory that automatically mounts the "prodigy" directory by connecting to a host called "prodigy" using NFS. The problem seems to be related to the fact that the "/net/prodigy" directory does not actually exist until it is first accessed.

I tried running `mkdir -p /net/prodigy/tmp`, and it succeeds even though the "/net/prodigy" directory did not exist before the "mkdir" command was run.

I'm not sure exactly how `mkdir -p` is implemented, but one potential workaround for Python's makedirs would be to add the following at the top of the function:

    os.stat(name)

This stat call really only needs to be run the first time makedirs is called (it does not need to be used for each recursive call).

----------
components: Library (Lib)
messages: 159728
nosy: amcnabb
priority: normal
severity: normal
status: open
title: os.makedirs breaks under autofs directories
versions: Python 2.7

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue14702>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%2B1322467933539-512619%40n6.nabble.com

Reply | Threaded
Open this post in threaded view
|

[issue14702] os.makedirs breaks under autofs directories

STINNER Victor

Hynek Schlawack <[hidden email]> added the comment:

As makedirs in 3.x doesn’t handle EPERM and is otherwise the same, I presume the error is there as well.

I also presume, that after the failed makedirs(), the directory is mounted? I'd just handle the error just we handle EEXIST in 3.x now.

----------
nosy: +hynek
stage:  -> needs patch
type:  -> behavior
versions: +Python 3.2, Python 3.3

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue14702>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%2B1322467933539-512619%40n6.nabble.com

Reply | Threaded
Open this post in threaded view
|

[issue14702] os.makedirs breaks under autofs directories

STINNER Victor
In reply to this post by STINNER Victor

Changes by Hynek Schlawack <[hidden email]>:


----------
keywords: +easy

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue14702>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%2B1322467933539-512619%40n6.nabble.com