From 7f95a8a4c1a999bee77a323489341505abe2d3db Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Tue, 13 Aug 1996 20:09:00 +0000 Subject: *** empty log message *** --- nfs/ChangeLog | 11 +++++++++++ nfs/ops.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) (limited to 'nfs') diff --git a/nfs/ChangeLog b/nfs/ChangeLog index 23d5ba38..ee69f4ef 100644 --- a/nfs/ChangeLog +++ b/nfs/ChangeLog @@ -1,3 +1,14 @@ +Tue Aug 13 14:57:03 1996 Thomas Bushnell, n/BSG + + * ops.c (netfs_attempt_create_file): Sun's NFS client does not + expect NFSPROC_CREATE to be exclusive. Accordingly, on most + servers (including ours) it isn't exclusive. (Which, of course, + contradicts Sun's own RGC 1094, section 2.2.10.) Which means we + have to insert our own test here to make sure the file doesn't + exist before attempting NFSPROC_CREATE. + (netfs_attempt_link): Likewise. + (verify_nonexistent): New function. + Mon Aug 12 11:13:58 1996 Thomas Bushnell, n/BSG * nfs.c (nfs_error_trans): Repair syntax. diff --git a/nfs/ops.c b/nfs/ops.c index efeded10..4c7c5170 100644 --- a/nfs/ops.c +++ b/nfs/ops.c @@ -409,6 +409,30 @@ netfs_attempt_write (struct netcred *cred, struct node *np, return 0; } +/* See if NAME exists in DIR for CRED. If so, return EEXIST. */ +error_t +verify_nonexistent (struct netcred *cred, struct node *dir, + char *name) +{ + int *p; + void *rpcbuf; + error_t err; + + p = nfs_initialize_rpc (NFSPROC_LOOKUP, cred, 0, &rpcbuf, dir, -1); + p = xdr_encode_fhandle (p, &dir->nn->handle); + p = xdr_encode_string (p, name); + + mutex_lock (&dir->lock); + err = conduct_rpc (&rpcbuf, &p); + if (!err) + err = nfs_error_trans (ntohl (*p++)); + + if (!err) + return EEXIST; + else + return 0; +} + /* Implement the netfs_attempt_lookup callback as described in . */ error_t @@ -594,6 +618,11 @@ netfs_attempt_link (struct netcred *cred, struct node *dir, case BLKDEV: case FIFO: case SOCK: + + err = verify_nonexistent (cred, dir, name); + if (err) + return err; + mutex_lock (&dir->lock); p = nfs_initialize_rpc (NFSPROC_CREATE, cred, 0, &rpcbuf, dir, -1); p = xdr_encode_fhandle (p, &dir->nn->handle); @@ -704,6 +733,10 @@ netfs_attempt_create_file (struct netcred *cred, struct node *np, void *rpcbuf; error_t err; + err = verify_nonexistent (cred, np, name); + if (err) + return err; + p = nfs_initialize_rpc (NFSPROC_CREATE, cred, 0, &rpcbuf, np, -1); p = xdr_encode_fhandle (p, &np->nn->handle); p = xdr_encode_string (p, name); -- cgit v1.2.3