represents the maximum number of inputs that will be merged at once.
When processing more than NMERGE inputs, sort uses temporary files.
+ dd accepts a new parameter iflag=fullblock which turn on reading of full
+ blocks where possible. If this parameter is used and 'read' call is
+ terminated during read, it will be called again for remainder input.
+
** Bug fixes
chcon --verbose now prints a newline after each message
/* A count of the number of pending info signals that have been received. */
static sig_atomic_t volatile info_signal_count;
+/* Function used for read (to handle iflag=fullblock parameter) */
+static ssize_t (*iread_fnc) (int fd, char *buf, size_t size);
+
/* A longest symbol in the struct symbol_values tables below. */
#define LONGEST_SYMBOL "fdatasync"
};
/* Flags, for iflag="..." and oflag="...". */
+#define O_FULLBLOCK 010000000 /* Read only full blocks from input */
static struct symbol_value const flags[] =
{
{"append", O_APPEND},
{"nonblock", O_NONBLOCK},
{"sync", O_SYNC},
{"text", O_TEXT},
+ {"fullblock", O_FULLBLOCK}, /* Read only full blocks from input */
{"", 0}
};
}
}
+/* Wrapper around iread function which reads full blocks if possible */
+static ssize_t
+iread_fullblock (int fd, char *buf, size_t size)
+{
+ ssize_t nread = 0;
+
+ while (0 < size)
+ {
+ ssize_t ncurr = iread(fd, buf, size);
+ if (ncurr < 0)
+ return ncurr;
+ if (ncurr == 0)
+ break;
+ nread += ncurr;
+ buf += ncurr;
+ size -= ncurr;
+ }
+
+ return nread;
+}
+
/* Write to FD the buffer BUF of size SIZE, processing any signals
that arrive. Return the number of bytes written, setting errno if
this is less than SIZE. Keep trying if there are partial
if (input_flags & (O_DSYNC | O_SYNC))
input_flags |= O_RSYNC;
+ if (output_flags & O_FULLBLOCK)
+ {
+ error (0, 0, "%s: %s", _("invalid output flag"), "'fullblock'");
+ usage (EXIT_FAILURE);
+ }
+ iread_fnc = (input_flags & O_FULLBLOCK)?
+ iread_fullblock:
+ iread;
+
if (multiple_bits_set (conversions_mask & (C_ASCII | C_EBCDIC | C_IBM)))
error (EXIT_FAILURE, 0, _("cannot combine any two of {ascii,ebcdic,ibm}"));
if (multiple_bits_set (conversions_mask & (C_BLOCK | C_UNBLOCK)))
do
{
- ssize_t nread = iread (fdesc, buf, blocksize);
+ ssize_t nread = iread_fnc (fdesc, buf, blocksize);
if (nread < 0)
{
if (fdesc == STDIN_FILENO)
(conversions_mask & (C_BLOCK | C_UNBLOCK)) ? ' ' : '\0',
input_blocksize);
- nread = iread (STDIN_FILENO, ibuf, input_blocksize);
+ nread = iread_fnc (STDIN_FILENO, ibuf, input_blocksize);
if (nread == 0)
break; /* EOF. */
outbytes=`echo x | dd bs=3 ibs=10 obs=10 conv=sync 2>/dev/null | wc -c`
test "$outbytes" -eq 3 || fail=1
+(echo a; sleep .1; echo b) \
+ | LC_ALL=C dd bs=4 status=noxfer iflag=fullblock >out 2>err || fail=1
+echo "a
+b" > out_ok
+echo "1+0 records in
+1+0 records out" > err_ok
+compare out out_ok || fail=1
+compare err err_ok || fail=1
+
test $fail -eq 0 && fail=$warn
(exit $fail); exit $fail