DISK: Properly fail an attempt to access to a non-existent file in raw mode

This commit is contained in:
Mark Pizzolato 2018-04-10 11:45:22 -07:00
parent 6667f651a3
commit 8bec55b976

View file

@ -2622,6 +2622,12 @@ if (strchr (openmode, 'r') && (strchr (openmode, '+') || strchr (openmode, 'w'))
else else
if (strchr (openmode, 'r')) if (strchr (openmode, 'r'))
mode = O_RDONLY; mode = O_RDONLY;
if (mode == O_RDONLY) {
struct stat statb;
if (stat (rawdevicename, &statb)) /* test for existence/access */
return (FILE *)NULL;
}
#ifdef O_LARGEFILE #ifdef O_LARGEFILE
mode |= O_LARGEFILE; mode |= O_LARGEFILE;
#endif #endif