dev-io.c: give a better diagnostic upon failed stat
The main change here is to report strerror(errno) upon stat failure:
i.e., the s/log_error/log_sys_error/ part. Also made the "device changed" diagnostic more definite. Ok to commit?
Use log_sys_error after failed stat to report strerror(errno). Use a slightly different diagnostic to report mismatched device number.
--- lib/device/dev-io.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)
lib/device/dev-io.c +9 -4
@@ -359,10 +359,15 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)return 0 ; } -if (!(dev->flags &DEV_REGULAR ) && - ((stat (name, &buf) <0 ) || (buf.st_rdev != dev->dev))) { -log_error ("%s: stat failed: Has device name changed?" , name); -return 0 ; +if (!(dev->flags &DEV_REGULAR )) { +if (stat (name, &buf) <0 ) { +log_sys_error ("%s: stat failed" , name); +return 0 ; + } +if (buf.st_rdev != dev->dev) { +log_error ("%s: device changed" , name); +return 0 ; + } }#ifdef O_DIRECT_SUPPORT
Quoted 3 lines · Jim Meyering
The main change here is to report strerror(errno) upon stat failure:
i.e., the s/log_error/log_sys_error/ part. Also made the "device changed" diagnostic more definite. Ok to commit?
Yes.
Alasdair