Added logging for O_DIRECT if devices supports direct i/o

This commit is contained in:
Fabian Druschke
2025-11-17 20:02:54 +01:00
parent 2dbdaf447c
commit 4150dddd84

View File

@@ -493,15 +493,17 @@ int main( int argc, char** argv )
c2[i]->device_fd = open( c2[i]->device_name, open_flags );
#ifdef NWIPE_USE_DIRECT_IO
/* If O_DIRECT is not supported (or rejected by the FS), fall back to buffered I/O. */
if( c2[i]->device_fd < 0 && ( errno == EINVAL || errno == EOPNOTSUPP ) )
{
nwipe_log( NWIPE_LOG_WARNING,
"O_DIRECT not supported on '%s', retrying without O_DIRECT.",
c2[i]->device_name );
nwipe_log( NWIPE_LOG_WARNING, "O_DIRECT not supported on '%s', retrying without.", c2[i]->device_name );
open_flags &= ~O_DIRECT;
c2[i]->device_fd = open( c2[i]->device_name, open_flags );
}
else if( c2[i]->device_fd >= 0 && ( open_flags & O_DIRECT ) )
{
nwipe_log( NWIPE_LOG_NOTICE, "Using O_DIRECT on device '%s'.", c2[i]->device_name );
}
#endif
/* Check the open() result. */