summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bushnell <thomas@gnu.org>1996-11-18 23:57:04 +0000
committerThomas Bushnell <thomas@gnu.org>1996-11-18 23:57:04 +0000
commitae11604e4e92e547030664d8cfc2e448ba66b976 (patch)
tree4b604db2132382240f49ddf69fc595c055a3f583
parente7c792104650598a20172427df71c76fff36659d (diff)
Mon Nov 18 17:01:38 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* ops.c (guess_mode_use): Delete function. (netfs_report_access): Use fshelp_access instead of guess_mode_use. Change return type. Sat Nov 16 18:24:55 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> * Makefile (SRCS): Remove `cred.c'. * cred.c: Delete file. * nfs.h (struct netcred): Delete type. (cred_has_uid, cred_has_gid): Delete functions. (nfs_initialize_rpc): netcred arg now iouser. * ops.c: Change struct netcred to struct iouser throughout. * pager.c: Likewise. * cache.c (netfs_node_norefs): Likewise. * nfs.c (nfs_initialize_rpc): Convert use of netcred to iouser.
-rw-r--r--nfs/ChangeLog18
-rw-r--r--nfs/Makefile2
-rw-r--r--nfs/cache.c2
-rw-r--r--nfs/cred.c116
-rw-r--r--nfs/nfs.c34
-rw-r--r--nfs/nfs.h14
-rw-r--r--nfs/ops.c138
-rw-r--r--nfs/pager.c4
8 files changed, 92 insertions, 236 deletions
diff --git a/nfs/ChangeLog b/nfs/ChangeLog
index fb95b7cc..bd9b649c 100644
--- a/nfs/ChangeLog
+++ b/nfs/ChangeLog
@@ -1,3 +1,21 @@
+Mon Nov 18 17:01:38 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
+
+ * ops.c (guess_mode_use): Delete function.
+ (netfs_report_access): Use fshelp_access instead of
+ guess_mode_use. Change return type.
+
+Sat Nov 16 18:24:55 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
+
+ * Makefile (SRCS): Remove `cred.c'.
+ * cred.c: Delete file.
+ * nfs.h (struct netcred): Delete type.
+ (cred_has_uid, cred_has_gid): Delete functions.
+ (nfs_initialize_rpc): netcred arg now iouser.
+ * ops.c: Change struct netcred to struct iouser throughout.
+ * pager.c: Likewise.
+ * cache.c (netfs_node_norefs): Likewise.
+ * nfs.c (nfs_initialize_rpc): Convert use of netcred to iouser.
+
Mon Nov 4 21:23:58 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* rpc.c (rpc_list_lock): Delete variable. Omit all mention of it
diff --git a/nfs/Makefile b/nfs/Makefile
index 8c5baebd..a24a4196 100644
--- a/nfs/Makefile
+++ b/nfs/Makefile
@@ -23,7 +23,7 @@ makemode := server
target = nfs
LCLHDRS = nfs.h mount.h nfs-spec.h
-SRCS = ops.c rpc.c mount.c cred.c nfs.c cache.c consts.c main.c
+SRCS = ops.c rpc.c mount.c nfs.c cache.c consts.c main.c
OBJS = $(subst .c,.o,$(SRCS))
HURDLIBS=ports netfs fshelp threads
diff --git a/nfs/cache.c b/nfs/cache.c
index 7f5135f1..e09b7c38 100644
--- a/nfs/cache.c
+++ b/nfs/cache.c
@@ -117,7 +117,7 @@ netfs_node_norefs (struct node *np)
netfs_nput (np);
mutex_lock (&dir->lock);
- netfs_attempt_unlink ((struct netcred *)-1, dir, name);
+ netfs_attempt_unlink ((struct iouser *)-1, dir, name);
netfs_nput (dir);
free (name);
diff --git a/nfs/cred.c b/nfs/cred.c
deleted file mode 100644
index b83ebaaf..00000000
--- a/nfs/cred.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/* Credential manipulation for NFS client
- Copyright (C) 1995, 1996 Free Software Foundation, Inc.
- Written by Michael I. Bushnell, p/BSG.
-
- This file is part of the GNU Hurd.
-
- The GNU Hurd is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2, or (at
- your option) any later version.
-
- The GNU Hurd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
-
-#include <hurd/netfs.h>
-#include <string.h>
-
-#include "nfs.h"
-
-/* This lock must always be held when manipulating the reference count
- on credential structures. */
-static spin_lock_t cred_refcnt_lock = SPIN_LOCK_INITIALIZER;
-
-/* Interpret CRED, returning newly malloced storage describing the
- user identification references in UIDS, NUIDS, GIDS, and NGIDS.
- See <hurd/libnetfs.h> for details. */
-void
-netfs_interpret_credential (struct netcred *cred, uid_t **uids,
- int *nuids, uid_t **gids, int *ngids)
-{
- /* Who says C isn't APL? */
- bcopy (cred->uids, *uids = malloc ((*nuids = cred->nuids) * sizeof (uid_t)),
- cred->nuids * sizeof (uid_t));
- bcopy (cred->gids, *gids = malloc ((*ngids = cred->ngids) * sizeof (uid_t)),
- cred->ngids * sizeof (uid_t));
-}
-
-/* Return a new reference to CRED. See <hurd/libnetfs.h> for details. */
-struct netcred *
-netfs_copy_credential (struct netcred *cred)
-{
- spin_lock (&cred_refcnt_lock);
- cred->refcnt++;
- spin_unlock (&cred_refcnt_lock);
- return cred;
-}
-
-/* Drop a reference to CRED. See <hurd/libnetfs.h> for details. */
-void
-netfs_drop_credential (struct netcred *cred)
-{
- spin_lock (&cred_refcnt_lock);
- cred->refcnt--;
-
- if (!cred->refcnt)
- {
- spin_unlock (&cred_refcnt_lock);
- free (cred);
- }
- else
- spin_unlock (&cred_refcnt_lock);
-}
-
-/* Make and return a new credential referring to the user identified
- by UIDS, NUIDS, GIDS, and NGIDS. See <hurd/libnetfs.h> for
- details. */
-struct netcred *
-netfs_make_credential (uid_t *uids,
- int nuids,
- uid_t *gids,
- int ngids)
-{
- struct netcred *cred;
-
- cred = malloc (sizeof (struct netcred)
- + nuids * sizeof (uid_t)
- + ngids * sizeof (uid_t));
- cred->uids = (void *) cred + sizeof (struct netcred);
- cred->gids = (void *) cred->uids + nuids * sizeof (uid_t);
- cred->nuids = nuids;
- cred->ngids = ngids;
- cred->refcnt = 1;
-
- bcopy (uids, cred->uids, nuids + sizeof (uid_t));
- bcopy (gids, cred->gids, ngids + sizeof (uid_t));
-
- return cred;
-}
-
-/* Return nonzero iff CRED contains user id UID. */
-int
-cred_has_uid (struct netcred *cred, uid_t uid)
-{
- int i;
- for (i = 0; i < cred->nuids; i++)
- if (cred->uids[i] == uid)
- return 1;
- return 0;
-}
-
-/* Return nonzero iff CRED contains group id GID. */
-int
-cred_has_gid (struct netcred *cred, gid_t gid)
-{
- int i;
- for (i = 0; i < cred->ngids; i++)
- if (cred->gids[i] == gid)
- return 1;
- return 0;
-}
diff --git a/nfs/nfs.c b/nfs/nfs.c
index a44e1fde..ddeeb63e 100644
--- a/nfs/nfs.c
+++ b/nfs/nfs.c
@@ -446,7 +446,7 @@ xdr_decode_string (int *p, char *buf)
in). Allocate at least LEN bytes of space for bulk data in
addition to the normal amount for an RPC. */
int *
-nfs_initialize_rpc (int rpc_proc, struct netcred *cred,
+nfs_initialize_rpc (int rpc_proc, struct iouser *cred,
size_t len, void **bufp, struct node *np,
uid_t second_gid)
{
@@ -457,15 +457,15 @@ nfs_initialize_rpc (int rpc_proc, struct netcred *cred,
/* Use heuristics to figure out what ids to present to the server.
Don't lie, but adjust ids as necessary to secure the desired result. */
- if (cred == (struct netcred *) -1)
+ if (cred == (struct iouser *) -1)
{
uid = gid = 0;
second_gid = -1;
}
else if (cred
- && (cred->nuids || cred->ngids))
+ && (cred->uids->num || cred->gids->num))
{
- if (cred_has_uid (cred, 0))
+ if (idvec_contains (cred->uids, 0))
{
err = netfs_validate_stat (np, 0);
uid = 0;
@@ -475,35 +475,35 @@ nfs_initialize_rpc (int rpc_proc, struct netcred *cred,
}
else
{
- if (cred->nuids == 0)
+ if (cred->uids->num == 0)
uid = -2;
- else if (cred->nuids == 1)
- uid = cred->uids[0];
+ else if (cred->uids->num == 1)
+ uid = cred->uids->ids[0];
else
{
err = netfs_validate_stat (np, 0);
if (err)
{
- uid = cred->uids[0];
+ uid = cred->uids->ids[0];
printf ("NFS warning, internal stat failure\n");
}
else
{
- if (cred_has_uid (cred, np->nn_stat.st_uid))
+ if (idvec_contains (cred->uids, np->nn_stat.st_uid))
uid = np->nn_stat.st_uid;
else
- uid = cred->uids[0];
+ uid = cred->uids->ids[0];
}
}
- if (cred->ngids == 0)
+ if (cred->gids->num == 0)
{
gid = -2;
second_gid = -1;
}
- else if (cred->ngids == 1)
+ else if (cred->gids->num == 1)
{
- gid = cred->gids[0];
+ gid = cred->gids->ids[0];
second_gid = -1;
}
else
@@ -511,18 +511,18 @@ nfs_initialize_rpc (int rpc_proc, struct netcred *cred,
err = netfs_validate_stat (np, 0);
if (err)
{
- gid = cred->gids[0];
+ gid = cred->gids->ids[0];
printf ("NFS warning, internal stat failure\n");
}
else
{
- if (cred_has_gid (cred, np->nn_stat.st_gid))
+ if (idvec_contains (cred->gids, np->nn_stat.st_gid))
gid = np->nn_stat.st_gid;
else
- gid = cred->gids[0];
+ gid = cred->gids->ids[0];
}
if (second_gid != -1
- && !cred_has_gid (cred, second_gid))
+ && !idvec_contains (cred->gids, second_gid))
second_gid = -1;
}
}
diff --git a/nfs/nfs.h b/nfs/nfs.h
index f175eac5..2007237c 100644
--- a/nfs/nfs.h
+++ b/nfs/nfs.h
@@ -71,14 +71,6 @@ struct netnode
char *dead_name;
};
-/* Credential structure to identify a particular user. */
-struct netcred
-{
- uid_t *uids, *gids;
- int nuids, ngids;
- int refcnt;
-};
-
/* Socket file descriptor for talking to RPC servers. */
int main_udp_socket;
@@ -155,10 +147,6 @@ extern int protocol_version;
#define INTSIZE(len) (((len)+3)>>2)
-/* cred.c */
-int cred_has_uid (struct netcred *, uid_t);
-int cred_has_gid (struct netcred *, gid_t);
-
/* nfs.c */
int hurd_mode_to_nfs_type (mode_t);
int *xdr_encode_fhandle (int *, struct fhandle *);
@@ -172,7 +160,7 @@ int *xdr_encode_sattr_stat (int *, struct stat *);
int *xdr_encode_create_state (int *, mode_t);
int *xdr_decode_fattr (int *, struct stat *);
int *xdr_decode_string (int *, char *);
-int *nfs_initialize_rpc (int, struct netcred *, size_t, void **,
+int *nfs_initialize_rpc (int, struct iouser *, size_t, void **,
struct node *, uid_t);
error_t nfs_error_trans (int);
diff --git a/nfs/ops.c b/nfs/ops.c
index eb8cacca..1e4ffb26 100644
--- a/nfs/ops.c
+++ b/nfs/ops.c
@@ -132,7 +132,7 @@ process_wcc_stat (struct node *np, int *p, int mod)
/* Implement the netfs_validate_stat callback as described in
<hurd/netfs.h>. */
error_t
-netfs_validate_stat (struct node *np, struct netcred *cred)
+netfs_validate_stat (struct node *np, struct iouser *cred)
{
int *p;
void *rpcbuf;
@@ -142,7 +142,7 @@ netfs_validate_stat (struct node *np, struct netcred *cred)
return 0;
p = nfs_initialize_rpc (NFSPROC_GETATTR (protocol_version),
- (struct netcred *) -1, 0, &rpcbuf, np, -1);
+ (struct iouser *) -1, 0, &rpcbuf, np, -1);
p = xdr_encode_fhandle (p, &np->nn->handle);
err = conduct_rpc (&rpcbuf, &p);
@@ -160,7 +160,7 @@ netfs_validate_stat (struct node *np, struct netcred *cred)
/* Implement the netfs_attempt_chown callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_chown (struct netcred *cred, struct node *np,
+netfs_attempt_chown (struct iouser *cred, struct node *np,
uid_t uid, gid_t gid)
{
int *p;
@@ -190,7 +190,7 @@ netfs_attempt_chown (struct netcred *cred, struct node *np,
/* Implement the netfs_attempt_chauthor callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_chauthor (struct netcred *cred, struct node *rp,
+netfs_attempt_chauthor (struct iouser *cred, struct node *rp,
uid_t author)
{
return EOPNOTSUPP;
@@ -199,7 +199,7 @@ netfs_attempt_chauthor (struct netcred *cred, struct node *rp,
/* Implement the netfs_attempt_chmod callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_chmod (struct netcred *cred, struct node *np,
+netfs_attempt_chmod (struct iouser *cred, struct node *np,
mode_t mode)
{
int *p;
@@ -263,7 +263,7 @@ netfs_attempt_chmod (struct netcred *cred, struct node *np,
/* Implement the netfs_attempt_chflags callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_chflags (struct netcred *cred, struct node *np,
+netfs_attempt_chflags (struct iouser *cred, struct node *np,
int flags)
{
return EOPNOTSUPP;
@@ -272,7 +272,7 @@ netfs_attempt_chflags (struct netcred *cred, struct node *np,
/* Implement the netfs_attempt_utimes callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_utimes (struct netcred *cred, struct node *np,
+netfs_attempt_utimes (struct iouser *cred, struct node *np,
struct timespec *atime, struct timespec *mtime)
{
int *p;
@@ -301,7 +301,7 @@ netfs_attempt_utimes (struct netcred *cred, struct node *np,
/* Implement the netfs_attempt_set_size callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_set_size (struct netcred *cred, struct node *np,
+netfs_attempt_set_size (struct iouser *cred, struct node *np,
off_t size)
{
int *p;
@@ -330,7 +330,7 @@ netfs_attempt_set_size (struct netcred *cred, struct node *np,
/* Implement the netfs_attempt_statfs callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_statfs (struct netcred *cred, struct node *np,
+netfs_attempt_statfs (struct iouser *cred, struct node *np,
struct statfs *st)
{
int *p;
@@ -365,7 +365,7 @@ netfs_attempt_statfs (struct netcred *cred, struct node *np,
/* Implement the netfs_attempt_sync callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_sync (struct netcred *cred, struct node *np, int wait)
+netfs_attempt_sync (struct iouser *cred, struct node *np, int wait)
{
/* We are already completely synchronous. */
return 0;
@@ -374,7 +374,7 @@ netfs_attempt_sync (struct netcred *cred, struct node *np, int wait)
/* Implement the netfs_attempt_syncfs callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_syncfs (struct netcred *cred, int wait)
+netfs_attempt_syncfs (struct iouser *cred, int wait)
{
return 0;
}
@@ -382,7 +382,7 @@ netfs_attempt_syncfs (struct netcred *cred, int wait)
/* Implement the netfs_attempt_read callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_read (struct netcred *cred, struct node *np,
+netfs_attempt_read (struct iouser *cred, struct node *np,
off_t offset, size_t *len, void *data)
{
int *p;
@@ -449,7 +449,7 @@ netfs_attempt_read (struct netcred *cred, struct node *np,
/* Implement the netfs_attempt_write callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_write (struct netcred *cred, struct node *np,
+netfs_attempt_write (struct iouser *cred, struct node *np,
off_t offset, size_t *len, void *data)
{
int *p;
@@ -521,7 +521,7 @@ netfs_attempt_write (struct netcred *cred, struct node *np,
/* See if NAME exists in DIR for CRED. If so, return EEXIST. */
error_t
-verify_nonexistent (struct netcred *cred, struct node *dir,
+verify_nonexistent (struct iouser *cred, struct node *dir,
char *name)
{
int *p;
@@ -548,7 +548,7 @@ verify_nonexistent (struct netcred *cred, struct node *dir,
/* Implement the netfs_attempt_lookup callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_lookup (struct netcred *cred, struct node *np,
+netfs_attempt_lookup (struct iouser *cred, struct node *np,
char *name, struct node **newnp)
{
int *p;
@@ -595,7 +595,7 @@ netfs_attempt_lookup (struct netcred *cred, struct node *np,
/* Implement the netfs_attempt_mkdir callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_mkdir (struct netcred *cred, struct node *np,
+netfs_attempt_mkdir (struct iouser *cred, struct node *np,
char *name, mode_t mode)
{
int *p;
@@ -622,7 +622,7 @@ netfs_attempt_mkdir (struct netcred *cred, struct node *np,
/* Implement the netfs_attempt_rmdir callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_rmdir (struct netcred *cred, struct node *np,
+netfs_attempt_rmdir (struct iouser *cred, struct node *np,
char *name)
{
int *p;
@@ -651,7 +651,7 @@ netfs_attempt_rmdir (struct netcred *cred, struct node *np,
/* Implement the netfs_attempt_link callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_link (struct netcred *cred, struct node *dir,
+netfs_attempt_link (struct iouser *cred, struct node *dir,
struct node *np, char *name, int excl)
{
int *p;
@@ -884,7 +884,7 @@ netfs_attempt_link (struct netcred *cred, struct node *dir,
mutex_unlock (&np->lock);
mutex_lock (&dir->lock);
- netfs_attempt_unlink ((struct netcred *)-1, dir, name);
+ netfs_attempt_unlink ((struct iouser *)-1, dir, name);
mutex_unlock (&dir->lock);
}
else
@@ -896,7 +896,7 @@ netfs_attempt_link (struct netcred *cred, struct node *dir,
/* Implement the netfs_attempt_mkfile callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_mkfile (struct netcred *cred, struct node *dir,
+netfs_attempt_mkfile (struct iouser *cred, struct node *dir,
mode_t mode, struct node **newnp)
{
error_t err;
@@ -935,7 +935,7 @@ netfs_attempt_mkfile (struct netcred *cred, struct node *dir,
/* Implement the netfs_attempt_create_file callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_create_file (struct netcred *cred, struct node *np,
+netfs_attempt_create_file (struct iouser *cred, struct node *np,
char *name, mode_t mode, struct node **newnp)
{
int *p;
@@ -1007,7 +1007,7 @@ netfs_attempt_create_file (struct netcred *cred, struct node *np,
/* Implement the netfs_attempt_unlink callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_unlink (struct netcred *cred, struct node *dir,
+netfs_attempt_unlink (struct iouser *cred, struct node *dir,
char *name)
{
int *p;
@@ -1086,7 +1086,7 @@ netfs_attempt_unlink (struct netcred *cred, struct node *dir,
/* Implement the netfs_attempt_rename callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_rename (struct netcred *cred, struct node *fromdir,
+netfs_attempt_rename (struct iouser *cred, struct node *fromdir,
char *fromname, struct node *todir, char *toname,
int excl)
{
@@ -1128,7 +1128,7 @@ netfs_attempt_rename (struct netcred *cred, struct node *fromdir,
/* Implement the netfs_attempt_readlink callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_readlink (struct netcred *cred, struct node *np,
+netfs_attempt_readlink (struct iouser *cred, struct node *np,
char *buf)
{
int *p;
@@ -1159,54 +1159,10 @@ netfs_attempt_readlink (struct netcred *cred, struct node *np,
return err;
}
-/* For an NFS node NODE, guess whether CRED is able to read or write
- it by hoping the server uses permissions bits in the "expected
- way". Return the or of O_READ, O_WRITE, and O_EXEC accordingly as
- each is possible. */
-static int
-guess_mode_use (struct node *np,
- struct netcred *cred)
-{
- error_t err;
-
- err = netfs_validate_stat (np, cred);
- if (err)
- return err;
-
- if (cred_has_uid (cred, 0))
- return O_READ|O_WRITE|O_EXEC;
- else if (cred->nuids == 0
- && (np->nn_stat.st_mode & S_IUSEUNK))
- return
- (((np->nn_stat.st_mode & 04000000) ? O_READ : 0)
- | ((np->nn_stat.st_mode & 02000000) ? O_WRITE : 0)
- | ((np->nn_stat.st_mode & 01000000) ? O_EXEC : 0));
- else if (cred_has_uid (cred, np->nn_stat.st_uid)
- || (cred_has_gid (cred, np->nn_stat.st_gid)
- && cred_has_uid (cred, np->nn_stat.st_gid)))
- /* Owner */
- return
- (((np->nn_stat.st_mode & 0400) ? O_READ : 0)
- | ((np->nn_stat.st_mode & 0200) ? O_WRITE : 0)
- | ((np->nn_stat.st_mode & 0100) ? O_EXEC : 0));
- else if (cred_has_gid (cred, np->nn_stat.st_gid))
- /* Group */
- return
- (((np->nn_stat.st_mode & 040) ? O_READ : 0)
- | ((np->nn_stat.st_mode & 020) ? O_WRITE : 0)
- | ((np->nn_stat.st_mode & 010) ? O_EXEC : 0));
- else
- /* Other */
- return
- (((np->nn_stat.st_mode & 4) ? O_READ : 0)
- | ((np->nn_stat.st_mode & 2) ? O_WRITE : 0)
- | ((np->nn_stat.st_mode & 1) ? O_EXEC : 0));
-}
-
/* Implement the netfs_check_open_permissions callback as described in
<hurd/netfs.h>. */
error_t
-netfs_check_open_permissions (struct netcred *cred, struct node *np,
+netfs_check_open_permissions (struct iouser *cred, struct node *np,
int flags, int newnode)
{
int modes;
@@ -1223,13 +1179,29 @@ netfs_check_open_permissions (struct netcred *cred, struct node *np,
/* Implement the netfs_report_access callback as described in
<hurd/netfs.h>. */
-void
-netfs_report_access (struct netcred *cred,
+error_t
+netfs_report_access (struct iouser *cred,
struct node *np,
int *types)
{
+ error_t err;
+
+ err = netfs_validate_stat (np, cred);
+ if (err)
+ return err;
+
if (protocol_version == 2)
- *types = guess_mode_use (np, cred);
+ {
+ /* Hope the server means the same thing be the bits as we do. */
+ *types = 0;
+ if (fshelp_access (&np->nn_stat, S_IREAD, cred) == 0)
+ *types |= O_READ;
+ if (fshelp_access (&np->nn_stat, S_IWRITE, cred) == 0)
+ *types |= O_WRITE;
+ if (fshelp_access (&np->nn_stat, S_IEXEC, cred) == 0)
+ *types |= O_EXEC;
+ return 0;
+ }
else
{
int *p;
@@ -1238,9 +1210,6 @@ netfs_report_access (struct netcred *cred,
int ret;
int write_check, execute_check;
- err = netfs_validate_stat (np, cred);
- if (err)
- goto fallback;
if (S_ISDIR (np->nn_stat.st_mode))
{
write_check = ACCESS3_MODIFY | ACCESS3_DELETE | ACCESS3_EXTEND;
@@ -1268,11 +1237,8 @@ netfs_report_access (struct netcred *cred,
| (ret & write_check ? O_WRITE : 0)
| (ret & execute_check ? O_EXEC : 0));
}
- else
- /* fall back, sigh. */
- fallback:
- *types = guess_mode_use (np, cred);
}
+ return err;
}
}
@@ -1282,7 +1248,7 @@ netfs_report_access (struct netcred *cred,
/* Implement the netfs_check_open_permissions callback as described in
<hurd/netfs.h>. */
error_t
-netfs_check_open_permissions (struct netcred *cred, struct node *np,
+netfs_check_open_permissions (struct iouser *cred, struct node *np,
int flags, int newnode)
{
char byte;
@@ -1372,7 +1338,7 @@ netfs_check_open_permissions (struct netcred *cred, struct node *np,
/* Implement the netfs_report_access callback as described in
<hurd/netfs.h>. */
void
-netfs_report_access (struct netcred *cred,
+netfs_report_access (struct iouser *cred,
struct node *np,
int *types)
{
@@ -1422,7 +1388,7 @@ netfs_report_access (struct netcred *cred,
the error code. Set BUFSIZEP to the amount of data used inside
*BUFP and TOTALENTRIES to the total number of entries copied. */
static error_t
-fetch_directory (struct netcred *cred, struct node *dir,
+fetch_directory (struct iouser *cred, struct node *dir,
void **bufp, size_t *bufsizep, int *totalentries)
{
void *buf;
@@ -1520,7 +1486,7 @@ fetch_directory (struct netcred *cred, struct node *dir,
/* Implement the netfs_get_directs callback as described in
<hurd/netfs.h>. */
error_t
-netfs_get_dirents (struct netcred *cred, struct node *np,
+netfs_get_dirents (struct iouser *cred, struct node *np,
int entry, int nentries, char **data,
mach_msg_type_number_t *datacnt,
vm_size_t bufsiz, int *amt)
@@ -1590,7 +1556,7 @@ netfs_get_dirents (struct netcred *cred, struct node *np,
/* Implement the netfs_set_translator callback as described in
<hurd/netfs.h>. */
error_t
-netfs_set_translator (struct netcred *cred,
+netfs_set_translator (struct iouser *cred,
struct node *np,
char *argz,
size_t argzlen)
@@ -1601,7 +1567,7 @@ netfs_set_translator (struct netcred *cred,
/* Implement the netfs_attempt_mksymlink callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_mksymlink (struct netcred *cred,
+netfs_attempt_mksymlink (struct iouser *cred,
struct node *np,
char *arg)
{
@@ -1621,7 +1587,7 @@ netfs_attempt_mksymlink (struct netcred *cred,
/* Implement the netfs_attempt_mkdev callback as described in
<hurd/netfs.h>. */
error_t
-netfs_attempt_mkdev (struct netcred *cred,
+netfs_attempt_mkdev (struct iouser *cred,
struct node *np,
mode_t type,
dev_t indexes)
diff --git a/nfs/pager.c b/nfs/pager.c
index 687a0e2f..b511429b 100644
--- a/nfs/pager.c
+++ b/nfs/pager.c
@@ -129,7 +129,7 @@ pager_read_page (struct user_pager_info *pager,
if (thisamt > read_size)
thisamt = read_size;
- p = nfs_initialize_rpc (NFSPROC_READ, (struct netcred *)-1, 0,
+ p = nfs_initialize_rpc (NFSPROC_READ, (struct iouser *)-1, 0,
&rpcbuf, np, -1);
p = xdr_encode_fhandle (p, &np->nn->handle);
*p++ = htonl (offset);
@@ -197,7 +197,7 @@ pager_write_page (struct user_pager_info *pager,
if (amt > write_size)
amt = write_size;
- p = nfs_initialize_rpc (NFSPROC_WRITE, (struct netcred *) -1,
+ p = nfs_initialize_rpc (NFSPROC_WRITE, (struct iouser *) -1,
amt, &rpcbuf, np, -1);
p = xdr_encode_fhandle (p, &np->nn->handle);
*p++ = 0;