diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2009-12-24 06:47:55 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-03-03 13:00:21 -0500 |
commit | 8737c9305bd5602b11f7eb4655d5695d4a42a0c6 (patch) | |
tree | 54038cac1135b039a292151ebe9b156f80904843 /fs | |
parent | d208bbdda991b8808d9c033ce4d31cb1bd87dcfc (diff) |
Switch may_open() and break_lease() to passing O_...
... instead of mixing FMODE_ and O_
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/cifs/file.c | 4 | ||||
-rw-r--r-- | fs/locks.c | 5 | ||||
-rw-r--r-- | fs/namei.c | 10 | ||||
-rw-r--r-- | fs/nfsctl.c | 5 | ||||
-rw-r--r-- | fs/nfsd/vfs.c | 4 | ||||
-rw-r--r-- | fs/open.c | 2 |
6 files changed, 15 insertions, 15 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 057e1dae12ab..3d8f8a96f5a3 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
@@ -2289,9 +2289,9 @@ cifs_oplock_break(struct slow_work *work) | |||
2289 | if (inode && S_ISREG(inode->i_mode)) { | 2289 | if (inode && S_ISREG(inode->i_mode)) { |
2290 | #ifdef CONFIG_CIFS_EXPERIMENTAL | 2290 | #ifdef CONFIG_CIFS_EXPERIMENTAL |
2291 | if (cinode->clientCanCacheAll == 0) | 2291 | if (cinode->clientCanCacheAll == 0) |
2292 | break_lease(inode, FMODE_READ); | 2292 | break_lease(inode, O_RDONLY); |
2293 | else if (cinode->clientCanCacheRead == 0) | 2293 | else if (cinode->clientCanCacheRead == 0) |
2294 | break_lease(inode, FMODE_WRITE); | 2294 | break_lease(inode, O_WRONLY); |
2295 | #endif | 2295 | #endif |
2296 | rc = filemap_fdatawrite(inode->i_mapping); | 2296 | rc = filemap_fdatawrite(inode->i_mapping); |
2297 | if (cinode->clientCanCacheRead == 0) { | 2297 | if (cinode->clientCanCacheRead == 0) { |
diff --git a/fs/locks.c b/fs/locks.c index a8794f233bc9..ae9ded026b7c 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -1182,8 +1182,9 @@ int __break_lease(struct inode *inode, unsigned int mode) | |||
1182 | struct file_lock *fl; | 1182 | struct file_lock *fl; |
1183 | unsigned long break_time; | 1183 | unsigned long break_time; |
1184 | int i_have_this_lease = 0; | 1184 | int i_have_this_lease = 0; |
1185 | int want_write = (mode & O_ACCMODE) != O_RDONLY; | ||
1185 | 1186 | ||
1186 | new_fl = lease_alloc(NULL, mode & FMODE_WRITE ? F_WRLCK : F_RDLCK); | 1187 | new_fl = lease_alloc(NULL, want_write ? F_WRLCK : F_RDLCK); |
1187 | 1188 | ||
1188 | lock_kernel(); | 1189 | lock_kernel(); |
1189 | 1190 | ||
@@ -1197,7 +1198,7 @@ int __break_lease(struct inode *inode, unsigned int mode) | |||
1197 | if (fl->fl_owner == current->files) | 1198 | if (fl->fl_owner == current->files) |
1198 | i_have_this_lease = 1; | 1199 | i_have_this_lease = 1; |
1199 | 1200 | ||
1200 | if (mode & FMODE_WRITE) { | 1201 | if (want_write) { |
1201 | /* If we want write access, we have to revoke any lease. */ | 1202 | /* If we want write access, we have to revoke any lease. */ |
1202 | future = F_UNLCK | F_INPROGRESS; | 1203 | future = F_UNLCK | F_INPROGRESS; |
1203 | } else if (flock->fl_type & F_INPROGRESS) { | 1204 | } else if (flock->fl_type & F_INPROGRESS) { |
diff --git a/fs/namei.c b/fs/namei.c index a4855af776a8..b20f83d1e065 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -1503,7 +1503,7 @@ int may_open(struct path *path, int acc_mode, int flag) | |||
1503 | * An append-only file must be opened in append mode for writing. | 1503 | * An append-only file must be opened in append mode for writing. |
1504 | */ | 1504 | */ |
1505 | if (IS_APPEND(inode)) { | 1505 | if (IS_APPEND(inode)) { |
1506 | if ((flag & FMODE_WRITE) && !(flag & O_APPEND)) | 1506 | if ((flag & O_ACCMODE) != O_RDONLY && !(flag & O_APPEND)) |
1507 | return -EPERM; | 1507 | return -EPERM; |
1508 | if (flag & O_TRUNC) | 1508 | if (flag & O_TRUNC) |
1509 | return -EPERM; | 1509 | return -EPERM; |
@@ -1547,7 +1547,7 @@ static int handle_truncate(struct path *path) | |||
1547 | * what get passed to sys_open(). | 1547 | * what get passed to sys_open(). |
1548 | */ | 1548 | */ |
1549 | static int __open_namei_create(struct nameidata *nd, struct path *path, | 1549 | static int __open_namei_create(struct nameidata *nd, struct path *path, |
1550 | int flag, int mode) | 1550 | int open_flag, int mode) |
1551 | { | 1551 | { |
1552 | int error; | 1552 | int error; |
1553 | struct dentry *dir = nd->path.dentry; | 1553 | struct dentry *dir = nd->path.dentry; |
@@ -1565,7 +1565,7 @@ out_unlock: | |||
1565 | if (error) | 1565 | if (error) |
1566 | return error; | 1566 | return error; |
1567 | /* Don't check for write permission, don't truncate */ | 1567 | /* Don't check for write permission, don't truncate */ |
1568 | return may_open(&nd->path, 0, flag & ~O_TRUNC); | 1568 | return may_open(&nd->path, 0, open_flag & ~O_TRUNC); |
1569 | } | 1569 | } |
1570 | 1570 | ||
1571 | /* | 1571 | /* |
@@ -1736,7 +1736,7 @@ do_last: | |||
1736 | error = mnt_want_write(nd.path.mnt); | 1736 | error = mnt_want_write(nd.path.mnt); |
1737 | if (error) | 1737 | if (error) |
1738 | goto exit_mutex_unlock; | 1738 | goto exit_mutex_unlock; |
1739 | error = __open_namei_create(&nd, &path, flag, mode); | 1739 | error = __open_namei_create(&nd, &path, open_flag, mode); |
1740 | if (error) { | 1740 | if (error) { |
1741 | mnt_drop_write(nd.path.mnt); | 1741 | mnt_drop_write(nd.path.mnt); |
1742 | goto exit; | 1742 | goto exit; |
@@ -1798,7 +1798,7 @@ ok: | |||
1798 | if (error) | 1798 | if (error) |
1799 | goto exit; | 1799 | goto exit; |
1800 | } | 1800 | } |
1801 | error = may_open(&nd.path, acc_mode, flag); | 1801 | error = may_open(&nd.path, acc_mode, open_flag); |
1802 | if (error) { | 1802 | if (error) { |
1803 | if (will_truncate) | 1803 | if (will_truncate) |
1804 | mnt_drop_write(nd.path.mnt); | 1804 | mnt_drop_write(nd.path.mnt); |
diff --git a/fs/nfsctl.c b/fs/nfsctl.c index d3854d94b7cf..bf9cbd242ddd 100644 --- a/fs/nfsctl.c +++ b/fs/nfsctl.c | |||
@@ -36,10 +36,9 @@ static struct file *do_open(char *name, int flags) | |||
36 | return ERR_PTR(error); | 36 | return ERR_PTR(error); |
37 | 37 | ||
38 | if (flags == O_RDWR) | 38 | if (flags == O_RDWR) |
39 | error = may_open(&nd.path, MAY_READ|MAY_WRITE, | 39 | error = may_open(&nd.path, MAY_READ|MAY_WRITE, flags); |
40 | FMODE_READ|FMODE_WRITE); | ||
41 | else | 40 | else |
42 | error = may_open(&nd.path, MAY_WRITE, FMODE_WRITE); | 41 | error = may_open(&nd.path, MAY_WRITE, flags); |
43 | 42 | ||
44 | if (!error) | 43 | if (!error) |
45 | return dentry_open(nd.path.dentry, nd.path.mnt, flags, | 44 | return dentry_open(nd.path.dentry, nd.path.mnt, flags, |
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 8715d194561a..15dc2deaac5f 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -361,7 +361,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap, | |||
361 | * If we are changing the size of the file, then | 361 | * If we are changing the size of the file, then |
362 | * we need to break all leases. | 362 | * we need to break all leases. |
363 | */ | 363 | */ |
364 | host_err = break_lease(inode, FMODE_WRITE | O_NONBLOCK); | 364 | host_err = break_lease(inode, O_WRONLY | O_NONBLOCK); |
365 | if (host_err == -EWOULDBLOCK) | 365 | if (host_err == -EWOULDBLOCK) |
366 | host_err = -ETIMEDOUT; | 366 | host_err = -ETIMEDOUT; |
367 | if (host_err) /* ENOMEM or EWOULDBLOCK */ | 367 | if (host_err) /* ENOMEM or EWOULDBLOCK */ |
@@ -734,7 +734,7 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, | |||
734 | * Check to see if there are any leases on this file. | 734 | * Check to see if there are any leases on this file. |
735 | * This may block while leases are broken. | 735 | * This may block while leases are broken. |
736 | */ | 736 | */ |
737 | host_err = break_lease(inode, O_NONBLOCK | ((access & NFSD_MAY_WRITE) ? FMODE_WRITE : 0)); | 737 | host_err = break_lease(inode, O_NONBLOCK | ((access & NFSD_MAY_WRITE) ? O_WRONLY : 0)); |
738 | if (host_err == -EWOULDBLOCK) | 738 | if (host_err == -EWOULDBLOCK) |
739 | host_err = -ETIMEDOUT; | 739 | host_err = -ETIMEDOUT; |
740 | if (host_err) /* NOMEM or WOULDBLOCK */ | 740 | if (host_err) /* NOMEM or WOULDBLOCK */ |
@@ -271,7 +271,7 @@ static long do_sys_truncate(const char __user *pathname, loff_t length) | |||
271 | * Make sure that there are no leases. get_write_access() protects | 271 | * Make sure that there are no leases. get_write_access() protects |
272 | * against the truncate racing with a lease-granting setlease(). | 272 | * against the truncate racing with a lease-granting setlease(). |
273 | */ | 273 | */ |
274 | error = break_lease(inode, FMODE_WRITE); | 274 | error = break_lease(inode, O_WRONLY); |
275 | if (error) | 275 | if (error) |
276 | goto put_write_and_out; | 276 | goto put_write_and_out; |
277 | 277 | ||