diff options
-rw-r--r-- | ufs/inode.c | 126 |
1 files changed, 0 insertions, 126 deletions
diff --git a/ufs/inode.c b/ufs/inode.c index dc870525..2965114f 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -707,129 +707,3 @@ diskfs_S_file_get_storage_info (struct protid *cred, return err; } - -/* Must be exactly 28 bytes long */ -struct ufs_fhandle -{ - int filler1; - ino_t inum; - long gen; - int filler2[4]; -}; - -/* Return an NFS file handle */ - -error_t -diskfs_S_file_getfh (struct protid *cred, - char **fh, - u_int *fh_len) -{ - struct node *np; - struct ufs_fhandle *f; - - if (!cred) - return EOPNOTSUPP; - - if (!idvec_contains (cred->user->uids, 0)) - return EPERM; - - np = cred->po->np; - - mutex_lock (&np->lock); - - if (*fh_len < sizeof (struct ufs_fhandle)) - vm_allocate (mach_task_self (), (vm_address_t *) fh, - sizeof (struct ufs_fhandle), 1); - *fh_len = sizeof (struct ufs_fhandle); - - f = (struct ufs_fhandle *) *fh; - f->inum = np->dn->number; - f->gen = np->dn_stat.st_gen; - f->filler1 = 0; - f->filler2[0] = f->filler2[1] = f->filler2[2] = f->filler2[3] = 0; - mutex_unlock (&np->lock); - return 0; -} - -/* Lookup an NFS file handle */ -error_t -diskfs_S_fsys_getfile (mach_port_t fsys, - mach_port_t reply, - mach_msg_type_name_t replytype, - uid_t *uids, - u_int nuids, - uid_t *gids, - u_int ngids, - char *handle, - u_int handlelen, - mach_port_t *file, - mach_msg_type_name_t *filetype) -{ - struct port_info *pt = ports_lookup_port (diskfs_port_bucket, fsys, - diskfs_control_class); - struct node *np; - struct ufs_fhandle *f; - error_t err; - int flags; - struct protid *newpi; - struct idvec *uvec, *gvec; - struct iouser *user; - - if (!pt) - return EOPNOTSUPP; - - if (handlelen != sizeof (struct ufs_fhandle)) - { - ports_port_deref (pt); - return EINVAL; - } - - f = (struct ufs_fhandle *) handle; - - err = diskfs_cached_lookup (f->inum, &np); - if (err) - { - ports_port_deref (pt); - return err; - } - - if (np->dn_stat.st_gen != f->gen) - { - diskfs_nput (np); - ports_port_deref (pt); - return ESTALE; - } - - uvec = make_idvec (); - gvec = make_idvec (); - - idvec_set_ids (uvec, uids, nuids); - idvec_set_ids (gvec, gids, ngids); - user = iohelp_create_iouser (uvec, gvec); - - flags = 0; - if (!fshelp_access (&np->dn_stat, S_IREAD, user)) - flags |= O_READ; - if (!fshelp_access (&np->dn_stat, S_IEXEC, user)) - flags |= O_EXEC; - if (!fshelp_access (&np->dn_stat, S_IWRITE, user) - && !S_ISDIR (np->dn_stat.st_mode) - && !diskfs_check_readonly ()) - flags |= O_WRITE; - - err = diskfs_create_protid (diskfs_make_peropen (np, flags, - MACH_PORT_NULL, 0), - user, &newpi); - - iohelp_free_iouser (user); - - diskfs_nput (np); - ports_port_deref (pt); - - if (!err) - { - *file = ports_get_right (newpi); - *filetype = MACH_MSG_TYPE_MAKE_SEND; - } - return err; -} |