bug-coreutils
[Top][All Lists]
Advanced

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

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


From: Olivier Delhomme
Subject: Re: dd new iflag= oflag= flags directory, nolinks
Date: Wed, 8 Mar 2006 20:45:09 +0100

Le Mon, 06 Mar 2006 18:20:12 -0500, Phillip Susi disait :

> 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?

So do I ...I never used open() with a directory, but why shouldn't it
be possible ?

I looked to the man 2 open page and I saw the following which confuses
me more :

 O_DIRECTORY
              If  pathname  is not a directory, cause the open to
fail.  This flag is Linux-specific, and was added in kernel version
2.1.126, to avoid denial-of- service problems if opendir(3) is called
on a FIFO or tape device, but should not be used outside of the
implementation of opendir.


So if this flag is linux specific does it mean that dd iflag=directory
won't run on other unices ?

Thanks,

Olivier.


> 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  <address@hidden>
> >
> >     * 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 -0000      1.315
> > +++ doc/coreutils.texi      6 Mar 2006 07:15:27 -0000
> > @@ -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.
> >  
> > address@hidden directory
> > address@hidden directory
> > address@hidden 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.
> >  
> > address@hidden nofollow
> > address@hidden nofollow
> > address@hidden 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.
> >  
> > address@hidden nofollow
> > address@hidden nofollow
> > address@hidden symbolic links, following
> > +Do not follow symbolic links.
> > +
> > address@hidden nolinks
> > address@hidden nolinks
> > address@hidden 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.c        7 Dec 2005 21:12:12 -0000       1.190
> > +++ src/dd.c        6 Mar 2006 07:15:27 -0000
> > @@ -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 (_("  direct    use 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 (_("  noctty    do 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 (_("  binary    use 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.h    26 Feb 2006 10:03:17 -0000      1.143
> > +++ src/system.h    6 Mar 2006 07:15:27 -0000
> > @@ -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

-- 
Olivier Delhomme : http://blog.delhomme.org/    [fr]

Attachment: signature.asc
Description: PGP signature


reply via email to

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