diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2013-05-30 19:19:10 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2013-05-30 19:19:10 +0000 |
commit | f18acc3c55f821a92db9c79c9543a77f44614385 (patch) | |
tree | 84d06ac31173344def7160df45acb222adf933ff /sys | |
parent | 62394cd8a6d331826ba0a405415dc0cb58cd861b (diff) |
UFS does't do inode numbers >2^32, so use a smaller type internally,
only using ino_t in the VFS layer APIs: vget, readdir, getattr.
otto wrote the original diff for libsa to keep bootblock from overflowing
ok deraadt@ kettenis@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/lib/libsa/ufs.c | 18 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_alloc.c | 8 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_dinode.h | 9 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_extern.h | 6 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_lookup.c | 4 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_vfsops.c | 6 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_alloc.c | 16 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_extern.h | 10 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_softdep.c | 24 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_softdep_stub.c | 6 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 8 | ||||
-rw-r--r-- | sys/ufs/ffs/softdep.h | 18 | ||||
-rw-r--r-- | sys/ufs/ufs/dinode.h | 10 | ||||
-rw-r--r-- | sys/ufs/ufs/inode.h | 11 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_extern.h | 10 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_ihash.c | 14 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_lookup.c | 8 |
17 files changed, 101 insertions, 85 deletions
diff --git a/sys/lib/libsa/ufs.c b/sys/lib/libsa/ufs.c index 6f78d8adcbb..a9541c444a4 100644 --- a/sys/lib/libsa/ufs.c +++ b/sys/lib/libsa/ufs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs.c,v 1.21 2011/05/28 19:50:52 miod Exp $ */ +/* $OpenBSD: ufs.c,v 1.22 2013/05/30 19:19:09 guenther Exp $ */ /* $NetBSD: ufs.c,v 1.16 1996/09/30 16:01:22 ws Exp $ */ /*- @@ -94,10 +94,10 @@ struct file { daddr32_t f_buf_blkno; /* block number of data block */ }; -static int read_inode(ino_t, struct open_file *); +static int read_inode(ufsino_t, struct open_file *); static int block_map(struct open_file *, daddr32_t, daddr32_t *); static int buf_read_file(struct open_file *, char **, size_t *); -static int search_directory(char *, struct open_file *, ino_t *); +static int search_directory(char *, struct open_file *, ufsino_t *); static int ufs_close_internal(struct file *); #ifdef COMPAT_UFS static void ffs_oldfscompat(struct fs *); @@ -107,7 +107,7 @@ static void ffs_oldfscompat(struct fs *); * Read a new inode into a file structure. */ static int -read_inode(ino_t inumber, struct open_file *f) +read_inode(ufsino_t inumber, struct open_file *f) { struct file *fp = (struct file *)f->f_fsdata; struct fs *fs = fp->f_fs; @@ -313,7 +313,7 @@ buf_read_file(struct open_file *f, char **buf_p, size_t *size_p) * i_number. */ static int -search_directory(char *name, struct open_file *f, ino_t *inumber_p) +search_directory(char *name, struct open_file *f, ufsino_t *inumber_p) { struct file *fp = (struct file *)f->f_fsdata; int namlen, length, rc; @@ -332,7 +332,7 @@ search_directory(char *name, struct open_file *f, ino_t *inumber_p) dp = (struct direct *)buf; edp = (struct direct *)(buf + buf_size); while (dp < edp) { - if (dp->d_ino == (ino_t)0) + if (dp->d_ino == 0) goto next; #if BYTE_ORDER == LITTLE_ENDIAN if (fp->f_fs->fs_maxsymlinklen <= 0) @@ -361,7 +361,7 @@ int ufs_open(char *path, struct open_file *f) { char namebuf[MAXPATHLEN+1], *cp, *ncp, *buf = NULL; - ino_t inumber, parent_inumber; + ufsino_t inumber, parent_inumber; int rc, c, nlinks = 0; struct file *fp; size_t buf_size; @@ -513,7 +513,7 @@ ufs_open(char *path, struct open_file *f) if (*cp != '/') inumber = parent_inumber; else - inumber = (ino_t)ROOTINO; + inumber = ROOTINO; if ((rc = read_inode(inumber, f)) != 0) goto out; @@ -665,7 +665,7 @@ ufs_readdir(struct open_file *f, char *name) dp = (struct direct *)buf; edp = (struct direct *)(buf + buf_size); - while (dp < edp && dp->d_ino == (ino_t)0) + while (dp < edp && dp->d_ino == 0) dp = (struct direct *)((char *)dp + dp->d_reclen); fp->f_seekp += buf_size - ((u_int8_t *)edp - (u_int8_t *)dp); diff --git a/sys/ufs/ext2fs/ext2fs_alloc.c b/sys/ufs/ext2fs/ext2fs_alloc.c index a0937ec891f..508376cf9c0 100644 --- a/sys/ufs/ext2fs/ext2fs_alloc.c +++ b/sys/ufs/ext2fs/ext2fs_alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_alloc.c,v 1.27 2011/09/18 23:20:28 bluhm Exp $ */ +/* $OpenBSD: ext2fs_alloc.c,v 1.28 2013/05/30 19:19:09 guenther Exp $ */ /* $NetBSD: ext2fs_alloc.c,v 1.10 2001/07/05 08:38:27 toshii Exp $ */ /* @@ -138,7 +138,7 @@ ext2fs_inode_alloc(struct inode *pip, mode_t mode, struct ucred *cred, struct vnode *pvp; struct m_ext2fs *fs; struct inode *ip; - ino_t ino, ipref; + ufsino_t ino, ipref; int cg, error; *vpp = NULL; @@ -152,7 +152,7 @@ ext2fs_inode_alloc(struct inode *pip, mode_t mode, struct ucred *cred, else cg = ino_to_cg(fs, pip->i_number); ipref = cg * fs->e2fs.e2fs_ipg + 1; - ino = (ino_t)ext2fs_hashalloc(pip, cg, (long)ipref, mode, ext2fs_nodealloccg); + ino = (ufsino_t)ext2fs_hashalloc(pip, cg, (long)ipref, mode, ext2fs_nodealloccg); if (ino == 0) goto noinodes; error = VFS_VGET(pvp->v_mount, ino, vpp); @@ -506,7 +506,7 @@ ext2fs_blkfree(struct inode *ip, int32_t bno) * The specified inode is placed back in the free map. */ int -ext2fs_inode_free(struct inode *pip, ino_t ino, mode_t mode) +ext2fs_inode_free(struct inode *pip, ufsino_t ino, mode_t mode) { struct m_ext2fs *fs; char *ibp; diff --git a/sys/ufs/ext2fs/ext2fs_dinode.h b/sys/ufs/ext2fs/ext2fs_dinode.h index fcfcf2b17c8..e39dfccdde8 100644 --- a/sys/ufs/ext2fs/ext2fs_dinode.h +++ b/sys/ufs/ext2fs/ext2fs_dinode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_dinode.h,v 1.12 2010/02/16 08:24:13 otto Exp $ */ +/* $OpenBSD: ext2fs_dinode.h,v 1.13 2013/05/30 19:19:09 guenther Exp $ */ /* $NetBSD: ext2fs_dinode.h,v 1.6 2000/01/26 16:21:33 bouyer Exp $ */ /* @@ -40,6 +40,7 @@ */ #include <sys/stat.h> +#include <ufs/ufs/dinode.h> /* for ufsino_t */ /* * The root inode is the root of the file system. Inode 0 can't be used for @@ -47,9 +48,9 @@ * the root inode is 2. * Inode 3 to 10 are reserved in ext2fs. */ -#define EXT2_ROOTINO ((ino_t)2) -#define EXT2_RESIZEINO ((ino_t)7) -#define EXT2_FIRSTINO ((ino_t)11) +#define EXT2_ROOTINO ((ufsino_t)2) +#define EXT2_RESIZEINO ((ufsino_t)7) +#define EXT2_FIRSTINO ((ufsino_t)11) /* * A dinode contains all the meta-data associated with a UFS file. diff --git a/sys/ufs/ext2fs/ext2fs_extern.h b/sys/ufs/ext2fs/ext2fs_extern.h index b44b57b743b..2e114e2ac59 100644 --- a/sys/ufs/ext2fs/ext2fs_extern.h +++ b/sys/ufs/ext2fs/ext2fs_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_extern.h,v 1.30 2013/03/28 03:29:44 guenther Exp $ */ +/* $OpenBSD: ext2fs_extern.h,v 1.31 2013/05/30 19:19:09 guenther Exp $ */ /* $NetBSD: ext2fs_extern.h,v 1.1 1997/06/11 09:33:55 bouyer Exp $ */ /*- @@ -66,7 +66,7 @@ int ext2fs_inode_alloc(struct inode *pip, mode_t mode, struct ucred *, struct vnode **); daddr64_t ext2fs_blkpref(struct inode *, int32_t, int, int32_t *); void ext2fs_blkfree(struct inode *, int32_t); -int ext2fs_inode_free(struct inode *pip, ino_t ino, mode_t mode); +int ext2fs_inode_free(struct inode *pip, ufsino_t ino, mode_t mode); /* ext2fs_balloc.c */ int ext2fs_buf_alloc(struct inode *, daddr64_t, int, struct ucred *, @@ -92,7 +92,7 @@ int ext2fs_direnter(struct inode *, struct vnode *, int ext2fs_dirremove(struct vnode *, struct componentname *); int ext2fs_dirrewrite(struct inode *, struct inode *, struct componentname *); -int ext2fs_dirempty(struct inode *, ino_t, struct ucred *); +int ext2fs_dirempty(struct inode *, ufsino_t, struct ucred *); int ext2fs_checkpath(struct inode *, struct inode *, struct ucred *); /* ext2fs_subr.c */ diff --git a/sys/ufs/ext2fs/ext2fs_lookup.c b/sys/ufs/ext2fs/ext2fs_lookup.c index 0b507359f37..79c3729fc72 100644 --- a/sys/ufs/ext2fs/ext2fs_lookup.c +++ b/sys/ufs/ext2fs/ext2fs_lookup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_lookup.c,v 1.27 2010/11/18 21:18:10 miod Exp $ */ +/* $OpenBSD: ext2fs_lookup.c,v 1.28 2013/05/30 19:19:09 guenther Exp $ */ /* $NetBSD: ext2fs_lookup.c,v 1.16 2000/08/03 20:29:26 thorpej Exp $ */ /* @@ -957,7 +957,7 @@ ext2fs_dirrewrite(struct inode *dp, struct inode *ip, * NB: does not handle corrupted directories. */ int -ext2fs_dirempty(struct inode *ip, ino_t parentino, struct ucred *cred) +ext2fs_dirempty(struct inode *ip, ufsino_t parentino, struct ucred *cred) { off_t off; struct ext2fs_dirtemplate dbuf; diff --git a/sys/ufs/ext2fs/ext2fs_vfsops.c b/sys/ufs/ext2fs/ext2fs_vfsops.c index 84f392769b7..991a34452da 100644 --- a/sys/ufs/ext2fs/ext2fs_vfsops.c +++ b/sys/ufs/ext2fs/ext2fs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_vfsops.c,v 1.66 2013/04/15 15:32:19 jsing Exp $ */ +/* $OpenBSD: ext2fs_vfsops.c,v 1.67 2013/05/30 19:19:09 guenther Exp $ */ /* $NetBSD: ext2fs_vfsops.c,v 1.1 1997/06/11 09:34:07 bouyer Exp $ */ /* @@ -810,6 +810,10 @@ ext2fs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) dev_t dev; int error; + if (ino > (ufsino_t)-1) + panic("ext2fs_vget: alien ino_t %llu", + (unsigned long long)ino); + ump = VFSTOUFS(mp); dev = ump->um_dev; diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index d22bcd08144..10bd35fb382 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_alloc.c,v 1.93 2013/04/23 20:42:38 tedu Exp $ */ +/* $OpenBSD: ffs_alloc.c,v 1.94 2013/05/30 19:19:09 guenther Exp $ */ /* $NetBSD: ffs_alloc.c,v 1.11 1996/05/11 18:27:09 mycroft Exp $ */ /* @@ -73,7 +73,7 @@ daddr64_t ffs_alloccg(struct inode *, int, daddr64_t, int); struct buf * ffs_cgread(struct fs *, struct inode *, int); daddr64_t ffs_alloccgblk(struct inode *, struct buf *, daddr64_t); daddr64_t ffs_clusteralloc(struct inode *, int, daddr64_t, int); -ino_t ffs_dirpref(struct inode *); +ufsino_t ffs_dirpref(struct inode *); daddr64_t ffs_fragextend(struct inode *, int, daddr64_t, int, int); daddr64_t ffs_hashalloc(struct inode *, int, daddr64_t, int, daddr64_t (*)(struct inode *, int, daddr64_t, int)); @@ -834,7 +834,7 @@ ffs_inode_alloc(struct inode *pip, mode_t mode, struct ucred *cred, struct vnode *pvp = ITOV(pip); struct fs *fs; struct inode *ip; - ino_t ino, ipref; + ufsino_t ino, ipref; int cg, error; *vpp = NULL; @@ -861,7 +861,7 @@ ffs_inode_alloc(struct inode *pip, mode_t mode, struct ucred *cred, if (fs->fs_contigdirs[cg] > 0) fs->fs_contigdirs[cg]--; } - ino = (ino_t)ffs_hashalloc(pip, cg, ipref, mode, ffs_nodealloccg); + ino = (ufsino_t)ffs_hashalloc(pip, cg, ipref, mode, ffs_nodealloccg); if (ino == 0) goto noinodes; error = VFS_VGET(pvp->v_mount, ino, vpp); @@ -923,7 +923,7 @@ noinodes: * If we allocate a first level directory then force allocation * in another cylinder group. */ -ino_t +ufsino_t ffs_dirpref(struct inode *pip) { struct fs *fs; @@ -1037,7 +1037,7 @@ ffs_dirpref(struct inode *pip) if (fs->fs_cs(fs, cg).cs_nifree >= avgifree) goto end; end: - return ((ino_t)(fs->fs_ipg * cg)); + return ((ufsino_t)(fs->fs_ipg * cg)); } /* @@ -1932,7 +1932,7 @@ ffs_blkfree(struct inode *ip, daddr64_t bno, long size) } int -ffs_inode_free(struct inode *pip, ino_t ino, mode_t mode) +ffs_inode_free(struct inode *pip, ufsino_t ino, mode_t mode) { struct vnode *pvp = ITOV(pip); @@ -1949,7 +1949,7 @@ ffs_inode_free(struct inode *pip, ino_t ino, mode_t mode) * The specified inode is placed back in the free map. */ int -ffs_freefile(struct inode *pip, ino_t ino, mode_t mode) +ffs_freefile(struct inode *pip, ufsino_t ino, mode_t mode) { struct fs *fs; struct cg *cgp; diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h index ea96622c4fc..9514cc99372 100644 --- a/sys/ufs/ffs/ffs_extern.h +++ b/sys/ufs/ffs/ffs_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_extern.h,v 1.37 2010/12/21 20:14:44 thib Exp $ */ +/* $OpenBSD: ffs_extern.h,v 1.38 2013/05/30 19:19:09 guenther Exp $ */ /* $NetBSD: ffs_extern.h,v 1.4 1996/02/09 22:22:22 christos Exp $ */ /* @@ -105,8 +105,8 @@ int ffs_realloccg(struct inode *, daddr64_t, daddr64_t, int, int , struct ucred *, struct buf **, daddr64_t *); int ffs_reallocblks(void *); int ffs_inode_alloc(struct inode *, mode_t, struct ucred *, struct vnode **); -int ffs_inode_free(struct inode *, ino_t, mode_t); -int ffs_freefile(struct inode *, ino_t, mode_t); +int ffs_inode_free(struct inode *, ufsino_t, mode_t); +int ffs_freefile(struct inode *, ufsino_t, mode_t); int32_t ffs1_blkpref(struct inode *, daddr64_t, int, int32_t *); #ifdef FFS2 @@ -175,9 +175,9 @@ int softdep_flushworklist(struct mount *, int *, struct proc *); int softdep_flushfiles(struct mount *, int, struct proc *); void softdep_update_inodeblock(struct inode *, struct buf *, int); void softdep_load_inodeblock(struct inode *); -void softdep_freefile(struct vnode *, ino_t, mode_t); +void softdep_freefile(struct vnode *, ufsino_t, mode_t); void softdep_setup_freeblocks(struct inode *, off_t); -void softdep_setup_inomapdep(struct buf *, struct inode *, ino_t); +void softdep_setup_inomapdep(struct buf *, struct inode *, ufsino_t); void softdep_setup_blkmapdep(struct buf *, struct fs *, daddr64_t); void softdep_setup_allocdirect(struct inode *, daddr64_t, daddr64_t, daddr64_t, long, long, struct buf *); diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 2d3ffb4e9a9..56b7f9b0fcf 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_softdep.c,v 1.117 2013/04/04 17:29:36 beck Exp $ */ +/* $OpenBSD: ffs_softdep.c,v 1.118 2013/05/30 19:19:09 guenther Exp $ */ /* * Copyright 1998, 2000 Marshall Kirk McKusick. All Rights Reserved. @@ -120,7 +120,7 @@ STATIC void clear_remove(struct proc *); STATIC void clear_inodedeps(struct proc *); STATIC int flush_pagedep_deps(struct vnode *, struct mount *, struct diraddhd *); -STATIC int flush_inodedep_deps(struct fs *, ino_t); +STATIC int flush_inodedep_deps(struct fs *, ufsino_t); STATIC int handle_written_filepage(struct pagedep *, struct buf *); STATIC void diradd_inode_written(struct diradd *, struct inodedep *); STATIC int handle_written_inodeblock(struct inodedep *, struct buf *); @@ -158,7 +158,7 @@ STATIC void allocdirect_merge(struct allocdirectlst *, STATIC struct bmsafemap *bmsafemap_lookup(struct buf *); STATIC int newblk_lookup(struct fs *, daddr64_t, int, struct newblk **); -STATIC int inodedep_lookup(struct fs *, ino_t, int, struct inodedep **); +STATIC int inodedep_lookup(struct fs *, ufsino_t, int, struct inodedep **); STATIC int pagedep_lookup(struct inode *, daddr64_t, int, struct pagedep **); STATIC void pause_timer(void *); STATIC int request_cleanup(int, int); @@ -1026,7 +1026,7 @@ STATIC struct sema inodedep_in_progress; * This routine must be called with splbio interrupts blocked. */ STATIC int -inodedep_lookup(struct fs *fs, ino_t inum, int flags, +inodedep_lookup(struct fs *fs, ufsino_t inum, int flags, struct inodedep **inodedeppp) { struct inodedep *inodedep; @@ -1276,7 +1276,7 @@ softdep_mount(struct vnode *devvp, struct mount *mp, struct fs *fs, /* inode related to allocation */ /* new inode number being allocated */ void -softdep_setup_inomapdep(struct buf *bp, struct inode *ip, ino_t newinum) +softdep_setup_inomapdep(struct buf *bp, struct inode *ip, ufsino_t newinum) { struct inodedep *inodedep; struct bmsafemap *bmsafemap; @@ -2219,7 +2219,7 @@ free_newdirblk(struct newdirblk *newdirblk) * done until the zero'ed inode has been written to disk. */ void -softdep_freefile(struct vnode *pvp, ino_t ino, mode_t mode) +softdep_freefile(struct vnode *pvp, ufsino_t ino, mode_t mode) { struct inode *ip = VTOI(pvp); struct inodedep *inodedep; @@ -3077,7 +3077,7 @@ handle_workitem_remove(struct dirrem *dirrem) struct inodedep *inodedep; struct vnode *vp; struct inode *ip; - ino_t oldinum; + ufsino_t oldinum; int error; if ((error = VFS_VGET(dirrem->dm_mnt, dirrem->dm_oldinum, &vp)) != 0) { @@ -4486,7 +4486,7 @@ softdep_fsync(struct vnode *vp) struct fs *fs; struct proc *p = CURPROC; /* XXX */ int error, flushparent; - ino_t parentino; + ufsino_t parentino; daddr64_t lbn; ip = VTOI(vp); @@ -4927,7 +4927,7 @@ loop: * Called with splbio blocked. */ STATIC int -flush_inodedep_deps(struct fs *fs, ino_t ino) +flush_inodedep_deps(struct fs *fs, ufsino_t ino) { struct inodedep *inodedep; struct allocdirect *adp; @@ -5033,7 +5033,7 @@ flush_pagedep_deps(struct vnode *pvp, struct mount *mp, struct vnode *vp; int gotit, error = 0; struct buf *bp; - ino_t inum; + ufsino_t inum; splassert(IPL_BIO); @@ -5317,7 +5317,7 @@ clear_remove(struct proc *p) struct mount *mp; struct vnode *vp; int error, cnt; - ino_t ino; + ufsino_t ino; ACQUIRE_LOCK(&lk); for (cnt = 0; cnt <= pagedep_hash; cnt++) { @@ -5368,7 +5368,7 @@ clear_inodedeps(struct proc *p) struct vnode *vp; struct fs *fs; int error, cnt; - ino_t firstino, lastino, ino; + ufsino_t firstino, lastino, ino; ACQUIRE_LOCK(&lk); /* diff --git a/sys/ufs/ffs/ffs_softdep_stub.c b/sys/ufs/ffs/ffs_softdep_stub.c index d18c41c52e6..ac39eeb2d1a 100644 --- a/sys/ufs/ffs/ffs_softdep_stub.c +++ b/sys/ufs/ffs/ffs_softdep_stub.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_softdep_stub.c,v 1.16 2008/01/05 19:49:26 otto Exp $ */ +/* $OpenBSD: ffs_softdep_stub.c,v 1.17 2013/05/30 19:19:09 guenther Exp $ */ /* * Copyright 1998 Marshall Kirk McKusick. All Rights Reserved. @@ -68,7 +68,7 @@ softdep_initialize(void) #ifndef __OPTIMIZE__ void -softdep_setup_inomapdep(struct buf *bp, struct inode *ip, ino_t newinum) +softdep_setup_inomapdep(struct buf *bp, struct inode *ip, ufsino_t newinum) { panic("softdep_setup_inomapdep called"); } @@ -107,7 +107,7 @@ softdep_setup_freeblocks(struct inode *ip, off_t length) } void -softdep_freefile(struct vnode *pvp, ino_t ino, mode_t mode) +softdep_freefile(struct vnode *pvp, ufsino_t ino, mode_t mode) { panic("softdep_freefile called"); } diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index aa9843cfe06..d7dfe29ea7b 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_vfsops.c,v 1.136 2013/04/15 15:32:19 jsing Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.137 2013/05/30 19:19:09 guenther Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -1235,6 +1235,9 @@ ffs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) dev_t dev; int error; + if (ino > (ufsino_t)-1) + panic("ffs_vget: alien ino_t %llu", (unsigned long long)ino); + ump = VFSTOUFS(mp); dev = ump->um_dev; retry: @@ -1372,7 +1375,8 @@ ffs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) ufhp = (struct ufid *)fhp; fs = VFSTOUFS(mp)->um_fs; - if (ufhp->ufid_ino < ROOTINO || + if (ufhp->ufid_len != sizeof(*ufhp) || + ufhp->ufid_ino < ROOTINO || ufhp->ufid_ino >= fs->fs_ncg * fs->fs_ipg) return (ESTALE); return (ufs_fhtovp(mp, ufhp, vpp)); diff --git a/sys/ufs/ffs/softdep.h b/sys/ufs/ffs/softdep.h index 3f4bd355f00..01f2417fc63 100644 --- a/sys/ufs/ffs/softdep.h +++ b/sys/ufs/ffs/softdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: softdep.h,v 1.15 2008/01/05 19:49:26 otto Exp $ */ +/* $OpenBSD: softdep.h,v 1.16 2013/05/30 19:19:09 guenther Exp $ */ /* * Copyright 1998, 2000 Marshall Kirk McKusick. All Rights Reserved. @@ -191,7 +191,7 @@ struct pagedep { # define pd_state pd_list.wk_state /* check for multiple I/O starts */ LIST_ENTRY(pagedep) pd_hash; /* hashed lookup */ struct mount *pd_mnt; /* associated mount point */ - ino_t pd_ino; /* associated file */ + ufsino_t pd_ino; /* associated file */ daddr64_t pd_lbn; /* block within file */ struct dirremhd pd_dirremhd; /* dirrem's waiting for page */ struct diraddhd pd_diraddhd[DAHASHSZ]; /* diradd dir entry updates */ @@ -250,7 +250,7 @@ struct inodedep { # define id_state id_list.wk_state /* inode dependency state */ LIST_ENTRY(inodedep) id_hash; /* hashed lookup */ struct fs *id_fs; /* associated filesystem */ - ino_t id_ino; /* dependent inode */ + ufsino_t id_ino; /* dependent inode */ nlink_t id_nlinkdelta; /* saved effective link count */ union { /* Saved UFS1/UFS2 dinode contents */ struct ufs1_dinode *idu_savedino1; @@ -417,7 +417,7 @@ struct freefrag { struct mount *ff_mnt; /* associated mount point */ daddr64_t ff_blkno; /* fragment physical block number */ long ff_fragsize; /* size of fragment being deleted */ - ino_t ff_inum; /* owning inode number */ + ufsino_t ff_inum; /* owning inode number */ }; /* @@ -429,7 +429,7 @@ struct freefrag { struct freeblks { struct worklist fb_list; /* id_inowait or delayed worklist */ # define fb_state fb_list.wk_state /* inode and dirty block state */ - ino_t fb_previousinum; /* inode of previous owner of blocks */ + ufsino_t fb_previousinum; /* inode of previous owner of blocks */ struct vnode *fb_devvp; /* filesystem device vnode */ struct mount *fb_mnt; /* associated mount point */ off_t fb_oldsize; /* previous file size */ @@ -449,7 +449,7 @@ struct freeblks { struct freefile { struct worklist fx_list; /* id_inowait or delayed worklist */ mode_t fx_mode; /* mode of inode */ - ino_t fx_oldinum; /* inum of the unlinked file */ + ufsino_t fx_oldinum; /* inum of the unlinked file */ struct vnode *fx_devvp; /* filesystem device vnode */ struct mount *fx_mnt; /* associated mount point */ }; @@ -496,7 +496,7 @@ struct diradd { # define da_state da_list.wk_state /* state of the new directory entry */ LIST_ENTRY(diradd) da_pdlist; /* pagedep holding directory block */ doff_t da_offset; /* offset of new dir entry in dir blk */ - ino_t da_newinum; /* inode number for the new dir entry */ + ufsino_t da_newinum; /* inode number for the new dir entry */ union { struct dirrem *dau_previous; /* entry being replaced in dir change */ struct pagedep *dau_pagedep; /* pagedep dependency for addition */ @@ -554,10 +554,10 @@ struct dirrem { # define dm_state dm_list.wk_state /* state of the old directory entry */ LIST_ENTRY(dirrem) dm_next; /* pagedep's list of dirrem's */ struct mount *dm_mnt; /* associated mount point */ - ino_t dm_oldinum; /* inum of the removed dir entry */ + ufsino_t dm_oldinum; /* inum of the removed dir entry */ union { struct pagedep *dmu_pagedep; /* pagedep dependency for remove */ - ino_t dmu_dirinum; /* parent inode number (for rmdir) */ + ufsino_t dmu_dirinum; /* parent inode number (for rmdir) */ } dm_un; }; #define dm_pagedep dm_un.dmu_pagedep diff --git a/sys/ufs/ufs/dinode.h b/sys/ufs/ufs/dinode.h index 67fd7232035..5ad69be286e 100644 --- a/sys/ufs/ufs/dinode.h +++ b/sys/ufs/ufs/dinode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dinode.h,v 1.17 2007/06/02 01:32:04 pedro Exp $ */ +/* $OpenBSD: dinode.h,v 1.18 2013/05/30 19:19:09 guenther Exp $ */ /* $NetBSD: dinode.h,v 1.7 1995/06/15 23:22:48 cgd Exp $ */ /* @@ -41,12 +41,18 @@ #define _UFS_DINODE_H_ /* + * UFS directories use 32bit inode numbers internally, regardless + * of what the system on top of it uses. + */ +typedef u_int32_t ufsino_t; + +/* * The root inode is the root of the file system. Inode 0 can't be used for * normal purposes and historically bad blocks were linked to inode 1, thus * the root inode is 2. (Inode 1 is no longer used for this purpose, however * numerous dump tapes make this assumption, so we are stuck with it). */ -#define ROOTINO ((ino_t)2) +#define ROOTINO ((ufsino_t)2) /* * A dinode contains all the meta-data associated with a UFS file. diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h index 99edf4dbbf2..b44c15ca2cb 100644 --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: inode.h,v 1.38 2010/08/20 22:29:52 matthew Exp $ */ +/* $OpenBSD: inode.h,v 1.39 2013/05/30 19:19:09 guenther Exp $ */ /* $NetBSD: inode.h,v 1.8 1995/06/15 23:22:50 cgd Exp $ */ /* @@ -43,6 +43,7 @@ #include <ufs/ufs/dir.h> #include <ufs/ext2fs/ext2fs_dinode.h> + /* * Per-filesystem inode extensions. */ @@ -68,7 +69,7 @@ struct inode { struct ufsmount *i_ump; u_int32_t i_flag; /* flags, see below */ dev_t i_dev; /* Device associated with the inode. */ - ino_t i_number; /* The identity of the inode. */ + ufsino_t i_number; /* The identity of the inode. */ int i_effnlink; /* i_nlink when I/O completes */ union { /* Associated filesystem. */ @@ -92,7 +93,7 @@ struct inode { doff_t i_endoff; /* End of useful stuff in directory. */ doff_t i_diroff; /* Offset in dir, where we found last entry. */ doff_t i_offset; /* Offset of free space in directory. */ - ino_t i_ino; /* Inode number of found directory. */ + ufsino_t i_ino; /* Inode number of found directory. */ u_int32_t i_reclen; /* Size of found directory entry. */ /* * Inode extensions @@ -132,7 +133,7 @@ struct inode_vtbl { int waitfor); int (* iv_inode_alloc)(struct inode *, mode_t mode, struct ucred *, struct vnode **); - int (* iv_inode_free)(struct inode *, ino_t ino, mode_t mode); + int (* iv_inode_free)(struct inode *, ufsino_t ino, mode_t mode); int (* iv_buf_alloc)(struct inode *, off_t, int, struct ucred *, int, struct buf **); int (* iv_bufatoff)(struct inode *, off_t offset, char **res, @@ -364,7 +365,7 @@ struct indir { struct ufid { u_int16_t ufid_len; /* Length of structure. */ u_int16_t ufid_pad; /* Force 32-bit alignment. */ - ino_t ufid_ino; /* File number (ino). */ + ufsino_t ufid_ino; /* File number (ino). */ int32_t ufid_gen; /* Generation number. */ }; #endif /* _KERNEL */ diff --git a/sys/ufs/ufs/ufs_extern.h b/sys/ufs/ufs/ufs_extern.h index 23da91929ec..437883ccab4 100644 --- a/sys/ufs/ufs/ufs_extern.h +++ b/sys/ufs/ufs/ufs_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_extern.h,v 1.32 2010/12/21 20:14:44 thib Exp $ */ +/* $OpenBSD: ufs_extern.h,v 1.33 2013/05/30 19:19:09 guenther Exp $ */ /* $NetBSD: ufs_extern.h,v 1.5 1996/02/09 22:36:03 christos Exp $ */ /*- @@ -99,8 +99,8 @@ int ufs_getlbns(struct vnode *, daddr64_t, struct indir *, int *); /* ufs_ihash.c */ void ufs_ihashinit(void); -struct vnode *ufs_ihashlookup(dev_t, ino_t); -struct vnode *ufs_ihashget(dev_t, ino_t); +struct vnode *ufs_ihashlookup(dev_t, ufsino_t); +struct vnode *ufs_ihashget(dev_t, ufsino_t); int ufs_ihashins(struct inode *); void ufs_ihashrem(struct inode *); @@ -117,8 +117,8 @@ int ufs_direnter(struct vnode *, struct vnode *, struct direct *, struct componentname *, struct buf *); int ufs_dirremove(struct vnode *, struct inode *, int, int); int ufs_dirrewrite(struct inode *, struct inode *, - ino_t, int, int); -int ufs_dirempty(struct inode *, ino_t, struct ucred *); + ufsino_t, int, int); +int ufs_dirempty(struct inode *, ufsino_t, struct ucred *); int ufs_checkpath(struct inode *, struct inode *, struct ucred *); /* ufs_vfsops.c */ diff --git a/sys/ufs/ufs/ufs_ihash.c b/sys/ufs/ufs/ufs_ihash.c index 58412f00cc8..460fb9f5aa3 100644 --- a/sys/ufs/ufs/ufs_ihash.c +++ b/sys/ufs/ufs/ufs_ihash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_ihash.c,v 1.16 2010/07/19 21:13:43 deraadt Exp $ */ +/* $OpenBSD: ufs_ihash.c,v 1.17 2013/05/30 19:19:09 guenther Exp $ */ /* $NetBSD: ufs_ihash.c,v 1.3 1996/02/09 22:36:04 christos Exp $ */ /* @@ -63,7 +63,7 @@ ufs_ihashinit(void) * to it. If it is in core, return it, even if it is locked. */ struct vnode * -ufs_ihashlookup(dev_t dev, ino_t inum) +ufs_ihashlookup(dev_t dev, ufsino_t inum) { struct inode *ip; @@ -84,7 +84,7 @@ ufs_ihashlookup(dev_t dev, ino_t inum) * to it. If it is in core, but locked, wait for it. */ struct vnode * -ufs_ihashget(dev_t dev, ino_t inum) +ufs_ihashget(dev_t dev, ufsino_t inum) { struct proc *p = curproc; struct inode *ip; @@ -110,10 +110,10 @@ loop: int ufs_ihashins(struct inode *ip) { - struct inode *curip; - struct ihashhead *ipp; - dev_t dev = ip->i_dev; - ino_t inum = ip->i_number; + struct inode *curip; + struct ihashhead *ipp; + dev_t dev = ip->i_dev; + ufsino_t inum = ip->i_number; /* lock the inode, then put it on the appropriate hash list */ lockmgr(&ip->i_lock, LK_EXCLUSIVE, NULL); diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index 64ef520e71d..69cf5b7f493 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_lookup.c,v 1.41 2011/09/18 23:20:28 bluhm Exp $ */ +/* $OpenBSD: ufs_lookup.c,v 1.42 2013/05/30 19:19:09 guenther Exp $ */ /* $NetBSD: ufs_lookup.c,v 1.7 1996/02/09 22:36:06 christos Exp $ */ /* @@ -1021,8 +1021,8 @@ ufs_dirremove(struct vnode *dvp, struct inode *ip, int flags, int isrmdir) * set up by a call to namei. */ int -ufs_dirrewrite(struct inode *dp, struct inode *oip, ino_t newinum, int newtype, - int isrmdir) +ufs_dirrewrite(struct inode *dp, struct inode *oip, ufsino_t newinum, + int newtype, int isrmdir) { struct buf *bp; struct direct *ep; @@ -1064,7 +1064,7 @@ ufs_dirrewrite(struct inode *dp, struct inode *oip, ino_t newinum, int newtype, * NB: does not handle corrupted directories. */ int -ufs_dirempty(struct inode *ip, ino_t parentino, struct ucred *cred) +ufs_dirempty(struct inode *ip, ufsino_t parentino, struct ucred *cred) { off_t off, m; struct dirtemplate dbuf; |