From 5a36d1be4703a856456ca483c866955b969841db Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Wed, 20 Aug 1997 20:42:23 +0000 Subject: Wed Aug 20 14:31:03 1997 Thomas Bushnell, n/BSG * ops.c (netfs_attempt_link): Implement EXCL == 0 case. (netfs_attempt_rename): Implement EXCL != 0 case. --- nfs/ChangeLog | 3 +++ nfs/ops.c | 41 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) (limited to 'nfs') diff --git a/nfs/ChangeLog b/nfs/ChangeLog index afdb9495..4fcc0d83 100644 --- a/nfs/ChangeLog +++ b/nfs/ChangeLog @@ -1,5 +1,8 @@ Wed Aug 20 14:31:03 1997 Thomas Bushnell, n/BSG + * ops.c (netfs_attempt_link): Implement EXCL == 0 case. + (netfs_attempt_rename): Implement EXCL != 0 case. + * pager.c (netfs_get_filemap): If pager_create fails, return error to caller. diff --git a/nfs/ops.c b/nfs/ops.c index 4520e516..f23fcbc2 100644 --- a/nfs/ops.c +++ b/nfs/ops.c @@ -722,7 +722,14 @@ netfs_attempt_link (struct iouser *cred, struct node *dir, error_t err = 0; if (!excl) - return EOPNOTSUPP; /* XXX */ + { + /* We have no RPC available that will do an atomic replacement, + so we settle for second best; just doing an unlink and ignoring + any errors. */ + mutex_lock (&dir->lock); + netfs_attempt_unlink (cred, dir, name); + mutex_unlock (&dir->lock); + } /* If we have postponed a translator setting on an unlinked node, then here's where we set it, by creating the new node instead of @@ -1193,7 +1200,37 @@ netfs_attempt_rename (struct iouser *cred, struct node *fromdir, error_t err; if (excl) - return EOPNOTSUPP; /* XXX */ + { + struct node *np; + + /* Just do a lookup/link/unlink sequence. */ + + mutex_lock (&fromdir->lock); + err = netfs_attempt_lookup (cred, fromdir, fromname, &np); + mutex_unlock (&fromdir->lock); + if (err) + return err; + + err = netfs_attempt_link (cred, todir, np, toname, 1); + netfs_nput (np); + if (err) + return err; + + mutex_lock (&fromdir->lock); + err = netfs_attempt_unlink (cred, fromdir, fromname); + mutex_unlock (&fromdir->lock); + + /* If the unlink failed, then back out the link */ + if (err) + { + mutex_lock (&todir->lock); + netfs_attempt_unlink (cred, todir, toname); + mutex_unlock (&todir->lock); + return err; + } + + return 0; + } mutex_lock (&fromdir->lock); purge_lookup_cache (fromdir, fromname, strlen (fromname)); -- cgit v1.2.3