linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@CS.UCLA.EDU>
To: bug-coreutils@gnu.org
Cc: Andy Isaacson <adi@hexapodia.org>, Andrew Morton <akpm@osdl.org>,
	Bruce Allen <ballen@gravity.phys.uwm.edu>,
	linux-kernel@vger.kernel.org
Subject: dd patch to remove noctty
Date: Thu, 08 Apr 2004 13:20:57 -0700	[thread overview]
Message-ID: <87ekqyw79y.fsf_-_@penguin.cs.ucla.edu> (raw)
In-Reply-To: <87vfka30cm.fsf@ceramic.fifi.org> (Philippe Troin's message of "08 Apr 2004 09:23:21 -0700")

Philippe Troin <phil@fifi.org> writes:

> noctty definitely seems overkill... I can't see why dd would ever want
> to open a file without O_NOCTTY.

Good point; it's just a confusion for the user.  Here's a patch to
cause dd to always use O_NOCTTY.  If someone ever needs it the other
way (not likely) I suppose we can add a "ctty" flag.

2004-04-08  Paul Eggert  <eggert@cs.ucla.edu>

	* NEWS: Remove noctty flag from dd.  Suggested by Philippe Troin.
	* doc/coreutils.texi (dd invocation): Likewise.
	* src/shred.c (O_NOCTTY): Remove redundant decl.
	* src/dd.c (flags, usage): Remove noctty flag.
	(main): Always use O_NOCTTY when opening files.

Index: NEWS
===================================================================
RCS file: /home/meyering/coreutils/cu/NEWS,v
retrieving revision 1.199
diff -p -u -r1.199 NEWS
--- NEWS	8 Apr 2004 10:25:27 -0000	1.199
+++ NEWS	8 Apr 2004 20:04:42 -0000
@@ -24,7 +24,6 @@ GNU coreutils NEWS                      
     sync      likewise, but also for metadata
     nonblock  use non-blocking I/O
     nofollow  do not follow symlinks
-    noctty    do not assign controlling terminal from file
 
   stty now provides support (iutf8) for setting UTF-8 input mode.
 
Index: doc/coreutils.texi
===================================================================
RCS file: /home/meyering/coreutils/cu/doc/coreutils.texi,v
retrieving revision 1.176
diff -p -u -r1.176 coreutils.texi
--- doc/coreutils.texi	8 Apr 2004 15:35:40 -0000	1.176
+++ doc/coreutils.texi	8 Apr 2004 20:05:38 -0000
@@ -6666,18 +6666,12 @@ Use non-blocking I/O.
 @cindex symbolic links, following
 Do not follow symbolic links.
 
-@item noctty
-@opindex noctty
-@cindex controlling terminal
-Do not assign the file to be a controlling terminal for @command{dd}.
-This has no effect when the file is not a terminal.
-
 @end table
 
 These flags are not supported on all systems, and @samp{dd} rejects
 attempts to use them when they are not supported.  When reading from
-standard input or writing to standard output, the @samp{nofollow} and
-@samp{noctty} flags should not be specified, and the other flags
+standard input or writing to standard output, the @samp{nofollow} flag
+should not be specified, and the other flags
 (e.g., @samp{nonblock}) can affect how other processes behave with the
 affected file descriptors, even after @command{dd} exits.
 
Index: src/shred.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/shred.c,v
retrieving revision 1.84
diff -p -u -r1.84 shred.c
--- src/shred.c	21 Jan 2004 23:39:34 -0000	1.84
+++ src/shred.c	8 Apr 2004 20:04:45 -0000
@@ -110,10 +110,6 @@
 #include "quotearg.h"		/* For quotearg_colon */
 #include "quote.h"		/* For quotearg_colon */
 
-#ifndef O_NOCTTY
-# define O_NOCTTY 0  /* This is a very optional frill */
-#endif
-
 #define DEFAULT_PASSES 25	/* Default */
 
 /* How many seconds to wait before checking whether to output another
--- src/dd.c-bak	Thu Apr  8 12:17:02 2004
+++ src/dd.c	Thu Apr  8 13:18:30 2004
@@ -192,7 +192,6 @@ static struct symbol_value const flags[]
   {"append",	O_APPEND},
   {"direct",	O_DIRECT},
   {"dsync",	O_DSYNC},
-  {"noctty",	O_NOCTTY},
   {"nofollow",	O_NOFOLLOW},
   {"nonblock",	O_NONBLOCK},
   {"sync",	O_SYNC},
@@ -384,9 +383,6 @@ Each FLAG symbol may be:\n\
 	fputs (_("  nonblock  use non-blocking I/O\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);
       fputs (_("\
 \n\
 Note that sending a SIGUSR1 signal to a running `dd' process makes it\n\
@@ -1300,7 +1296,8 @@ main (int argc, char **argv)
     }
   else
     {
-      if (open_fd (STDIN_FILENO, input_file, O_RDONLY | input_flags, 0) < 0)
+      int opts = input_flags | O_NOCTTY;
+      if (open_fd (STDIN_FILENO, input_file, O_RDONLY | opts, 0) < 0)
 	error (EXIT_FAILURE, errno, _("opening %s"), quote (input_file));
     }
 
@@ -1313,7 +1310,7 @@ main (int argc, char **argv)
     {
       mode_t perms = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
       int opts
-	= (output_flags
+	= (output_flags | O_NOCTTY
 	   | (conversions_mask & C_NOCREAT ? 0 : O_CREAT)
 	   | (conversions_mask & C_EXCL ? O_EXCL : 0)
 	   | (seek_records || (conversions_mask & C_NOTRUNC) ? 0 : O_TRUNC));

  reply	other threads:[~2004-04-08 20:25 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-06 22:03 dd PATCH: add conv=direct Andy Isaacson
2004-04-07  0:33 ` Andrew Morton
2004-04-07 16:21   ` Bruce Allen
2004-04-07 16:42     ` Andrew Morton
2004-04-07 17:31   ` Andy Isaacson
2004-04-07 18:18     ` Andrew Morton
2004-04-07 19:24       ` Andy Isaacson
2004-04-07 19:34         ` Andrew Morton
2004-04-07 19:47           ` Andy Isaacson
2004-04-07 20:03             ` Andrew Morton
2004-04-07 20:43               ` Andy Isaacson
2004-04-07 21:00                 ` Valdis.Kletnieks
2004-04-07 21:35                 ` Bruce Allen
2004-04-08  6:56                   ` Paul Eggert
2004-04-08 11:07                     ` Jim Meyering
2004-04-08 19:32                       ` Paul Eggert
2004-04-08 19:51                         ` Paul Jarc
2004-04-08 21:34                         ` Jim Meyering
2004-04-08 16:23                     ` Philippe Troin
2004-04-08 20:20                       ` Paul Eggert [this message]
2004-04-08 21:40                         ` dd patch to remove noctty Jim Meyering
2004-04-09  0:37             ` dd PATCH: add conv=direct Anton Blanchard
2004-04-09  1:42               ` Wim Coekaerts
2004-04-10 21:28                 ` Jim Meyering
2004-04-07 20:46       ` Paul Eggert
2004-04-07 21:06         ` Andrew Morton
2004-04-07 21:09         ` Andy Isaacson
2004-04-07 19:12     ` Miquel van Smoorenburg
2004-04-07 20:14       ` Andy Isaacson
2004-04-07 22:02 ` Nathan Straz
2004-04-07 22:09   ` Andy Isaacson
2004-04-08 11:44     ` Miquel van Smoorenburg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ekqyw79y.fsf_-_@penguin.cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=adi@hexapodia.org \
    --cc=akpm@osdl.org \
    --cc=ballen@gravity.phys.uwm.edu \
    --cc=bug-coreutils@gnu.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).