diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-02-11 17:49:24 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-05-06 17:32:55 -0400 |
commit | 7f7f25e82d54870df24d415a7007fbd327da027b (patch) | |
tree | bac50bd31cd0582a873e1429271299536fb768bc /fs/open.c | |
parent | b318891929c2750055a4002bee3e7636ca3684de (diff) |
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>
Diffstat (limited to 'fs/open.c')
-rw-r--r-- | fs/open.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -725,6 +725,10 @@ static int do_dentry_open(struct file *f, | |||
725 | } | 725 | } |
726 | if ((f->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) | 726 | if ((f->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) |
727 | i_readcount_inc(inode); | 727 | i_readcount_inc(inode); |
728 | if ((f->f_mode & FMODE_READ) && likely(f->f_op->read || f->f_op->aio_read)) | ||
729 | f->f_mode |= FMODE_CAN_READ; | ||
730 | if ((f->f_mode & FMODE_WRITE) && likely(f->f_op->write || f->f_op->aio_write)) | ||
731 | f->f_mode |= FMODE_CAN_WRITE; | ||
728 | 732 | ||
729 | f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); | 733 | f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); |
730 | 734 | ||