Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Safely create new directory

by BrowserUk (Patriarch)
on Jul 25, 2012 at 19:52 UTC ( [id://983728]=note: print w/replies, xml ) Need Help??


in reply to Safely create new directory

(WARNING: Old, fuzzy, possibly inapplicable and out-of-date memory from the distant past!)

On HP-UX 10.something, we successfully used something like:

my $dir = "/mnt/home/volume/"; my $i = 0; ++$i until mkdir "$dir$i"; ## $i contains the dir successfully created

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Replies are listed 'Best First'.
Re^2: Safely create new directory
by elTriberium (Friar) on Jul 26, 2012 at 07:37 UTC
    Thanks all!

    Together with the other information in this thread that mkdir is in fact atomic this will do.

      nformation in this thread that mkdir is in fact atomic

      I don't believe that atomicity of mkdir was ever in doubt as far as local filesystems are concerned.

      The question, I thought, was about whether it remained atomic for NFS mounted directories.

      My point in posting was -- on ancient HP/UX, where mkdir was tested and found atomic on NFS-mounted drives -- not just that that simple form of loop was sufficient to obtain a unique directory, but actually that it is far more likely to be reliable than the two-stage mechanisms that create files first, then directories.

      Tendered with the clear caveat of the ancient state of my knowledge, I fail to see that creating a file -- just another name in the directory space -- is any more likely to be atomic than creating a directory.

      But ... that is based on logic alone; not current, OS-specific knowledge.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://983728]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-03-29 08:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found