Index: xfs_syscalls-common.c =================================================================== RCS file: /afs/stacken.kth.se/src/SourceRepository/arla/xfs/bsd/xfs_syscalls-common.c,v retrieving revision 1.57 diff -u -w -u -w -r1.57 xfs_syscalls-common.c --- xfs_syscalls-common.c 2001/01/01 22:17:40 1.57 +++ xfs_syscalls-common.c 2001/01/01 22:37:07 @@ -303,42 +303,18 @@ } /* - * return file handle of `vp' in vice_ioctl->out - * vp is vrele:d + * implement xfs fhget in a way that should be compatible with the native + * getfh */ static int -fhget_call (struct proc *p, +getfh_compat (struct proc *p, struct ViceIoctl *vice_ioctl, struct vnode *vp) { - int error; -#if !((defined(HAVE_GETFH) && defined(HAVE_FHOPEN)) || defined(__osf__)) - struct mount *mnt; - struct vattr vattr; - size_t len; - struct xfs_fhandle_t xfs_handle; - struct xfs_fh_args fh_args; -#endif - - XFSDEB(XDEBSYS, ("fhget_call\n")); - - if (vp == NULL) - return EBADF; - -#ifdef __APPLE__ - error = EINVAL; /* XXX: Leaks vnodes if fhget/fhopen is used */ - goto out; -#endif - - error = xfs_suser (p); - if (error) - goto out; - -#if (defined(HAVE_GETFH) && defined(HAVE_FHOPEN)) || defined(__osf__) - { /* This is to be same as getfh */ fhandle_t fh; + int error; bzero((caddr_t)&fh, sizeof(fh)); fh.fh_fsid = vp->v_mount->mnt_stat.f_fsid; @@ -348,20 +324,33 @@ error = VFS_VPTOFH(vp, &fh.fh_fid); #endif if (error) - goto out; + return error; - if (vice_ioctl->out_size < sizeof(fh)) { - error = EINVAL; - goto out; - } + if (vice_ioctl->out_size < sizeof(fh)) + return EINVAL; - error = copyout((caddr_t)&fh, vice_ioctl->out, sizeof (fh)); - goto out; + return copyout((caddr_t)&fh, vice_ioctl->out, sizeof (fh)); } -#else + +/* + * implement xfs fhget by combining (dev, ino, generation) + */ + +static int +trad_fhget (struct proc *p, + struct ViceIoctl *vice_ioctl, + struct vnode *vp) +{ + int error; + struct mount *mnt; + struct vattr vattr; + size_t len; + struct xfs_fhandle_t xfs_handle; + struct xfs_fh_args fh_args; + xfs_vop_getattr(vp, &vattr, xfs_proc_to_cred(p), p, error); if (error) - goto out; + return error; mnt = vp->v_mount; @@ -373,21 +362,50 @@ memcpy (xfs_handle.fhdata, &fh_args, sizeof(fh_args)); len = sizeof(xfs_handle); - if (vice_ioctl->out_size < len) { - error = EINVAL; - goto out; - } + if (vice_ioctl->out_size < len) + return EINVAL; error = copyout (&xfs_handle, vice_ioctl->out, len); if (error) { XFSDEB(XDEBSYS, ("fhget_call: copyout failed: %d\n", error)); } + return error; +} + +/* + * return file handle of `vp' in vice_ioctl->out + * vp is vrele:d + */ + +static int +fhget_call (struct proc *p, + struct ViceIoctl *vice_ioctl, + struct vnode *vp) +{ + int error; + + XFSDEB(XDEBSYS, ("fhget_call\n")); + if (vp == NULL) + return EBADF; + +#ifdef __APPLE__ + error = EINVAL; /* XXX: Leaks vnodes if fhget/fhopen is used */ + goto out; +#endif + + error = xfs_suser (p); + if (error) + goto out; + +#if (defined(HAVE_GETFH) && defined(HAVE_FHOPEN)) || defined(__osf__) + error = getfh_compat (p, vice_ioctl, vp); +#else + error = trad_fhget (p, vice_ioctl, vp); +#endif /* HAVE_GETFH && HAVE_FHOPEN */ out: vrele (vp); return error; -#endif /* HAVE_GETFH && HAVE_FHOPEN */ - } /*