From 5f3115535b32a9c0cc5aee5cf5b4001f684ad56e Mon Sep 17 00:00:00 2001 From: Pádraig Brady
Date: Tue, 22 Feb 2011 21:14:00 +0000
Subject: dd: add a flag to discard cached data
* src/dd.c (FFS_MASK): A new macro (Find First Set) refactored
from the following enum as it's now used twice.
(usage): Mention the new 'nocache' flag.
(cache_round): A new function to help ignore requests
to drop cache, that are less than page_size.
(invalidate_cache): A new function to call posix_fadvise()
with the appropriate offset and length. Note we don't
use fdadvise() so we can detect errors when count=0.
(dd_copy): Call invalidate_cache() for the portions read.
(iwrite): Likewise for the portions written.
(main): Call invalidate_cache for page_size slop or
for full file when count=0.
* cfg.mk (sc_dd_O_FLAGS): Adjust to pass.
* doc/coreutils.texi (dd invocation): Describe the 'nocache' flag,
and give some examples of how it can be used.
* tests/dd/nocache: A new test.
* tests/Makefile.am: Reference the new test.
* NEWS: Mention the new feature.
---
tests/Makefile.am | 1 +
tests/dd/nocache | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+)
create mode 100755 tests/dd/nocache
(limited to 'tests')
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 28eafe8ae..99b46e8e8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -352,6 +352,7 @@ TESTS = \
df/unreadable \
dd/direct \
dd/misc \
+ dd/nocache \
dd/not-rewound \
dd/reblock \
dd/skip-seek \
diff --git a/tests/dd/nocache b/tests/dd/nocache
new file mode 100755
index 000000000..b0d4cc107
--- /dev/null
+++ b/tests/dd/nocache
@@ -0,0 +1,58 @@
+#!/bin/sh
+# Ensure dd handles the 'nocache' flag
+
+# Copyright (C) 2011 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see