.SH SYNOPSIS
.B badblocks
[
-.B \-svwnf
+.B \-svwnfBX
]
[
.B \-b
.B \-n
option, as they are mutually exclusive.
.TP
+.B \-B
+Use buffered I/O and do not use Direct I/O, even if it is available.
+.TP
.B \-X
Internal flag only to be used by
.BR e2fsck (8)
static int t_max = 0; /* allocated test patterns */
static unsigned int *t_patts = NULL; /* test patterns */
static int current_O_DIRECT = 0; /* Current status of O_DIRECT flag */
+static int use_buffered_io = 0;
static int exclusive_ok = 0;
static unsigned int max_bb = 0; /* Abort test if more than this number of bad blocks has been encountered */
static unsigned int d_flag = 0; /* delay factor between reads */
int new_flag = O_DIRECT;
int flag;
- if ((((unsigned long) buffer & (sys_page_size - 1)) != 0) ||
+ if ((use_buffered_io != 0) ||
+ (((unsigned long) buffer & (sys_page_size - 1)) != 0) ||
((size & (sys_page_size - 1)) != 0) ||
((offset & (O_DIRECT_SIZE - 1)) != 0))
new_flag = 0;
{
errcode_t retval;
+#ifdef O_DIRECT
+ if (!use_buffered_io)
+ return;
+#endif
retval = ext2fs_sync_device(host_dev, 1);
if (retval)
com_err(program_name, retval, _("during ext2fs_sync_device"));
if (argc && *argv)
program_name = *argv;
- while ((c = getopt (argc, argv, "b:d:e:fi:o:svwnc:p:h:t:X")) != EOF) {
+ while ((c = getopt (argc, argv, "b:d:e:fi:o:svwnc:p:h:t:BX")) != EOF) {
switch (c) {
case 'b':
block_size = parse_uint(optarg, "block size");
t_patts[t_flag++] = pattern;
}
break;
+ case 'B':
+ use_buffered_io = 1;
+ break;
case 'X':
exclusive_ok++;
break;