Add lgetfh(2) which is like getfh(2) but doesn't follow symlinks.

This commit is contained in:
Doug Rabson 2004-04-05 10:15:53 +00:00
parent e776f0f9f8
commit 0b0a60fb43
3 changed files with 77 additions and 1 deletions

View File

@ -247,7 +247,7 @@
157 COMPAT4 { int statfs(char *path, struct ostatfs *buf); }
158 COMPAT4 { int fstatfs(int fd, struct ostatfs *buf); }
159 UNIMPL nosys
160 UNIMPL nosys
160 STD { int lgetfh(char *fname, struct fhandle *fhp); }
161 STD { int getfh(char *fname, struct fhandle *fhp); }
162 MSTD { int getdomainname(char *domainname, int len); }
163 MSTD { int setdomainname(char *domainname, int len); }

View File

@ -3823,6 +3823,44 @@ getvnode(fdp, fd, fpp)
/*
* Get (NFS) file handle
*/
#ifndef _SYS_SYSPROTO_H_
struct lgetfh_args {
char *fname;
fhandle_t *fhp;
};
#endif
int
lgetfh(td, uap)
struct thread *td;
register struct lgetfh_args *uap;
{
struct nameidata nd;
fhandle_t fh;
register struct vnode *vp;
int error;
/*
* Must be super user
*/
error = suser(td);
if (error)
return (error);
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, td);
error = namei(&nd);
if (error)
return (error);
NDFREE(&nd, NDF_ONLY_PNBUF);
vp = nd.ni_vp;
bzero(&fh, sizeof(fh));
fh.fh_fsid = vp->v_mount->mnt_stat.f_fsid;
error = VFS_VPTOFH(vp, &fh.fh_fid);
vput(vp);
if (error)
return (error);
error = copyout(&fh, uap->fhp, sizeof (fh));
return (error);
}
#ifndef _SYS_SYSPROTO_H_
struct getfh_args {
char *fname;

View File

@ -3823,6 +3823,44 @@ getvnode(fdp, fd, fpp)
/*
* Get (NFS) file handle
*/
#ifndef _SYS_SYSPROTO_H_
struct lgetfh_args {
char *fname;
fhandle_t *fhp;
};
#endif
int
lgetfh(td, uap)
struct thread *td;
register struct lgetfh_args *uap;
{
struct nameidata nd;
fhandle_t fh;
register struct vnode *vp;
int error;
/*
* Must be super user
*/
error = suser(td);
if (error)
return (error);
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, td);
error = namei(&nd);
if (error)
return (error);
NDFREE(&nd, NDF_ONLY_PNBUF);
vp = nd.ni_vp;
bzero(&fh, sizeof(fh));
fh.fh_fsid = vp->v_mount->mnt_stat.f_fsid;
error = VFS_VPTOFH(vp, &fh.fh_fid);
vput(vp);
if (error)
return (error);
error = copyout(&fh, uap->fhp, sizeof (fh));
return (error);
}
#ifndef _SYS_SYSPROTO_H_
struct getfh_args {
char *fname;