summaryrefslogtreecommitdiff
path: root/nfs/ops.c
diff options
context:
space:
mode:
authorThomas Bushnell <thomas@gnu.org>1996-08-13 20:09:00 +0000
committerThomas Bushnell <thomas@gnu.org>1996-08-13 20:09:00 +0000
commit7f95a8a4c1a999bee77a323489341505abe2d3db (patch)
treeb75b85bc8d298d7b0b015d2a9b7400310515f793 /nfs/ops.c
parentb615272fa6dc79bd23eba5fe889733773076779d (diff)
*** empty log message ***
Diffstat (limited to 'nfs/ops.c')
-rw-r--r--nfs/ops.c33
1 files changed, 33 insertions, 0 deletions
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
<hurd/netfs.h>. */
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);