diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-06-22 04:39:14 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-07-14 08:33:35 -0400 |
commit | d95852777bc8ba6b3ad3397d495c5f9dd8ca8383 (patch) | |
tree | 96e9d8b1d33c4f6f7b5ba5be0fa4fd8f77c7a67f /fs/nfs/dir.c | |
parent | 3d8a00d2099ebc6d5a6e95fadaf861709d9919a8 (diff) |
make ->atomic_open() return int
Change of calling conventions:
old new
NULL 1
file 0
ERR_PTR(-ve) -ve
Caller *knows* that struct file *; no need to return it.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/nfs/dir.c')
-rw-r--r-- | fs/nfs/dir.c | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 6deb2549ead5..b56f4b36ed41 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -111,9 +111,9 @@ const struct inode_operations nfs3_dir_inode_operations = { | |||
111 | 111 | ||
112 | #ifdef CONFIG_NFS_V4 | 112 | #ifdef CONFIG_NFS_V4 |
113 | 113 | ||
114 | static struct file *nfs_atomic_open(struct inode *, struct dentry *, | 114 | static int nfs_atomic_open(struct inode *, struct dentry *, |
115 | struct opendata *, unsigned, umode_t, | 115 | struct opendata *, unsigned, umode_t, |
116 | int *); | 116 | int *); |
117 | const struct inode_operations nfs4_dir_inode_operations = { | 117 | const struct inode_operations nfs4_dir_inode_operations = { |
118 | .create = nfs_create, | 118 | .create = nfs_create, |
119 | .lookup = nfs_lookup, | 119 | .lookup = nfs_lookup, |
@@ -1387,10 +1387,10 @@ static int do_open(struct inode *inode, struct file *filp) | |||
1387 | return 0; | 1387 | return 0; |
1388 | } | 1388 | } |
1389 | 1389 | ||
1390 | static struct file *nfs_finish_open(struct nfs_open_context *ctx, | 1390 | static int nfs_finish_open(struct nfs_open_context *ctx, |
1391 | struct dentry *dentry, | 1391 | struct dentry *dentry, |
1392 | struct opendata *od, unsigned open_flags, | 1392 | struct opendata *od, unsigned open_flags, |
1393 | int *opened) | 1393 | int *opened) |
1394 | { | 1394 | { |
1395 | struct file *filp; | 1395 | struct file *filp; |
1396 | int err; | 1396 | int err; |
@@ -1403,30 +1403,31 @@ static struct file *nfs_finish_open(struct nfs_open_context *ctx, | |||
1403 | /* If the open_intent is for execute, we have an extra check to make */ | 1403 | /* If the open_intent is for execute, we have an extra check to make */ |
1404 | if (ctx->mode & FMODE_EXEC) { | 1404 | if (ctx->mode & FMODE_EXEC) { |
1405 | err = nfs_may_open(dentry->d_inode, ctx->cred, open_flags); | 1405 | err = nfs_may_open(dentry->d_inode, ctx->cred, open_flags); |
1406 | if (err < 0) { | 1406 | if (err < 0) |
1407 | filp = ERR_PTR(err); | ||
1408 | goto out; | 1407 | goto out; |
1409 | } | ||
1410 | } | 1408 | } |
1411 | 1409 | ||
1412 | filp = finish_open(od, dentry, do_open, opened); | 1410 | filp = finish_open(od, dentry, do_open, opened); |
1413 | if (!IS_ERR(filp)) | 1411 | if (IS_ERR(filp)) { |
1414 | nfs_file_set_open_context(filp, ctx); | 1412 | err = PTR_ERR(filp); |
1413 | goto out; | ||
1414 | } | ||
1415 | nfs_file_set_open_context(filp, ctx); | ||
1416 | err = 0; | ||
1415 | 1417 | ||
1416 | out: | 1418 | out: |
1417 | put_nfs_open_context(ctx); | 1419 | put_nfs_open_context(ctx); |
1418 | return filp; | 1420 | return err; |
1419 | } | 1421 | } |
1420 | 1422 | ||
1421 | static struct file *nfs_atomic_open(struct inode *dir, struct dentry *dentry, | 1423 | static int nfs_atomic_open(struct inode *dir, struct dentry *dentry, |
1422 | struct opendata *od, unsigned open_flags, | 1424 | struct opendata *od, unsigned open_flags, |
1423 | umode_t mode, int *opened) | 1425 | umode_t mode, int *opened) |
1424 | { | 1426 | { |
1425 | struct nfs_open_context *ctx; | 1427 | struct nfs_open_context *ctx; |
1426 | struct dentry *res; | 1428 | struct dentry *res; |
1427 | struct iattr attr = { .ia_valid = ATTR_OPEN }; | 1429 | struct iattr attr = { .ia_valid = ATTR_OPEN }; |
1428 | struct inode *inode; | 1430 | struct inode *inode; |
1429 | struct file *filp; | ||
1430 | int err; | 1431 | int err; |
1431 | 1432 | ||
1432 | /* Expect a negative dentry */ | 1433 | /* Expect a negative dentry */ |
@@ -1437,21 +1438,19 @@ static struct file *nfs_atomic_open(struct inode *dir, struct dentry *dentry, | |||
1437 | 1438 | ||
1438 | /* NFS only supports OPEN on regular files */ | 1439 | /* NFS only supports OPEN on regular files */ |
1439 | if ((open_flags & O_DIRECTORY)) { | 1440 | if ((open_flags & O_DIRECTORY)) { |
1440 | err = -ENOENT; | ||
1441 | if (!d_unhashed(dentry)) { | 1441 | if (!d_unhashed(dentry)) { |
1442 | /* | 1442 | /* |
1443 | * Hashed negative dentry with O_DIRECTORY: dentry was | 1443 | * Hashed negative dentry with O_DIRECTORY: dentry was |
1444 | * revalidated and is fine, no need to perform lookup | 1444 | * revalidated and is fine, no need to perform lookup |
1445 | * again | 1445 | * again |
1446 | */ | 1446 | */ |
1447 | goto out_err; | 1447 | return -ENOENT; |
1448 | } | 1448 | } |
1449 | goto no_open; | 1449 | goto no_open; |
1450 | } | 1450 | } |
1451 | 1451 | ||
1452 | err = -ENAMETOOLONG; | ||
1453 | if (dentry->d_name.len > NFS_SERVER(dir)->namelen) | 1452 | if (dentry->d_name.len > NFS_SERVER(dir)->namelen) |
1454 | goto out_err; | 1453 | return -ENAMETOOLONG; |
1455 | 1454 | ||
1456 | if (open_flags & O_CREAT) { | 1455 | if (open_flags & O_CREAT) { |
1457 | attr.ia_valid |= ATTR_MODE; | 1456 | attr.ia_valid |= ATTR_MODE; |
@@ -1465,7 +1464,7 @@ static struct file *nfs_atomic_open(struct inode *dir, struct dentry *dentry, | |||
1465 | ctx = create_nfs_open_context(dentry, open_flags); | 1464 | ctx = create_nfs_open_context(dentry, open_flags); |
1466 | err = PTR_ERR(ctx); | 1465 | err = PTR_ERR(ctx); |
1467 | if (IS_ERR(ctx)) | 1466 | if (IS_ERR(ctx)) |
1468 | goto out_err; | 1467 | goto out; |
1469 | 1468 | ||
1470 | nfs_block_sillyrename(dentry->d_parent); | 1469 | nfs_block_sillyrename(dentry->d_parent); |
1471 | inode = NFS_PROTO(dir)->open_context(dir, ctx, open_flags, &attr); | 1470 | inode = NFS_PROTO(dir)->open_context(dir, ctx, open_flags, &attr); |
@@ -1489,7 +1488,7 @@ static struct file *nfs_atomic_open(struct inode *dir, struct dentry *dentry, | |||
1489 | default: | 1488 | default: |
1490 | break; | 1489 | break; |
1491 | } | 1490 | } |
1492 | goto out_err; | 1491 | goto out; |
1493 | } | 1492 | } |
1494 | res = d_add_unique(dentry, inode); | 1493 | res = d_add_unique(dentry, inode); |
1495 | if (res != NULL) | 1494 | if (res != NULL) |
@@ -1498,22 +1497,20 @@ static struct file *nfs_atomic_open(struct inode *dir, struct dentry *dentry, | |||
1498 | nfs_unblock_sillyrename(dentry->d_parent); | 1497 | nfs_unblock_sillyrename(dentry->d_parent); |
1499 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | 1498 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); |
1500 | 1499 | ||
1501 | filp = nfs_finish_open(ctx, dentry, od, open_flags, opened); | 1500 | err = nfs_finish_open(ctx, dentry, od, open_flags, opened); |
1502 | 1501 | ||
1503 | dput(res); | 1502 | dput(res); |
1504 | return filp; | 1503 | out: |
1505 | 1504 | return err; | |
1506 | out_err: | ||
1507 | return ERR_PTR(err); | ||
1508 | 1505 | ||
1509 | no_open: | 1506 | no_open: |
1510 | res = nfs_lookup(dir, dentry, NULL); | 1507 | res = nfs_lookup(dir, dentry, NULL); |
1511 | err = PTR_ERR(res); | 1508 | err = PTR_ERR(res); |
1512 | if (IS_ERR(res)) | 1509 | if (IS_ERR(res)) |
1513 | goto out_err; | 1510 | goto out; |
1514 | 1511 | ||
1515 | finish_no_open(od, res); | 1512 | finish_no_open(od, res); |
1516 | return NULL; | 1513 | return 1; |
1517 | } | 1514 | } |
1518 | 1515 | ||
1519 | static int nfs4_lookup_revalidate(struct dentry *dentry, struct nameidata *nd) | 1516 | static int nfs4_lookup_revalidate(struct dentry *dentry, struct nameidata *nd) |