summaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1997-06-01 03:16:17 +0000
committerRalf Baechle <ralf@linux-mips.org>1997-06-01 03:16:17 +0000
commitd8d9b8f76f22b7a16a83e261e64f89ee611f49df (patch)
tree3067bc130b80d52808e6390c9fc7fc087ec1e33c /fs/namei.c
parent19c9bba94152148523ba0f7ef7cffe3d45656b11 (diff)
Initial revision
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/fs/namei.c b/fs/namei.c
index aeaca8f45..35ebbd4f4 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -124,24 +124,16 @@ int permission(struct inode * inode,int mask)
* put_write_access() releases this write permission.
* This is used for regular files.
* We cannot support write (and maybe mmap read-write shared) accesses and
- * MAP_DENYWRITE mmappings simultaneously.
+ * MAP_DENYWRITE mmappings simultaneously. The i_writecount field of an inode
+ * can have the following values:
+ * 0: no writers, no VM_DENYWRITE mappings
+ * < 0: (-i_writecount) vm_area_structs with VM_DENYWRITE set exist
+ * > 0: (i_writecount) users are writing to the file.
*/
int get_write_access(struct inode * inode)
{
- struct task_struct * p;
-
- if ((inode->i_count > 1) && S_ISREG(inode->i_mode)) /* shortcut */
- for_each_task(p) {
- struct vm_area_struct * mpnt;
- if (!p->mm)
- continue;
- for(mpnt = p->mm->mmap; mpnt; mpnt = mpnt->vm_next) {
- if (inode != mpnt->vm_inode)
- continue;
- if (mpnt->vm_flags & VM_DENYWRITE)
- return -ETXTBSY;
- }
- }
+ if (inode->i_writecount < 0)
+ return -ETXTBSY;
inode->i_writecount++;
return 0;
}