From c1854e43b352d7b3fe3a861302d18d729cf8dced Mon Sep 17 00:00:00 2001 From: Kirk McKusick Date: Thu, 10 Aug 2023 17:50:23 -0700 Subject: [PATCH] Clean up and document UFS/FFS error returns. Sponsored-by: The FreeBSD Foundation (cherry picked from commit 886fd36e1ac2082f1b0decb89d70e1e7a0dc3043) --- sys/ufs/ffs/ffs_vfsops.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 23d0c9bc60d..bdb3fadb84e 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -820,7 +820,7 @@ ffs_reload(struct mount *mp, int flags) newfs->fs_bsize > MAXBSIZE || newfs->fs_bsize < sizeof(struct fs)) { brelse(bp); - return (EIO); /* XXX needs translation */ + return (EINTEGRITY); } /* * Preserve the summary information, read-only status, and @@ -2079,6 +2079,11 @@ ffs_fhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp) vpp, 0)); } +/* + * Return a vnode from a mounted filesystem for inode with specified + * generation number. Return ESTALE if the inode with given generation + * number no longer exists on that filesystem. + */ int ffs_inotovp(struct mount *mp, ino_t ino, @@ -2094,7 +2099,6 @@ ffs_inotovp(struct mount *mp, struct cg *cgp; struct buf *bp; uint64_t cg; - int error; ump = VFSTOUFS(mp); fs = ump->um_fs; @@ -2109,9 +2113,8 @@ ffs_inotovp(struct mount *mp, */ 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 (ffs_getcg(fs, ump->um_devvp, cg, 0, &bp, &cgp) != 0) + return (ESTALE); if (ino >= cg * fs->fs_ipg + cgp->cg_initediblk) { brelse(bp); return (ESTALE); @@ -2119,9 +2122,8 @@ ffs_inotovp(struct mount *mp, brelse(bp); } - error = ffs_vgetf(mp, ino, lflags, &nvp, ffs_flags); - if (error != 0) - return (error); + if (ffs_vgetf(mp, ino, lflags, &nvp, ffs_flags) != 0) + return (ESTALE); ip = VTOI(nvp); if (ip->i_mode == 0 || ip->i_gen != gen || ip->i_effnlink <= 0) { -- 2.45.0