Return EBADF rather than EINVAL for FWRITE failure as per POSIX.
MFC after: 1 week
This commit is contained in:
parent
8dc0e02023
commit
38f63f7e47
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=154072
@ -1983,8 +1983,7 @@ _fget(struct thread *td, int fd, struct file **fpp, int flags, int hold)
|
||||
}
|
||||
|
||||
/*
|
||||
* Note: FREAD failure returns EBADF to maintain backwards
|
||||
* compatibility with what routines returned before.
|
||||
* FREAD and FWRITE failure return EBADF as per POSIX.
|
||||
*
|
||||
* Only one flag, or 0, may be specified.
|
||||
*/
|
||||
@ -1994,7 +1993,7 @@ _fget(struct thread *td, int fd, struct file **fpp, int flags, int hold)
|
||||
}
|
||||
if (flags == FWRITE && (fp->f_flag & FWRITE) == 0) {
|
||||
FILEDESC_UNLOCK(fdp);
|
||||
return (EINVAL);
|
||||
return (EBADF);
|
||||
}
|
||||
if (hold) {
|
||||
fhold(fp);
|
||||
|
Loading…
Reference in New Issue
Block a user