bug-coreutils
[Top][All Lists]
Advanced

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

Re: choice of file system build-dir can change how coreutils works


From: Paul Eggert
Subject: Re: choice of file system build-dir can change how coreutils works
Date: Wed, 21 Feb 2007 13:59:36 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Jim Meyering <address@hidden> writes:

> However, note that for O_NOFOLLOW, it'd be a whole different kettle
> of fish, (since it is used in security-related areas) if configure
> detected support for it on the build file system, but an application
> used it on a different file system, without support.

This should be a rarer problem, I think, since O_NOFOLLOW is typically
implemented by the operating system, not by the file system, so it
typically either works on all file systems, or works on no file
systems.

> In this case, perhaps it's ok to let dd support the notaime flag
> as long as the system defines O_NOATIME.

I think so too.  Here's a patch.

2007-02-21  Paul Eggert  <address@hidden>

        * doc/coreutils.texi (dd invocation): Warn that noatime might not be
        reliable.
        * src/dd.c (flags, usage): Look at O_NOATIME, not
        HAVE_WORKING_O_NOATIME, to decide whether to support the noatime
        flag, so that dd attempts O_NOATIME even if the build file system
        does not support it.  Problem reported by Jim Meyering today in
        bug-coreutils.
        * tests/dd/misc: Generate a warning, not a failure, if noatime
        exists but fails.

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 1a2dba4..04c1b4e 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -7442,6 +7442,8 @@ Use non-blocking I/O.
 @opindex noatime
 @cindex access time
 Do not update the file's access time.
+Some older file systems silently ignore this flag, so it is a good
+idea to test it on your files before relying on it.

 @item noctty
 @opindex noctty
diff --git a/src/dd.c b/src/dd.c
index d699955..27a4a08 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -265,7 +265,7 @@ static struct symbol_value const flags[] =
   {"direct",   O_DIRECT},
   {"directory",        O_DIRECTORY},
   {"dsync",    O_DSYNC},
-  {"noatime",  HAVE_WORKING_O_NOATIME ? O_NOATIME : 0},
+  {"noatime",  O_NOATIME},
   {"noctty",   O_NOCTTY},
   {"nofollow", HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0},
   {"nolinks",  O_NOLINKS},
@@ -472,7 +472,7 @@ Each FLAG symbol may be:\n\
        fputs (_("  sync      likewise, but also for metadata\n"), stdout);
       if (O_NONBLOCK)
        fputs (_("  nonblock  use non-blocking I/O\n"), stdout);
-      if (HAVE_WORKING_O_NOATIME)
+      if (O_NOATIME)
        fputs (_("  noatime   do not update access time\n"), stdout);
       if (O_NOCTTY)
        fputs (_("  noctty    do not assign controlling terminal from file\n"),
diff --git a/tests/dd/misc b/tests/dd/misc
index 513221b..fa5cfbe 100755
--- a/tests/dd/misc
+++ b/tests/dd/misc
@@ -29,6 +29,8 @@ if test "$VERBOSE" = yes; then
   dd --version
 fi

+fail=0
+warn=0
 test_failure=0
 echo data > $tmp_in || test_failure=1
 ln $tmp_in $tmp_in2 || test_failure=1
@@ -63,8 +65,15 @@ sleep 1
 if dd iflag=noatime if=$tmp_in of=$tmp_out 2> /dev/null; then
   new_ls=`ls -u --full-time $tmp_in`
   if test "x$old_ls" != "x$new_ls"; then
-    echo "dd iflag=noatime updated atime; O_NOATIME bug in your kernel?" >&2
-    fail=1
+    cat >&2 <<EOF
+=================================================================
+$0: WARNING!!!
+This operating system has the O_NOATIME file status flag,
+but it is silently ignored in some cases.
+Therefore, dd options like iflag=noatime may be silently ignored.
+=================================================================
+EOF
+    warn=77
   fi
 fi

@@ -77,6 +86,7 @@ fi
 outbytes=`echo x | dd bs=3 ibs=10 obs=10 conv=sync 2>/dev/null | wc -c`
 test "$outbytes" -eq 3 || fail=1

-rm -f $tmp_in $tmp_in2 $tmp_sym $tmp_out
+rm -f $tmp_in $tmp_in2 $tmp_sym $tmp_out || fail=1

+test $fail -eq 0 && fail=$warn
 exit $fail
M ChangeLog
M doc/ChangeLog
M doc/coreutils.texi
M src/dd.c
M tests/dd/misc
Committed as e67725a333183beb9531d02645bfb942fb170a7d




reply via email to

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