[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dd new iflag= oflag= flags directory, nolinks

From: Phillip Susi
Subject: Re: dd new iflag= oflag= flags directory, nolinks
Date: Wed, 08 Mar 2006 10:43:47 -0500
User-agent: Thunderbird 1.5 (Windows/20051201)

Paul Eggert wrote:
No, because "test -d foo && test -r foo" is _two_ invocations of
"test", not one.  A race condition is therefore possible.  The race
condition is not possible with dd if=foo iflag=directory count=0.

Ok, so this allows you to atomically test if the named object is both a directory and is readable, but why bother? It's a bit silly to worry about a race between the two tests when you still have a race between the dd-test and whatever it is the script actually does with the directory, such as try to list the files in it. Practically, eliminating the one pedantic race condition doesn't solve any problems because you've still got a dozen others.

Admittedly this usage is unusual.  The main arguments for it are
(1) "dd" supports all the other O_* flags, so why not O_DIRECTORY? and
(2) I ran into a situation where I could use O_DIRECTORY.
(1) is far more important than (2).

The purpose of dd is to transfer data. Since O_DIRECTORY excludes transfering data, its use goes against the grain of dd, and since it doesn't actually accomplish anything useful either, I don't think it should be done. It just adds complexity for no good reason.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]