** Improvements
+ dd now supports iflag=direct with arbitrary sized files on all file systems.
+
tail --bytes=NUM will efficiently seek to the end of block devices,
rather than reading from the start.
iread (int fd, char *buf, size_t size)
{
ssize_t nread;
+ static ssize_t prev_nread;
do
{
process_signals ();
nread = read (fd, buf, size);
+ /* Ignore final read error with iflag=direct as that
+ returns EINVAL due to the non aligned file offset. */
+ if (nread == -1 && errno == EINVAL
+ && 0 < prev_nread && prev_nread < size
+ && (input_flags & O_DIRECT))
+ {
+ errno = 0;
+ nread = 0;
+ }
}
while (nread < 0 && errno == EINTR);
if (0 < nread && warn_partial_read)
{
- static ssize_t prev_nread;
-
if (0 < prev_nread && prev_nread < size)
{
uintmax_t prev = prev_nread;
prev);
warn_partial_read = false;
}
-
- prev_nread = nread;
}
+ prev_nread = nread;
return nread;
}
#!/bin/sh
-# ensure that dd's oflag=direct works
+# ensure that dd's iflag=direct and oflag=direct work
# Copyright (C) 2009-2017 Free Software Foundation, Inc.
for i in short m1 p1; do
rm -f out
- dd if=$i oflag=direct of=out || fail=1
+ dd if=$i iflag=direct oflag=direct of=out || fail=1
done
Exit $fail