mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 00:32:25 -04:00
ffs_inotovp(): interface to convert (ino, gen) into alive vnode
(cherry picked from commit 5952c86c78)
This commit is contained in:
parent
9255b36faf
commit
e3e958f3a4
4 changed files with 40 additions and 29 deletions
|
|
@ -80,6 +80,8 @@ int ffs_freefile(struct ufsmount *, struct fs *, struct vnode *, ino_t,
|
|||
void ffs_fserr(struct fs *, ino_t, char *);
|
||||
int ffs_getcg(struct fs *, struct vnode *, u_int, int, struct buf **,
|
||||
struct cg **);
|
||||
int ffs_inotovp(struct mount *, ino_t, u_int64_t, int, struct vnode **,
|
||||
int);
|
||||
int ffs_isblock(struct fs *, u_char *, ufs1_daddr_t);
|
||||
int ffs_isfreeblock(struct fs *, u_char *, ufs1_daddr_t);
|
||||
void ffs_oldfscompat_write(struct fs *, struct ufsmount *);
|
||||
|
|
|
|||
|
|
@ -2153,35 +2153,55 @@ ffs_fhtovp(mp, fhp, flags, vpp)
|
|||
struct vnode **vpp;
|
||||
{
|
||||
struct ufid *ufhp;
|
||||
|
||||
ufhp = (struct ufid *)fhp;
|
||||
return (ffs_inotovp(mp, ufhp->ufid_ino, ufhp->ufid_gen, flags,
|
||||
vpp, 0));
|
||||
}
|
||||
|
||||
int
|
||||
ffs_inotovp(mp, ino, gen, lflags, vpp, ffs_flags)
|
||||
struct mount *mp;
|
||||
ino_t ino;
|
||||
u_int64_t gen;
|
||||
int lflags;
|
||||
struct vnode **vpp;
|
||||
int ffs_flags;
|
||||
{
|
||||
struct ufsmount *ump;
|
||||
struct vnode *nvp;
|
||||
struct fs *fs;
|
||||
struct cg *cgp;
|
||||
struct buf *bp;
|
||||
ino_t ino;
|
||||
u_int cg;
|
||||
int error;
|
||||
|
||||
ufhp = (struct ufid *)fhp;
|
||||
ino = ufhp->ufid_ino;
|
||||
ump = VFSTOUFS(mp);
|
||||
fs = ump->um_fs;
|
||||
if (ino < UFS_ROOTINO || ino >= fs->fs_ncg * fs->fs_ipg)
|
||||
return (ESTALE);
|
||||
|
||||
/*
|
||||
* Need to check if inode is initialized because UFS2 does lazy
|
||||
* initialization and nfs_fhtovp can offer arbitrary inode numbers.
|
||||
*/
|
||||
if (fs->fs_magic != FS_UFS2_MAGIC)
|
||||
return (ufs_fhtovp(mp, ufhp, flags, vpp));
|
||||
cg = ino_to_cg(fs, ino);
|
||||
if ((error = ffs_getcg(fs, ump->um_devvp, cg, 0, &bp, &cgp)) != 0)
|
||||
return (error);
|
||||
if (ino >= cg * fs->fs_ipg + cgp->cg_initediblk) {
|
||||
if (fs->fs_magic == FS_UFS2_MAGIC) {
|
||||
cg = ino_to_cg(fs, ino);
|
||||
error = ffs_getcg(fs, ump->um_devvp, cg, 0, &bp, &cgp);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
if (ino >= cg * fs->fs_ipg + cgp->cg_initediblk) {
|
||||
brelse(bp);
|
||||
return (ESTALE);
|
||||
}
|
||||
brelse(bp);
|
||||
return (ESTALE);
|
||||
}
|
||||
brelse(bp);
|
||||
return (ufs_fhtovp(mp, ufhp, flags, vpp));
|
||||
|
||||
error = ffs_vgetf(mp, ino, lflags, &nvp, ffs_flags);
|
||||
if (error == 0)
|
||||
error = ufs_fhtovp(mp, nvp, gen);
|
||||
*vpp = error == 0 ? nvp : NULLVP;
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ int ufs_bmap(struct vop_bmap_args *);
|
|||
int ufs_bmaparray(struct vnode *, ufs2_daddr_t, ufs2_daddr_t *,
|
||||
struct buf *, int *, int *);
|
||||
int ufs_bmap_seekdata(struct vnode *, off_t *);
|
||||
int ufs_fhtovp(struct mount *, struct ufid *, int, struct vnode **);
|
||||
int ufs_fhtovp(struct mount *, struct vnode *, u_int64_t);
|
||||
int ufs_checkpath(ino_t, ino_t, struct inode *, struct ucred *, ino_t *);
|
||||
void ufs_dirbad(struct inode *, doff_t, char *);
|
||||
int ufs_dirbadentry(struct vnode *, struct direct *, int);
|
||||
|
|
|
|||
|
|
@ -222,31 +222,20 @@ ufs_uninit(vfsp)
|
|||
* Call the VFS_CHECKEXP beforehand to verify access.
|
||||
*/
|
||||
int
|
||||
ufs_fhtovp(mp, ufhp, flags, vpp)
|
||||
ufs_fhtovp(mp, nvp, gen)
|
||||
struct mount *mp;
|
||||
struct ufid *ufhp;
|
||||
int flags;
|
||||
struct vnode **vpp;
|
||||
struct vnode *nvp;
|
||||
u_int64_t gen;
|
||||
{
|
||||
struct inode *ip;
|
||||
struct vnode *nvp;
|
||||
int error;
|
||||
|
||||
error = VFS_VGET(mp, ufhp->ufid_ino, flags, &nvp);
|
||||
if (error) {
|
||||
*vpp = NULLVP;
|
||||
return (error);
|
||||
}
|
||||
ip = VTOI(nvp);
|
||||
if (ip->i_mode == 0 || ip->i_gen != ufhp->ufid_gen ||
|
||||
ip->i_effnlink <= 0) {
|
||||
if (ip->i_mode == 0 || ip->i_gen != gen || ip->i_effnlink <= 0) {
|
||||
if (ip->i_mode == 0)
|
||||
vgone(nvp);
|
||||
vput(nvp);
|
||||
*vpp = NULLVP;
|
||||
return (ESTALE);
|
||||
}
|
||||
*vpp = nvp;
|
||||
vnode_create_vobject(*vpp, DIP(ip, i_size), curthread);
|
||||
vnode_create_vobject(nvp, DIP(ip, i_size), curthread);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue