I'm confused. You can't open() and write() to a directory, so how does
it make any sense to ask dd to set O_DIRECTORY?
Paul Eggert wrote:
I wanted to use dd iflag=directory (to test whether a file is a
directory, atomically), and noticed that dd didn't have it. The use
was a fairly obscure one (just testing the O_DIRECTORY flag) but I
figured dd should support all the flags. I noticed also that dd
doesn't support the Solaris 10 O_NOLINKS option. So I installed this:
2006-03-05 Paul Eggert <[EMAIL PROTECTED]>
* doc/coreutils.texi (dd invocation): New flags directory, nolinks.
Alphabetize nofollow.
* src/dd.c (flags, usage): New flags directory, nolinks.
* src/system.h (O_NOLINKS): Define to 0 if not already defined.
Index: doc/coreutils.texi
===
RCS file: /fetish/cu/doc/coreutils.texi,v
retrieving revision 1.315
diff -p -u -r1.315 coreutils.texi
--- doc/coreutils.texi 27 Feb 2006 10:47:23 - 1.315
+++ doc/coreutils.texi 6 Mar 2006 07:15:27 -
@@ -7003,7 +7003,8 @@ argument(s). (No spaces around any comm
Access the output file using the flags specified by the @var{flag}
argument(s). (No spaces around any comma(s).)
-Flags:
+Here are the flags. Not every flag is supported on every operating
+system.
@table @samp
@@ -7019,6 +7020,13 @@ contents of the file. This flag makes s
@cindex direct I/O
Use direct I/O for data, avoiding the buffer cache.
[EMAIL PROTECTED] directory
[EMAIL PROTECTED] directory
[EMAIL PROTECTED] directory I/O
+
+Fail unless the file is a directory. Most operating systems do not
+allow I/O to a directory, so this flag has limited utility.
+
@item dsync
@opindex dsync
@cindex synchronized data reads
@@ -7043,11 +7051,6 @@ Use non-blocking I/O.
@cindex access time
Do not update the file's access time.
[EMAIL PROTECTED] nofollow
[EMAIL PROTECTED] nofollow
[EMAIL PROTECTED] symbolic links, following
-Do not follow symbolic links.
-
@item noctty
@opindex noctty
@cindex controlling terminal
@@ -7056,6 +7059,16 @@ This has no effect when the file is not
On many hosts (e.g., @acronym{GNU}/Linux hosts), this option has no effect
at all.
[EMAIL PROTECTED] nofollow
[EMAIL PROTECTED] nofollow
[EMAIL PROTECTED] symbolic links, following
+Do not follow symbolic links.
+
[EMAIL PROTECTED] nolinks
[EMAIL PROTECTED] nolinks
[EMAIL PROTECTED] hard links
+Fail if the file has multiple hard links.
+
@item binary
@opindex binary
@cindex binary I/O
Index: src/dd.c
===
RCS file: /fetish/cu/src/dd.c,v
retrieving revision 1.190
diff -p -u -r1.190 dd.c
--- src/dd.c7 Dec 2005 21:12:12 - 1.190
+++ src/dd.c6 Mar 2006 07:15:27 -
@@ -263,10 +263,12 @@ static struct symbol_value const flags[]
{"append", O_APPEND},
{"binary", O_BINARY},
{"direct", O_DIRECT},
+ {"directory", O_DIRECTORY},
{"dsync", O_DSYNC},
{"noatime",O_NOATIME},
{"noctty", O_NOCTTY},
{"nofollow", O_NOFOLLOW},
+ {"nolinks",O_NOLINKS},
{"nonblock", O_NONBLOCK},
{"sync", O_SYNC},
{"text", O_TEXT},
@@ -460,6 +462,8 @@ Each FLAG symbol may be:\n\
"), stdout);
if (O_DIRECT)
fputs (_(" directuse direct I/O for data\n"), stdout);
+ if (O_DIRECTORY)
+ fputs (_(" directory fail unless a directory\n"), stdout);
if (O_DSYNC)
fputs (_(" dsync use synchronized I/O for data\n"), stdout);
if (O_SYNC)
@@ -468,11 +472,13 @@ Each FLAG symbol may be:\n\
fputs (_(" nonblock use non-blocking I/O\n"), stdout);
if (O_NOATIME)
fputs (_(" noatime do not update access time\n"), stdout);
- if (O_NOFOLLOW)
- fputs (_(" nofollow do not follow symlinks\n"), stdout);
if (O_NOCTTY)
fputs (_(" nocttydo not assign controlling terminal from file\n"),
stdout);
+ if (O_NOFOLLOW)
+ fputs (_(" nofollow do not follow symlinks\n"), stdout);
+ if (O_NOLINKS)
+ fputs (_(" nolinks fail if multiply-linked\n"), stdout);
if (O_BINARY)
fputs (_(" binaryuse binary I/O for data\n"), stdout);
if (O_TEXT)
Index: src/system.h
===
RCS file: /fetish/cu/src/system.h,v
retrieving revision 1.143
diff -p -u -r1.143 system.h
--- src/system.h26 Feb 2006 10:03:17 - 1.143
+++ src/system.h6 Mar 2006 07:15:27 -
@@ -193,6 +193,10 @@ initialize_exit_failure (int status)
# define O_NOFOLLOW 0
#endif
+#if !defined O_NOLINKS
+# define O_NOLINKS 0
+#endif
+
#if !defined O_RSYNC
# define O_RSYNC 0
#endif
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils