mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-26 16:41:25 +00:00
replace checking for ->read/->aio_read presence with check in ->f_mode
Since we are about to introduce new methods (read_iter/write_iter), the tests in a bunch of places would have to grow inconveniently. Check once (at open() time) and store results in ->f_mode as FMODE_CAN_READ and FMODE_CAN_WRITE resp. It might end up being a temporary measure - once everything switches from ->aio_{read,write} to ->{read,write}_iter it might make sense to return to open-coded checks. We'll see... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
b318891929
commit
7f7f25e82d
6 changed files with 23 additions and 11 deletions
|
@ -725,6 +725,10 @@ static int do_dentry_open(struct file *f,
|
|||
}
|
||||
if ((f->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
|
||||
i_readcount_inc(inode);
|
||||
if ((f->f_mode & FMODE_READ) && likely(f->f_op->read || f->f_op->aio_read))
|
||||
f->f_mode |= FMODE_CAN_READ;
|
||||
if ((f->f_mode & FMODE_WRITE) && likely(f->f_op->write || f->f_op->aio_write))
|
||||
f->f_mode |= FMODE_CAN_WRITE;
|
||||
|
||||
f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue