Commit 8737c9305bd5602b11f7eb4655d5695d4a42a0c6

Authored by Al Viro
1 parent d208bbdda9

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>

Showing 8 changed files with 18 additions and 21 deletions Side-by-side Diff

arch/um/drivers/mconsole_kern.c
... ... @@ -140,7 +140,7 @@
140 140 goto out;
141 141 }
142 142  
143   - err = may_open(&nd.path, MAY_READ, FMODE_READ);
  143 + err = may_open(&nd.path, MAY_READ, O_RDONLY);
144 144 if (result) {
145 145 mconsole_reply(req, "Failed to open file", 1, 0);
146 146 path_put(&nd.path);
... ... @@ -2289,9 +2289,9 @@
2289 2289 if (inode && S_ISREG(inode->i_mode)) {
2290 2290 #ifdef CONFIG_CIFS_EXPERIMENTAL
2291 2291 if (cinode->clientCanCacheAll == 0)
2292   - break_lease(inode, FMODE_READ);
  2292 + break_lease(inode, O_RDONLY);
2293 2293 else if (cinode->clientCanCacheRead == 0)
2294   - break_lease(inode, FMODE_WRITE);
  2294 + break_lease(inode, O_WRONLY);
2295 2295 #endif
2296 2296 rc = filemap_fdatawrite(inode->i_mapping);
2297 2297 if (cinode->clientCanCacheRead == 0) {
... ... @@ -1182,8 +1182,9 @@
1182 1182 struct file_lock *fl;
1183 1183 unsigned long break_time;
1184 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 1189 lock_kernel();
1189 1190  
... ... @@ -1197,7 +1198,7 @@
1197 1198 if (fl->fl_owner == current->files)
1198 1199 i_have_this_lease = 1;
1199 1200  
1200   - if (mode & FMODE_WRITE) {
  1201 + if (want_write) {
1201 1202 /* If we want write access, we have to revoke any lease. */
1202 1203 future = F_UNLCK | F_INPROGRESS;
1203 1204 } else if (flock->fl_type & F_INPROGRESS) {
... ... @@ -1503,7 +1503,7 @@
1503 1503 * An append-only file must be opened in append mode for writing.
1504 1504 */
1505 1505 if (IS_APPEND(inode)) {
1506   - if ((flag & FMODE_WRITE) && !(flag & O_APPEND))
  1506 + if ((flag & O_ACCMODE) != O_RDONLY && !(flag & O_APPEND))
1507 1507 return -EPERM;
1508 1508 if (flag & O_TRUNC)
1509 1509 return -EPERM;
... ... @@ -1547,7 +1547,7 @@
1547 1547 * what get passed to sys_open().
1548 1548 */
1549 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 1552 int error;
1553 1553 struct dentry *dir = nd->path.dentry;
... ... @@ -1565,7 +1565,7 @@
1565 1565 if (error)
1566 1566 return error;
1567 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 @@
1736 1736 error = mnt_want_write(nd.path.mnt);
1737 1737 if (error)
1738 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 1740 if (error) {
1741 1741 mnt_drop_write(nd.path.mnt);
1742 1742 goto exit;
... ... @@ -1798,7 +1798,7 @@
1798 1798 if (error)
1799 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 1802 if (error) {
1803 1803 if (will_truncate)
1804 1804 mnt_drop_write(nd.path.mnt);
... ... @@ -36,10 +36,9 @@
36 36 return ERR_PTR(error);
37 37  
38 38 if (flags == O_RDWR)
39   - error = may_open(&nd.path, MAY_READ|MAY_WRITE,
40   - FMODE_READ|FMODE_WRITE);
  39 + error = may_open(&nd.path, MAY_READ|MAY_WRITE, flags);
41 40 else
42   - error = may_open(&nd.path, MAY_WRITE, FMODE_WRITE);
  41 + error = may_open(&nd.path, MAY_WRITE, flags);
43 42  
44 43 if (!error)
45 44 return dentry_open(nd.path.dentry, nd.path.mnt, flags,
... ... @@ -361,7 +361,7 @@
361 361 * If we are changing the size of the file, then
362 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 365 if (host_err == -EWOULDBLOCK)
366 366 host_err = -ETIMEDOUT;
367 367 if (host_err) /* ENOMEM or EWOULDBLOCK */
... ... @@ -734,7 +734,7 @@
734 734 * Check to see if there are any leases on this file.
735 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 738 if (host_err == -EWOULDBLOCK)
739 739 host_err = -ETIMEDOUT;
740 740 if (host_err) /* NOMEM or WOULDBLOCK */
... ... @@ -271,7 +271,7 @@
271 271 * Make sure that there are no leases. get_write_access() protects
272 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 275 if (error)
276 276 goto put_write_and_out;
277 277  
kernel/sysctl_binary.c
... ... @@ -1331,7 +1331,7 @@
1331 1331 ssize_t result;
1332 1332 char *pathname;
1333 1333 int flags;
1334   - int acc_mode, fmode;
  1334 + int acc_mode;
1335 1335  
1336 1336 pathname = sysctl_getname(name, nlen, &table);
1337 1337 result = PTR_ERR(pathname);
1338 1338  
1339 1339  
... ... @@ -1342,15 +1342,12 @@
1342 1342 if (oldval && oldlen && newval && newlen) {
1343 1343 flags = O_RDWR;
1344 1344 acc_mode = MAY_READ | MAY_WRITE;
1345   - fmode = FMODE_READ | FMODE_WRITE;
1346 1345 } else if (newval && newlen) {
1347 1346 flags = O_WRONLY;
1348 1347 acc_mode = MAY_WRITE;
1349   - fmode = FMODE_WRITE;
1350 1348 } else if (oldval && oldlen) {
1351 1349 flags = O_RDONLY;
1352 1350 acc_mode = MAY_READ;
1353   - fmode = FMODE_READ;
1354 1351 } else {
1355 1352 result = 0;
1356 1353 goto out_putname;
... ... @@ -1361,7 +1358,7 @@
1361 1358 if (result)
1362 1359 goto out_putname;
1363 1360  
1364   - result = may_open(&nd.path, acc_mode, fmode);
  1361 + result = may_open(&nd.path, acc_mode, flags);
1365 1362 if (result)
1366 1363 goto out_putpath;
1367 1364