diff options
Diffstat (limited to 'libdiskfs/file-getfh.c')
-rw-r--r-- | libdiskfs/file-getfh.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/libdiskfs/file-getfh.c b/libdiskfs/file-getfh.c index 1b23b80c..2dcf68e5 100644 --- a/libdiskfs/file-getfh.c +++ b/libdiskfs/file-getfh.c @@ -1,6 +1,6 @@ /* Return a file handle (for nfs server support) - Copyright (C) 1997 Free Software Foundation + Copyright (C) 1997,99,2002 Free Software Foundation, Inc. This file is part of the GNU Hurd. @@ -9,7 +9,7 @@ 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, + 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. @@ -26,33 +26,33 @@ /* Return an NFS file handle for CRED in FH & FN_LEN. */ error_t -diskfs_S_file_getfh (struct protid *cred, char **fh, unsigned *fh_len) +diskfs_S_file_getfh (struct protid *cred, char **fh, size_t *fh_len) { struct node *node; - struct diskfs_fhandle *f; + union diskfs_fhandle *f; if (! cred) return EOPNOTSUPP; if (! idvec_contains (cred->user->uids, 0)) return EPERM; - + + assert (sizeof *f == sizeof f->bytes); + node = cred->po->np; mutex_lock (&node->lock); - if (*fh_len < sizeof (struct diskfs_fhandle)) - vm_allocate (mach_task_self (), (vm_address_t *) fh, - sizeof (struct diskfs_fhandle), 1); - *fh_len = sizeof (struct diskfs_fhandle); - - f = (struct diskfs_fhandle *)*fh; + if (*fh_len < sizeof (union diskfs_fhandle)) + *fh = mmap (0, sizeof (union diskfs_fhandle), PROT_READ|PROT_WRITE, + MAP_ANON, 0, 0); + *fh_len = sizeof *f; - f->cache_id = node->cache_id; - f->gen = node->dn_stat.st_gen; + f = (union diskfs_fhandle *) *fh; - f->filler1 = 0; - bzero (f->filler2, sizeof f->filler2); + bzero (f, sizeof *f); + f->data.cache_id = node->cache_id; + f->data.gen = node->dn_stat.st_gen; mutex_unlock (&node->lock); |