Re: dd PATCH: add conv=direct

From: Jim Meyering
Date: Thu Apr 08 2004 - 06:09:15 EST


Paul Eggert <eggert@xxxxxxxxxxx> wrote:
> At the end of this message is a proposed patch to implement everything
> people other than myself have asked for so far, along with several
> other things since I was in the neighborhood.

Thanks for that nice patch!
I've applied it, and made these additional changes:

2004-04-08 Jim Meyering <jim@xxxxxxxxxxxx>

* src/dd.c (set_fd_flags): Don't OR in -1 when fcntl fails.
Rename parameter, flags, to avoid shadowing global.

Index: dd.c
===================================================================
RCS file: /fetish/cu/src/dd.c,v
retrieving revision 1.155
diff -u -p -r1.155 dd.c
--- a/dd.c 8 Apr 2004 10:22:05 -0000 1.155
+++ b/dd.c 8 Apr 2004 11:02:20 -0000
@@ -1017,12 +1017,12 @@ copy_with_unblock (char const *buf, size
in FLAGS. The file's name is NAME. */

static void
-set_fd_flags (int fd, int flags, char const *name)
+set_fd_flags (int fd, int add_flags, char const *name)
{
- if (flags)
+ if (add_flags)
{
int old_flags = fcntl (fd, F_GETFL);
- int new_flags = old_flags | flags;
+ int new_flags = old_flags < 0 ? add_flags : (old_flags | add_flags);
if (old_flags < 0
|| (new_flags != old_flags && fcntl (fd, F_SETFL, new_flags) == -1))
error (EXIT_FAILURE, errno, _("setting flags for %s"), quote (name));


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/