From 9f61e0864a90b646e2ab89a05f1f8f13dddf7faa Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Thu, 10 Apr 1997 17:26:19 +0000 Subject: Thu Apr 10 13:25:12 1997 Thomas Bushnell, n/BSG * ops.c (netfs_attempt_set_size): Short circuit EACCES to cover one important case. --- nfs/ChangeLog | 5 +++++ nfs/ops.c | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'nfs') diff --git a/nfs/ChangeLog b/nfs/ChangeLog index 9b2b81ea..3623a990 100644 --- a/nfs/ChangeLog +++ b/nfs/ChangeLog @@ -1,3 +1,8 @@ +Thu Apr 10 13:25:12 1997 Thomas Bushnell, n/BSG + + * ops.c (netfs_attempt_set_size): Short circuit EACCES to cover + one important case. + Fri Feb 21 16:47:35 1997 Miles Bader * main.c (netfs_append_args): Present the remote filesystem as a diff --git a/nfs/ops.c b/nfs/ops.c index 03d3be9b..52953ec7 100644 --- a/nfs/ops.c +++ b/nfs/ops.c @@ -323,6 +323,23 @@ netfs_attempt_set_size (struct iouser *cred, struct node *np, p = process_wcc_stat (np, p, !err); } + /* If we got EACCES, but the user has the file open for writing, + then the NFS protocol has screwed us. There's nothing we can do, + except in the important case of opens with + O_TRUNC|O_CREAT|O_WRONLY|O_EXCL where the new mode does not allow + writing. RCS, for example, uses this to create lock files. So permit + cases where the O_TRUNC isn't doing anything to succeed if the user + does have the file open for writing. */ + if (err == EACCES && (cred->po->openstat & O_WRITE)) + { + err = netfs_validate_stat (np, cred); + if (!err && np->nn_stat.st_size == size) + err = 0; + else + /* Never mind, put the old error back */ + err = EACCES; + } + free (rpcbuf); return err; } -- cgit v1.2.3