From 54f5ccceca2531f1a88cb4d0404f92edffa09cae Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Tue, 7 Jul 2009 02:33:43 +0000 Subject: filter: use O_ACCMODE for checking file access modes. Signed-off-by: Anand V. Avati --- xlators/features/filter/src/filter.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'xlators/features/filter') diff --git a/xlators/features/filter/src/filter.c b/xlators/features/filter/src/filter.c index 154b172af5c..c9cd8dbfa6b 100644 --- a/xlators/features/filter/src/filter.c +++ b/xlators/features/filter/src/filter.c @@ -1059,13 +1059,15 @@ filter_open (call_frame_t *frame, case GF_FILTER_MAP_UID: if (loc->inode->st_mode & S_IWGRP) break; - if (!((flags & O_WRONLY) || (flags & O_RDWR)) + if (!(((flags & O_ACCMODE) == O_WRONLY) + || ((flags & O_ACCMODE) == O_RDWR)) && (loc->inode->st_mode & S_IRGRP)) break; case GF_FILTER_MAP_BOTH: if (loc->inode->st_mode & S_IWOTH) break; - if (!((flags & O_WRONLY) || (flags & O_RDWR)) + if (!(((flags & O_ACCMODE) == O_WRONLY) + || ((flags & O_ACCMODE) == O_RDWR)) && (loc->inode->st_mode & S_IROTH)) break; gf_log (this->name, GF_LOG_DEBUG, @@ -1076,7 +1078,8 @@ filter_open (call_frame_t *frame, case GF_FILTER_FILTER_UID: case GF_FILTER_FILTER_GID: case GF_FILTER_RO_FS: - if (!((flags & O_WRONLY) || (flags & O_RDWR))) + if (!(((flags & O_ACCMODE) == O_WRONLY) + || ((flags & O_ACCMODE) == O_RDWR))) break; STACK_UNWIND (frame, -1, EROFS, NULL); return 0; -- cgit