CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: kamil Date: Sun Mar 8 17:38:12 UTC 2020 Modified Files: src/sys/ufs/ext2fs: ext2fs_vnops.c Log Message: Perform bit operations on unsigned integer ext2fs_vnops.c:1002:2, signed integer overflow: 510008 * 4294 cannot be represented in type 'int Maximum usec * 4294 is in the range of unsigned int. >>> 100*4294 429400 >>> 2**32 4294967296 Patch submitted by Nisarg S. Joshi. To generate a diff of this commit: cvs rdiff -u -r1.130 -r1.131 src/sys/ufs/ext2fs/ext2fs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vnops.c diff -u src/sys/ufs/ext2fs/ext2fs_vnops.c:1.130 src/sys/ufs/ext2fs/ext2fs_vnops.c:1.131 --- src/sys/ufs/ext2fs/ext2fs_vnops.c:1.130 Wed Sep 18 17:59:15 2019 +++ src/sys/ufs/ext2fs/ext2fs_vnops.c Sun Mar 8 17:38:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vnops.c,v 1.130 2019/09/18 17:59:15 christos Exp $ */ +/* $NetBSD: ext2fs_vnops.c,v 1.131 2020/03/08 17:38:12 kamil Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.130 2019/09/18 17:59:15 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.131 2020/03/08 17:38:12 kamil Exp $"); #include #include @@ -999,7 +999,7 @@ ext2fs_vinit(struct mount *mntp, int (** */ getmicrouptime(&tv); SETHIGH(ip->i_modrev, tv.tv_sec); - SETLOW(ip->i_modrev, tv.tv_usec * 4294); + SETLOW(ip->i_modrev, tv.tv_usec * 4294U); *vpp = vp; return 0; }
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: riastradh Date: Sun Jul 30 14:23:54 UTC 2017 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: kmem_xyz(sizeof(struct foo)) --> kmem_xyz(sizeof(*foo)) No change to amd64 binary. To generate a diff of this commit: cvs rdiff -u -r1.209 -r1.210 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.209 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.210 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.209 Sun May 28 16:38:55 2017 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Sun Jul 30 14:23:54 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.209 2017/05/28 16:38:55 hannken Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.210 2017/07/30 14:23:54 riastradh Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.209 2017/05/28 16:38:55 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.210 2017/07/30 14:23:54 riastradh Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -675,7 +675,7 @@ ext2fs_mountfs(struct vnode *devvp, stru if (error) goto out; fs = (struct ext2fs *)bp->b_data; - m_fs = kmem_zalloc(sizeof(struct m_ext2fs), KM_SLEEP); + m_fs = kmem_zalloc(sizeof(*m_fs), KM_SLEEP); e2fs_sbload(fs, &m_fs->e2fs); brelse(bp, 0); @@ -684,7 +684,7 @@ ext2fs_mountfs(struct vnode *devvp, stru /* Once swapped, validate and fill in the superblock. */ error = ext2fs_sbfill(m_fs, ronly); if (error) { - kmem_free(m_fs, sizeof(struct m_ext2fs)); + kmem_free(m_fs, sizeof(*m_fs)); goto out; } m_fs->e2fs_ronly = ronly; @@ -755,7 +755,7 @@ out: if (bp != NULL) brelse(bp, 0); if (ump) { - kmem_free(ump->um_e2fs, sizeof(struct m_ext2fs)); + kmem_free(ump->um_e2fs, sizeof(*m_fs)); kmem_free(ump, sizeof(*ump)); mp->mnt_data = NULL; }
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: hannken Date: Sun May 28 16:38:55 UTC 2017 Modified Files: src/sys/ufs/ext2fs: ext2fs_alloc.c ext2fs_extern.h ext2fs_vfsops.c ext2fs_vnops.c Log Message: Change ext2fs to use vcache_new like we did for ffs: - Change ext2fs_valloc to return an inode number. - Make ext2fs_makeinode private to ext2fs_vnops.c and pass vattr instead of mode. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/ufs/ext2fs/ext2fs_alloc.c cvs rdiff -u -r1.55 -r1.56 src/sys/ufs/ext2fs/ext2fs_extern.h cvs rdiff -u -r1.208 -r1.209 src/sys/ufs/ext2fs/ext2fs_vfsops.c cvs rdiff -u -r1.127 -r1.128 src/sys/ufs/ext2fs/ext2fs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_alloc.c diff -u src/sys/ufs/ext2fs/ext2fs_alloc.c:1.51 src/sys/ufs/ext2fs/ext2fs_alloc.c:1.52 --- src/sys/ufs/ext2fs/ext2fs_alloc.c:1.51 Sat Aug 20 19:53:43 2016 +++ src/sys/ufs/ext2fs/ext2fs_alloc.c Sun May 28 16:38:55 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_alloc.c,v 1.51 2016/08/20 19:53:43 jdolecek Exp $ */ +/* $NetBSD: ext2fs_alloc.c,v 1.52 2017/05/28 16:38:55 hannken Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.51 2016/08/20 19:53:43 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.52 2017/05/28 16:38:55 hannken Exp $"); #include #include @@ -167,16 +167,13 @@ nospace: * available inode is located. */ int -ext2fs_valloc(struct vnode *pvp, int mode, kauth_cred_t cred, -struct vnode **vpp) +ext2fs_valloc(struct vnode *pvp, int mode, kauth_cred_t cred, ino_t *inop) { struct inode *pip; struct m_ext2fs *fs; - struct inode *ip; ino_t ino, ipref; - int cg, error; + int cg; - *vpp = NULL; pip = VTOI(pvp); fs = pip->i_e2fs; if (fs->e2fs.e2fs_ficount == 0) @@ -190,32 +187,10 @@ ext2fs_valloc(struct vnode *pvp, int mod ino = (ino_t)ext2fs_hashalloc(pip, cg, (long)ipref, mode, ext2fs_nodealloccg); if (ino == 0) goto noinodes; - error = VFS_VGET(pvp->v_mount, ino, vpp); - if (error) { - ext2fs_vfree(pvp, ino, mode); - return error; - } - ip = VTOI(*vpp); - - KASSERT(!E2FS_HAS_GD_CSUM(fs) || (fs->e2fs_gd[ino_to_cg(fs, ino)].ext2bgd_flags & h2fs16(E2FS_BG_INODE_ZEROED)) != 0); - - /* check for already used inode; makes sense only for ZEROED itable */ - if (__predict_false(ip->i_e2fs_mode && ip->i_e2fs_nlink != 0)) { - printf("mode = 0%o, nlinks %d, inum = %llu, fs = %s\n", - ip->i_e2fs_mode, ip->i_e2fs_nlink, - (unsigned long long)ip->i_number, fs->e2fs_fsmnt); - panic("ext2fs_valloc: dup alloc"); - } - - memset(ip->i_din.e2fs_din, 0, EXT2_DINODE_SIZE(fs)); - /* - * Set up a new generation number for this inode. - */ - if (++ext2gennumber < time_second) - ext2gennumber = time_second; - ip->i_e2fs_gen = ext2gennumber; + *inop = ino; return 0; + noinodes: ext2fs_fserr(fs, kauth_cred_geteuid(cred), "out of inodes"); uprintf("\n%s: create/symlink failed, no inodes free\n", fs->e2fs_fsmnt); Index: src/sys/ufs/ext2fs/ext2fs_extern.h diff -u src/sys/ufs/ext2fs/ext2fs_extern.h:1.55 src/sys/ufs/ext2fs/ext2fs_extern.h:1.56 --- src/sys/ufs/ext2fs/ext2fs_extern.h:1.55 Sat Aug 20 19:47:44 2016 +++ src/sys/ufs/ext2fs/ext2fs_extern.h Sun May 28 16:38:55 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_extern.h,v 1.55 2016/08/20 19:47:44 jdolecek Exp $ */ +/* $NetBSD: ext2fs_extern.h,v 1.56 2017/05/28 16:38:55 hannken Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -95,7 +95,7 @@ int ext2fs_alloc(struct inode *, daddr_t daddr_t *); int ext2fs_realloccg(struct inode *, daddr_t, daddr_t, int, int , kauth_cred_t, struct buf **); -int ext2fs_valloc(struct vnode *, int, kauth_cred_t, struct vnode **); +int ext2fs_valloc(struct vnode *, int, kauth_cred_t, ino_t *); /* XXX ondisk32 */ daddr_t ext2fs_blkpref(struct inode *, daddr_t, int, int32_t *); void ext2fs_blkfree(struct inode *, daddr_t); @@ -176,8 +176,6 @@ int ext2fs_advlock(void *); int ext2fs_fsync(void *); int ext2fs_vinit(struct mount *, int (**specops)(void *), int (**fifoops)(void *), struct vnode **); -int ext2fs_makeinode(int, struct vnode *, struct vnode **, - struct componentname *cnp, int); int ext2fs_reclaim(void *); /* ext2fs_hash.c */ Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.208 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.209 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.208 Mon Apr 17 08:32:01 2017 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Sun May 28 16:38:55 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.208 2017/04/17 08:32:01 hannken Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.209 2017/05/28 16:38:55 hannken Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.208 2017/04/17 08:32:01 hannk
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Fri Jan 13 18:04:36 UTC 2017 Modified Files: src/sys/ufs/ext2fs: ext2fs_dinode.h Log Message: Fix unsigned To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/ufs/ext2fs/ext2fs_dinode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_dinode.h diff -u src/sys/ufs/ext2fs/ext2fs_dinode.h:1.36 src/sys/ufs/ext2fs/ext2fs_dinode.h:1.37 --- src/sys/ufs/ext2fs/ext2fs_dinode.h:1.36 Fri Aug 12 15:04:03 2016 +++ src/sys/ufs/ext2fs/ext2fs_dinode.h Fri Jan 13 13:04:36 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_dinode.h,v 1.36 2016/08/12 19:04:03 jdolecek Exp $ */ +/* $NetBSD: ext2fs_dinode.h,v 1.37 2017/01/13 18:04:36 christos Exp $ */ /* * Copyright (c) 1982, 1989, 1993 @@ -205,7 +205,7 @@ struct ext2fs_dinode { #define EXT2_PROJINHERIT 0x2000 /* Children inherit project ID */ /* Size of on-disk inode. */ -#define EXT2_REV0_DINODE_SIZE 128 +#define EXT2_REV0_DINODE_SIZE 128U #define EXT2_DINODE_SIZE(fs) ((fs)->e2fs.e2fs_rev > E2FS_REV0 ? \ (fs)->e2fs.e2fs_inode_size : \ EXT2_REV0_DINODE_SIZE)
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Thu Aug 25 07:18:35 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: put back second strlcpy; pointed out by dholland. To generate a diff of this commit: cvs rdiff -u -r1.203 -r1.204 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.203 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.204 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.203 Tue Aug 23 02:24:30 2016 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Thu Aug 25 03:18:35 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.203 2016/08/23 06:24:30 christos Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.204 2016/08/25 07:18:35 christos Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.203 2016/08/23 06:24:30 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.204 2016/08/25 07:18:35 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -245,6 +245,9 @@ ext2fs_sb_setmountinfo(struct m_ext2fs * (void)strlcpy(fs->e2fs_fsmnt, mp->mnt_stat.f_mntonname, sizeof(fs->e2fs_fsmnt)); if (fs->e2fs_ronly == 0 && fs->e2fs.e2fs_rev > E2FS_REV0) { + (void)strlcpy(fs->e2fs.e2fs_fsmnt, mp->mnt_stat.f_mntonname, + sizeof(fs->e2fs.e2fs_fsmnt)); + fs->e2fs.e2fs_mtime = time_second; fs->e2fs.e2fs_mnt_count++;
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Tue Aug 23 06:40:54 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_xattr.c Log Message: CID 1371648: off by one in index checking KNF. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/ufs/ext2fs/ext2fs_xattr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_xattr.c diff -u src/sys/ufs/ext2fs/ext2fs_xattr.c:1.3 src/sys/ufs/ext2fs/ext2fs_xattr.c:1.4 --- src/sys/ufs/ext2fs/ext2fs_xattr.c:1.3 Sun Aug 14 07:40:31 2016 +++ src/sys/ufs/ext2fs/ext2fs_xattr.c Tue Aug 23 02:40:54 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_xattr.c,v 1.3 2016/08/14 11:40:31 jdolecek Exp $ */ +/* $NetBSD: ext2fs_xattr.c,v 1.4 2016/08/23 06:40:54 christos Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_xattr.c,v 1.3 2016/08/14 11:40:31 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_xattr.c,v 1.4 2016/08/23 06:40:54 christos Exp $"); #include #include @@ -68,7 +68,9 @@ static const char * const xattr_prefix_i }; static int -ext2fs_find_xattr(struct ext2fs_xattr_entry *e, uint8_t *start, uint8_t *end, int attrnamespace, struct uio *uio, size_t *size, uint8_t name_index, const char *name) +ext2fs_find_xattr(struct ext2fs_xattr_entry *e, uint8_t *start, uint8_t *end, +int attrnamespace, struct uio *uio, size_t *size, uint8_t name_index, +const char *name) { uint8_t *value; int error; @@ -83,8 +85,10 @@ ext2fs_find_xattr(struct ext2fs_xattr_en * Only EXT2FS_XATTR_PREFIX_USER is USER, anything else * is considered SYSTEM. */ - if ((attrnamespace == EXTATTR_NAMESPACE_USER && e->e_name_index != EXT2FS_XATTR_PREFIX_USER) || - (attrnamespace == EXTATTR_NAMESPACE_SYSTEM && e->e_name_index == EXT2FS_XATTR_PREFIX_USER)) { + if ((attrnamespace == EXTATTR_NAMESPACE_USER + && e->e_name_index != EXT2FS_XATTR_PREFIX_USER) || + (attrnamespace == EXTATTR_NAMESPACE_SYSTEM + && e->e_name_index == EXT2FS_XATTR_PREFIX_USER)) { continue; } @@ -94,8 +98,8 @@ ext2fs_find_xattr(struct ext2fs_xattr_en continue; value_offs = fs2h32(e->e_value_offs); - value_len = fs2h32(e->e_value_size); - value = &start[value_offs]; + value_len = fs2h32(e->e_value_size); + value = &start[value_offs]; /* make sure the value offset are sane */ if (&value[value_len] > end) @@ -103,8 +107,8 @@ ext2fs_find_xattr(struct ext2fs_xattr_en if (uio != NULL) { /* - * Figure out maximum to transfer -- use buffer size and - * local data limit. + * Figure out maximum to transfer -- use buffer size + * and local data limit. */ len = MIN(uio->uio_resid, value_len); old_len = uio->uio_resid; @@ -131,24 +135,27 @@ ext2fs_find_xattr(struct ext2fs_xattr_en } static int -ext2fs_get_inode_xattr(struct inode *ip, int attrnamespace, struct uio *uio, size_t *size, uint8_t name_index, const char *name) +ext2fs_get_inode_xattr(struct inode *ip, int attrnamespace, struct uio *uio, +size_t *size, uint8_t name_index, const char *name) { struct ext2fs_dinode *di = ip->i_din.e2fs_din; struct ext2fs_xattr_ibody_header *h; uint8_t *start, *end; start = &((uint8_t *)di)[EXT2_REV0_DINODE_SIZE + di->e2di_extra_isize]; - h = (struct ext2fs_xattr_ibody_header *)start; - end = &((uint8_t *)di)[EXT2_DINODE_SIZE(ip->i_e2fs)]; + h = (struct ext2fs_xattr_ibody_header *)start; + end = &((uint8_t *)di)[EXT2_DINODE_SIZE(ip->i_e2fs)]; if (end <= start || fs2h32(h->h_magic) != EXT2FS_XATTR_MAGIC) return ENODATA; - return ext2fs_find_xattr(EXT2FS_XATTR_IFIRST(h), start, end, attrnamespace, uio, size, name_index, name); + return ext2fs_find_xattr(EXT2FS_XATTR_IFIRST(h), start, end, + attrnamespace, uio, size, name_index, name); } static int -ext2fs_get_block_xattr(struct inode *ip, int attrnamespace, struct uio *uio, size_t *size, uint8_t name_index, const char *name) +ext2fs_get_block_xattr(struct inode *ip, int attrnamespace, struct uio *uio, +size_t *size, uint8_t name_index, const char *name) { struct ext2fs_dinode *di = ip->i_din.e2fs_din; uint8_t *start, *end; @@ -165,7 +172,8 @@ ext2fs_get_block_xattr(struct inode *ip, if (xblk == 0) return 0; - error = bread(ip->i_devvp, fsbtodb(ip->i_e2fs, xblk), (int)ip->i_e2fs->e2fs_bsize, 0, &bp); + error = bread(ip->i_devvp, fsbtodb(ip->i_e2fs, xblk), + (int)ip->i_e2fs->e2fs_bsize, 0, &bp); if (error) goto out; @@ -176,9 +184,10 @@ ext2fs_get_block_xattr(struct inode *ip, if (end <= start || fs2h32(h->h_magic) != EXT2FS_XATTR_MAGIC) goto out; - error = ext2fs_find_xattr(EXT2FS_XATTR_BFIRST(h), start, end, attrnamespace, uio, size, name_index, name); + error = ext2fs_find_xattr(EXT2FS_XATTR_BFIRST(h), start, end, + attrnamespace, uio, size, name_index, name); -out: +out: if
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Tue Aug 23 06:40:25 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_lookup.c Log Message: KNF, no functional change To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/sys/ufs/ext2fs/ext2fs_lookup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_lookup.c diff -u src/sys/ufs/ext2fs/ext2fs_lookup.c:1.87 src/sys/ufs/ext2fs/ext2fs_lookup.c:1.88 --- src/sys/ufs/ext2fs/ext2fs_lookup.c:1.87 Thu Aug 18 20:05:43 2016 +++ src/sys/ufs/ext2fs/ext2fs_lookup.c Tue Aug 23 02:40:25 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_lookup.c,v 1.87 2016/08/19 00:05:43 jdolecek Exp $ */ +/* $NetBSD: ext2fs_lookup.c,v 1.88 2016/08/23 06:40:25 christos Exp $ */ /* * Modified for NetBSD 1.2E @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.87 2016/08/19 00:05:43 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.88 2016/08/23 06:40:25 christos Exp $"); #include #include @@ -305,8 +305,6 @@ ext2fs_lookup(void *v) int dirblksiz = ump->um_dirblksiz; ino_t foundino; struct ufs_lookup_results *results; - doff_t i_offset; /* cached i_offset value */ - struct ext2fs_searchslot ss; flags = cnp->cn_flags; @@ -386,7 +384,6 @@ ext2fs_lookup(void *v) prevoff = results->ulr_offset; endsearch = roundup(ext2fs_size(dp), dirblksiz); enduseful = 0; - /* * Try to lookup dir entry using htree directory index. * @@ -394,6 +391,8 @@ ext2fs_lookup(void *v) * we will fall back to linear search. */ if (!ext2fs_is_dot_entry(cnp) && ext2fs_htree_has_idx(dp)) { + doff_t i_offset; /* cached i_offset value */ + struct ext2fs_searchslot ss; numdirpasses = 1; entryoffsetinblock = 0; @@ -402,8 +401,7 @@ ext2fs_lookup(void *v) &prevoff, &enduseful, &ss); switch (htree_lookup_ret) { case 0: - ep = (struct ext2fs_direct*)((char *)bp->b_data + - (i_offset & bmask)); + ep = (void *)((char *)bp->b_data + (i_offset & bmask)); foundino = ep->e2d_ino; goto found; case ENOENT: @@ -428,8 +426,8 @@ searchloop: if ((results->ulr_offset & bmask) == 0) { if (bp != NULL) brelse(bp, 0); - error = ext2fs_blkatoff(vdp, (off_t)results->ulr_offset, NULL, - &bp); + error = ext2fs_blkatoff(vdp, (off_t)results->ulr_offset, + NULL, &bp); if (error != 0) return error; entryoffsetinblock = 0;
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Tue Aug 23 06:24:30 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: CID 1371644: use strlcpy, remove dup copy. To generate a diff of this commit: cvs rdiff -u -r1.202 -r1.203 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.202 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.203 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.202 Sat Aug 20 17:22:25 2016 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Tue Aug 23 02:24:30 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.202 2016/08/20 21:22:25 jdolecek Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.203 2016/08/23 06:24:30 christos Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.202 2016/08/20 21:22:25 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.203 2016/08/23 06:24:30 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -242,12 +242,9 @@ ext2fs_done(void) static void ext2fs_sb_setmountinfo(struct m_ext2fs *fs, struct mount *mp) { - (void)strncpy(fs->e2fs_fsmnt, mp->mnt_stat.f_mntonname, + (void)strlcpy(fs->e2fs_fsmnt, mp->mnt_stat.f_mntonname, sizeof(fs->e2fs_fsmnt)); if (fs->e2fs_ronly == 0 && fs->e2fs.e2fs_rev > E2FS_REV0) { - (void)strncpy(fs->e2fs.e2fs_fsmnt, mp->mnt_stat.f_mntonname, -sizeof(fs->e2fs.e2fs_fsmnt)); - fs->e2fs.e2fs_mtime = time_second; fs->e2fs.e2fs_mnt_count++;
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Tue Aug 23 06:23:27 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_htree.c Log Message: CID 1371645: remove dead code To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/ufs/ext2fs/ext2fs_htree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_htree.c diff -u src/sys/ufs/ext2fs/ext2fs_htree.c:1.8 src/sys/ufs/ext2fs/ext2fs_htree.c:1.9 --- src/sys/ufs/ext2fs/ext2fs_htree.c:1.8 Sat Aug 20 15:45:20 2016 +++ src/sys/ufs/ext2fs/ext2fs_htree.c Tue Aug 23 02:23:26 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_htree.c,v 1.8 2016/08/20 19:45:20 jdolecek Exp $ */ +/* $NetBSD: ext2fs_htree.c,v 1.9 2016/08/23 06:23:26 christos Exp $ */ /*- * Copyright (c) 2010, 2012 Zheng Liu @@ -29,7 +29,7 @@ * $FreeBSD: head/sys/fs/ext2fs/ext2fs_htree.c 294653 2016-01-24 02:41:49Z pfg $ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.8 2016/08/20 19:45:20 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.9 2016/08/23 06:23:26 christos Exp $"); #include #include @@ -451,8 +451,6 @@ ext2fs_htree_create_index(struct vnode * bdwrite(bp); dp->i_flag |= IN_CHANGE | IN_UPDATE; - if (error) - goto out; /* * Write directory block 1.
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Sat Aug 20 21:22:25 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: fix code which sets REV1 e2fs_fsmnt, set also mount time and mount count To generate a diff of this commit: cvs rdiff -u -r1.201 -r1.202 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.201 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.202 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.201 Sat Aug 20 20:05:28 2016 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Sat Aug 20 21:22:25 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.201 2016/08/20 20:05:28 jdolecek Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.202 2016/08/20 21:22:25 jdolecek Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.201 2016/08/20 20:05:28 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.202 2016/08/20 21:22:25 jdolecek Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -239,6 +239,22 @@ ext2fs_done(void) pool_destroy(&ext2fs_inode_pool); } +static void +ext2fs_sb_setmountinfo(struct m_ext2fs *fs, struct mount *mp) +{ + (void)strncpy(fs->e2fs_fsmnt, mp->mnt_stat.f_mntonname, +sizeof(fs->e2fs_fsmnt)); + if (fs->e2fs_ronly == 0 && fs->e2fs.e2fs_rev > E2FS_REV0) { + (void)strncpy(fs->e2fs.e2fs_fsmnt, mp->mnt_stat.f_mntonname, +sizeof(fs->e2fs.e2fs_fsmnt)); + + fs->e2fs.e2fs_mtime = time_second; + fs->e2fs.e2fs_mnt_count++; + + fs->e2fs_fmod = 1; + } +} + /* * Called by main() when ext2fs is going to be mounted as root. * @@ -270,14 +286,7 @@ ext2fs_mountroot(void) mountlist_append(mp); ump = VFSTOUFS(mp); fs = ump->um_e2fs; - memset(fs->e2fs_fsmnt, 0, sizeof(fs->e2fs_fsmnt)); - (void) copystr(mp->mnt_stat.f_mntonname, fs->e2fs_fsmnt, - sizeof(fs->e2fs_fsmnt) - 1, 0); - if (fs->e2fs.e2fs_rev > E2FS_REV0) { - memset(fs->e2fs.e2fs_fsmnt, 0, sizeof(fs->e2fs.e2fs_fsmnt)); - (void) copystr(mp->mnt_stat.f_mntonname, fs->e2fs.e2fs_fsmnt, - sizeof(fs->e2fs.e2fs_fsmnt) - 1, 0); - } + ext2fs_sb_setmountinfo(fs, mp); (void)ext2fs_statvfs(mp, &mp->mnt_stat); vfs_unbusy(mp, false, NULL); setrootfstime((time_t)fs->e2fs.e2fs_wtime); @@ -297,7 +306,6 @@ ext2fs_mount(struct mount *mp, const cha struct ufs_args *args = data; struct ufsmount *ump = NULL; struct m_ext2fs *fs; - size_t size; int error = 0, flags, update; mode_t accessmode; @@ -467,15 +475,9 @@ ext2fs_mount(struct mount *mp, const cha error = set_statvfs_info(path, UIO_USERSPACE, args->fspec, UIO_USERSPACE, mp->mnt_op->vfs_name, mp, l); - (void) copystr(mp->mnt_stat.f_mntonname, fs->e2fs_fsmnt, - sizeof(fs->e2fs_fsmnt) - 1, &size); - memset(fs->e2fs_fsmnt + size, 0, sizeof(fs->e2fs_fsmnt) - size); - if (fs->e2fs.e2fs_rev > E2FS_REV0) { - (void) copystr(mp->mnt_stat.f_mntonname, fs->e2fs.e2fs_fsmnt, - sizeof(fs->e2fs.e2fs_fsmnt) - 1, &size); - memset(fs->e2fs.e2fs_fsmnt, 0, - sizeof(fs->e2fs.e2fs_fsmnt) - size); - } + if (error == 0) + ext2fs_sb_setmountinfo(fs, mp); + if (fs->e2fs_fmod != 0) { /* XXX */ fs->e2fs_fmod = 0; if (fs->e2fs.e2fs_state == 0)
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Sat Aug 20 20:05:28 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: adjust ext2fs_loadvnode_content() to do the sanity checking before allocating memory, and avoid reallocaing memory on vnode reload To generate a diff of this commit: cvs rdiff -u -r1.200 -r1.201 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.200 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.201 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.200 Sat Aug 20 19:47:44 2016 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Sat Aug 20 20:05:28 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.200 2016/08/20 19:47:44 jdolecek Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.201 2016/08/20 20:05:28 jdolecek Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.200 2016/08/20 19:47:44 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.201 2016/08/20 20:05:28 jdolecek Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -493,22 +493,19 @@ fail: } /* - * + * Sanity check the disk vnode content, and copy it over to inode structure. */ static int ext2fs_loadvnode_content(struct m_ext2fs *fs, ino_t ino, struct buf *bp, struct inode *ip) { struct ext2fs_dinode *din; - void *cp; int error = 0; - cp = (char *)bp->b_data + (ino_to_fsbo(fs, ino) * EXT2_DINODE_SIZE(fs)); - din = kmem_alloc(EXT2_DINODE_SIZE(fs), KM_SLEEP); - e2fs_iload((struct ext2fs_dinode *)cp, din, EXT2_DINODE_SIZE(fs)); + din = (struct ext2fs_dinode *)((char *)bp->b_data + (ino_to_fsbo(fs, ino) * EXT2_DINODE_SIZE(fs))); - /* sanity checks */ + /* sanity checks - inode data NOT byteswapped at this point */ if (EXT2_DINODE_FITS(din, e2di_extra_isize, EXT2_DINODE_SIZE(fs)) - && (EXT2_DINODE_SIZE(fs) - EXT2_REV0_DINODE_SIZE) < din->e2di_extra_isize) + && (EXT2_DINODE_SIZE(fs) - EXT2_REV0_DINODE_SIZE) < fs2h16(din->e2di_extra_isize)) { printf("ext2fs: inode %"PRIu64" bad extra_isize %u", ino, din->e2di_extra_isize); @@ -516,16 +513,15 @@ ext2fs_loadvnode_content(struct m_ext2fs goto bad; } - /* replace old dinode; assumes new dinode size is same as old one */ - if (ip->i_din.e2fs_din) - kmem_free(ip->i_din.e2fs_din, EXT2_DINODE_SIZE(fs)); - ip->i_din.e2fs_din = din; + /* everything allright, proceed with copy */ + if (ip->i_din.e2fs_din == NULL) + ip->i_din.e2fs_din = kmem_alloc(EXT2_DINODE_SIZE(fs), KM_SLEEP); + + e2fs_iload(din, ip->i_din.e2fs_din, EXT2_DINODE_SIZE(fs)); ext2fs_set_inode_guid(ip); - return error; bad: - kmem_free(din, EXT2_DINODE_SIZE(fs)); return error; }
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Sat Aug 20 19:53:43 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_alloc.c Log Message: modify the comment to note code needs to brele() to have a shot on actually working To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/ufs/ext2fs/ext2fs_alloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_alloc.c diff -u src/sys/ufs/ext2fs/ext2fs_alloc.c:1.50 src/sys/ufs/ext2fs/ext2fs_alloc.c:1.51 --- src/sys/ufs/ext2fs/ext2fs_alloc.c:1.50 Sat Aug 20 19:51:50 2016 +++ src/sys/ufs/ext2fs/ext2fs_alloc.c Sat Aug 20 19:53:43 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_alloc.c,v 1.50 2016/08/20 19:51:50 jdolecek Exp $ */ +/* $NetBSD: ext2fs_alloc.c,v 1.51 2016/08/20 19:53:43 jdolecek Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.50 2016/08/20 19:51:50 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.51 2016/08/20 19:53:43 jdolecek Exp $"); #include #include @@ -418,7 +418,10 @@ ext2fs_alloccg(struct inode *ip, int cg, bno = ext2fs_mapsearch(fs, bbp, bpref); #if 0 - /* XXX jdolecek mapsearch actually never fails, it panics instead */ + /* + * XXX jdolecek mapsearch actually never fails, it panics instead. + * If re-enabling, make sure to brele() before returning. + */ if (bno < 0) return 0; #endif
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Sat Aug 20 19:51:50 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_alloc.c Log Message: #if 0 the check for ext2fs_mapsearch() failure (similar what was done for ffs counterpart), it actually never fails, it panics instead To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/ufs/ext2fs/ext2fs_alloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_alloc.c diff -u src/sys/ufs/ext2fs/ext2fs_alloc.c:1.49 src/sys/ufs/ext2fs/ext2fs_alloc.c:1.50 --- src/sys/ufs/ext2fs/ext2fs_alloc.c:1.49 Sat Aug 20 19:47:44 2016 +++ src/sys/ufs/ext2fs/ext2fs_alloc.c Sat Aug 20 19:51:50 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_alloc.c,v 1.49 2016/08/20 19:47:44 jdolecek Exp $ */ +/* $NetBSD: ext2fs_alloc.c,v 1.50 2016/08/20 19:51:50 jdolecek Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.49 2016/08/20 19:47:44 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.50 2016/08/20 19:51:50 jdolecek Exp $"); #include #include @@ -417,8 +417,11 @@ ext2fs_alloccg(struct inode *ip, int cg, } bno = ext2fs_mapsearch(fs, bbp, bpref); +#if 0 + /* XXX jdolecek mapsearch actually never fails, it panics instead */ if (bno < 0) return 0; +#endif gotit: #ifdef DIAGNOSTIC if (isset(bbp, (daddr_t)bno)) {
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Sat Aug 20 19:47:44 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs.h ext2fs_alloc.c ext2fs_bswap.c ext2fs_extern.h ext2fs_vfsops.c Log Message: add support for GDT_CSUM AKA uninit_bg feature To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/ufs/ext2fs/ext2fs.h cvs rdiff -u -r1.48 -r1.49 src/sys/ufs/ext2fs/ext2fs_alloc.c cvs rdiff -u -r1.23 -r1.24 src/sys/ufs/ext2fs/ext2fs_bswap.c cvs rdiff -u -r1.54 -r1.55 src/sys/ufs/ext2fs/ext2fs_extern.h cvs rdiff -u -r1.199 -r1.200 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs.h diff -u src/sys/ufs/ext2fs/ext2fs.h:1.47 src/sys/ufs/ext2fs/ext2fs.h:1.48 --- src/sys/ufs/ext2fs/ext2fs.h:1.47 Mon Aug 15 18:46:11 2016 +++ src/sys/ufs/ext2fs/ext2fs.h Sat Aug 20 19:47:44 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.47 2016/08/15 18:46:11 jdolecek Exp $ */ +/* $NetBSD: ext2fs.h,v 1.48 2016/08/20 19:47:44 jdolecek Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -249,10 +249,10 @@ struct m_ext2fs { int64_t e2fs_qbmask; /* ~fs_bmask - for use with quad size */ int32_t e2fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */ int32_t e2fs_ncg; /* number of cylinder groups */ - int32_t e2fs_ngdb; /* number of group descriptor block */ + int32_t e2fs_ngdb; /* number of group descriptor blocks */ int32_t e2fs_ipb; /* number of inodes per block */ - int32_t e2fs_itpg; /* number of inode table per group */ - struct ext2_gd *e2fs_gd; /* group descripors */ + int32_t e2fs_itpg; /* number of inode table blocks per group */ + struct ext2_gd *e2fs_gd; /* group descriptors (data not byteswapped) */ }; @@ -366,7 +366,8 @@ struct m_ext2fs { | EXT2F_ROCOMPAT_LARGEFILE \ | EXT2F_ROCOMPAT_HUGE_FILE \ | EXT2F_ROCOMPAT_EXTRA_ISIZE \ - | EXT2F_ROCOMPAT_DIR_NLINK) + | EXT2F_ROCOMPAT_DIR_NLINK \ + | EXT2F_ROCOMPAT_GDT_CSUM) #define EXT2F_INCOMPAT_SUPP (EXT2F_INCOMPAT_FTYPE \ | EXT2F_INCOMPAT_EXTENTS \ | EXT2F_INCOMPAT_FLEX_BG) @@ -415,15 +416,35 @@ struct m_ext2fs { struct ext2_gd { uint32_t ext2bgd_b_bitmap; /* blocks bitmap block */ uint32_t ext2bgd_i_bitmap; /* inodes bitmap block */ - uint32_t ext2bgd_i_tables; /* inodes table block */ + uint32_t ext2bgd_i_tables; /* first inodes table block */ uint16_t ext2bgd_nbfree; /* number of free blocks */ uint16_t ext2bgd_nifree; /* number of free inodes */ uint16_t ext2bgd_ndirs; /* number of directories */ - uint16_t reserved; - uint32_t reserved2[3]; + + /* + * Following only valid when either GDT_CSUM (AKA uninit_bg) + * or METADATA_CKSUM feature is on + */ + uint16_t ext2bgd_flags; /* ext4 bg flags (INODE_UNINIT, ...)*/ + uint32_t ext2bgd_exclude_bitmap_lo; /* snapshot exclude bitmap */ + uint16_t ext2bgd_block_bitmap_csum_lo; /* Low block bitmap checksum */ + uint16_t ext2bgd_inode_bitmap_csum_lo; /* Low inode bitmap checksum */ + uint16_t ext2bgd_itable_unused_lo; /* Low unused inode offset */ + uint16_t ext2bgd_checksum; /* Group desc checksum */ + + /* + * XXX disk32 Further fields only exist if 64BIT feature is on + * and superblock desc_size > 32, not supported for now. + */ }; +#define E2FS_BG_INODE_UNINIT 0x0001 /* Inode bitmap not used/initialized */ +#define E2FS_BG_BLOCK_UNINIT 0x0002 /* Block bitmap not used/initialized */ +#define E2FS_BG_INODE_ZEROED 0x0004 /* On-disk inode table initialized */ +#define E2FS_HAS_GD_CSUM(fs) \ + EXT2F_HAS_ROCOMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM|EXT2F_ROCOMPAT_METADATA_CKSUM) != 0 + /* * If the EXT2F_ROCOMPAT_SPARSESUPER flag is set, the cylinder group has a * copy of the super and cylinder group descriptors blocks only if it's @@ -457,13 +478,10 @@ cg_has_sb(int i) # define fs2h16(x) (x) # define fs2h32(x) (x) # define fs2h64(x) (x) -# define e2fs_sbload(old, new) memcpy((new), (old), SBSIZE); -# define e2fs_cgload(old, new, size) memcpy((new), (old), (size)); -# define e2fs_sbsave(old, new) memcpy((new), (old), SBSIZE); -# define e2fs_cgsave(old, new, size) memcpy((new), (old), (size)); +# define e2fs_sbload(old, new) memcpy((new), (old), SBSIZE) +# define e2fs_sbsave(old, new) memcpy((new), (old), SBSIZE) #else void e2fs_sb_bswap(struct ext2fs *, struct ext2fs *); -void e2fs_cg_bswap(struct ext2_gd *, struct ext2_gd *, int); # define h2fs16(x) bswap16(x) # define h2fs32(x) bswap32(x) # define h2fs64(x) bswap64(x) @@ -471,11 +489,13 @@ void e2fs_cg_bswap(struct ext2_gd *, str # define fs2h32(x) bswap32(x) # define fs2h64(x) bswap64(x) # define e2fs_sbload(old, new) e2fs_sb_bswap((old), (new)) -# define e2fs_cgload(old, new, size) e2fs_cg_bswap((old), (new), (size)); # define e2fs_sbsave(old, new) e2fs_sb_bswap((old), (new)) -# define e2fs_cgsave(old, new, size) e2fs_cg_bswap((old), (new), (size)); #endif +/* Group descriptors ar
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Sat Aug 20 19:45:20 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_htree.c Log Message: whitespace fix To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/ufs/ext2fs/ext2fs_htree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_htree.c diff -u src/sys/ufs/ext2fs/ext2fs_htree.c:1.7 src/sys/ufs/ext2fs/ext2fs_htree.c:1.8 --- src/sys/ufs/ext2fs/ext2fs_htree.c:1.7 Fri Aug 19 00:05:43 2016 +++ src/sys/ufs/ext2fs/ext2fs_htree.c Sat Aug 20 19:45:20 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_htree.c,v 1.7 2016/08/19 00:05:43 jdolecek Exp $ */ +/* $NetBSD: ext2fs_htree.c,v 1.8 2016/08/20 19:45:20 jdolecek Exp $ */ /*- * Copyright (c) 2010, 2012 Zheng Liu @@ -29,7 +29,7 @@ * $FreeBSD: head/sys/fs/ext2fs/ext2fs_htree.c 294653 2016-01-24 02:41:49Z pfg $ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.7 2016/08/19 00:05:43 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.8 2016/08/20 19:45:20 jdolecek Exp $"); #include #include @@ -306,7 +306,7 @@ ext2fs_htree_split_dirblock(char *block1 * Sort directory entry descriptors by name hash value. */ kheapsort(sort_info, entry_cnt, sizeof(struct ext2fs_htree_sort_entry), - ext2fs_htree_cmp_sort_entry,&dummy); + ext2fs_htree_cmp_sort_entry, &dummy); /* * Count the number of entries to move to directory block 2.
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Fri Aug 19 00:05:43 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_extern.h ext2fs_htree.c ext2fs_lookup.c Log Message: fix bug introduced in rev 1.82 of ext2fs_lookup.c, when ext2fs_add_entry() was introduced splitting code from ext2fs_direnter() - code used incorrect new entry size, leading to incomplete entry copy or buffer overflow; fixed by passing the right size from ext2fs_direnter() To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/sys/ufs/ext2fs/ext2fs_extern.h cvs rdiff -u -r1.6 -r1.7 src/sys/ufs/ext2fs/ext2fs_htree.c cvs rdiff -u -r1.86 -r1.87 src/sys/ufs/ext2fs/ext2fs_lookup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_extern.h diff -u src/sys/ufs/ext2fs/ext2fs_extern.h:1.53 src/sys/ufs/ext2fs/ext2fs_extern.h:1.54 --- src/sys/ufs/ext2fs/ext2fs_extern.h:1.53 Mon Aug 15 18:29:34 2016 +++ src/sys/ufs/ext2fs/ext2fs_extern.h Fri Aug 19 00:05:43 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_extern.h,v 1.53 2016/08/15 18:29:34 jdolecek Exp $ */ +/* $NetBSD: ext2fs_extern.h,v 1.54 2016/08/19 00:05:43 jdolecek Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -134,7 +134,7 @@ int ext2fs_dirrewrite(struct inode *, co struct inode *, struct componentname *); int ext2fs_dirempty(struct inode *, ino_t, kauth_cred_t); int ext2fs_add_entry(struct vnode *, struct ext2fs_direct *, -const struct ufs_lookup_results *); +const struct ufs_lookup_results *, size_t); /* ext2fs_subr.c */ int ext2fs_blkatoff(struct vnode *, off_t, char **, struct buf **); @@ -190,7 +190,7 @@ int ext2fs_htree_lookup(struct inode *, int ext2fs_htree_create_index(struct vnode *, struct componentname *, struct ext2fs_direct *); int ext2fs_htree_add_entry(struct vnode *, struct ext2fs_direct *, -struct componentname *); +struct componentname *, size_t); __END_DECLS Index: src/sys/ufs/ext2fs/ext2fs_htree.c diff -u src/sys/ufs/ext2fs/ext2fs_htree.c:1.6 src/sys/ufs/ext2fs/ext2fs_htree.c:1.7 --- src/sys/ufs/ext2fs/ext2fs_htree.c:1.6 Sun Aug 14 11:42:50 2016 +++ src/sys/ufs/ext2fs/ext2fs_htree.c Fri Aug 19 00:05:43 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_htree.c,v 1.6 2016/08/14 11:42:50 jdolecek Exp $ */ +/* $NetBSD: ext2fs_htree.c,v 1.7 2016/08/19 00:05:43 jdolecek Exp $ */ /*- * Copyright (c) 2010, 2012 Zheng Liu @@ -29,7 +29,7 @@ * $FreeBSD: head/sys/fs/ext2fs/ext2fs_htree.c 294653 2016-01-24 02:41:49Z pfg $ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.6 2016/08/14 11:42:50 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.7 2016/08/19 00:05:43 jdolecek Exp $"); #include #include @@ -480,7 +480,7 @@ out1: */ int ext2fs_htree_add_entry(struct vnode *dvp, struct ext2fs_direct *entry, -struct componentname *cnp) +struct componentname *cnp, size_t newentrysize) { struct ext2fs_htree_entry *entries, *leaf_node; struct ext2fs_htree_lookup_info info; @@ -507,7 +507,8 @@ ext2fs_htree_add_entry(struct vnode *dvp blksize = m_fs->e2fs_bsize; if (ip->i_crap.ulr_count != 0) - return ext2fs_add_entry(dvp, entry, &(ip->i_crap)); + return ext2fs_add_entry(dvp, entry, &(ip->i_crap), newentrysize); + /* Target directory block is full, split it */ memset(&info, 0, sizeof(info)); error = ext2fs_htree_find_leaf(ip, entry->e2d_name, entry->e2d_namlen, Index: src/sys/ufs/ext2fs/ext2fs_lookup.c diff -u src/sys/ufs/ext2fs/ext2fs_lookup.c:1.86 src/sys/ufs/ext2fs/ext2fs_lookup.c:1.87 --- src/sys/ufs/ext2fs/ext2fs_lookup.c:1.86 Sun Aug 14 11:46:05 2016 +++ src/sys/ufs/ext2fs/ext2fs_lookup.c Fri Aug 19 00:05:43 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_lookup.c,v 1.86 2016/08/14 11:46:05 jdolecek Exp $ */ +/* $NetBSD: ext2fs_lookup.c,v 1.87 2016/08/19 00:05:43 jdolecek Exp $ */ /* * Modified for NetBSD 1.2E @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.86 2016/08/14 11:46:05 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.87 2016/08/19 00:05:43 jdolecek Exp $"); #include #include @@ -839,10 +839,8 @@ ext2fs_dirbadentry(struct vnode *dp, str if (reclen < EXT2FS_DIRSIZ(1)) /* e2d_namlen = 1 */ error_msg = "rec_len is smaller than minimal"; -#if 0 else if (reclen % 4 != 0) error_msg = "rec_len % 4 != 0"; -#endif else if (namlen > EXT2FS_MAXNAMLEN) error_msg = "namlen > EXT2FS_MAXNAMLEN"; else if (reclen < EXT2FS_DIRSIZ(namlen)) @@ -880,9 +878,10 @@ ext2fs_direnter(struct inode *ip, struct struct ext2fs_direct newdir; struct iovec aiov; struct uio auio; - int error, newentrysize; + int error; struct ufsmount *ump = VFSTOUFS(dvp->v_mount); int dirblksiz = ump->um_dirblksiz; + size_t newentrysize; dp = VTOI(dvp); @@ -895,11 +894,11 @@ ext2fs_direnter(struct inode *ip, struct } memcpy(newdir.e2d_name, cnp->cn_nameptr, (unsigned)cnp->cn_n
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Mon Aug 15 18:46:11 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs.h Log Message: EXT2F_INCOMPAT_FLEX_BG feature actually doesn't require any explicit code changes, all magic is done by setting the block offsets appropriately in group descriptors by newfs; add it to the list of supported INCOMPAT flags To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/ufs/ext2fs/ext2fs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs.h diff -u src/sys/ufs/ext2fs/ext2fs.h:1.46 src/sys/ufs/ext2fs/ext2fs.h:1.47 --- src/sys/ufs/ext2fs/ext2fs.h:1.46 Mon Aug 15 18:38:10 2016 +++ src/sys/ufs/ext2fs/ext2fs.h Mon Aug 15 18:46:11 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.46 2016/08/15 18:38:10 jdolecek Exp $ */ +/* $NetBSD: ext2fs.h,v 1.47 2016/08/15 18:46:11 jdolecek Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -368,7 +368,8 @@ struct m_ext2fs { | EXT2F_ROCOMPAT_EXTRA_ISIZE \ | EXT2F_ROCOMPAT_DIR_NLINK) #define EXT2F_INCOMPAT_SUPP (EXT2F_INCOMPAT_FTYPE \ - | EXT2F_INCOMPAT_EXTENTS) + | EXT2F_INCOMPAT_EXTENTS \ + | EXT2F_INCOMPAT_FLEX_BG) /* * Feature set definitions
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Mon Aug 15 18:38:10 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs.h ext2fs_rename.c ext2fs_vnops.c Log Message: bump link limit to 65000 for files, and add support for EXT2F_ROCOMPAT_DIR_NLINK to make link count unlimited for directories To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/ufs/ext2fs/ext2fs.h cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/ext2fs/ext2fs_rename.c cvs rdiff -u -r1.124 -r1.125 src/sys/ufs/ext2fs/ext2fs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs.h diff -u src/sys/ufs/ext2fs/ext2fs.h:1.45 src/sys/ufs/ext2fs/ext2fs.h:1.46 --- src/sys/ufs/ext2fs/ext2fs.h:1.45 Sun Aug 14 11:42:50 2016 +++ src/sys/ufs/ext2fs/ext2fs.h Mon Aug 15 18:38:10 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.45 2016/08/14 11:42:50 jdolecek Exp $ */ +/* $NetBSD: ext2fs.h,v 1.46 2016/08/15 18:38:10 jdolecek Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -128,6 +128,13 @@ #define MINFREE 5 /* + * This is maximum amount of links allowed for files. For directories, + * going over this means setting DIR_NLINK feature. + */ +#define EXT2FS_LINK_MAX 65000 +#define EXT2FS_LINK_INF 1 /* link count unknown */ + +/* * Super block for an ext2fs file system. */ struct ext2fs { @@ -358,7 +365,8 @@ struct m_ext2fs { #define EXT2F_ROCOMPAT_SUPP (EXT2F_ROCOMPAT_SPARSESUPER \ | EXT2F_ROCOMPAT_LARGEFILE \ | EXT2F_ROCOMPAT_HUGE_FILE \ - | EXT2F_ROCOMPAT_EXTRA_ISIZE) + | EXT2F_ROCOMPAT_EXTRA_ISIZE \ + | EXT2F_ROCOMPAT_DIR_NLINK) #define EXT2F_INCOMPAT_SUPP (EXT2F_INCOMPAT_FTYPE \ | EXT2F_INCOMPAT_EXTENTS) Index: src/sys/ufs/ext2fs/ext2fs_rename.c diff -u src/sys/ufs/ext2fs/ext2fs_rename.c:1.10 src/sys/ufs/ext2fs/ext2fs_rename.c:1.11 --- src/sys/ufs/ext2fs/ext2fs_rename.c:1.10 Sat Aug 13 07:40:10 2016 +++ src/sys/ufs/ext2fs/ext2fs_rename.c Mon Aug 15 18:38:10 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_rename.c,v 1.10 2016/08/13 07:40:10 christos Exp $ */ +/* $NetBSD: ext2fs_rename.c,v 1.11 2016/08/15 18:38:10 jdolecek Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_rename.c,v 1.10 2016/08/13 07:40:10 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_rename.c,v 1.11 2016/08/15 18:38:10 jdolecek Exp $"); #include #include @@ -307,7 +307,7 @@ ext2fs_gro_rename(struct mount *mp, kaut * We shall need to temporarily bump the link count, so make * sure there is room to do so. */ - if ((nlink_t)VTOI(fvp)->i_e2fs_nlink >= LINK_MAX) + if ((nlink_t)VTOI(fvp)->i_e2fs_nlink >= EXT2FS_LINK_MAX) return EMLINK; directory_p = (fvp->v_type == VDIR); @@ -330,7 +330,7 @@ ext2fs_gro_rename(struct mount *mp, kaut *may be wrong, but correctable. */ - KASSERT((nlink_t)VTOI(fvp)->i_e2fs_nlink < LINK_MAX); + KASSERT((nlink_t)VTOI(fvp)->i_e2fs_nlink < EXT2FS_LINK_MAX); VTOI(fvp)->i_e2fs_nlink++; VTOI(fvp)->i_flag |= IN_CHANGE; error = ext2fs_update(fvp, NULL, NULL, UPDATE_WAIT); @@ -352,11 +352,11 @@ ext2fs_gro_rename(struct mount *mp, kaut * parent we don't fool with the link count. */ if (directory_p && reparent_p) { - if ((nlink_t)VTOI(tdvp)->i_e2fs_nlink >= LINK_MAX) { + if ((nlink_t)VTOI(tdvp)->i_e2fs_nlink >= EXT2FS_LINK_MAX) { error = EMLINK; goto whymustithurtsomuch; } - KASSERT((nlink_t)VTOI(tdvp)->i_e2fs_nlink < LINK_MAX); + KASSERT((nlink_t)VTOI(tdvp)->i_e2fs_nlink < EXT2FS_LINK_MAX); VTOI(tdvp)->i_e2fs_nlink++; VTOI(tdvp)->i_flag |= IN_CHANGE; error = ext2fs_update(tdvp, NULL, NULL, UPDATE_WAIT); Index: src/sys/ufs/ext2fs/ext2fs_vnops.c diff -u src/sys/ufs/ext2fs/ext2fs_vnops.c:1.124 src/sys/ufs/ext2fs/ext2fs_vnops.c:1.125 --- src/sys/ufs/ext2fs/ext2fs_vnops.c:1.124 Mon Aug 15 18:29:34 2016 +++ src/sys/ufs/ext2fs/ext2fs_vnops.c Mon Aug 15 18:38:10 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vnops.c,v 1.124 2016/08/15 18:29:34 jdolecek Exp $ */ +/* $NetBSD: ext2fs_vnops.c,v 1.125 2016/08/15 18:38:10 jdolecek Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.124 2016/08/15 18:29:34 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.125 2016/08/15 18:38:10 jdolecek Exp $"); #include #include @@ -626,7 +626,7 @@ ext2fs_link(void *v) goto out2; } ip = VTOI(vp); - if ((nlink_t)ip->i_e2fs_nlink >= LINK_MAX) { + if ((nlink_t)ip->i_e2fs_nlink >= EXT2FS_LINK_MAX) { VOP_ABORTOP(dvp, cnp); error = EMLINK; goto out1; @@ -677,11 +677,6 @@ ext2fs_mkdir(void *v) ulr = &VTOI(dvp)->i_crap; UFS_CHECK_CRAPCOUNTER(VTOI(dvp)); - if ((nlink_t)dp->i_e2fs_nlink >= LINK_MAX) { - error = EMLINK; - goto out; - } - /* * Acquire the inode, but don't sync/direnter it just yet */ @@ -700,7
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Mon Aug 15 18:29:34 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_bswap.c ext2fs_extern.h ext2fs_vnops.c Log Message: adjust ext2fs_makeinode() so that the direnter is optional, use the function (with the direnter off) in ext2fs_mkdir() instead of the code copy; adjust ext2fs_makeinode() to initialize extra_isize and set creation time, if supported by the filesystem To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/ext2fs/ext2fs_bswap.c cvs rdiff -u -r1.52 -r1.53 src/sys/ufs/ext2fs/ext2fs_extern.h cvs rdiff -u -r1.123 -r1.124 src/sys/ufs/ext2fs/ext2fs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_bswap.c diff -u src/sys/ufs/ext2fs/ext2fs_bswap.c:1.22 src/sys/ufs/ext2fs/ext2fs_bswap.c:1.23 --- src/sys/ufs/ext2fs/ext2fs_bswap.c:1.22 Thu Aug 4 17:43:48 2016 +++ src/sys/ufs/ext2fs/ext2fs_bswap.c Mon Aug 15 18:29:34 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_bswap.c,v 1.22 2016/08/04 17:43:48 jdolecek Exp $ */ +/* $NetBSD: ext2fs_bswap.c,v 1.23 2016/08/15 18:29:34 jdolecek Exp $ */ /* * Copyright (c) 1997 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_bswap.c,v 1.22 2016/08/04 17:43:48 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_bswap.c,v 1.23 2016/08/15 18:29:34 jdolecek Exp $"); #include #include @@ -79,6 +79,7 @@ e2fs_sb_bswap(struct ext2fs *old, struct new->e2fs_features_rocompat = bswap32(old->e2fs_features_rocompat); new->e2fs_algo = bswap32(old->e2fs_algo); new->e2fs_reserved_ngdb = bswap16(old->e2fs_reserved_ngdb); + new->e4fs_want_extra_isize = bswap16(old->e4fs_want_extra_isize); } void Index: src/sys/ufs/ext2fs/ext2fs_extern.h diff -u src/sys/ufs/ext2fs/ext2fs_extern.h:1.52 src/sys/ufs/ext2fs/ext2fs_extern.h:1.53 --- src/sys/ufs/ext2fs/ext2fs_extern.h:1.52 Tue Aug 9 21:08:02 2016 +++ src/sys/ufs/ext2fs/ext2fs_extern.h Mon Aug 15 18:29:34 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_extern.h,v 1.52 2016/08/09 21:08:02 kre Exp $ */ +/* $NetBSD: ext2fs_extern.h,v 1.53 2016/08/15 18:29:34 jdolecek Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -176,7 +176,7 @@ int ext2fs_fsync(void *); int ext2fs_vinit(struct mount *, int (**specops)(void *), int (**fifoops)(void *), struct vnode **); int ext2fs_makeinode(int, struct vnode *, struct vnode **, - struct componentname *cnp); + struct componentname *cnp, int); int ext2fs_reclaim(void *); /* ext2fs_hash.c */ Index: src/sys/ufs/ext2fs/ext2fs_vnops.c diff -u src/sys/ufs/ext2fs/ext2fs_vnops.c:1.123 src/sys/ufs/ext2fs/ext2fs_vnops.c:1.124 --- src/sys/ufs/ext2fs/ext2fs_vnops.c:1.123 Sun Aug 14 11:44:54 2016 +++ src/sys/ufs/ext2fs/ext2fs_vnops.c Mon Aug 15 18:29:34 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vnops.c,v 1.123 2016/08/14 11:44:54 jdolecek Exp $ */ +/* $NetBSD: ext2fs_vnops.c,v 1.124 2016/08/15 18:29:34 jdolecek Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.123 2016/08/14 11:44:54 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.124 2016/08/15 18:29:34 jdolecek Exp $"); #include #include @@ -136,7 +136,7 @@ ext2fs_create(void *v) error = ext2fs_makeinode(MAKEIMODE(ap->a_vap->va_type, ap->a_vap->va_mode), - ap->a_dvp, ap->a_vpp, ap->a_cnp); + ap->a_dvp, ap->a_vpp, ap->a_cnp, 1); if (error) return error; @@ -166,7 +166,7 @@ ext2fs_mknod(void *v) ino_t ino; if ((error = ext2fs_makeinode(MAKEIMODE(vap->va_type, vap->va_mode), - ap->a_dvp, vpp, ap->a_cnp)) != 0) + ap->a_dvp, vpp, ap->a_cnp, 1)) != 0) return error; VN_KNOTE(ap->a_dvp, NOTE_WRITE); ip = VTOI(*vpp); @@ -666,12 +666,11 @@ ext2fs_mkdir(void *v) struct vattr *a_vap; } */ *ap = v; struct vnode *dvp = ap->a_dvp; - struct vattr *vap = ap->a_vap; struct componentname *cnp = ap->a_cnp; struct inode *ip, *dp = VTOI(dvp); struct vnode *tvp; struct ext2fs_dirtemplate dirtemplate; - int error, dmode; + int error; struct ufs_lookup_results *ulr; /* XXX should handle this material another way */ @@ -682,30 +681,17 @@ ext2fs_mkdir(void *v) error = EMLINK; goto out; } - dmode = vap->va_mode & ACCESSPERMS; - dmode |= IFDIR; + /* - * Must simulate part of ext2fs_makeinode here to acquire the inode, - * but not have it entered in the parent directory. The entry is - * made later after writing "." and ".." entries. + * Acquire the inode, but don't sync/direnter it just yet */ - if ((error = ext2fs_valloc(dvp, dmode, cnp->cn_cred, &tvp)) != 0) + error = ext2fs_makeinode(IFDIR | ap->a_vap->va_mode, ap->a_dvp, + &tvp, ap->a_cnp, 0); + if (error) goto out; + + /* the link count is going to be 2 when all is done */ ip = VTOI(tvp); - ip->i_uid = kauth_cred_geteuid(cnp->c
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Sun Aug 14 11:46:06 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_lookup.c Log Message: when converting on-disk direntry, only use the on-disk filetype if the feature flag is present To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/sys/ufs/ext2fs/ext2fs_lookup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_lookup.c diff -u src/sys/ufs/ext2fs/ext2fs_lookup.c:1.85 src/sys/ufs/ext2fs/ext2fs_lookup.c:1.86 --- src/sys/ufs/ext2fs/ext2fs_lookup.c:1.85 Sun Aug 14 11:44:54 2016 +++ src/sys/ufs/ext2fs/ext2fs_lookup.c Sun Aug 14 11:46:05 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_lookup.c,v 1.85 2016/08/14 11:44:54 jdolecek Exp $ */ +/* $NetBSD: ext2fs_lookup.c,v 1.86 2016/08/14 11:46:05 jdolecek Exp $ */ /* * Modified for NetBSD 1.2E @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.85 2016/08/14 11:44:54 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.86 2016/08/14 11:46:05 jdolecek Exp $"); #include #include @@ -76,7 +76,8 @@ __KERNEL_RCSID(0, "$NetBSD: ext2fs_looku extern int dirchk; -static void ext2fs_dirconv2ffs(struct ext2fs_direct *e2dir, +static void ext2fs_dirconv2ffs(struct m_ext2fs *fs, + struct ext2fs_direct *e2dir, struct dirent *ffsdir); static int ext2fs_dirbadentry(struct vnode *dp, struct ext2fs_direct *de, @@ -93,13 +94,16 @@ static int ext2fs_dirbadentry(struct vno * have worked w/o changes (except for the difference in DIRBLKSIZ) */ static void -ext2fs_dirconv2ffs(struct ext2fs_direct *e2dir, struct dirent *ffsdir) +ext2fs_dirconv2ffs(struct m_ext2fs *fs, struct ext2fs_direct *e2dir, struct dirent *ffsdir) { memset(ffsdir, 0, sizeof(struct dirent)); ffsdir->d_fileno = fs2h32(e2dir->e2d_ino); ffsdir->d_namlen = e2dir->e2d_namlen; - ffsdir->d_type = ext2dt2dt(e2dir->e2d_type); + if (EXT2F_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_FTYPE)) + ffsdir->d_type = ext2dt2dt(e2dir->e2d_type); + else + ffsdir->d_type = DT_UNKNOWN; #ifdef DIAGNOSTIC #if MAXNAMLEN < E2FS_MAXNAMLEN @@ -199,7 +203,7 @@ ext2fs_readdir(void *v) error = EIO; break; } - ext2fs_dirconv2ffs(dp, dstd); + ext2fs_dirconv2ffs(fs, dp, dstd); if(dstd->d_reclen > uio->uio_resid) { break; }
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Sun Aug 14 11:44:54 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_inode.c ext2fs_lookup.c ext2fs_vfsops.c ext2fs_vnops.c Log Message: switch code to use the EXT2_HAS_{COMPAT|ROCOMPAT|INCOMPAT}_FEATURE() macros instead of open coding the checks To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/sys/ufs/ext2fs/ext2fs_inode.c cvs rdiff -u -r1.84 -r1.85 src/sys/ufs/ext2fs/ext2fs_lookup.c cvs rdiff -u -r1.198 -r1.199 src/sys/ufs/ext2fs/ext2fs_vfsops.c cvs rdiff -u -r1.122 -r1.123 src/sys/ufs/ext2fs/ext2fs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_inode.c diff -u src/sys/ufs/ext2fs/ext2fs_inode.c:1.85 src/sys/ufs/ext2fs/ext2fs_inode.c:1.86 --- src/sys/ufs/ext2fs/ext2fs_inode.c:1.85 Sat Aug 13 07:40:10 2016 +++ src/sys/ufs/ext2fs/ext2fs_inode.c Sun Aug 14 11:44:54 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_inode.c,v 1.85 2016/08/13 07:40:10 christos Exp $ */ +/* $NetBSD: ext2fs_inode.c,v 1.86 2016/08/14 11:44:54 jdolecek Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.85 2016/08/13 07:40:10 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.86 2016/08/14 11:44:54 jdolecek Exp $"); #include #include @@ -121,8 +121,8 @@ ext2fs_setsize(struct inode *ip, uint64_ /* Linux automagically upgrades to REV1 here! */ return EFBIG; } - if (!(fs->e2fs.e2fs_features_rocompat - & EXT2F_ROCOMPAT_LARGEFILE)) { + if (!EXT2F_HAS_ROCOMPAT_FEATURE(fs, + EXT2F_ROCOMPAT_LARGEFILE)) { fs->e2fs.e2fs_features_rocompat |= EXT2F_ROCOMPAT_LARGEFILE; fs->e2fs_fmod = 1; @@ -142,7 +142,7 @@ ext2fs_nblock(struct inode *ip) uint64_t nblock = ip->i_e2fs_nblock; struct m_ext2fs * const fs = ip->i_e2fs; - if (fs->e2fs.e2fs_features_rocompat & EXT2F_ROCOMPAT_HUGE_FILE) { + if (EXT2F_HAS_ROCOMPAT_FEATURE(fs, EXT2F_ROCOMPAT_HUGE_FILE)) { nblock |= (uint64_t)ip->i_e2fs_nblock_high << 32; if ((ip->i_e2fs_flags & EXT2_HUGE_FILE)) { @@ -164,7 +164,7 @@ ext2fs_setnblock(struct inode *ip, uint6 return 0; } - if (!ISSET(fs->e2fs.e2fs_features_rocompat, EXT2F_ROCOMPAT_HUGE_FILE)) + if (!EXT2F_HAS_ROCOMPAT_FEATURE(fs, EXT2F_ROCOMPAT_HUGE_FILE)) return EFBIG; if (nblock <= 0xULL) { Index: src/sys/ufs/ext2fs/ext2fs_lookup.c diff -u src/sys/ufs/ext2fs/ext2fs_lookup.c:1.84 src/sys/ufs/ext2fs/ext2fs_lookup.c:1.85 --- src/sys/ufs/ext2fs/ext2fs_lookup.c:1.84 Sat Aug 13 07:40:10 2016 +++ src/sys/ufs/ext2fs/ext2fs_lookup.c Sun Aug 14 11:44:54 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_lookup.c,v 1.84 2016/08/13 07:40:10 christos Exp $ */ +/* $NetBSD: ext2fs_lookup.c,v 1.85 2016/08/14 11:44:54 jdolecek Exp $ */ /* * Modified for NetBSD 1.2E @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.84 2016/08/13 07:40:10 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.85 2016/08/14 11:44:54 jdolecek Exp $"); #include #include @@ -884,8 +884,7 @@ ext2fs_direnter(struct inode *ip, struct newdir.e2d_ino = h2fs32(ip->i_number); newdir.e2d_namlen = cnp->cn_namelen; - if (ip->i_e2fs->e2fs.e2fs_rev > E2FS_REV0 && - (ip->i_e2fs->e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) { + if (EXT2F_HAS_INCOMPAT_FEATURE(ip->i_e2fs, EXT2F_INCOMPAT_FTYPE)) { newdir.e2d_type = inot2ext2dt(IFTODT(ip->i_e2fs_mode)); } else { newdir.e2d_type = 0; @@ -1099,8 +1098,7 @@ ext2fs_dirrewrite(struct inode *dp, cons if (error != 0) return error; ep->e2d_ino = h2fs32(ip->i_number); - if (ip->i_e2fs->e2fs.e2fs_rev > E2FS_REV0 && - (ip->i_e2fs->e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) { + if (EXT2F_HAS_INCOMPAT_FEATURE(dp->i_e2fs, EXT2F_INCOMPAT_FTYPE)) { ep->e2d_type = inot2ext2dt(IFTODT(ip->i_e2fs_mode)); } else { ep->e2d_type = 0; Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.198 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.199 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.198 Sat Aug 13 07:40:10 2016 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Sun Aug 14 11:44:54 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.198 2016/08/13 07:40:10 christos Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.199 2016/08/14 11:44:54 jdolecek Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.198 2016/08/13 07:40:10 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.199 2016/08/14 11:44:54 jdolecek Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -834,8 +834,7 @@ ext2fs_statvfs(struct mount *mp, struct fs->e2fs_itpg; overhead = fs->e2fs.e2fs_first_dblock + fs->e2fs_ncg * overhead_per_group; - if (fs->e2fs.e2fs_rev > E2FS
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Sun Aug 14 11:42:50 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs.h ext2fs_htree.c Log Message: switch ext2fs_htree_has_idx() over to EXT2F_HAS_COMPAT_FEATURE() and remove EXT2F_HAS_COMPAT_FEATURE() - this also fixes it for BE machines, as EXT2F_HAS_COMPAT_FEATURE() did extra byte swap; also remove XXX comment about IN_E3INDEX To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/ufs/ext2fs/ext2fs.h cvs rdiff -u -r1.5 -r1.6 src/sys/ufs/ext2fs/ext2fs_htree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs.h diff -u src/sys/ufs/ext2fs/ext2fs.h:1.44 src/sys/ufs/ext2fs/ext2fs.h:1.45 --- src/sys/ufs/ext2fs/ext2fs.h:1.44 Sun Aug 14 11:40:31 2016 +++ src/sys/ufs/ext2fs/ext2fs.h Sun Aug 14 11:42:50 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.44 2016/08/14 11:40:31 jdolecek Exp $ */ +/* $NetBSD: ext2fs.h,v 1.45 2016/08/14 11:42:50 jdolecek Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -365,8 +365,6 @@ struct m_ext2fs { /* * Feature set definitions */ -#define EXT2_HAS_COMPAT_FEATURE(sb, mask) \ -((sb)->e2fs.e2fs_features_compat & htole32(mask)) #define EXT2F_HAS_COMPAT_FEATURE(fs, feature) \ ((fs)->e2fs.e2fs_rev >= E2FS_REV1 && \ ((fs)->e2fs.e2fs_features_compat & (feature)) != 0) Index: src/sys/ufs/ext2fs/ext2fs_htree.c diff -u src/sys/ufs/ext2fs/ext2fs_htree.c:1.5 src/sys/ufs/ext2fs/ext2fs_htree.c:1.6 --- src/sys/ufs/ext2fs/ext2fs_htree.c:1.5 Sat Aug 13 07:40:10 2016 +++ src/sys/ufs/ext2fs/ext2fs_htree.c Sun Aug 14 11:42:50 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_htree.c,v 1.5 2016/08/13 07:40:10 christos Exp $ */ +/* $NetBSD: ext2fs_htree.c,v 1.6 2016/08/14 11:42:50 jdolecek Exp $ */ /*- * Copyright (c) 2010, 2012 Zheng Liu @@ -29,7 +29,7 @@ * $FreeBSD: head/sys/fs/ext2fs/ext2fs_htree.c 294653 2016-01-24 02:41:49Z pfg $ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.5 2016/08/13 07:40:10 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.6 2016/08/14 11:42:50 jdolecek Exp $"); #include #include @@ -65,8 +65,7 @@ static int ext2fs_htree_find_leaf(struct int ext2fs_htree_has_idx(struct inode *ip) { - /* XXX ip->i_flags should have got checked here for IN_E3INDEX */ - return EXT2_HAS_COMPAT_FEATURE(ip->i_e2fs, EXT2F_COMPAT_DIRHASHINDEX) + return EXT2F_HAS_COMPAT_FEATURE(ip->i_e2fs, EXT2F_COMPAT_DIRHASHINDEX) && (ip->i_din.e2fs_din->e2di_flags & EXT2_INDEX); }
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Sun Aug 14 11:40:31 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs.h ext2fs_xattr.c Log Message: add EXT2F_HAS_ROCOMPAT_FEATURE() macro, and change the current EXT2F_HAS_{COMPAT|INCOMPAT}_FEATURE() to take fs as first parameter To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/ufs/ext2fs/ext2fs.h cvs rdiff -u -r1.2 -r1.3 src/sys/ufs/ext2fs/ext2fs_xattr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs.h diff -u src/sys/ufs/ext2fs/ext2fs.h:1.43 src/sys/ufs/ext2fs/ext2fs.h:1.44 --- src/sys/ufs/ext2fs/ext2fs.h:1.43 Fri Aug 12 20:26:15 2016 +++ src/sys/ufs/ext2fs/ext2fs.h Sun Aug 14 11:40:31 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.43 2016/08/12 20:26:15 macallan Exp $ */ +/* $NetBSD: ext2fs.h,v 1.44 2016/08/14 11:40:31 jdolecek Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -341,14 +341,6 @@ struct m_ext2fs { "\02INCOMPAT_FTYPE" \ "\01INCOMPAT_COMP" -#define EXT2F_HAS_COMPAT_FEATURE(ip, feature) \ - ((ip)->i_e2fs->e2fs.e2fs_rev >= E2FS_REV1 && \ - ((ip)->i_e2fs->e2fs.e2fs_features_compat & (feature)) != 0) - -#define EXT2F_HAS_INCOMPAT_FEATURE(ip, feature) \ - ((ip)->i_e2fs->e2fs.e2fs_rev >= E2FS_REV1 && \ - ((ip)->i_e2fs->e2fs.e2fs_features_incompat & (feature)) != 0) - /* * Features supported in this implementation * @@ -375,6 +367,18 @@ struct m_ext2fs { */ #define EXT2_HAS_COMPAT_FEATURE(sb, mask) \ ((sb)->e2fs.e2fs_features_compat & htole32(mask)) +#define EXT2F_HAS_COMPAT_FEATURE(fs, feature) \ + ((fs)->e2fs.e2fs_rev >= E2FS_REV1 && \ + ((fs)->e2fs.e2fs_features_compat & (feature)) != 0) + +#define EXT2F_HAS_ROCOMPAT_FEATURE(fs, feature) \ + ((fs)->e2fs.e2fs_rev >= E2FS_REV1 && \ + ((fs)->e2fs.e2fs_features_rocompat & (feature)) != 0) + +#define EXT2F_HAS_INCOMPAT_FEATURE(fs, feature) \ + ((fs)->e2fs.e2fs_rev >= E2FS_REV1 && \ + ((fs)->e2fs.e2fs_features_incompat & (feature)) != 0) + /* * Definitions of behavior on errors Index: src/sys/ufs/ext2fs/ext2fs_xattr.c diff -u src/sys/ufs/ext2fs/ext2fs_xattr.c:1.2 src/sys/ufs/ext2fs/ext2fs_xattr.c:1.3 --- src/sys/ufs/ext2fs/ext2fs_xattr.c:1.2 Sat Aug 13 07:40:10 2016 +++ src/sys/ufs/ext2fs/ext2fs_xattr.c Sun Aug 14 11:40:31 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_xattr.c,v 1.2 2016/08/13 07:40:10 christos Exp $ */ +/* $NetBSD: ext2fs_xattr.c,v 1.3 2016/08/14 11:40:31 jdolecek Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_xattr.c,v 1.2 2016/08/13 07:40:10 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_xattr.c,v 1.3 2016/08/14 11:40:31 jdolecek Exp $"); #include #include @@ -158,7 +158,7 @@ ext2fs_get_block_xattr(struct inode *ip, daddr_t xblk; xblk = di->e2di_facl; - if (EXT2F_HAS_INCOMPAT_FEATURE(ip, EXT2F_INCOMPAT_64BIT)) + if (EXT2F_HAS_INCOMPAT_FEATURE(ip->i_e2fs, EXT2F_INCOMPAT_64BIT)) xblk |= (((daddr_t)di->e2di_facl_high) << 32); /* don't do anything if no attr block was allocated */ @@ -348,7 +348,7 @@ ext2fs_list_block_xattr(struct inode *ip daddr_t xblk; xblk = di->e2di_facl; - if (EXT2F_HAS_INCOMPAT_FEATURE(ip, EXT2F_INCOMPAT_64BIT)) + if (EXT2F_HAS_INCOMPAT_FEATURE(ip->i_e2fs, EXT2F_INCOMPAT_64BIT)) xblk |= (((daddr_t)di->e2di_facl_high) << 32); /* don't do anything if no attr block was allocated */ @@ -390,7 +390,7 @@ ext2fs_listextattr(void *v) const char *prefix; size_t listsize = 0; - if (!EXT2F_HAS_COMPAT_FEATURE(ip, EXT2F_COMPAT_EXTATTR)) { + if (!EXT2F_HAS_COMPAT_FEATURE(ip->i_e2fs, EXT2F_COMPAT_EXTATTR)) { /* no EA on the filesystem */ goto out; }
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Sun Aug 14 11:26:35 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_bmap.c Log Message: whitespace cleanup To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/ufs/ext2fs/ext2fs_bmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_bmap.c diff -u src/sys/ufs/ext2fs/ext2fs_bmap.c:1.29 src/sys/ufs/ext2fs/ext2fs_bmap.c:1.30 --- src/sys/ufs/ext2fs/ext2fs_bmap.c:1.29 Sun Aug 14 11:25:36 2016 +++ src/sys/ufs/ext2fs/ext2fs_bmap.c Sun Aug 14 11:26:35 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_bmap.c,v 1.29 2016/08/14 11:25:36 jdolecek Exp $ */ +/* $NetBSD: ext2fs_bmap.c,v 1.30 2016/08/14 11:26:35 jdolecek Exp $ */ /* * Copyright (c) 1989, 1991, 1993 @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_bmap.c,v 1.29 2016/08/14 11:25:36 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_bmap.c,v 1.30 2016/08/14 11:26:35 jdolecek Exp $"); #include #include @@ -106,6 +106,7 @@ ext2fs_bmap(void *v) daddr_t *a_bnp; int *a_runp; } */ *ap = v; + /* * Check for underlying vnode requests and ensure that logical * to physical mapping is requested. @@ -114,16 +115,13 @@ ext2fs_bmap(void *v) *ap->a_vpp = VTOI(ap->a_vp)->i_devvp; if (ap->a_bnp == NULL) return 0; - - + if (VTOI(ap->a_vp)->i_din.e2fs_din->e2di_flags & EXT2_EXTENTS) return ext4_bmapext(ap->a_vp, ap->a_bn, ap->a_bnp, ap->a_runp, NULL); else return ext2fs_bmaparray(ap->a_vp, ap->a_bn, ap->a_bnp, NULL, NULL, ap->a_runp); - - } /*
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Sun Aug 14 11:25:36 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_bmap.c Log Message: check correct inode extents flag - IN_E4EXTENTS is defined as 0x8000, correct flag EXT2_EXTENTS is 0x8 To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/ufs/ext2fs/ext2fs_bmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_bmap.c diff -u src/sys/ufs/ext2fs/ext2fs_bmap.c:1.28 src/sys/ufs/ext2fs/ext2fs_bmap.c:1.29 --- src/sys/ufs/ext2fs/ext2fs_bmap.c:1.28 Sat Aug 13 07:40:10 2016 +++ src/sys/ufs/ext2fs/ext2fs_bmap.c Sun Aug 14 11:25:36 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_bmap.c,v 1.28 2016/08/13 07:40:10 christos Exp $ */ +/* $NetBSD: ext2fs_bmap.c,v 1.29 2016/08/14 11:25:36 jdolecek Exp $ */ /* * Copyright (c) 1989, 1991, 1993 @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_bmap.c,v 1.28 2016/08/13 07:40:10 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_bmap.c,v 1.29 2016/08/14 11:25:36 jdolecek Exp $"); #include #include @@ -116,7 +116,7 @@ ext2fs_bmap(void *v) return 0; - if (VTOI(ap->a_vp)->i_din.e2fs_din->e2di_flags & IN_E4EXTENTS) + if (VTOI(ap->a_vp)->i_din.e2fs_din->e2di_flags & EXT2_EXTENTS) return ext4_bmapext(ap->a_vp, ap->a_bn, ap->a_bnp, ap->a_runp, NULL); else
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Sat Aug 13 07:40:10 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_alloc.c ext2fs_balloc.c ext2fs_bmap.c ext2fs_extents.c ext2fs_hash.c ext2fs_htree.c ext2fs_inode.c ext2fs_lookup.c ext2fs_readwrite.c ext2fs_rename.c ext2fs_subr.c ext2fs_vfsops.c ext2fs_vnops.c ext2fs_xattr.c Log Message: KNF, no functional changes... To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/ufs/ext2fs/ext2fs_alloc.c cvs rdiff -u -r1.40 -r1.41 src/sys/ufs/ext2fs/ext2fs_balloc.c cvs rdiff -u -r1.27 -r1.28 src/sys/ufs/ext2fs/ext2fs_bmap.c cvs rdiff -u -r1.2 -r1.3 src/sys/ufs/ext2fs/ext2fs_extents.c cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/ext2fs/ext2fs_hash.c \ src/sys/ufs/ext2fs/ext2fs_xattr.c cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/ext2fs/ext2fs_htree.c cvs rdiff -u -r1.84 -r1.85 src/sys/ufs/ext2fs/ext2fs_inode.c cvs rdiff -u -r1.83 -r1.84 src/sys/ufs/ext2fs/ext2fs_lookup.c cvs rdiff -u -r1.74 -r1.75 src/sys/ufs/ext2fs/ext2fs_readwrite.c cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/ext2fs/ext2fs_rename.c cvs rdiff -u -r1.32 -r1.33 src/sys/ufs/ext2fs/ext2fs_subr.c cvs rdiff -u -r1.197 -r1.198 src/sys/ufs/ext2fs/ext2fs_vfsops.c cvs rdiff -u -r1.121 -r1.122 src/sys/ufs/ext2fs/ext2fs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_alloc.c diff -u src/sys/ufs/ext2fs/ext2fs_alloc.c:1.47 src/sys/ufs/ext2fs/ext2fs_alloc.c:1.48 --- src/sys/ufs/ext2fs/ext2fs_alloc.c:1.47 Wed Aug 3 17:53:02 2016 +++ src/sys/ufs/ext2fs/ext2fs_alloc.c Sat Aug 13 03:40:10 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_alloc.c,v 1.47 2016/08/03 21:53:02 jdolecek Exp $ */ +/* $NetBSD: ext2fs_alloc.c,v 1.48 2016/08/13 07:40:10 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.47 2016/08/03 21:53:02 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.48 2016/08/13 07:40:10 christos Exp $"); #include #include @@ -138,12 +138,12 @@ ext2fs_alloc(struct inode *ip, daddr_t l ext2fs_setnblock(ip, ext2fs_nblock(ip) + btodb(fs->e2fs_bsize)); ip->i_flag |= IN_CHANGE | IN_UPDATE; *bnp = bno; - return (0); + return 0; } nospace: ext2fs_fserr(fs, kauth_cred_geteuid(cred), "file system full"); uprintf("\n%s: write failed, file system is full\n", fs->e2fs_fsmnt); - return (ENOSPC); + return ENOSPC; } /* @@ -188,7 +188,7 @@ ext2fs_valloc(struct vnode *pvp, int mod error = VFS_VGET(pvp->v_mount, ino, vpp); if (error) { ext2fs_vfree(pvp, ino, mode); - return (error); + return error; } ip = VTOI(*vpp); if (ip->i_e2fs_mode && ip->i_e2fs_nlink != 0) { @@ -206,11 +206,11 @@ ext2fs_valloc(struct vnode *pvp, int mod if (++ext2gennumber < time_second) ext2gennumber = time_second; ip->i_e2fs_gen = ext2gennumber; - return (0); + return 0; noinodes: ext2fs_fserr(fs, kauth_cred_geteuid(cred), "out of inodes"); uprintf("\n%s: create/symlink failed, no inodes free\n", fs->e2fs_fsmnt); - return (ENOSPC); + return ENOSPC; } /* @@ -307,7 +307,7 @@ ext2fs_hashalloc(struct inode *ip, int c */ result = (*allocator)(ip, cg, pref, size); if (result) - return (result); + return result; /* * 2: quadratic rehash */ @@ -317,7 +317,7 @@ ext2fs_hashalloc(struct inode *ip, int c cg -= fs->e2fs_ncg; result = (*allocator)(ip, cg, 0, size); if (result) - return (result); + return result; } /* * 3: brute force search @@ -328,12 +328,12 @@ ext2fs_hashalloc(struct inode *ip, int c for (i = 2; i < fs->e2fs_ncg; i++) { result = (*allocator)(ip, cg, 0, size); if (result) - return (result); + return result; cg++; if (cg == fs->e2fs_ncg) cg = 0; } - return (0); + return 0; } /* @@ -354,12 +354,12 @@ ext2fs_alloccg(struct inode *ip, int cg, fs = ip->i_e2fs; if (fs->e2fs_gd[cg].ext2bgd_nbfree == 0) - return (0); + return 0; error = bread(ip->i_devvp, EXT2_FSBTODB(fs, fs->e2fs_gd[cg].ext2bgd_b_bitmap), (int)fs->e2fs_bsize, B_MODIFY, &bp); if (error) { - return (0); + return 0; } bbp = (char *)bp->b_data; @@ -401,7 +401,7 @@ ext2fs_alloccg(struct inode *ip, int cg, bno = ext2fs_mapsearch(fs, bbp, bpref); if (bno < 0) - return (0); + return 0; gotit: #ifdef DIAGNOSTIC if (isset(bbp, (daddr_t)bno)) { @@ -415,7 +415,7 @@ gotit: fs->e2fs_gd[cg].ext2bgd_nbfree--; fs->e2fs_fmod = 1; bdwrite(bp); - return (cg * fs->e2fs.e2fs_fpg + fs->e2fs.e2fs_first_dblock + bno); + return cg * fs->e2fs.e2fs_fpg + fs->e2fs.e2fs_first_dblock + bno; } /* @@ -440,12 +440,12 @@ ext2fs_nodealloccg(struct inode *ip, int ipref = 0; fs = ip->i_e2fs; if (fs->e2fs_gd[cg].ext2bgd_nifree == 0) - return (0); + return 0; error = bread(ip->i_devvp, EXT2_FSBTODB(fs, fs->e2fs_gd[cg].ext2bgd_i_bitmap), (int)fs->e2fs_bsize, B_MODI
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Sat Aug 13 07:25:29 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_lookup.c Log Message: sync with hrishi's git To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/sys/ufs/ext2fs/ext2fs_lookup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_lookup.c diff -u src/sys/ufs/ext2fs/ext2fs_lookup.c:1.82 src/sys/ufs/ext2fs/ext2fs_lookup.c:1.83 --- src/sys/ufs/ext2fs/ext2fs_lookup.c:1.82 Tue Aug 9 16:18:08 2016 +++ src/sys/ufs/ext2fs/ext2fs_lookup.c Sat Aug 13 03:25:29 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_lookup.c,v 1.82 2016/08/09 20:18:08 christos Exp $ */ +/* $NetBSD: ext2fs_lookup.c,v 1.83 2016/08/13 07:25:29 christos Exp $ */ /* * Modified for NetBSD 1.2E @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.82 2016/08/09 20:18:08 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.83 2016/08/13 07:25:29 christos Exp $"); #include #include @@ -389,7 +389,7 @@ ext2fs_lookup(void *v) * If we got an error or we want to find '.' or '..' entry, * we will fall back to linear search. */ - if (ext2fs_htree_has_idx(dp) && ext2fs_is_dot_entry(cnp)) { + if (!ext2fs_is_dot_entry(cnp) && ext2fs_htree_has_idx(dp)) { numdirpasses = 1; entryoffsetinblock = 0; @@ -707,6 +707,37 @@ found: cache_enter(vdp, *vpp, cnp->cn_nameptr, cnp->cn_namelen, cnp->cn_flags); return 0; } +static void +ext2fs_accumulatespace (struct ext2fs_searchslot *ssp, struct ext2fs_direct *ep, +doff_t *offp) +{ + int size = ep->e2d_reclen; + + if (ep->e2d_ino != 0) + size -= EXT2_DIR_REC_LEN(ep->e2d_namlen); + + if (size <= 0) + return; + + if (size >= ssp->slotneeded) { + ssp->slotstatus = FOUND; + ssp->slotoffset = *offp; + ssp->slotsize = ep->e2d_reclen; + return; + } + + if (ssp->slotstatus != NONE) + return; + + ssp->slotfreespace += size; + if (ssp->slotoffset == -1) + ssp->slotoffset = *offp; + + if (ssp->slotfreespace >= ssp->slotneeded) { + ssp->slotstatus = COMPACT; + ssp->slotsize = *offp + ep->e2d_reclen - ssp->slotoffset; + } +} int ext2fs_search_dirblock(struct inode *ip, void *data, int *foundp, @@ -746,26 +777,8 @@ ext2fs_search_dirblock(struct inode *ip, * in the current block so that we can determine if * compaction is viable. */ - if (ssp->slotstatus != FOUND) { - int size = ep->e2d_reclen; - - if (ep->e2d_ino != 0) -size -= EXT2_DIR_REC_LEN(ep->e2d_namlen); - if (size >= ssp->slotneeded) { -ssp->slotstatus = FOUND; -ssp->slotoffset = *offp; -ssp->slotsize = ep->e2d_reclen; - } else if (size > 0 && ssp->slotstatus == NONE) { -ssp->slotfreespace += size; -if (ssp->slotoffset == -1) - ssp->slotoffset = *offp; -if (ssp->slotfreespace >= ssp->slotneeded) { - ssp->slotstatus = COMPACT; - ssp->slotsize = *offp + ep->e2d_reclen - - ssp->slotoffset; -} - } - } + if (ssp->slotstatus != FOUND) + ext2fs_accumulatespace(ssp, ep, offp); /* * Check for a name match.
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: macallan Date: Fri Aug 12 20:30:15 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_xattr.h Log Message: cast pointers to uintptr_t before comparing them, also ()s now this at least compiles To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/ext2fs/ext2fs_xattr.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_xattr.h diff -u src/sys/ufs/ext2fs/ext2fs_xattr.h:1.1 src/sys/ufs/ext2fs/ext2fs_xattr.h:1.2 --- src/sys/ufs/ext2fs/ext2fs_xattr.h:1.1 Fri Aug 12 19:04:03 2016 +++ src/sys/ufs/ext2fs/ext2fs_xattr.h Fri Aug 12 20:30:15 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_xattr.h,v 1.1 2016/08/12 19:04:03 jdolecek Exp $ */ +/* $NetBSD: ext2fs_xattr.h,v 1.2 2016/08/12 20:30:15 macallan Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ #define _UFS_EXT2FS_EXT2FS_XATTR_H_ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_xattr.h,v 1.1 2016/08/12 19:04:03 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_xattr.h,v 1.2 2016/08/12 20:30:15 macallan Exp $"); #ifdef _KERNEL @@ -79,7 +79,7 @@ struct ext2fs_xattr_entry { * doesn't overflow past end. */ #define EXT2FS_XATTR_IS_LAST_ENTRY(entry, end) \ - *((uint32_t *)(entry)) == 0 || EXT2FS_XATTR_NEXT(entry) > end + (*((uint32_t *)(entry)) == 0 || (uintptr_t)EXT2FS_XATTR_NEXT(entry) > (uintptr_t)end) /* * Each ext2fs_xattr_entry starts on next 4-byte boundary, pad if necessary.
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: macallan Date: Fri Aug 12 20:26:15 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs.h Log Message: sprinkle ()s in macros with comparisons, shuts up compiler warnings To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/ufs/ext2fs/ext2fs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs.h diff -u src/sys/ufs/ext2fs/ext2fs.h:1.42 src/sys/ufs/ext2fs/ext2fs.h:1.43 --- src/sys/ufs/ext2fs/ext2fs.h:1.42 Fri Aug 12 19:04:03 2016 +++ src/sys/ufs/ext2fs/ext2fs.h Fri Aug 12 20:26:15 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.42 2016/08/12 19:04:03 jdolecek Exp $ */ +/* $NetBSD: ext2fs.h,v 1.43 2016/08/12 20:26:15 macallan Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -342,12 +342,12 @@ struct m_ext2fs { "\01INCOMPAT_COMP" #define EXT2F_HAS_COMPAT_FEATURE(ip, feature) \ - (ip)->i_e2fs->e2fs.e2fs_rev >= E2FS_REV1 && \ - ((ip)->i_e2fs->e2fs.e2fs_features_compat & (feature)) != 0 + ((ip)->i_e2fs->e2fs.e2fs_rev >= E2FS_REV1 && \ + ((ip)->i_e2fs->e2fs.e2fs_features_compat & (feature)) != 0) #define EXT2F_HAS_INCOMPAT_FEATURE(ip, feature) \ - (ip)->i_e2fs->e2fs.e2fs_rev >= E2FS_REV1 && \ - ((ip)->i_e2fs->e2fs.e2fs_features_incompat & (feature)) != 0 + ((ip)->i_e2fs->e2fs.e2fs_rev >= E2FS_REV1 && \ + ((ip)->i_e2fs->e2fs.e2fs_features_incompat & (feature)) != 0) /* * Features supported in this implementation
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: kre Date: Tue Aug 9 21:08:02 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_extern.h ext2fs_htree.c Log Message: Undo revert now Christos has added the missing glue... To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/ufs/ext2fs/ext2fs_extern.h cvs rdiff -u -r1.3 -r1.4 src/sys/ufs/ext2fs/ext2fs_htree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_extern.h diff -u src/sys/ufs/ext2fs/ext2fs_extern.h:1.51 src/sys/ufs/ext2fs/ext2fs_extern.h:1.52 --- src/sys/ufs/ext2fs/ext2fs_extern.h:1.51 Tue Aug 9 20:03:05 2016 +++ src/sys/ufs/ext2fs/ext2fs_extern.h Tue Aug 9 21:08:02 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_extern.h,v 1.51 2016/08/09 20:03:05 kre Exp $ */ +/* $NetBSD: ext2fs_extern.h,v 1.52 2016/08/09 21:08:02 kre Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -79,6 +79,7 @@ struct mbuf; struct componentname; struct ufs_lookup_results; struct ext2fs_searchslot; +struct ext2fs_direct; extern struct pool ext2fs_inode_pool; /* memory pool for inodes */ extern struct pool ext2fs_dinode_pool; /* memory pool for dinodes */ @@ -132,6 +133,8 @@ int ext2fs_dirremove(struct vnode *, con int ext2fs_dirrewrite(struct inode *, const struct ufs_lookup_results *, struct inode *, struct componentname *); int ext2fs_dirempty(struct inode *, ino_t, kauth_cred_t); +int ext2fs_add_entry(struct vnode *, struct ext2fs_direct *, +const struct ufs_lookup_results *); /* ext2fs_subr.c */ int ext2fs_blkatoff(struct vnode *, off_t, char **, struct buf **); @@ -184,6 +187,10 @@ int ext2fs_htree_hash(const char *, int, int ext2fs_htree_has_idx(struct inode *); int ext2fs_htree_lookup(struct inode *, const char *, int, struct buf **, int *, doff_t *, doff_t *, doff_t *, struct ext2fs_searchslot *); +int ext2fs_htree_create_index(struct vnode *, struct componentname *, +struct ext2fs_direct *); +int ext2fs_htree_add_entry(struct vnode *, struct ext2fs_direct *, +struct componentname *); __END_DECLS Index: src/sys/ufs/ext2fs/ext2fs_htree.c diff -u src/sys/ufs/ext2fs/ext2fs_htree.c:1.3 src/sys/ufs/ext2fs/ext2fs_htree.c:1.4 --- src/sys/ufs/ext2fs/ext2fs_htree.c:1.3 Tue Aug 9 20:03:05 2016 +++ src/sys/ufs/ext2fs/ext2fs_htree.c Tue Aug 9 21:08:02 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_htree.c,v 1.3 2016/08/09 20:03:05 kre Exp $ */ +/* $NetBSD: ext2fs_htree.c,v 1.4 2016/08/09 21:08:02 kre Exp $ */ /*- * Copyright (c) 2010, 2012 Zheng Liu @@ -26,10 +26,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: head/sys/fs/ext2fs/ext2_htree.c 294653 2016-01-24 02:41:49Z pfg $ + * $FreeBSD: head/sys/fs/ext2fs/ext2fs_htree.c 294653 2016-01-24 02:41:49Z pfg $ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.3 2016/08/09 20:03:05 kre Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.4 2016/08/09 21:08:02 kre Exp $"); #include #include @@ -46,7 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: ext2fs_htree #include #include #include - +#include #include #include @@ -59,9 +59,13 @@ __KERNEL_RCSID(0, "$NetBSD: ext2fs_htree #include #include +static int ext2fs_htree_find_leaf(struct inode *, const char *, int , +uint32_t *, uint8_t *, struct ext2fs_htree_lookup_info *); + int ext2fs_htree_has_idx(struct inode *ip) { + /* XXX ip->i_flags should have got checked here for IN_E3INDEX */ return EXT2_HAS_COMPAT_FEATURE(ip->i_e2fs, EXT2F_COMPAT_DIRHASHINDEX) && (ip->i_din.e2fs_din->e2di_flags & EXT2_INDEX); } @@ -72,7 +76,6 @@ ext2fs_htree_get_block(struct ext2fs_htr return ep->h_blk & 0x00FF; } - static void ext2fs_htree_release(struct ext2fs_htree_lookup_info *info) { @@ -109,6 +112,555 @@ ext2fs_htree_get_hash(struct ext2fs_htre return ep->h_hash; } + +static void +ext2fs_htree_set_block(struct ext2fs_htree_entry *ep, uint32_t blk) +{ + ep->h_blk = blk; +} + +static void +ext2fs_htree_set_count(struct ext2fs_htree_entry *ep, uint16_t cnt) +{ + ((struct ext2fs_htree_count *)(ep))->h_entries_num = cnt; +} + +static void +ext2fs_htree_set_hash(struct ext2fs_htree_entry *ep, uint32_t hash) +{ + ep->h_hash = hash; +} + +static void +ext2fs_htree_set_limit(struct ext2fs_htree_entry *ep, uint16_t limit) +{ + ((struct ext2fs_htree_count *)(ep))->h_entries_max = limit; +} + +static uint32_t +ext2fs_htree_node_limit(struct inode *ip) +{ + struct m_ext2fs *fs; + uint32_t space; + + fs = ip->i_e2fs; + space = fs->e2fs_bsize - EXT2_DIR_REC_LEN(0); + + return space / sizeof(struct ext2fs_htree_entry); +} + +static int +ext2fs_htree_append_block(struct vnode *vp, char *data, +struct componentname *cnp, uint32_t blksize) +{ + struct iovec aiov; + struct uio auio; + struct inode *dp = VTOI(vp); + uint64_t cursize, newsize; + int error; + + cursize = roundup(dp->i_size, blksize); + n
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Tue Aug 9 20:18:08 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_lookup.c Log Message: merge missing function. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/sys/ufs/ext2fs/ext2fs_lookup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_lookup.c diff -u src/sys/ufs/ext2fs/ext2fs_lookup.c:1.81 src/sys/ufs/ext2fs/ext2fs_lookup.c:1.82 --- src/sys/ufs/ext2fs/ext2fs_lookup.c:1.81 Sat Aug 6 17:39:48 2016 +++ src/sys/ufs/ext2fs/ext2fs_lookup.c Tue Aug 9 16:18:08 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_lookup.c,v 1.81 2016/08/06 21:39:48 jdolecek Exp $ */ +/* $NetBSD: ext2fs_lookup.c,v 1.82 2016/08/09 20:18:08 christos Exp $ */ /* * Modified for NetBSD 1.2E @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.81 2016/08/06 21:39:48 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.82 2016/08/09 20:18:08 christos Exp $"); #include #include @@ -816,33 +816,35 @@ ext2fs_dirbadentry(struct vnode *dp, str struct ufsmount *ump = VFSTOUFS(dp->v_mount); int dirblksiz = ump->um_dirblksiz; - const char *error_msg = NULL; - int reclen = fs2h16(de->e2d_reclen); - int namlen = de->e2d_namlen; - - if (reclen < EXT2FS_DIRSIZ(1)) /* e2d_namlen = 1 */ - error_msg = "rec_len is smaller than minimal"; - else if (reclen % 4 != 0) - error_msg = "rec_len % 4 != 0"; - else if (namlen > EXT2FS_MAXNAMLEN) - error_msg = "namlen > EXT2FS_MAXNAMLEN"; - else if (reclen < EXT2FS_DIRSIZ(namlen)) - error_msg = "reclen is too small for name_len"; - else if (entryoffsetinblock + reclen > dirblksiz) - error_msg = "directory entry across blocks"; - else if (fs2h32(de->e2d_ino) > - VTOI(dp)->i_e2fs->e2fs.e2fs_icount) - error_msg = "inode out of bounds"; - - if (error_msg != NULL) { - printf( "bad directory entry: %s\n" - "offset=%d, inode=%lu, rec_len=%d, name_len=%d \n", - error_msg, entryoffsetinblock, - (unsigned long) fs2h32(de->e2d_ino), - reclen, namlen); - panic("ext2fs_dirbadentry"); - } - return error_msg == NULL ? 0 : 1; + const char *error_msg = NULL; + int reclen = fs2h16(de->e2d_reclen); + int namlen = de->e2d_namlen; + + if (reclen < EXT2FS_DIRSIZ(1)) /* e2d_namlen = 1 */ + error_msg = "rec_len is smaller than minimal"; +#if 0 + else if (reclen % 4 != 0) + error_msg = "rec_len % 4 != 0"; +#endif + else if (namlen > EXT2FS_MAXNAMLEN) + error_msg = "namlen > EXT2FS_MAXNAMLEN"; + else if (reclen < EXT2FS_DIRSIZ(namlen)) + error_msg = "reclen is too small for name_len"; + else if (entryoffsetinblock + reclen > dirblksiz) + error_msg = "directory entry across blocks"; + else if (fs2h32(de->e2d_ino) > + VTOI(dp)->i_e2fs->e2fs.e2fs_icount) + error_msg = "inode out of bounds"; + + if (error_msg != NULL) { + printf( "bad directory entry: %s\n" + "offset=%d, inode=%lu, rec_len=%d, name_len=%d \n", + error_msg, entryoffsetinblock, + (unsigned long) fs2h32(de->e2d_ino), + reclen, namlen); + panic("ext2fs_dirbadentry"); + } + return error_msg == NULL ? 0 : 1; } /* @@ -855,18 +857,13 @@ ext2fs_dirbadentry(struct vnode *dp, str */ int ext2fs_direnter(struct inode *ip, struct vnode *dvp, - const struct ufs_lookup_results *ulr, - struct componentname *cnp) +const struct ufs_lookup_results *ulr, struct componentname *cnp) { - struct ext2fs_direct *ep, *nep; struct inode *dp; - struct buf *bp; struct ext2fs_direct newdir; struct iovec aiov; struct uio auio; - u_int dsize; - int error, loc, newentrysize, spacefree; - char *dirbuf; + int error, newentrysize; struct ufsmount *ump = VFSTOUFS(dvp->v_mount); int dirblksiz = ump->um_dirblksiz; @@ -882,6 +879,20 @@ ext2fs_direnter(struct inode *ip, struct } memcpy(newdir.e2d_name, cnp->cn_nameptr, (unsigned)cnp->cn_namelen + 1); newentrysize = EXT2FS_DIRSIZ(cnp->cn_namelen); + + if (ext2fs_htree_has_idx(dp)) { + error = ext2fs_htree_add_entry(dvp, &newdir, cnp); + if (error) { + dp->i_e2fs_flags&= ~EXT2_INDEX; + dp->i_flag |= IN_CHANGE | IN_UPDATE; + } + return error; + } + + /* + * TODO check if Htree index is not created for the directory then + * create one if directory entries get overflew the first dir-block + */ if (ulr->ulr_count == 0) { /* * If ulr_count is 0, then namei could find no @@ -912,9 +923,35 @@ ext2fs_direnter(struct inode *ip, struct dp->i_flag |= IN_CHANGE; uvm_vnp_setsize(dvp, ext2fs_size(dp)); } - return (error); + return error; } + error = ext2fs_add_entry(dvp, &newdir,ulr); + + if (!error && ulr->ulr_endoff && ulr->ulr_endoff < ext2fs_size(dp)) + error = ext2fs_truncate(dvp, (off_t)ulr->ulr_endoff, IO_SYNC, + cnp->cn_cred); + return error; +} + +/* + * Insert an entry into the directory block. + * Compact the contents. + */ + +int +ext2fs_add_e
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: kre Date: Tue Aug 9 20:03:05 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_extern.h ext2fs_htree.c Log Message: Revert previous. This work isn't complete enough to include yet, and the build of current really does need to go back to a working state. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/ufs/ext2fs/ext2fs_extern.h cvs rdiff -u -r1.2 -r1.3 src/sys/ufs/ext2fs/ext2fs_htree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_extern.h diff -u src/sys/ufs/ext2fs/ext2fs_extern.h:1.50 src/sys/ufs/ext2fs/ext2fs_extern.h:1.51 --- src/sys/ufs/ext2fs/ext2fs_extern.h:1.50 Tue Aug 9 07:15:35 2016 +++ src/sys/ufs/ext2fs/ext2fs_extern.h Tue Aug 9 20:03:05 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_extern.h,v 1.50 2016/08/09 07:15:35 christos Exp $ */ +/* $NetBSD: ext2fs_extern.h,v 1.51 2016/08/09 20:03:05 kre Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -79,7 +79,6 @@ struct mbuf; struct componentname; struct ufs_lookup_results; struct ext2fs_searchslot; -struct ext2fs_direct; extern struct pool ext2fs_inode_pool; /* memory pool for inodes */ extern struct pool ext2fs_dinode_pool; /* memory pool for dinodes */ @@ -133,8 +132,6 @@ int ext2fs_dirremove(struct vnode *, con int ext2fs_dirrewrite(struct inode *, const struct ufs_lookup_results *, struct inode *, struct componentname *); int ext2fs_dirempty(struct inode *, ino_t, kauth_cred_t); -int ext2fs_add_entry(struct vnode *, struct ext2fs_direct *, -const struct ufs_lookup_results *); /* ext2fs_subr.c */ int ext2fs_blkatoff(struct vnode *, off_t, char **, struct buf **); @@ -187,10 +184,6 @@ int ext2fs_htree_hash(const char *, int, int ext2fs_htree_has_idx(struct inode *); int ext2fs_htree_lookup(struct inode *, const char *, int, struct buf **, int *, doff_t *, doff_t *, doff_t *, struct ext2fs_searchslot *); -int ext2fs_htree_create_index(struct vnode *, struct componentname *, -struct ext2fs_direct *); -int ext2fs_htree_add_entry(struct vnode *, struct ext2fs_direct *, -struct componentname *); __END_DECLS Index: src/sys/ufs/ext2fs/ext2fs_htree.c diff -u src/sys/ufs/ext2fs/ext2fs_htree.c:1.2 src/sys/ufs/ext2fs/ext2fs_htree.c:1.3 --- src/sys/ufs/ext2fs/ext2fs_htree.c:1.2 Tue Aug 9 07:15:35 2016 +++ src/sys/ufs/ext2fs/ext2fs_htree.c Tue Aug 9 20:03:05 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_htree.c,v 1.2 2016/08/09 07:15:35 christos Exp $ */ +/* $NetBSD: ext2fs_htree.c,v 1.3 2016/08/09 20:03:05 kre Exp $ */ /*- * Copyright (c) 2010, 2012 Zheng Liu @@ -26,10 +26,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: head/sys/fs/ext2fs/ext2fs_htree.c 294653 2016-01-24 02:41:49Z pfg $ + * $FreeBSD: head/sys/fs/ext2fs/ext2_htree.c 294653 2016-01-24 02:41:49Z pfg $ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.2 2016/08/09 07:15:35 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.3 2016/08/09 20:03:05 kre Exp $"); #include #include @@ -46,7 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: ext2fs_htree #include #include #include -#include + #include #include @@ -59,13 +59,9 @@ __KERNEL_RCSID(0, "$NetBSD: ext2fs_htree #include #include -static int ext2fs_htree_find_leaf(struct inode *, const char *, int , -uint32_t *, uint8_t *, struct ext2fs_htree_lookup_info *); - int ext2fs_htree_has_idx(struct inode *ip) { - /* XXX ip->i_flags should have got checked here for IN_E3INDEX */ return EXT2_HAS_COMPAT_FEATURE(ip->i_e2fs, EXT2F_COMPAT_DIRHASHINDEX) && (ip->i_din.e2fs_din->e2di_flags & EXT2_INDEX); } @@ -76,6 +72,7 @@ ext2fs_htree_get_block(struct ext2fs_htr return ep->h_blk & 0x00FF; } + static void ext2fs_htree_release(struct ext2fs_htree_lookup_info *info) { @@ -112,555 +109,6 @@ ext2fs_htree_get_hash(struct ext2fs_htre return ep->h_hash; } - -static void -ext2fs_htree_set_block(struct ext2fs_htree_entry *ep, uint32_t blk) -{ - ep->h_blk = blk; -} - -static void -ext2fs_htree_set_count(struct ext2fs_htree_entry *ep, uint16_t cnt) -{ - ((struct ext2fs_htree_count *)(ep))->h_entries_num = cnt; -} - -static void -ext2fs_htree_set_hash(struct ext2fs_htree_entry *ep, uint32_t hash) -{ - ep->h_hash = hash; -} - -static void -ext2fs_htree_set_limit(struct ext2fs_htree_entry *ep, uint16_t limit) -{ - ((struct ext2fs_htree_count *)(ep))->h_entries_max = limit; -} - -static uint32_t -ext2fs_htree_node_limit(struct inode *ip) -{ - struct m_ext2fs *fs; - uint32_t space; - - fs = ip->i_e2fs; - space = fs->e2fs_bsize - EXT2_DIR_REC_LEN(0); - - return space / sizeof(struct ext2fs_htree_entry); -} - -static int -ext2fs_htree_append_block(struct vnode *vp, char *data, -struct componentname *cnp, uint32_t blksize) -{ - struct iovec aiov; - struct uio auio; - struct inode *dp =
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: kre Date: Tue Aug 9 13:18:50 UTC 2016 Modified Files: src/sys/ufs/ext2fs: Makefile ext2fs_extents.h Log Message: Revert previous - which itself (incorrectly) reverted the previous changes, breaking the build. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/ufs/ext2fs/Makefile \ src/sys/ufs/ext2fs/ext2fs_extents.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/Makefile diff -u src/sys/ufs/ext2fs/Makefile:1.3 src/sys/ufs/ext2fs/Makefile:1.4 --- src/sys/ufs/ext2fs/Makefile:1.3 Tue Aug 9 07:15:35 2016 +++ src/sys/ufs/ext2fs/Makefile Tue Aug 9 13:18:50 2016 @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.3 2016/08/09 07:15:35 christos Exp $ +# $NetBSD: Makefile,v 1.4 2016/08/09 13:18:50 kre Exp $ INCSDIR= /usr/include/ufs/ext2fs -INCS= ext2fs.h ext2fs_dinode.h ext2fs_dir.h ext2fs_extern.h +INCS= ext2fs.h ext2fs_dinode.h ext2fs_dir.h ext2fs_extents.h ext2fs_extern.h .include Index: src/sys/ufs/ext2fs/ext2fs_extents.h diff -u src/sys/ufs/ext2fs/ext2fs_extents.h:1.3 src/sys/ufs/ext2fs/ext2fs_extents.h:1.4 --- src/sys/ufs/ext2fs/ext2fs_extents.h:1.3 Tue Aug 9 07:15:35 2016 +++ src/sys/ufs/ext2fs/ext2fs_extents.h Tue Aug 9 13:18:50 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_extents.h,v 1.3 2016/08/09 07:15:35 christos Exp $ */ +/* $NetBSD: ext2fs_extents.h,v 1.4 2016/08/09 13:18:50 kre Exp $ */ /*- * Copyright (c) 2012, 2010 Zheng Liu @@ -32,6 +32,10 @@ #define _UFS_EXT2FS_EXT2FS_EXTENTS_H_ #include +#ifndef _KERNEL +#include +#endif + #include #define EXT4_EXT_MAGIC 0xf30a
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Tue Aug 9 07:15:35 UTC 2016 Modified Files: src/sys/ufs/ext2fs: Makefile ext2fs_extents.h ext2fs_extern.h ext2fs_htree.c Log Message: More htree writing support (Hrishikesh Goyal GSoC 2016) To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/ufs/ext2fs/Makefile \ src/sys/ufs/ext2fs/ext2fs_extents.h cvs rdiff -u -r1.49 -r1.50 src/sys/ufs/ext2fs/ext2fs_extern.h cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/ext2fs/ext2fs_htree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/Makefile diff -u src/sys/ufs/ext2fs/Makefile:1.2 src/sys/ufs/ext2fs/Makefile:1.3 --- src/sys/ufs/ext2fs/Makefile:1.2 Fri Jun 3 17:55:50 2016 +++ src/sys/ufs/ext2fs/Makefile Tue Aug 9 03:15:35 2016 @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.2 2016/06/03 21:55:50 joerg Exp $ +# $NetBSD: Makefile,v 1.3 2016/08/09 07:15:35 christos Exp $ INCSDIR= /usr/include/ufs/ext2fs -INCS= ext2fs.h ext2fs_dinode.h ext2fs_dir.h ext2fs_extents.h ext2fs_extern.h +INCS= ext2fs.h ext2fs_dinode.h ext2fs_dir.h ext2fs_extern.h .include Index: src/sys/ufs/ext2fs/ext2fs_extents.h diff -u src/sys/ufs/ext2fs/ext2fs_extents.h:1.2 src/sys/ufs/ext2fs/ext2fs_extents.h:1.3 --- src/sys/ufs/ext2fs/ext2fs_extents.h:1.2 Fri Jun 10 02:30:58 2016 +++ src/sys/ufs/ext2fs/ext2fs_extents.h Tue Aug 9 03:15:35 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_extents.h,v 1.2 2016/06/10 06:30:58 dholland Exp $ */ +/* $NetBSD: ext2fs_extents.h,v 1.3 2016/08/09 07:15:35 christos Exp $ */ /*- * Copyright (c) 2012, 2010 Zheng Liu @@ -32,10 +32,6 @@ #define _UFS_EXT2FS_EXT2FS_EXTENTS_H_ #include -#ifndef _KERNEL -#include -#endif - #include #define EXT4_EXT_MAGIC 0xf30a Index: src/sys/ufs/ext2fs/ext2fs_extern.h diff -u src/sys/ufs/ext2fs/ext2fs_extern.h:1.49 src/sys/ufs/ext2fs/ext2fs_extern.h:1.50 --- src/sys/ufs/ext2fs/ext2fs_extern.h:1.49 Fri Jun 24 13:21:30 2016 +++ src/sys/ufs/ext2fs/ext2fs_extern.h Tue Aug 9 03:15:35 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_extern.h,v 1.49 2016/06/24 17:21:30 christos Exp $ */ +/* $NetBSD: ext2fs_extern.h,v 1.50 2016/08/09 07:15:35 christos Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -79,6 +79,7 @@ struct mbuf; struct componentname; struct ufs_lookup_results; struct ext2fs_searchslot; +struct ext2fs_direct; extern struct pool ext2fs_inode_pool; /* memory pool for inodes */ extern struct pool ext2fs_dinode_pool; /* memory pool for dinodes */ @@ -132,6 +133,8 @@ int ext2fs_dirremove(struct vnode *, con int ext2fs_dirrewrite(struct inode *, const struct ufs_lookup_results *, struct inode *, struct componentname *); int ext2fs_dirempty(struct inode *, ino_t, kauth_cred_t); +int ext2fs_add_entry(struct vnode *, struct ext2fs_direct *, +const struct ufs_lookup_results *); /* ext2fs_subr.c */ int ext2fs_blkatoff(struct vnode *, off_t, char **, struct buf **); @@ -184,6 +187,10 @@ int ext2fs_htree_hash(const char *, int, int ext2fs_htree_has_idx(struct inode *); int ext2fs_htree_lookup(struct inode *, const char *, int, struct buf **, int *, doff_t *, doff_t *, doff_t *, struct ext2fs_searchslot *); +int ext2fs_htree_create_index(struct vnode *, struct componentname *, +struct ext2fs_direct *); +int ext2fs_htree_add_entry(struct vnode *, struct ext2fs_direct *, +struct componentname *); __END_DECLS Index: src/sys/ufs/ext2fs/ext2fs_htree.c diff -u src/sys/ufs/ext2fs/ext2fs_htree.c:1.1 src/sys/ufs/ext2fs/ext2fs_htree.c:1.2 --- src/sys/ufs/ext2fs/ext2fs_htree.c:1.1 Fri Jun 24 13:21:30 2016 +++ src/sys/ufs/ext2fs/ext2fs_htree.c Tue Aug 9 03:15:35 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_htree.c,v 1.1 2016/06/24 17:21:30 christos Exp $ */ +/* $NetBSD: ext2fs_htree.c,v 1.2 2016/08/09 07:15:35 christos Exp $ */ /*- * Copyright (c) 2010, 2012 Zheng Liu @@ -26,10 +26,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: head/sys/fs/ext2fs/ext2_htree.c 294653 2016-01-24 02:41:49Z pfg $ + * $FreeBSD: head/sys/fs/ext2fs/ext2fs_htree.c 294653 2016-01-24 02:41:49Z pfg $ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.1 2016/06/24 17:21:30 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.2 2016/08/09 07:15:35 christos Exp $"); #include #include @@ -46,7 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: ext2fs_htree #include #include #include - +#include #include #include @@ -59,9 +59,13 @@ __KERNEL_RCSID(0, "$NetBSD: ext2fs_htree #include #include +static int ext2fs_htree_find_leaf(struct inode *, const char *, int , +uint32_t *, uint8_t *, struct ext2fs_htree_lookup_info *); + int ext2fs_htree_has_idx(struct inode *ip) { + /* XXX ip->i_flags should have got checked here for IN_E3INDEX */ return EXT2_HAS_COMPAT_FEATURE(ip->i_e2fs, EXT2F_COMPAT_DIRHASHINDEX) && (ip
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Tue Aug 9 06:40:25 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_extents.c Log Message: KNF To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/ext2fs/ext2fs_extents.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_extents.c diff -u src/sys/ufs/ext2fs/ext2fs_extents.c:1.1 src/sys/ufs/ext2fs/ext2fs_extents.c:1.2 --- src/sys/ufs/ext2fs/ext2fs_extents.c:1.1 Fri Jun 3 11:35:48 2016 +++ src/sys/ufs/ext2fs/ext2fs_extents.c Tue Aug 9 02:40:24 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_extents.c,v 1.1 2016/06/03 15:35:48 christos Exp $ */ +/* $NetBSD: ext2fs_extents.c,v 1.2 2016/08/09 06:40:24 christos Exp $ */ /*- * Copyright (c) 2010 Zheng Liu @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_extents.c,v 1.1 2016/06/03 15:35:48 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_extents.c,v 1.2 2016/08/09 06:40:24 christos Exp $"); #include #include @@ -80,13 +80,13 @@ ext4_ext_binsearch_index(struct inode *i path->ep_sparse_ext.e_start_hi = 0; path->ep_sparse_ext.e_start_lo = 0; path->ep_is_sparse = true; - return (true); + return true; } path->ep_index = l - 1; *first_lbn = path->ep_index->ei_blk; if (path->ep_index < last) *last_lbn = l->ei_blk - 1; - return (false); + return false; } static void @@ -156,7 +156,7 @@ ext4_ext_in_cache(struct inode *ip, dadd ep->e_len = ecp->ec_len; ret = ecp->ec_type; } - return (ret); + return ret; } /* @@ -189,7 +189,7 @@ ext4_ext_find_extent(struct m_ext2fs *fs ehp = (struct ext4_extent_header *)ip->i_din.e2fs_din->e2di_blocks; if (ehp->eh_magic != EXT4_EXT_MAGIC) - return (NULL); + return NULL; path->ep_header = ehp; @@ -201,7 +201,7 @@ ext4_ext_find_extent(struct m_ext2fs *fs path->ep_ext = NULL; if (ext4_ext_binsearch_index(ip, path, lbn, &first_lbn, &last_lbn)) { - return (path); + return path; } nblk = (daddr_t)path->ep_index->ei_leaf_hi << 32 | @@ -216,7 +216,7 @@ ext4_ext_find_extent(struct m_ext2fs *fs if (error) { brelse(path->ep_bp, 0); path->ep_bp = NULL; - return (NULL); + return NULL; } ehp = (struct ext4_extent_header *)path->ep_bp->b_data; path->ep_header = ehp; @@ -228,5 +228,5 @@ ext4_ext_find_extent(struct m_ext2fs *fs path->ep_is_sparse = false; ext4_ext_binsearch(ip, path, lbn, first_lbn, last_lbn); - return (path); + return path; }
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: kre Date: Sun Aug 7 01:47:11 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_dir.h Log Message: If using constants from dirent.h it ought to be included. Hopefully fixes i386 build. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/ufs/ext2fs/ext2fs_dir.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_dir.h diff -u src/sys/ufs/ext2fs/ext2fs_dir.h:1.21 src/sys/ufs/ext2fs/ext2fs_dir.h:1.22 --- src/sys/ufs/ext2fs/ext2fs_dir.h:1.21 Sat Aug 6 21:39:48 2016 +++ src/sys/ufs/ext2fs/ext2fs_dir.h Sun Aug 7 01:47:11 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_dir.h,v 1.21 2016/08/06 21:39:48 jdolecek Exp $ */ +/* $NetBSD: ext2fs_dir.h,v 1.22 2016/08/07 01:47:11 kre Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -67,6 +67,7 @@ #ifndef _UFS_EXT2FS_EXT2FS_DIR_H_ #define _UFS_EXT2FS_EXT2FS_DIR_H_ +#include #include /*
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Sat Aug 6 21:39:48 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_dir.h ext2fs_lookup.c ext2fs_rename.c Log Message: actually pass the d_type from the on-disk directory entry to the lookup results To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/ufs/ext2fs/ext2fs_dir.h cvs rdiff -u -r1.80 -r1.81 src/sys/ufs/ext2fs/ext2fs_lookup.c cvs rdiff -u -r1.8 -r1.9 src/sys/ufs/ext2fs/ext2fs_rename.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_dir.h diff -u src/sys/ufs/ext2fs/ext2fs_dir.h:1.20 src/sys/ufs/ext2fs/ext2fs_dir.h:1.21 --- src/sys/ufs/ext2fs/ext2fs_dir.h:1.20 Fri Jun 24 17:21:30 2016 +++ src/sys/ufs/ext2fs/ext2fs_dir.h Sat Aug 6 21:39:48 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_dir.h,v 1.20 2016/06/24 17:21:30 christos Exp $ */ +/* $NetBSD: ext2fs_dir.h,v 1.21 2016/08/06 21:39:48 jdolecek Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -167,6 +167,30 @@ inot2ext2dt(uint16_t type) } } +static __inline uint8_t ext2dt2dt(uint8_t) __unused; +static __inline uint8_t +ext2dt2dt(uint8_t type) +{ + switch (type) { + case EXT2_FT_REG_FILE: + return DT_FIFO; + case EXT2_FT_DIR: + return DT_DIR; + case EXT2_FT_CHRDEV: + return DT_CHR; + case EXT2_FT_BLKDEV: + return DT_BLK; + case EXT2_FT_FIFO: + return DT_FIFO; + case EXT2_FT_SOCK: + return DT_SOCK; + case EXT2_FT_SYMLINK: + return DT_LNK; + default: + return DT_UNKNOWN; + } +} + /* * The EXT2FS_DIRSIZ macro gives the minimum record length which will hold * the directory entryfor a name len "len" (without the terminating null byte). Index: src/sys/ufs/ext2fs/ext2fs_lookup.c diff -u src/sys/ufs/ext2fs/ext2fs_lookup.c:1.80 src/sys/ufs/ext2fs/ext2fs_lookup.c:1.81 --- src/sys/ufs/ext2fs/ext2fs_lookup.c:1.80 Fri Jun 24 17:21:30 2016 +++ src/sys/ufs/ext2fs/ext2fs_lookup.c Sat Aug 6 21:39:48 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_lookup.c,v 1.80 2016/06/24 17:21:30 christos Exp $ */ +/* $NetBSD: ext2fs_lookup.c,v 1.81 2016/08/06 21:39:48 jdolecek Exp $ */ /* * Modified for NetBSD 1.2E @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.80 2016/06/24 17:21:30 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.81 2016/08/06 21:39:48 jdolecek Exp $"); #include #include @@ -99,7 +99,8 @@ ext2fs_dirconv2ffs(struct ext2fs_direct ffsdir->d_fileno = fs2h32(e2dir->e2d_ino); ffsdir->d_namlen = e2dir->e2d_namlen; - ffsdir->d_type = DT_UNKNOWN; /* don't know more here */ + ffsdir->d_type = ext2dt2dt(e2dir->e2d_type); + #ifdef DIAGNOSTIC #if MAXNAMLEN < E2FS_MAXNAMLEN /* Index: src/sys/ufs/ext2fs/ext2fs_rename.c diff -u src/sys/ufs/ext2fs/ext2fs_rename.c:1.8 src/sys/ufs/ext2fs/ext2fs_rename.c:1.9 --- src/sys/ufs/ext2fs/ext2fs_rename.c:1.8 Fri Mar 27 17:27:56 2015 +++ src/sys/ufs/ext2fs/ext2fs_rename.c Sat Aug 6 21:39:48 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_rename.c,v 1.8 2015/03/27 17:27:56 riastradh Exp $ */ +/* $NetBSD: ext2fs_rename.c,v 1.9 2016/08/06 21:39:48 jdolecek Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_rename.c,v 1.8 2015/03/27 17:27:56 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_rename.c,v 1.9 2016/08/06 21:39:48 jdolecek Exp $"); #include #include @@ -44,6 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: ext2fs_renam #include #include #include +#include #include
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Sat Aug 6 09:29:28 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_dinode.h Log Message: some more inode flags To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/ufs/ext2fs/ext2fs_dinode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_dinode.h diff -u src/sys/ufs/ext2fs/ext2fs_dinode.h:1.34 src/sys/ufs/ext2fs/ext2fs_dinode.h:1.35 --- src/sys/ufs/ext2fs/ext2fs_dinode.h:1.34 Thu Aug 4 17:50:51 2016 +++ src/sys/ufs/ext2fs/ext2fs_dinode.h Sat Aug 6 09:29:28 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_dinode.h,v 1.34 2016/08/04 17:50:51 jdolecek Exp $ */ +/* $NetBSD: ext2fs_dinode.h,v 1.35 2016/08/06 09:29:28 jdolecek Exp $ */ /* * Copyright (c) 1982, 1989, 1993 @@ -199,7 +199,10 @@ struct ext2fs_dinode { #define EXT2_TOPDIR 0x0002 /* Top of directory hierarchies*/ #define EXT2_HUGE_FILE 0x0004 /* Set to each huge file */ #define EXT2_EXTENTS 0x0008 /* Inode uses extents */ +#define EXT2_EA_INODE 0x0020 /* Inode used for large EA */ #define EXT2_EOFBLOCKS 0x0040 /* Blocks allocated beyond EOF */ +#define EXT2_INLINE_DATA 0x1000 /* Inode has inline data */ +#define EXT2_PROJINHERIT 0x2000 /* Children inherit project ID */ /* Size of on-disk inode. */ #define EXT2_REV0_DINODE_SIZE 128
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Fri Aug 5 21:22:06 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs.h Log Message: add defines for the missing ext4 feature flags To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/ufs/ext2fs/ext2fs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs.h diff -u src/sys/ufs/ext2fs/ext2fs.h:1.40 src/sys/ufs/ext2fs/ext2fs.h:1.41 --- src/sys/ufs/ext2fs/ext2fs.h:1.40 Thu Aug 4 17:43:48 2016 +++ src/sys/ufs/ext2fs/ext2fs.h Fri Aug 5 21:22:06 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.40 2016/08/04 17:43:48 jdolecek Exp $ */ +/* $NetBSD: ext2fs.h,v 1.41 2016/08/05 21:22:06 jdolecek Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -264,8 +264,13 @@ struct m_ext2fs { #define EXT2F_COMPAT_EXTATTR 0x0008 #define EXT2F_COMPAT_RESIZE 0x0010 #define EXT2F_COMPAT_DIRHASHINDEX 0x0020 +#define EXT2F_COMPAT_SPARSESUPER2 0x0200 #define EXT2F_COMPAT_BITS \ "\20" \ + "\12COMPAT_SPARSESUPER2" \ + "\11" \ + "\10" \ + "\07" \ "\06COMPAT_DIRHASHINDEX" \ "\05COMPAT_RESIZE" \ "\04COMPAT_EXTATTR" \ @@ -280,8 +285,20 @@ struct m_ext2fs { #define EXT2F_ROCOMPAT_GDT_CSUM 0x0010 #define EXT2F_ROCOMPAT_DIR_NLINK 0x0020 #define EXT2F_ROCOMPAT_EXTRA_ISIZE 0x0040 +#define EXT2F_ROCOMPAT_QUOTA 0x0100 +#define EXT2F_ROCOMPAT_BIGALLOC 0x0200 +#define EXT2F_ROCOMPAT_METADATA_CKSUM 0x0400 +#define EXT2F_ROCOMPAT_READONLY 0x1000 +#define EXT2F_ROCOMPAT_PROJECT 0x2000 #define EXT2F_ROCOMPAT_BITS \ "\20" \ + "\16ROCOMPAT_PROJECT" \ + "\15ROCOMPAT_READONLY" \ + "\14" \ + "\13ROCOMPAT_METADATA_CKSUM" \ + "\12ROCOMPAT_BIGALLOC" \ + "\11ROCOMPAT_QUOTA" \ + "\10" \ "\07ROCOMPAT_EXTRA_ISIZE" \ "\06ROCOMPAT_DIR_NLINK" \ "\05ROCOMPAT_GDT_CSUM" \ @@ -299,8 +316,21 @@ struct m_ext2fs { #define EXT2F_INCOMPAT_64BIT 0x0080 #define EXT2F_INCOMPAT_MMP 0x0100 #define EXT2F_INCOMPAT_FLEX_BG 0x0200 +#define EXT2F_INCOMPAT_EA_INODE 0x0400 +#define EXT2F_INCOMPAT_DIRDATA 0x1000 +#define EXT2F_INCOMPAT_CSUM_SEED 0x2000 +#define EXT2F_INCOMPAT_LARGEDIR 0x4000 +#define EXT2F_INCOMPAT_INLINE_DATA 0x8000 +#define EXT2F_INCOMPAT_ENCRYPT 0x1 #define EXT2F_INCOMPAT_BITS \ "\20" \ + "\021INCOMPAT_ENCRYPT" \ + "\020INCOMPAT_INLINE_DATA" \ + "\017INCOMPAT_LARGEDIR" \ + "\016INCOMPAT_CSUM_SEED" \ + "\015INCOMPAT_DIRDATA" \ + "\014" \ + "\013INCOMPAT_EA_INODE" \ "\012INCOMPAT_FLEX_BG" \ "\011INCOMPAT_MMP" \ "\010INCOMPAT_64BIT" \
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Fri Aug 5 20:15:41 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_vnops.c Log Message: PR kern/7867 add support for UF_NODUMP flag to ext2fs To generate a diff of this commit: cvs rdiff -u -r1.119 -r1.120 src/sys/ufs/ext2fs/ext2fs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vnops.c diff -u src/sys/ufs/ext2fs/ext2fs_vnops.c:1.119 src/sys/ufs/ext2fs/ext2fs_vnops.c:1.120 --- src/sys/ufs/ext2fs/ext2fs_vnops.c:1.119 Wed Aug 3 23:29:05 2016 +++ src/sys/ufs/ext2fs/ext2fs_vnops.c Fri Aug 5 20:15:41 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vnops.c,v 1.119 2016/08/03 23:29:05 jdolecek Exp $ */ +/* $NetBSD: ext2fs_vnops.c,v 1.120 2016/08/05 20:15:41 jdolecek Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.119 2016/08/03 23:29:05 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.120 2016/08/05 20:15:41 jdolecek Exp $"); #include #include @@ -311,13 +311,17 @@ ext2fs_getattr(void *v) if (EXT2_DINODE_FITS(ip->i_din.e2fs_din, e2di_crtime, EXT2_DINODE_SIZE(ip->i_e2fs))) { EXT2_DINODE_TIME_GET(&vap->va_birthtime, ip->i_din.e2fs_din, e2di_crtime, EXT2_DINODE_SIZE(ip->i_e2fs)); } + + vap->va_flags = 0; + vap->va_flags |= (ip->i_e2fs_flags & EXT2_NODUMP) ? UF_NODUMP : 0; #ifdef EXT2FS_SYSTEM_FLAGS - vap->va_flags = (ip->i_e2fs_flags & EXT2_APPEND) ? SF_APPEND : 0; vap->va_flags |= (ip->i_e2fs_flags & EXT2_IMMUTABLE) ? SF_IMMUTABLE : 0; + vap->va_flags |= (ip->i_e2fs_flags & EXT2_APPEND) ? SF_APPEND : 0; #else - vap->va_flags = (ip->i_e2fs_flags & EXT2_APPEND) ? UF_APPEND : 0; vap->va_flags |= (ip->i_e2fs_flags & EXT2_IMMUTABLE) ? UF_IMMUTABLE : 0; + vap->va_flags |= (ip->i_e2fs_flags & EXT2_APPEND) ? UF_APPEND : 0; #endif + vap->va_gen = ip->i_e2fs_gen; /* this doesn't belong here */ if (vp->v_type == VBLK) @@ -391,17 +395,18 @@ ext2fs_setattr(void *v) if (error) return (error); + ip->i_e2fs_flags &= ~(EXT2_APPEND | EXT2_IMMUTABLE | EXT2_NODUMP); #ifdef EXT2FS_SYSTEM_FLAGS - ip->i_e2fs_flags &= ~(EXT2_APPEND | EXT2_IMMUTABLE); ip->i_e2fs_flags |= (vap->va_flags & SF_APPEND) ? EXT2_APPEND : 0 | (vap->va_flags & SF_IMMUTABLE) ? EXT2_IMMUTABLE : 0; #else - ip->i_e2fs_flags &= ~(EXT2_APPEND | EXT2_IMMUTABLE); ip->i_e2fs_flags |= (vap->va_flags & UF_APPEND) ? EXT2_APPEND : 0 | (vap->va_flags & UF_IMMUTABLE) ? EXT2_IMMUTABLE : 0; #endif + ip->i_e2fs_flags |= + (vap->va_flags & UF_NODUMP) ? EXT2_NODUMP : 0; ip->i_flag |= IN_CHANGE; if (vap->va_flags & (IMMUTABLE | APPEND)) return (0);
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Fri Aug 5 20:06:55 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: add devel ifndefs for incompat/rocompat features so that it's possible to ignore them and mount the filesystem; default is for the mount to fail To generate a diff of this commit: cvs rdiff -u -r1.196 -r1.197 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.196 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.197 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.196 Wed Aug 3 23:33:59 2016 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Fri Aug 5 20:06:55 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.196 2016/08/03 23:33:59 pgoyette Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.197 2016/08/05 20:06:55 jdolecek Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.196 2016/08/03 23:33:59 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.197 2016/08/05 20:06:55 jdolecek Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -1238,14 +1238,18 @@ ext2fs_sbfill(struct m_ext2fs *m_fs, int if (u32) { snprintb(buf, sizeof(buf), EXT2F_INCOMPAT_BITS, u32); printf("ext2fs: unsupported incompat features: %s\n", buf); +#ifndef EXT2_IGNORE_INCOMPAT_FEATURES return EINVAL; +#endif } u32 = fs->e2fs_features_rocompat & ~EXT2F_ROCOMPAT_SUPP; if (!ronly && u32) { snprintb(buf, sizeof(buf), EXT2F_ROCOMPAT_BITS, u32); printf("ext2fs: unsupported ro-incompat features: %s\n", buf); +#ifndef EXT2_IGNORE_ROCOMPAT_FEATURES return EROFS; +#endif } if (fs->e2fs_inode_size == 0 || !powerof2(fs->e2fs_inode_size) || fs->e2fs_inode_size > m_fs->e2fs_bsize) { printf("ext2fs: bad inode size\n");
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Thu Aug 4 17:50:52 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_dinode.h Log Message: make E2MAXSYMLINKLEN just alias for EXT2_MAXSYMLINKLEN, they are the same To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/ufs/ext2fs/ext2fs_dinode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_dinode.h diff -u src/sys/ufs/ext2fs/ext2fs_dinode.h:1.33 src/sys/ufs/ext2fs/ext2fs_dinode.h:1.34 --- src/sys/ufs/ext2fs/ext2fs_dinode.h:1.33 Thu Aug 4 17:47:48 2016 +++ src/sys/ufs/ext2fs/ext2fs_dinode.h Thu Aug 4 17:50:51 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_dinode.h,v 1.33 2016/08/04 17:47:48 jdolecek Exp $ */ +/* $NetBSD: ext2fs_dinode.h,v 1.34 2016/08/04 17:50:51 jdolecek Exp $ */ /* * Copyright (c) 1982, 1989, 1993 @@ -105,6 +105,7 @@ #define EXT2FS_NIADDR 3 /* Indirect addresses in inode. */ #define EXT2_MAXSYMLINKLEN ((EXT2FS_NDADDR+EXT2FS_NIADDR) * sizeof (uint32_t)) +#define E2MAXSYMLINKLEN EXT2_MAXSYMLINKLEN struct ext2fs_dinode { uint16_t e2di_mode; /* 0: IFMT, permissions; see below. */ @@ -142,9 +143,6 @@ struct ext2fs_dinode { uint32_t e2di_projid;/* 156: project id (not implemented) (ext4) */ }; -/* XXX how does this differ from EXT2_MAXSYMLINKLEN above? */ -#define E2MAXSYMLINKLEN ((EXT2FS_NDADDR + EXT2FS_NIADDR) * sizeof(uint32_t)) - #define i_e2fs_mode i_din.e2fs_din->e2di_mode #define i_e2fs_uid i_din.e2fs_din->e2di_uid #define i_e2fs_size i_din.e2fs_din->e2di_size
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: nonaka Date: Thu Aug 4 04:05:14 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_dinode.h Log Message: include stddef.h for offsetof. fix newfs_ext2fs build failure on evbppc. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/ufs/ext2fs/ext2fs_dinode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_dinode.h diff -u src/sys/ufs/ext2fs/ext2fs_dinode.h:1.30 src/sys/ufs/ext2fs/ext2fs_dinode.h:1.31 --- src/sys/ufs/ext2fs/ext2fs_dinode.h:1.30 Thu Aug 4 02:49:50 2016 +++ src/sys/ufs/ext2fs/ext2fs_dinode.h Thu Aug 4 04:05:14 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_dinode.h,v 1.30 2016/08/04 02:49:50 nonaka Exp $ */ +/* $NetBSD: ext2fs_dinode.h,v 1.31 2016/08/04 04:05:14 nonaka Exp $ */ /* * Copyright (c) 1982, 1989, 1993 @@ -67,6 +67,10 @@ #ifndef _UFS_EXT2FS_EXT2FS_DINODE_H_ #define _UFS_EXT2FS_EXT2FS_DINODE_H_ +#if !defined(_KERNEL) && !defined(_STANDALONE) +#include /* for offsetof */ +#endif + #include /*
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: nonaka Date: Thu Aug 4 02:49:50 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_dinode.h Log Message: pass isize to e2fs_i_bswap() if BYTE_ORDER != LITTLE_ENDIAN. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/ufs/ext2fs/ext2fs_dinode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_dinode.h diff -u src/sys/ufs/ext2fs/ext2fs_dinode.h:1.29 src/sys/ufs/ext2fs/ext2fs_dinode.h:1.30 --- src/sys/ufs/ext2fs/ext2fs_dinode.h:1.29 Wed Aug 3 23:29:05 2016 +++ src/sys/ufs/ext2fs/ext2fs_dinode.h Thu Aug 4 02:49:50 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_dinode.h,v 1.29 2016/08/03 23:29:05 jdolecek Exp $ */ +/* $NetBSD: ext2fs_dinode.h,v 1.30 2016/08/04 02:49:50 nonaka Exp $ */ /* * Copyright (c) 1982, 1989, 1993 @@ -253,8 +253,8 @@ ext2fs_dinode_time_set(const struct time memcpy((new),(old),(isize)) #else void e2fs_i_bswap(struct ext2fs_dinode *, struct ext2fs_dinode *, size_t); -# define e2fs_iload(old, new, isize) e2fs_i_bswap((old), (new)) -# define e2fs_isave(old, new, isize) e2fs_i_bswap((old), (new)) +# define e2fs_iload(old, new, isize) e2fs_i_bswap((old), (new), (isize)) +# define e2fs_isave(old, new, isize) e2fs_i_bswap((old), (new), (isize)) #endif #endif /* !_UFS_EXT2FS_EXT2FS_DINODE_H_ */
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: pgoyette Date: Wed Aug 3 23:33:59 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: Update previous. Since original format was %llu, replace it with % PRIu64 (unsigned). To generate a diff of this commit: cvs rdiff -u -r1.195 -r1.196 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.195 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.196 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.195 Wed Aug 3 23:28:01 2016 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Wed Aug 3 23:33:59 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.195 2016/08/03 23:28:01 pgoyette Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.196 2016/08/03 23:33:59 pgoyette Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.195 2016/08/03 23:28:01 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.196 2016/08/03 23:33:59 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -510,7 +510,7 @@ ext2fs_loadvnode_content(struct m_ext2fs if (EXT2_DINODE_FITS(din, e2di_extra_isize, EXT2_DINODE_SIZE(fs)) && (EXT2_DINODE_SIZE(fs) - EXT2_REV0_DINODE_SIZE) < din->e2di_extra_isize) { - printf("ext2fs: inode %"PRId64" bad extra_isize %u", + printf("ext2fs: inode %"PRIu64" bad extra_isize %u", ino, din->e2di_extra_isize); error = EINVAL; goto bad;
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Wed Aug 3 23:29:05 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_dinode.h ext2fs_subr.c ext2fs_vnops.c Log Message: get and set expanded timestamp if the inode contains the extra information, add support for create time To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/ufs/ext2fs/ext2fs_dinode.h cvs rdiff -u -r1.31 -r1.32 src/sys/ufs/ext2fs/ext2fs_subr.c cvs rdiff -u -r1.118 -r1.119 src/sys/ufs/ext2fs/ext2fs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_dinode.h diff -u src/sys/ufs/ext2fs/ext2fs_dinode.h:1.28 src/sys/ufs/ext2fs/ext2fs_dinode.h:1.29 --- src/sys/ufs/ext2fs/ext2fs_dinode.h:1.28 Wed Aug 3 21:53:02 2016 +++ src/sys/ufs/ext2fs/ext2fs_dinode.h Wed Aug 3 23:29:05 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_dinode.h,v 1.28 2016/08/03 21:53:02 jdolecek Exp $ */ +/* $NetBSD: ext2fs_dinode.h,v 1.29 2016/08/03 23:29:05 jdolecek Exp $ */ /* * Copyright (c) 1982, 1989, 1993 @@ -189,6 +189,52 @@ struct ext2fs_dinode { ) /* + * Time encoding + * Lower two bits of extra field are extra high bits for epoch; unfortunately still, Linux kernels treat 11 there as 00 for compatibility + * Rest of extra fields are nanoseconds + */ +static __inline void +ext2fs_dinode_time_get(struct timespec *ts, uint32_t epoch, uint32_t extra) +{ + ts->tv_sec = (signed) epoch; + + if (extra) { + uint64_t epoch_bits = extra & 0x3; + /* XXX compatibility with linux kernel < 4.20 */ + if (epoch_bits == 3 && ts->tv_sec < 0) + epoch_bits = 0; + + ts->tv_sec |= epoch_bits << 32; + + ts->tv_nsec = extra >> 2; + } else { + ts->tv_nsec = 0; + } +} +#define EXT2_DINODE_TIME_GET(ts, dinode, field, isize) \ + ext2fs_dinode_time_get(ts, (dinode)->field, \ + EXT2_DINODE_FITS(dinode, field ## _extra, isize) \ + ? (dinode)->field ## _extra : 0 \ + ) + +static __inline void +ext2fs_dinode_time_set(const struct timespec *ts, uint32_t *epoch, uint32_t *extra) +{ + *epoch = (int32_t) ts->tv_sec; + + if (extra) { + uint32_t epoch_bits = (ts->tv_sec >> 32) & 0x3; + + *extra = (ts->tv_nsec << 2) | epoch_bits; + } +} +#define EXT2_DINODE_TIME_SET(ts, dinode, field, isize) \ + ext2fs_dinode_time_set(ts, &(dinode)->field, \ + EXT2_DINODE_FITS(dinode, field ## _extra, isize) \ + ? &(dinode)->field ## _extra : NULL \ + ) + +/* * The e2di_blocks fields may be overlaid with other information for * file types that do not have associated disk storage. Block * and character devices overlay the first data block with their Index: src/sys/ufs/ext2fs/ext2fs_subr.c diff -u src/sys/ufs/ext2fs/ext2fs_subr.c:1.31 src/sys/ufs/ext2fs/ext2fs_subr.c:1.32 --- src/sys/ufs/ext2fs/ext2fs_subr.c:1.31 Sat Mar 28 19:24:04 2015 +++ src/sys/ufs/ext2fs/ext2fs_subr.c Wed Aug 3 23:29:05 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_subr.c,v 1.31 2015/03/28 19:24:04 maxv Exp $ */ +/* $NetBSD: ext2fs_subr.c,v 1.32 2016/08/03 23:29:05 jdolecek Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_subr.c,v 1.31 2015/03/28 19:24:04 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_subr.c,v 1.32 2016/08/03 23:29:05 jdolecek Exp $"); #include #include @@ -115,18 +115,18 @@ ext2fs_itimes(struct inode *ip, const st if (ip->i_flag & IN_ACCESS) { if (acc == NULL) acc = &now; - ip->i_e2fs_atime = acc->tv_sec; + EXT2_DINODE_TIME_SET(acc, ip->i_din.e2fs_din, e2di_atime, EXT2_DINODE_SIZE(ip->i_e2fs)); } if (ip->i_flag & (IN_UPDATE | IN_MODIFY)) { if (mod == NULL) mod = &now; - ip->i_e2fs_mtime = mod->tv_sec; + EXT2_DINODE_TIME_SET(mod, ip->i_din.e2fs_din, e2di_mtime, EXT2_DINODE_SIZE(ip->i_e2fs)); ip->i_modrev++; } if (ip->i_flag & (IN_CHANGE | IN_MODIFY)) { if (cre == NULL) cre = &now; - ip->i_e2fs_ctime = cre->tv_sec; + EXT2_DINODE_TIME_SET(cre, ip->i_din.e2fs_din, e2di_ctime, EXT2_DINODE_SIZE(ip->i_e2fs)); } if (ip->i_flag & (IN_ACCESS | IN_MODIFY)) ip->i_flag |= IN_ACCESSED; Index: src/sys/ufs/ext2fs/ext2fs_vnops.c diff -u src/sys/ufs/ext2fs/ext2fs_vnops.c:1.118 src/sys/ufs/ext2fs/ext2fs_vnops.c:1.119 --- src/sys/ufs/ext2fs/ext2fs_vnops.c:1.118 Wed Aug 3 21:53:03 2016 +++ src/sys/ufs/ext2fs/ext2fs_vnops.c Wed Aug 3 23:29:05 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vnops.c,v 1.118 2016/08/03 21:53:03 jdolecek Exp $ */ +/* $NetBSD: ext2fs_vnops.c,v 1.119 2016/08/03 23:29:05 jdolecek Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.118 2016/08/03 21:53:03 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.119 2016/08/03 23:29:05 jdolecek Exp $"); #include #include @@ -305,12 +305,12 @@ ext2fs_getattr(void *v) vap->va_gid = ip->i_gid; vap->va_rdev = (dev_t)fs2h32(ip->i_din.e2fs_din->e2di_rdev); vap->va_size
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: pgoyette Date: Wed Aug 3 23:28:01 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: Use correct printf() format for inode (fixes build for me) To generate a diff of this commit: cvs rdiff -u -r1.194 -r1.195 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.194 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.195 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.194 Wed Aug 3 21:53:02 2016 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Wed Aug 3 23:28:01 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.194 2016/08/03 21:53:02 jdolecek Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.195 2016/08/03 23:28:01 pgoyette Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.194 2016/08/03 21:53:02 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.195 2016/08/03 23:28:01 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -510,7 +510,7 @@ ext2fs_loadvnode_content(struct m_ext2fs if (EXT2_DINODE_FITS(din, e2di_extra_isize, EXT2_DINODE_SIZE(fs)) && (EXT2_DINODE_SIZE(fs) - EXT2_REV0_DINODE_SIZE) < din->e2di_extra_isize) { - printf("ext2fs: inode %llu bad extra_isize %u", + printf("ext2fs: inode %"PRId64" bad extra_isize %u", ino, din->e2di_extra_isize); error = EINVAL; goto bad;
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Wed Aug 3 21:53:03 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs.h ext2fs_alloc.c ext2fs_bswap.c ext2fs_dinode.h ext2fs_inode.c ext2fs_vfsops.c ext2fs_vnops.c Log Message: support arbitrary ext3/ext4 inode size, add all the new ext4 fields ext2fs_dinode, and add support for loading the extra inode data To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/ufs/ext2fs/ext2fs.h cvs rdiff -u -r1.46 -r1.47 src/sys/ufs/ext2fs/ext2fs_alloc.c cvs rdiff -u -r1.20 -r1.21 src/sys/ufs/ext2fs/ext2fs_bswap.c cvs rdiff -u -r1.27 -r1.28 src/sys/ufs/ext2fs/ext2fs_dinode.h cvs rdiff -u -r1.82 -r1.83 src/sys/ufs/ext2fs/ext2fs_inode.c cvs rdiff -u -r1.193 -r1.194 src/sys/ufs/ext2fs/ext2fs_vfsops.c cvs rdiff -u -r1.117 -r1.118 src/sys/ufs/ext2fs/ext2fs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs.h diff -u src/sys/ufs/ext2fs/ext2fs.h:1.38 src/sys/ufs/ext2fs/ext2fs.h:1.39 --- src/sys/ufs/ext2fs/ext2fs.h:1.38 Fri Jun 24 17:21:30 2016 +++ src/sys/ufs/ext2fs/ext2fs.h Wed Aug 3 21:53:02 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.38 2016/06/24 17:21:30 christos Exp $ */ +/* $NetBSD: ext2fs.h,v 1.39 2016/08/03 21:53:02 jdolecek Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -327,7 +327,8 @@ struct m_ext2fs { #define EXT2F_COMPAT_SUPP 0x #define EXT2F_ROCOMPAT_SUPP (EXT2F_ROCOMPAT_SPARSESUPER \ | EXT2F_ROCOMPAT_LARGEFILE \ - | EXT2F_ROCOMPAT_HUGE_FILE) + | EXT2F_ROCOMPAT_HUGE_FILE \ + | EXT2F_ROCOMPAT_EXTRA_ISIZE) #define EXT2F_INCOMPAT_SUPP (EXT2F_INCOMPAT_FTYPE \ | EXT2F_INCOMPAT_EXTENTS) Index: src/sys/ufs/ext2fs/ext2fs_alloc.c diff -u src/sys/ufs/ext2fs/ext2fs_alloc.c:1.46 src/sys/ufs/ext2fs/ext2fs_alloc.c:1.47 --- src/sys/ufs/ext2fs/ext2fs_alloc.c:1.46 Sat Mar 28 19:24:04 2015 +++ src/sys/ufs/ext2fs/ext2fs_alloc.c Wed Aug 3 21:53:02 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_alloc.c,v 1.46 2015/03/28 19:24:04 maxv Exp $ */ +/* $NetBSD: ext2fs_alloc.c,v 1.47 2016/08/03 21:53:02 jdolecek Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.46 2015/03/28 19:24:04 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.47 2016/08/03 21:53:02 jdolecek Exp $"); #include #include @@ -198,7 +198,7 @@ ext2fs_valloc(struct vnode *pvp, int mod panic("ext2fs_valloc: dup alloc"); } - memset(ip->i_din.e2fs_din, 0, sizeof(struct ext2fs_dinode)); + memset(ip->i_din.e2fs_din, 0, EXT2_DINODE_SIZE(fs)); /* * Set up a new generation number for this inode. Index: src/sys/ufs/ext2fs/ext2fs_bswap.c diff -u src/sys/ufs/ext2fs/ext2fs_bswap.c:1.20 src/sys/ufs/ext2fs/ext2fs_bswap.c:1.21 --- src/sys/ufs/ext2fs/ext2fs_bswap.c:1.20 Tue Aug 2 17:24:24 2016 +++ src/sys/ufs/ext2fs/ext2fs_bswap.c Wed Aug 3 21:53:02 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_bswap.c,v 1.20 2016/08/02 17:24:24 jdolecek Exp $ */ +/* $NetBSD: ext2fs_bswap.c,v 1.21 2016/08/03 21:53:02 jdolecek Exp $ */ /* * Copyright (c) 1997 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_bswap.c,v 1.20 2016/08/02 17:24:24 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_bswap.c,v 1.21 2016/08/03 21:53:02 jdolecek Exp $"); #include #include @@ -81,7 +81,8 @@ e2fs_sb_bswap(struct ext2fs *old, struct new->e2fs_reserved_ngdb = bswap16(old->e2fs_reserved_ngdb); } -void e2fs_cg_bswap(struct ext2_gd *old, struct ext2_gd *new, int size) +void +e2fs_cg_bswap(struct ext2_gd *old, struct ext2_gd *new, int size) { int i; @@ -95,9 +96,13 @@ void e2fs_cg_bswap(struct ext2_gd *old, } } -void e2fs_i_bswap(struct ext2fs_dinode *old, struct ext2fs_dinode *new) +void +e2fs_i_bswap(struct ext2fs_dinode *old, struct ext2fs_dinode *new, size_t isize) { + /* preserve non-swapped and unused fields */ + memcpy(new, old, isize); + /* swap what needs to be swapped */ new->e2di_mode = bswap16(old->e2di_mode); new->e2di_uid = bswap16(old->e2di_uid); new->e2di_gid = bswap16(old->e2di_gid); @@ -117,7 +122,32 @@ void e2fs_i_bswap(struct ext2fs_dinode * new->e2di_facl_high = bswap16(old->e2di_facl_high); new->e2di_uid_high = bswap16(old->e2di_uid_high); new->e2di_gid_high = bswap16(old->e2di_gid_high); - memcpy(&new->e2di_blocks[0], &old->e2di_blocks[0], - (EXT2FS_NDADDR + EXT2FS_NIADDR) * sizeof(uint32_t)); + new->e2di_checksum_low = bswap16(old->e2di_checksum_low); + + /* + * Following fields are only supported for inode sizes bigger + * than the old ext2 one + */ + if (isize == EXT2_REV0_DINODE_SIZE) + return; + + new->e2di_extra_isize = bswap16(old->e2di_extra_isize); + new->e2di_checksum_high = bswap16(old->e2di_checksum_high); + + /* Following fields are ext4, might not be actually present */ + if (EXT2_DINODE_FITS(new, e2di_ctime_e
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Tue Aug 2 17:36:02 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_dinode.h Log Message: adjust the comments for on-disk ext2fs inode to indicate which of the ext* was it implemented for linux kernel; makes it a bit easier to locate split e2di_linux_reserved3 with e2di_extra_isize and e2di_checksum_high, tag as ext4 To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/ufs/ext2fs/ext2fs_dinode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_dinode.h diff -u src/sys/ufs/ext2fs/ext2fs_dinode.h:1.26 src/sys/ufs/ext2fs/ext2fs_dinode.h:1.27 --- src/sys/ufs/ext2fs/ext2fs_dinode.h:1.26 Tue Jan 22 09:39:15 2013 +++ src/sys/ufs/ext2fs/ext2fs_dinode.h Tue Aug 2 17:36:02 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_dinode.h,v 1.26 2013/01/22 09:39:15 dholland Exp $ */ +/* $NetBSD: ext2fs_dinode.h,v 1.27 2016/08/02 17:36:02 jdolecek Exp $ */ /* * Copyright (c) 1982, 1989, 1993 @@ -118,14 +118,15 @@ struct ext2fs_dinode { uint32_t e2di_blocks[EXT2FS_NDADDR+EXT2FS_NIADDR]; /* 40: disk blocks */ uint32_t e2di_gen; /* 100: generation number */ - uint32_t e2di_facl; /* 104: file ACL (not implemented) */ - uint32_t e2di_dacl; /* 108: dir ACL (not implemented) */ - uint32_t e2di_faddr; /* 112: fragment address */ - uint16_t e2di_nblock_high; /* 116: Blocks count bits 47:32 */ - uint16_t e2di_facl_high; /* 118: file ACL bits 47:32 */ - uint16_t e2di_uid_high; /* 120: Owner UID top 16 bits */ - uint16_t e2di_gid_high; /* 122: Owner GID top 16 bits */ - uint32_t e2di_linux_reserved3; /* 124 */ + uint32_t e2di_facl; /* 104: file ACL (not implemented) (ext3) */ + uint32_t e2di_dacl; /* 108: dir ACL (not implemented) (ext3) */ + uint32_t e2di_obso_faddr;/* 112: obsolete fragment address (ext2) */ + uint16_t e2di_nblock_high; /* 116: Blocks count bits 47:32 (ext4) */ + uint16_t e2di_facl_high; /* 118: file ACL bits 47:32 (ext4) */ + uint16_t e2di_uid_high; /* 120: Owner UID top 16 bits (ext4) */ + uint16_t e2di_gid_high; /* 122: Owner GID top 16 bits (ext4) */ + uint16_t e2di_extra_isize; /* 124: inode extra size (over 128) actually used (ext4) */ + uint16_t e2di_checksum_high; /* 126: crc (not implemented) (ext4) */ };
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jdolecek Date: Tue Aug 2 17:24:24 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_bswap.c Log Message: do not bswap fragment address, support in ext* for them was never actually implemented in linux kernels To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/ufs/ext2fs/ext2fs_bswap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_bswap.c diff -u src/sys/ufs/ext2fs/ext2fs_bswap.c:1.19 src/sys/ufs/ext2fs/ext2fs_bswap.c:1.20 --- src/sys/ufs/ext2fs/ext2fs_bswap.c:1.19 Tue Jan 22 09:39:15 2013 +++ src/sys/ufs/ext2fs/ext2fs_bswap.c Tue Aug 2 17:24:24 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_bswap.c,v 1.19 2013/01/22 09:39:15 dholland Exp $ */ +/* $NetBSD: ext2fs_bswap.c,v 1.20 2016/08/02 17:24:24 jdolecek Exp $ */ /* * Copyright (c) 1997 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_bswap.c,v 1.19 2013/01/22 09:39:15 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_bswap.c,v 1.20 2016/08/02 17:24:24 jdolecek Exp $"); #include #include @@ -113,7 +113,6 @@ void e2fs_i_bswap(struct ext2fs_dinode * new->e2di_gen = bswap32(old->e2di_gen); new->e2di_facl = bswap32(old->e2di_facl); new->e2di_dacl = bswap32(old->e2di_dacl); - new->e2di_faddr = bswap32(old->e2di_faddr); new->e2di_nblock_high = bswap16(old->e2di_nblock_high); new->e2di_facl_high = bswap16(old->e2di_facl_high); new->e2di_uid_high = bswap16(old->e2di_uid_high);
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Fri Jun 24 17:21:30 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs.h ext2fs_dir.h ext2fs_extern.h ext2fs_lookup.c Added Files: src/sys/ufs/ext2fs: ext2fs_hash.c ext2fs_hash.h ext2fs_htree.c ext2fs_htree.h Log Message: GSoC 2016 (Hrishikesh Goyal): Htree index support from FreeBSD To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/ufs/ext2fs/ext2fs.h cvs rdiff -u -r1.19 -r1.20 src/sys/ufs/ext2fs/ext2fs_dir.h cvs rdiff -u -r1.48 -r1.49 src/sys/ufs/ext2fs/ext2fs_extern.h cvs rdiff -u -r0 -r1.1 src/sys/ufs/ext2fs/ext2fs_hash.c \ src/sys/ufs/ext2fs/ext2fs_hash.h src/sys/ufs/ext2fs/ext2fs_htree.c \ src/sys/ufs/ext2fs/ext2fs_htree.h cvs rdiff -u -r1.79 -r1.80 src/sys/ufs/ext2fs/ext2fs_lookup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs.h diff -u src/sys/ufs/ext2fs/ext2fs.h:1.37 src/sys/ufs/ext2fs/ext2fs.h:1.38 --- src/sys/ufs/ext2fs/ext2fs.h:1.37 Fri Jun 3 11:35:48 2016 +++ src/sys/ufs/ext2fs/ext2fs.h Fri Jun 24 13:21:30 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.37 2016/06/03 15:35:48 christos Exp $ */ +/* $NetBSD: ext2fs.h,v 1.38 2016/06/24 17:21:30 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -235,6 +235,7 @@ struct m_ext2fs { u_char e2fs_fsmnt[MAXMNTLEN]; /* name mounted on */ int8_t e2fs_ronly; /* mounted read-only flag */ int8_t e2fs_fmod; /* super block modified flag */ + int8_t e2fs_uhash; /* 3 if hash should be signed, 0 if not */ int32_t e2fs_bsize; /* block size */ int32_t e2fs_bshift; /* ``lblkno'' calc of logical blkno */ int32_t e2fs_bmask; /* ``blkoff'' calc of blk offsets */ @@ -331,6 +332,12 @@ struct m_ext2fs { | EXT2F_INCOMPAT_EXTENTS) /* + * Feature set definitions + */ +#define EXT2_HAS_COMPAT_FEATURE(sb, mask) \ +((sb)->e2fs.e2fs_features_compat & htole32(mask)) + +/* * Definitions of behavior on errors */ #define E2FS_BEH_CONTINUE 1 /* continue operation */ Index: src/sys/ufs/ext2fs/ext2fs_dir.h diff -u src/sys/ufs/ext2fs/ext2fs_dir.h:1.19 src/sys/ufs/ext2fs/ext2fs_dir.h:1.20 --- src/sys/ufs/ext2fs/ext2fs_dir.h:1.19 Tue May 8 20:21:18 2012 +++ src/sys/ufs/ext2fs/ext2fs_dir.h Fri Jun 24 13:21:30 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_dir.h,v 1.19 2012/05/09 00:21:18 riastradh Exp $ */ +/* $NetBSD: ext2fs_dir.h,v 1.20 2016/06/24 17:21:30 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -114,6 +114,20 @@ struct ext2fs_direct { char e2d_name[EXT2FS_MAXNAMLEN];/* name with length<=EXT2FS_MAXNAMLEN */ }; +enum ext2fs_slotstatus { + NONE, + COMPACT, + FOUND +}; + +struct ext2fs_searchslot { + enum ext2fs_slotstatus slotstatus; + doff_t slotoffset; /* offset of area with free space */ + int slotsize; /* size of area at slotoffset */ + int slotfreespace; /* amount of space free in slot */ + int slotneeded; /* sizeof the entry we are seeking */ +}; + /* Ext2 directory file types (not the same as FFS. Sigh.) */ #define EXT2_FT_UNKNOWN 0 #define EXT2_FT_REG_FILE1 @@ -179,4 +193,14 @@ struct ext2fs_dirtemplate { char dotdot_name[4]; /* ditto */ }; +/* + * EXT2_DIR_PAD defines the directory entries boundaries + * + * NOTE: It must be a multiple of 4 + */ +#define EXT2_DIR_PAD 4 +#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) +#define EXT2_DIR_REC_LEN(namelen) \ +(((namelen) + 8 + EXT2_DIR_ROUND) & ~EXT2_DIR_ROUND) + #endif /* !_UFS_EXT2FS_EXT2FS_DIR_H_ */ Index: src/sys/ufs/ext2fs/ext2fs_extern.h diff -u src/sys/ufs/ext2fs/ext2fs_extern.h:1.48 src/sys/ufs/ext2fs/ext2fs_extern.h:1.49 --- src/sys/ufs/ext2fs/ext2fs_extern.h:1.48 Fri Mar 27 13:27:56 2015 +++ src/sys/ufs/ext2fs/ext2fs_extern.h Fri Jun 24 13:21:30 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_extern.h,v 1.48 2015/03/27 17:27:56 riastradh Exp $ */ +/* $NetBSD: ext2fs_extern.h,v 1.49 2016/06/24 17:21:30 christos Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -78,6 +78,7 @@ struct vnode; struct mbuf; struct componentname; struct ufs_lookup_results; +struct ext2fs_searchslot; extern struct pool ext2fs_inode_pool; /* memory pool for inodes */ extern struct pool ext2fs_dinode_pool; /* memory pool for dinodes */ @@ -120,6 +121,9 @@ int ext2fs_inactive(void *); /* ext2fs_lookup.c */ int ext2fs_readdir(void *); int ext2fs_lookup(void *); +int ext2fs_search_dirblock(struct inode *, void *, int *, +const char *, int , int *, doff_t *, doff_t *, doff_t *, +struct ext2fs_searchslot *); int ext2fs_direnter(struct inode *, struct vnode *, const struct ufs_lookup_results *, struct componentname *); @@ -172,6 +176,15 @@ int ext2fs_makeinode(int, struct vnode * struct componentname *cnp); int ext2fs_reclaim(void *); +/* ext2fs_hash.c */ +int ext2fs_htree_hash(const char *, int, uint32_t *, int, uint32_t *, +uint32_t *); + +/* ext2fs_htree.c */
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: dholland Date: Fri Jun 10 06:30:59 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_extents.h Log Message: needs To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/ext2fs/ext2fs_extents.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_extents.h diff -u src/sys/ufs/ext2fs/ext2fs_extents.h:1.1 src/sys/ufs/ext2fs/ext2fs_extents.h:1.2 --- src/sys/ufs/ext2fs/ext2fs_extents.h:1.1 Fri Jun 3 15:35:48 2016 +++ src/sys/ufs/ext2fs/ext2fs_extents.h Fri Jun 10 06:30:58 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_extents.h,v 1.1 2016/06/03 15:35:48 christos Exp $ */ +/* $NetBSD: ext2fs_extents.h,v 1.2 2016/06/10 06:30:58 dholland Exp $ */ /*- * Copyright (c) 2012, 2010 Zheng Liu @@ -32,6 +32,10 @@ #define _UFS_EXT2FS_EXT2FS_EXTENTS_H_ #include +#ifndef _KERNEL +#include +#endif + #include #define EXT4_EXT_MAGIC 0xf30a
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Fri Jun 3 15:35:48 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs.h ext2fs_bmap.c Added Files: src/sys/ufs/ext2fs: ext2fs_extents.c ext2fs_extents.h Log Message: Add ext4 extent support from GSoC 2016 (Hrishikesh Goyal), from the FreeBSD ext2 code. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/ufs/ext2fs/ext2fs.h cvs rdiff -u -r1.26 -r1.27 src/sys/ufs/ext2fs/ext2fs_bmap.c cvs rdiff -u -r0 -r1.1 src/sys/ufs/ext2fs/ext2fs_extents.c \ src/sys/ufs/ext2fs/ext2fs_extents.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs.h diff -u src/sys/ufs/ext2fs/ext2fs.h:1.36 src/sys/ufs/ext2fs/ext2fs.h:1.37 --- src/sys/ufs/ext2fs/ext2fs.h:1.36 Sun Jun 23 03:28:37 2013 +++ src/sys/ufs/ext2fs/ext2fs.h Fri Jun 3 11:35:48 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.36 2013/06/23 07:28:37 dholland Exp $ */ +/* $NetBSD: ext2fs.h,v 1.37 2016/06/03 15:35:48 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -86,6 +86,11 @@ #define BBLOCK ((daddr_t)(0)) #define SBLOCK ((daddr_t)(BBLOCK + BBSIZE / DEV_BSIZE)) +#define fsbtodb(fs, b) ((daddr_t)(b) << (fs)->e2fs_fsbtodb) +/* calculates (loc / fs->fs_bsize) */ +#define lblkno(fs, loc) ((loc) >> (fs->e2fs_bshift)) +#define blksize(fs, ip, lbn) ((fs)->e2fs_bsize) + /* * Addresses stored in inodes are capable of addressing blocks * XXX @@ -132,7 +137,7 @@ struct ext2fs { uint32_t e2fs_fbcount; /* free blocks count */ uint32_t e2fs_ficount; /* free inodes count */ uint32_t e2fs_first_dblock; /* first data block */ - uint32_t e2fs_log_bsize; /* block size = 1024*(2^e2fs_log_bsize) */ + uint32_t e2fs_log_bsize; /* bsize = 1024*(2^e2fs_log_bsize) */ uint32_t e2fs_fsize; /* fragment size */ uint32_t e2fs_bpg; /* blocks per group */ uint32_t e2fs_fpg; /* frags per group */ @@ -165,7 +170,62 @@ struct ext2fs { uint8_t e2fs_prealloc; /* # of blocks to preallocate */ uint8_t e2fs_dir_prealloc; /* # of blocks to preallocate for dir */ uint16_t e2fs_reserved_ngdb; /* # of reserved gd blocks for resize */ - uint32_t reserved2[204]; + + /* Additional fields */ + char e3fs_journal_uuid[16];/* uuid of journal superblock */ + uint32_t e3fs_journal_inum; /* inode number of journal file */ + uint32_t e3fs_journal_dev; /* device number of journal file */ + uint32_t e3fs_last_orphan; /* start of list of inodes to delete */ + uint32_t e3fs_hash_seed[4]; /* HTREE hash seed */ + char e3fs_def_hash_version;/* Default hash version to use */ + char e3fs_jnl_backup_type; + uint16_t e3fs_desc_size; /* size of group descriptor */ + uint32_t e3fs_default_mount_opts; + uint32_t e3fs_first_meta_bg; /* First metablock block group */ + uint32_t e3fs_mkfs_time; /* when the fs was created */ + uint32_t e3fs_jnl_blks[17]; /* backup of the journal inode */ + uint32_t e4fs_bcount_hi; /* high bits of blocks count */ + uint32_t e4fs_rbcount_hi; /* high bits of reserved blocks count */ + uint32_t e4fs_fbcount_hi; /* high bits of free blocks count */ + uint16_t e4fs_min_extra_isize; /* all inodes have some bytes */ + uint16_t e4fs_want_extra_isize;/* inodes must reserve some bytes */ + uint32_t e4fs_flags; /* miscellaneous flags */ + uint16_t e4fs_raid_stride; /* RAID stride */ + uint16_t e4fs_mmpintv; /* seconds to wait in MMP checking */ + uint64_t e4fs_mmpblk; /* block for multi-mount protection */ + uint32_t e4fs_raid_stripe_wid; /* blocks on data disks (N * stride) */ + uint8_t e4fs_log_gpf; /* FLEX_BG group size */ + uint8_t e4fs_chksum_type; /* metadata checksum algorithm used */ + uint8_t e4fs_encrypt; /* versioning level for encryption */ + uint8_t e4fs_reserved_pad; + uint64_t e4fs_kbytes_written; /* number of lifetime kilobytes */ + uint32_t e4fs_snapinum; /* inode number of active snapshot */ + uint32_t e4fs_snapid; /* sequential ID of active snapshot */ + uint64_t e4fs_snaprbcount; /* rsvd blocks for active snapshot */ + uint32_t e4fs_snaplist; /* inode number for on-disk snapshot */ + uint32_t e4fs_errcount; /* number of file system errors */ + uint32_t e4fs_first_errtime; /* first time an error happened */ + uint32_t e4fs_first_errino; /* inode involved in first error */ + uint64_t e4fs_first_errblk; /* block involved of first error */ + uint8_t e4fs_first_errfunc[32];/* function where error happened */ + uint32_t e4fs_first_errline; /* line number where error happened */ + uint32_t e4fs_last_errtime; /* most recent time of an error */ + uint32_t e4fs_last_errino; /* inode involved in last error */ + uint32_t e4fs_last_errline; /* line number where error happened */ + uint64_t e4fs_last_errblk; /* block involved of last error */ + uint8_t e4fs_last_errfunc[32];/* function where error happened */ + uint8_t e4fs_mount_opts[64]; + uint32_t e4fs_usrquota_inum; /* i
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: riastradh Date: Tue Jan 12 21:29:29 UTC 2016 Modified Files: src/sys/ufs/ext2fs: ext2fs_lookup.c Log Message: Use buffer cache, not page cache, to expand directories in ext2fs. Candidate fix for PR kern/50607, PR port-evbmips/50059. Formerly VOP_WRITE-->ext2fs_write would automatically dispatch to this code path for writes to directories, but I broke that in ext2fs_lookup.c rev. 1.78 when disentangling page-cached and buffer-cached writes. This was not a problem in ufs, and I didn't notice it in ext2fs, because ufs consistently used buffercache(9) directly instead of using VOP_WRITE sometimes as ext2fs did. To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/sys/ufs/ext2fs/ext2fs_lookup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_lookup.c diff -u src/sys/ufs/ext2fs/ext2fs_lookup.c:1.78 src/sys/ufs/ext2fs/ext2fs_lookup.c:1.79 --- src/sys/ufs/ext2fs/ext2fs_lookup.c:1.78 Fri Mar 27 17:27:56 2015 +++ src/sys/ufs/ext2fs/ext2fs_lookup.c Tue Jan 12 21:29:29 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_lookup.c,v 1.78 2015/03/27 17:27:56 riastradh Exp $ */ +/* $NetBSD: ext2fs_lookup.c,v 1.79 2016/01/12 21:29:29 riastradh Exp $ */ /* * Modified for NetBSD 1.2E @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.78 2015/03/27 17:27:56 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.79 2016/01/12 21:29:29 riastradh Exp $"); #include #include @@ -768,7 +768,7 @@ ext2fs_direnter(struct inode *ip, struct auio.uio_iovcnt = 1; auio.uio_rw = UIO_WRITE; UIO_SETUP_SYSSPACE(&auio); - error = VOP_WRITE(dvp, &auio, IO_SYNC, cnp->cn_cred); + error = ext2fs_bufwr(dvp, &auio, IO_SYNC, cnp->cn_cred); if (dirblksiz > dvp->v_mount->mnt_stat.f_bsize) /* XXX should grow with balloc() */ panic("ext2fs_direnter: frag size");
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: riastradh Date: Sat Mar 28 03:49:41 UTC 2015 Modified Files: src/sys/ufs/ext2fs: ext2fs_readwrite.c Log Message: Missed another spot, in ext2fs_write. To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 src/sys/ufs/ext2fs/ext2fs_readwrite.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_readwrite.c diff -u src/sys/ufs/ext2fs/ext2fs_readwrite.c:1.68 src/sys/ufs/ext2fs/ext2fs_readwrite.c:1.69 --- src/sys/ufs/ext2fs/ext2fs_readwrite.c:1.68 Sat Mar 28 03:46:51 2015 +++ src/sys/ufs/ext2fs/ext2fs_readwrite.c Sat Mar 28 03:49:41 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_readwrite.c,v 1.68 2015/03/28 03:46:51 riastradh Exp $ */ +/* $NetBSD: ext2fs_readwrite.c,v 1.69 2015/03/28 03:49:41 riastradh Exp $ */ /*- * Copyright (c) 1993 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.68 2015/03/28 03:46:51 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.69 2015/03/28 03:49:41 riastradh Exp $"); #include #include @@ -284,12 +284,6 @@ ext2fs_write(void *v) if ((ip->i_e2fs_flags & EXT2_APPEND) && uio->uio_offset != ext2fs_size(ip)) return (EPERM); - /* FALLTHROUGH */ - case VLNK: - break; - case VDIR: - if ((ioflag & IO_SYNC) == 0) - panic("%s: nonsync dir write", "ext2fs_write"); break; default: panic("%s: type", "ext2fs_write");
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: riastradh Date: Sat Mar 28 03:46:51 UTC 2015 Modified Files: src/sys/ufs/ext2fs: ext2fs_readwrite.c Log Message: Missed a spot in ext2fs_read To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/ufs/ext2fs/ext2fs_readwrite.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_readwrite.c diff -u src/sys/ufs/ext2fs/ext2fs_readwrite.c:1.67 src/sys/ufs/ext2fs/ext2fs_readwrite.c:1.68 --- src/sys/ufs/ext2fs/ext2fs_readwrite.c:1.67 Fri Mar 27 17:27:56 2015 +++ src/sys/ufs/ext2fs/ext2fs_readwrite.c Sat Mar 28 03:46:51 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_readwrite.c,v 1.67 2015/03/27 17:27:56 riastradh Exp $ */ +/* $NetBSD: ext2fs_readwrite.c,v 1.68 2015/03/28 03:46:51 riastradh Exp $ */ /*- * Copyright (c) 1993 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.67 2015/03/27 17:27:56 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.68 2015/03/28 03:46:51 riastradh Exp $"); #include #include @@ -112,11 +112,7 @@ ext2fs_read(void *v) if (uio->uio_rw != UIO_READ) panic("%s: mode", "ext2fs_read"); - if (vp->v_type == VLNK) { - if (ext2fs_size(ip) < ump->um_maxsymlinklen || - (ump->um_maxsymlinklen == 0 && ext2fs_nblock(ip) == 0)) - panic("%s: short symlink", "ext2fs_read"); - } else if (vp->v_type != VREG && vp->v_type != VDIR) + if (vp->v_type != VREG && vp->v_type != VDIR) panic("%s: type %d", "ext2fs_read", vp->v_type); #endif /* XXX Eliminate me by refusing directory reads from userland. */
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: maxv Date: Mon Feb 23 17:05:59 UTC 2015 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: Hum. Perhaps I missed a bit of the specification. Let's not be that severe when checking the superblock. Should fix ATF. To generate a diff of this commit: cvs rdiff -u -r1.189 -r1.190 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.189 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.190 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.189 Sun Feb 22 14:55:23 2015 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Mon Feb 23 17:05:58 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.189 2015/02/22 14:55:23 maxv Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.190 2015/02/23 17:05:58 maxv Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.189 2015/02/22 14:55:23 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.190 2015/02/23 17:05:58 maxv Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -1189,11 +1189,11 @@ ext2fs_sbfill(struct m_ext2fs *m_fs, int * Compute the fields of the superblock */ u32 = fs->e2fs_bcount - fs->e2fs_first_dblock; /* > 0 */ - if (u32 < fs->e2fs_bpg) { + m_fs->e2fs_ncg = howmany(u32, fs->e2fs_bpg); + if (m_fs->e2fs_ncg == 0) { printf("ext2fs: invalid number of cylinder groups\n"); return EINVAL; } - m_fs->e2fs_ncg = howmany(u32, fs->e2fs_bpg); m_fs->e2fs_fsbtodb = fs->e2fs_log_bsize + LOG_MINBSIZE - DEV_BSHIFT; m_fs->e2fs_bsize = MINBSIZE << fs->e2fs_log_bsize; @@ -1201,13 +1201,12 @@ ext2fs_sbfill(struct m_ext2fs *m_fs, int m_fs->e2fs_qbmask = m_fs->e2fs_bsize - 1; m_fs->e2fs_bmask = ~m_fs->e2fs_qbmask; - if (m_fs->e2fs_bsize < sizeof(struct ext2_gd)) { + if ((u32 = m_fs->e2fs_bsize / sizeof(struct ext2_gd)) == 0) { /* Unlikely to happen */ printf("ext2fs: invalid block size\n"); return EINVAL; } - m_fs->e2fs_ngdb = - howmany(m_fs->e2fs_ncg, m_fs->e2fs_bsize / sizeof(struct ext2_gd)); + m_fs->e2fs_ngdb = howmany(m_fs->e2fs_ncg, u32); if (m_fs->e2fs_ngdb == 0) { printf("ext2fs: invalid number of group descriptor blocks\n"); return EINVAL;
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: maxv Date: Sun Feb 22 14:55:23 UTC 2015 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: Merge _sbcompute() and _sbcheck() into _sbfill(). In ext2fs_sbfill(), check more fields of the superblock, to prevent several kernel panics when mounting/unmounting a disk. To generate a diff of this commit: cvs rdiff -u -r1.188 -r1.189 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.188 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.189 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.188 Fri Feb 20 17:44:54 2015 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Sun Feb 22 14:55:23 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.188 2015/02/20 17:44:54 maxv Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.189 2015/02/22 14:55:23 maxv Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.188 2015/02/20 17:44:54 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.189 2015/02/22 14:55:23 maxv Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -104,8 +104,7 @@ __KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsop MODULE(MODULE_CLASS_VFS, ext2fs, "ffs"); int ext2fs_sbupdate(struct ufsmount *, int); -static void ext2fs_sbcompute(struct m_ext2fs *); -static int ext2fs_sbcheck(struct ext2fs *, int); +static int ext2fs_sbfill(struct m_ext2fs *, int); static struct sysctllog *ext2fs_sysctl_log; @@ -549,10 +548,9 @@ ext2fs_reload(struct mount *mp, kauth_cr brelse(bp, 0); - error = ext2fs_sbcheck(&fs->e2fs, (mp->mnt_flag & MNT_RDONLY) != 0); + error = ext2fs_sbfill(fs, (mp->mnt_flag & MNT_RDONLY) != 0); if (error) return error; - ext2fs_sbcompute(fs); /* * Step 3: re-read summary information from disk. @@ -649,8 +647,8 @@ ext2fs_mountfs(struct vnode *devvp, stru brelse(bp, 0); bp = NULL; - /* Once swapped, validate the superblock. */ - error = ext2fs_sbcheck(&m_fs->e2fs, ronly); + /* Once swapped, validate and fill in the superblock. */ + error = ext2fs_sbfill(m_fs, ronly); if (error) { kmem_free(m_fs, sizeof(struct m_ext2fs)); goto out; @@ -670,9 +668,7 @@ ext2fs_mountfs(struct vnode *devvp, stru m_fs->e2fs_fmod = 1; } - /* Compute dynamic sb infos */ - ext2fs_sbcompute(m_fs); - + /* XXX: should be added in ext2fs_sbfill()? */ m_fs->e2fs_gd = kmem_alloc(m_fs->e2fs_ngdb * m_fs->e2fs_bsize, KM_SLEEP); for (i = 0; i < m_fs->e2fs_ngdb; i++) { error = bread(devvp, @@ -1118,30 +1114,19 @@ ext2fs_cgupdate(struct ufsmount *mp, int return (allerror); } -static void -ext2fs_sbcompute(struct m_ext2fs *fs) -{ - fs->e2fs_ncg = howmany(fs->e2fs.e2fs_bcount - fs->e2fs.e2fs_first_dblock, - fs->e2fs.e2fs_bpg); - fs->e2fs_fsbtodb = fs->e2fs.e2fs_log_bsize + LOG_MINBSIZE - DEV_BSHIFT; - fs->e2fs_bsize = MINBSIZE << fs->e2fs.e2fs_log_bsize; - fs->e2fs_bshift = LOG_MINBSIZE + fs->e2fs.e2fs_log_bsize; - fs->e2fs_qbmask = fs->e2fs_bsize - 1; - fs->e2fs_bmask = ~fs->e2fs_qbmask; - fs->e2fs_ngdb = - howmany(fs->e2fs_ncg, fs->e2fs_bsize / sizeof(struct ext2_gd)); - fs->e2fs_ipb = fs->e2fs_bsize / EXT2_DINODE_SIZE(fs); - fs->e2fs_itpg = fs->e2fs.e2fs_ipg / fs->e2fs_ipb; -} - /* + * Fill in the m_fs structure, and validate the fields of the superblock. * NOTE: here, the superblock is already swapped. */ static int -ext2fs_sbcheck(struct ext2fs *fs, int ronly) +ext2fs_sbfill(struct m_ext2fs *m_fs, int ronly) { uint32_t u32; + struct ext2fs *fs = &m_fs->e2fs; + /* + * General sanity checks + */ if (fs->e2fs_magic != E2FS_MAGIC) return EINVAL; if (fs->e2fs_rev > E2FS_REV1) { @@ -1157,7 +1142,24 @@ ext2fs_sbcheck(struct ext2fs *fs, int ro printf("ext2fs: zero blocks per group\n"); return EINVAL; } + if (fs->e2fs_ipg == 0) { + printf("ext2fs: zero inodes per group\n"); + return EINVAL; + } + if (fs->e2fs_first_dblock >= fs->e2fs_bcount) { + printf("ext2fs: invalid first data block\n"); + return EINVAL; + } + if (fs->e2fs_rbcount > fs->e2fs_bcount || + fs->e2fs_fbcount > fs->e2fs_bcount) { + printf("ext2fs: invalid block count\n"); + return EINVAL; + } + + /* + * Revision-specific checks + */ if (fs->e2fs_rev > E2FS_REV0) { char buf[256]; if (fs->e2fs_first_ino != EXT2_FIRSTINO) { @@ -1177,10 +1179,47 @@ ext2fs_sbcheck(struct ext2fs *fs, int ro buf); return EROFS; } - if (fs->e2fs_inode_size == 0) { + if (fs->e2fs_inode_size == 0 || !powerof2(fs->e2fs_inode_size)) { printf("ext2fs: bad inode size\n"); return EINVAL; } } + + /* + * Compute the fields of the superblock + */ + u32 = fs->e2fs_bcount - fs->e2fs_first_dblock; /* > 0 */ + if (u32 < fs->e2fs_bpg) { + printf("ext2fs: invalid number of cylinder groups\n"); + return EINVAL; + } + m_fs->e2fs_ncg = howmany(u32,
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: maxv Date: Fri Feb 20 17:44:54 UTC 2015 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: Several fixes: - rename ext2fs_checksb() -> ext2fs_sbcheck(): more consistent - in ext2fs_sbcheck(), add a check to ensure e2fs_inode_size!=0, otherwise division by zero - add ext2fs_sbcompute(), to compute dynamic values of the superblock. It is done twice in _reload() and _mountfs(), so put it in a function. - reorder the code in charge of loading the superblock: now, read the superblock, swap it directly, and *then* pass it to ext2fs_sbcheck(). It is similar to what ffs now does. It is better since the fields don't need to be swapped on the fly in ext2fs_sbcheck(). Tested on amd64. To generate a diff of this commit: cvs rdiff -u -r1.187 -r1.188 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.187 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.188 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.187 Thu Feb 19 21:31:44 2015 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Fri Feb 20 17:44:54 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.187 2015/02/19 21:31:44 maxv Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.188 2015/02/20 17:44:54 maxv Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.187 2015/02/19 21:31:44 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.188 2015/02/20 17:44:54 maxv Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -104,7 +104,8 @@ __KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsop MODULE(MODULE_CLASS_VFS, ext2fs, "ffs"); int ext2fs_sbupdate(struct ufsmount *, int); -static int ext2fs_checksb(struct ext2fs *, int); +static void ext2fs_sbcompute(struct m_ext2fs *); +static int ext2fs_sbcheck(struct ext2fs *, int); static struct sysctllog *ext2fs_sysctl_log; @@ -534,43 +535,28 @@ ext2fs_reload(struct mount *mp, kauth_cr VOP_UNLOCK(devvp); if (error) panic("ext2fs_reload: dirty1"); - /* - * Step 2: re-read superblock from disk. - */ - error = bread(devvp, SBLOCK, SBSIZE, NOCRED, 0, &bp); - if (error) { - return (error); - } - newfs = (struct ext2fs *)bp->b_data; - error = ext2fs_checksb(newfs, (mp->mnt_flag & MNT_RDONLY) != 0); - if (error) { - brelse(bp, 0); - return (error); - } fs = ump->um_e2fs; /* - * copy in new superblock, and compute in-memory values + * Step 2: re-read superblock from disk. Copy in new superblock, and compute + * in-memory values. */ + error = bread(devvp, SBLOCK, SBSIZE, NOCRED, 0, &bp); + if (error) + return error; + newfs = (struct ext2fs *)bp->b_data; e2fs_sbload(newfs, &fs->e2fs); - fs->e2fs_ncg = - howmany(fs->e2fs.e2fs_bcount - fs->e2fs.e2fs_first_dblock, - fs->e2fs.e2fs_bpg); - fs->e2fs_fsbtodb = fs->e2fs.e2fs_log_bsize + LOG_MINBSIZE - DEV_BSHIFT; - fs->e2fs_bsize = MINBSIZE << fs->e2fs.e2fs_log_bsize; - fs->e2fs_bshift = LOG_MINBSIZE + fs->e2fs.e2fs_log_bsize; - fs->e2fs_qbmask = fs->e2fs_bsize - 1; - fs->e2fs_bmask = ~fs->e2fs_qbmask; - fs->e2fs_ngdb = - howmany(fs->e2fs_ncg, fs->e2fs_bsize / sizeof(struct ext2_gd)); - fs->e2fs_ipb = fs->e2fs_bsize / EXT2_DINODE_SIZE(fs); - fs->e2fs_itpg = fs->e2fs.e2fs_ipg / fs->e2fs_ipb; + brelse(bp, 0); + error = ext2fs_sbcheck(&fs->e2fs, (mp->mnt_flag & MNT_RDONLY) != 0); + if (error) + return error; + ext2fs_sbcompute(fs); + /* * Step 3: re-read summary information from disk. */ - for (i = 0; i < fs->e2fs_ngdb; i++) { error = bread(devvp , EXT2_FSBTODB(fs, fs->e2fs.e2fs_first_dblock + @@ -652,29 +638,30 @@ ext2fs_mountfs(struct vnode *devvp, stru bp = NULL; ump = NULL; -#ifdef DEBUG_EXT2 - printf("ext2 sb size: %zu\n", sizeof(struct ext2fs)); -#endif + /* Read the superblock from disk, and swap it directly. */ error = bread(devvp, SBLOCK, SBSIZE, cred, 0, &bp); if (error) goto out; fs = (struct ext2fs *)bp->b_data; - error = ext2fs_checksb(fs, ronly); - if (error) + m_fs = kmem_zalloc(sizeof(struct m_ext2fs), KM_SLEEP); + e2fs_sbload(fs, &m_fs->e2fs); + + brelse(bp, 0); + bp = NULL; + + /* Once swapped, validate the superblock. */ + error = ext2fs_sbcheck(&m_fs->e2fs, ronly); + if (error) { + kmem_free(m_fs, sizeof(struct m_ext2fs)); goto out; + } + m_fs->e2fs_ronly = ronly; + ump = kmem_zalloc(sizeof(*ump), KM_SLEEP); ump->um_fstype = UFS1; ump->um_ops = &ext2fs_ufsops; - ump->um_e2fs = kmem_zalloc(sizeof(struct m_ext2fs), KM_SLEEP); - e2fs_sbload((struct ext2fs *)bp->b_data, &ump->um_e2fs->e2fs); - brelse(bp, 0); - bp = NULL; - m_fs = ump->um_e2fs; - m_fs->e2fs_ronly = ronly; + ump->um_e2fs = m_fs; -#ifdef DEBUG_EXT2 - printf("ext2 ino size %zu\n", EXT2_DINODE_SIZE(m_fs)); -#endif if (ronly == 0) { if (m_fs->e2fs.e2fs_state == E2FS_ISCLE
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: maxv Date: Thu Feb 19 21:31:45 UTC 2015 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: e2fs_sbcheck(): add a check to ensure e2fs_bpg!=0. Otherwise the kernel panics with a division by zero. While here, remove the #ifdef's. To generate a diff of this commit: cvs rdiff -u -r1.186 -r1.187 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.186 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.187 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.186 Sun Nov 9 18:23:28 2014 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Thu Feb 19 21:31:44 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.186 2014/11/09 18:23:28 maxv Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.187 2015/02/19 21:31:44 maxv Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.186 2014/11/09 18:23:28 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.187 2015/02/19 21:31:44 maxv Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -1151,20 +1151,21 @@ ext2fs_checksb(struct ext2fs *fs, int ro return (EINVAL); /* XXX needs translation */ } if (fs2h32(fs->e2fs_rev) > E2FS_REV1) { -#ifdef DIAGNOSTIC printf("ext2fs: unsupported revision number: %x\n", fs2h32(fs->e2fs_rev)); -#endif return (EINVAL); /* XXX needs translation */ } if (fs2h32(fs->e2fs_log_bsize) > 2) { /* block size = 1024|2048|4096 */ -#ifdef DIAGNOSTIC printf("ext2fs: bad block size: %d " "(expected <= 2 for ext2 fs)\n", fs2h32(fs->e2fs_log_bsize)); -#endif return (EINVAL); /* XXX needs translation */ } + if (fs->e2fs_bpg == 0) { + printf("ext2fs: zero blocks per group\n"); + return EINVAL; + } + if (fs2h32(fs->e2fs_rev) > E2FS_REV0) { char buf[256]; if (fs2h32(fs->e2fs_first_ino) != EXT2_FIRSTINO) {
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: matt Date: Fri Sep 19 23:52:34 UTC 2014 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: curlwp can never be NULL now. To generate a diff of this commit: cvs rdiff -u -r1.184 -r1.185 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.184 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.185 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.184 Fri Aug 22 16:49:30 2014 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Fri Sep 19 23:52:34 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.184 2014/08/22 16:49:30 hannken Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.185 2014/09/19 23:52:34 matt Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.184 2014/08/22 16:49:30 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.185 2014/09/19 23:52:34 matt Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -639,7 +639,7 @@ ext2fs_mountfs(struct vnode *devvp, stru kauth_cred_t cred; dev = devvp->v_rdev; - cred = l ? l->l_cred : NOCRED; + cred = l->l_cred; /* Flush out any old buffers remaining from a previous use. */ vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: hannken Date: Fri Aug 22 16:49:30 UTC 2014 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: Use mount from argument "mp", "vp->v_mount" is not valid here. PR kern/49142 (panic in ext2fs_loadvnode mounting an ext2fs filesystem) Needs pullup to -7 To generate a diff of this commit: cvs rdiff -u -r1.183 -r1.184 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.183 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.184 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.183 Wed Jul 9 08:43:54 2014 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Fri Aug 22 16:49:30 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.183 2014/07/09 08:43:54 maxv Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.184 2014/08/22 16:49:30 hannken Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.183 2014/07/09 08:43:54 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.184 2014/08/22 16:49:30 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -1024,7 +1024,7 @@ ext2fs_loadvnode(struct mount *mp, struc if (++ext2gennumber < (u_long)time_second) ext2gennumber = time_second; ip->i_e2fs_gen = ext2gennumber; - if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0) + if ((mp->mnt_flag & MNT_RDONLY) == 0) ip->i_flag |= IN_MODIFIED; } uvm_vnp_setsize(vp, ext2fs_size(ip));
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: maxv Date: Tue Aug 12 06:49:11 UTC 2014 Modified Files: src/sys/ufs/ext2fs: ext2fs_readwrite.c Log Message: http://m00nbsd.net/ae123a9bae03f7dde5c6d654412daf5a.html#Report-2 #04-0x02: Remove 'doclusterread' and 'doclusterwrite' (unused). To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/ufs/ext2fs/ext2fs_readwrite.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_readwrite.c diff -u src/sys/ufs/ext2fs/ext2fs_readwrite.c:1.64 src/sys/ufs/ext2fs/ext2fs_readwrite.c:1.65 --- src/sys/ufs/ext2fs/ext2fs_readwrite.c:1.64 Sun Jun 23 07:28:37 2013 +++ src/sys/ufs/ext2fs/ext2fs_readwrite.c Tue Aug 12 06:49:10 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_readwrite.c,v 1.64 2013/06/23 07:28:37 dholland Exp $ */ +/* $NetBSD: ext2fs_readwrite.c,v 1.65 2014/08/12 06:49:10 maxv Exp $ */ /*- * Copyright (c) 1993 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.64 2013/06/23 07:28:37 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.65 2014/08/12 06:49:10 maxv Exp $"); #include #include @@ -82,10 +82,6 @@ __KERNEL_RCSID(0, "$NetBSD: ext2fs_readw #include #include - -#define doclusterread 0 /* XXX underway */ -#define doclusterwrite 0 - /* * Vnode op for reading. */
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: hannken Date: Sun May 25 14:07:19 UTC 2014 Modified Files: src/sys/ufs/ext2fs: ext2fs_extern.h ext2fs_lookup.c Log Message: Remove ext2fs_checkpath(). It is a relic from the pre-genfs_rename era. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/ufs/ext2fs/ext2fs_extern.h cvs rdiff -u -r1.75 -r1.76 src/sys/ufs/ext2fs/ext2fs_lookup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_extern.h diff -u src/sys/ufs/ext2fs/ext2fs_extern.h:1.46 src/sys/ufs/ext2fs/ext2fs_extern.h:1.47 --- src/sys/ufs/ext2fs/ext2fs_extern.h:1.46 Wed Nov 21 23:11:23 2012 +++ src/sys/ufs/ext2fs/ext2fs_extern.h Sun May 25 14:07:19 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_extern.h,v 1.46 2012/11/21 23:11:23 jakllsch Exp $ */ +/* $NetBSD: ext2fs_extern.h,v 1.47 2014/05/25 14:07:19 hannken Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -128,7 +128,6 @@ int ext2fs_dirremove(struct vnode *, con int ext2fs_dirrewrite(struct inode *, const struct ufs_lookup_results *, struct inode *, struct componentname *); int ext2fs_dirempty(struct inode *, ino_t, kauth_cred_t); -int ext2fs_checkpath(struct inode *, struct inode *, kauth_cred_t); /* ext2fs_subr.c */ int ext2fs_blkatoff(struct vnode *, off_t, char **, struct buf **); Index: src/sys/ufs/ext2fs/ext2fs_lookup.c diff -u src/sys/ufs/ext2fs/ext2fs_lookup.c:1.75 src/sys/ufs/ext2fs/ext2fs_lookup.c:1.76 --- src/sys/ufs/ext2fs/ext2fs_lookup.c:1.75 Thu May 8 08:21:53 2014 +++ src/sys/ufs/ext2fs/ext2fs_lookup.c Sun May 25 14:07:19 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_lookup.c,v 1.75 2014/05/08 08:21:53 hannken Exp $ */ +/* $NetBSD: ext2fs_lookup.c,v 1.76 2014/05/25 14:07:19 hannken Exp $ */ /* * Modified for NetBSD 1.2E @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.75 2014/05/08 08:21:53 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.76 2014/05/25 14:07:19 hannken Exp $"); #include #include @@ -985,70 +985,3 @@ ext2fs_dirempty(struct inode *ip, ino_t } return (1); } - -/* - * Check if source directory is in the path of the target directory. - * Target is supplied locked, source is unlocked. - * The target is always vput before returning. - */ -int -ext2fs_checkpath(struct inode *source, struct inode *target, - kauth_cred_t cred) -{ - struct vnode *vp; - int error, rootino, namlen; - struct ext2fs_dirtemplate dirbuf; - uint32_t ino; - - vp = ITOV(target); - if (target->i_number == source->i_number) { - error = EEXIST; - goto out; - } - rootino = UFS_ROOTINO; - error = 0; - if (target->i_number == rootino) - goto out; - - for (;;) { - if (vp->v_type != VDIR) { - error = ENOTDIR; - break; - } - error = vn_rdwr(UIO_READ, vp, (void *)&dirbuf, - sizeof (struct ext2fs_dirtemplate), (off_t)0, - UIO_SYSSPACE, IO_NODELOCKED, cred, (size_t *)0, - NULL); - if (error != 0) - break; - namlen = dirbuf.dotdot_namlen; - if (namlen != 2 || - dirbuf.dotdot_name[0] != '.' || - dirbuf.dotdot_name[1] != '.') { - error = ENOTDIR; - break; - } - ino = fs2h32(dirbuf.dotdot_ino); - if (ino == source->i_number) { - error = EINVAL; - break; - } - if (ino == rootino) - break; - vput(vp); - error = VFS_VGET(vp->v_mount, ino, &vp); - if (error != 0) { - vp = NULL; - break; - } - } - -out: - if (error == ENOTDIR) { - printf("checkpath: .. not a directory\n"); - panic("checkpath"); - } - if (vp != NULL) - vput(vp); - return (error); -}
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: hannken Date: Sun May 25 13:47:22 UTC 2014 Modified Files: src/sys/ufs/ext2fs: ext2fs_vnops.c Log Message: ext2fs_mknod: use vcache_get() to reload the new node. To generate a diff of this commit: cvs rdiff -u -r1.111 -r1.112 src/sys/ufs/ext2fs/ext2fs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vnops.c diff -u src/sys/ufs/ext2fs/ext2fs_vnops.c:1.111 src/sys/ufs/ext2fs/ext2fs_vnops.c:1.112 --- src/sys/ufs/ext2fs/ext2fs_vnops.c:1.111 Mon Mar 24 13:42:40 2014 +++ src/sys/ufs/ext2fs/ext2fs_vnops.c Sun May 25 13:47:22 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vnops.c,v 1.111 2014/03/24 13:42:40 hannken Exp $ */ +/* $NetBSD: ext2fs_vnops.c,v 1.112 2014/05/25 13:47:22 hannken Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.111 2014/03/24 13:42:40 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.112 2014/05/25 13:47:22 hannken Exp $"); #include #include @@ -181,19 +181,18 @@ ext2fs_mknod(void *v) ip->i_din.e2fs_din->e2di_rdev = h2fs32(vap->va_rdev); } /* - * Remove inode so that it will be reloaded by VFS_VGET and + * Remove inode so that it will be reloaded by vcache_get and * checked to see if it is an alias of an existing entry in * the inode cache. */ (*vpp)->v_type = VNON; VOP_UNLOCK(*vpp); vgone(*vpp); - error = VFS_VGET(mp, ino, vpp); + error = vcache_get(mp, &ino, sizeof(ino), vpp); if (error != 0) { *vpp = NULL; return (error); } - VOP_UNLOCK(*vpp); return (0); }
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: hannken Date: Sun May 25 13:46:58 UTC 2014 Modified Files: src/sys/ufs/ext2fs: ext2fs_rename.c Log Message: ext2fs_gro_genealogy: use vcache_get() to lookup DOTDOT. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/ufs/ext2fs/ext2fs_rename.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_rename.c diff -u src/sys/ufs/ext2fs/ext2fs_rename.c:1.6 src/sys/ufs/ext2fs/ext2fs_rename.c:1.7 --- src/sys/ufs/ext2fs/ext2fs_rename.c:1.6 Tue Jan 28 13:02:56 2014 +++ src/sys/ufs/ext2fs/ext2fs_rename.c Sun May 25 13:46:58 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_rename.c,v 1.6 2014/01/28 13:02:56 martin Exp $ */ +/* $NetBSD: ext2fs_rename.c,v 1.7 2014/05/25 13:46:58 hannken Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_rename.c,v 1.6 2014/01/28 13:02:56 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_rename.c,v 1.7 2014/05/25 13:46:58 hannken Exp $"); #include #include @@ -846,20 +846,15 @@ ext2fs_gro_genealogy(struct mount *mp, k } /* Neither -- keep ascending the family tree. */ - - /* - * Unlock vp so that we can lock the parent, but keep - * vp referenced until after we have found the parent, - * so that dotdot_ino will not be recycled. - * - * XXX This guarantees that vp's inode number will not - * be recycled, but why can't dotdot_ino be recycled? - */ - VOP_UNLOCK(vp); - error = VFS_VGET(mp, dotdot_ino, &dvp); - vrele(vp); - if (error) + error = vcache_get(mp, &dotdot_ino, sizeof(dotdot_ino), &dvp); + vput(vp); + if (error) + return error; + error = vn_lock(dvp, LK_EXCLUSIVE); + if (error) { + vrele(dvp); return error; + } KASSERT(dvp != NULL); KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: hannken Date: Mon Mar 17 09:30:32 UTC 2014 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: Change ext2fs_sync() to use vfs_vnode_iterator. To generate a diff of this commit: cvs rdiff -u -r1.177 -r1.178 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.177 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.178 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.177 Wed Mar 5 09:37:29 2014 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Mon Mar 17 09:30:32 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.177 2014/03/05 09:37:29 hannken Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.178 2014/03/17 09:30:32 hannken Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.177 2014/03/05 09:37:29 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.178 2014/03/17 09:30:32 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -871,10 +871,11 @@ ext2fs_statvfs(struct mount *mp, struct int ext2fs_sync(struct mount *mp, int waitfor, kauth_cred_t cred) { - struct vnode *vp, *mvp; + struct vnode *vp; struct inode *ip; struct ufsmount *ump = VFSTOUFS(mp); struct m_ext2fs *fs; + struct vnode_iterator *marker; int error, allerror = 0; fs = ump->um_e2fs; @@ -883,43 +884,30 @@ ext2fs_sync(struct mount *mp, int waitfo panic("update: rofs mod"); } - /* Allocate a marker vnode. */ - mvp = vnalloc(mp); - /* * Write back each (modified) inode. */ - mutex_enter(&mntvnode_lock); -loop: - /* - * NOTE: not using the TAILQ_FOREACH here since in this loop vgone() - * and vclean() can be called indirectly - */ - for (vp = TAILQ_FIRST(&mp->mnt_vnodelist); vp; vp = vunmark(mvp)) { - vmark(mvp, vp); - if (vp->v_mount != mp || vismarker(vp)) + vfs_vnode_iterator_init(mp, &marker); + while (vfs_vnode_iterator_next(marker, &vp)) { + error = vn_lock(vp, LK_EXCLUSIVE); + if (error) { + vrele(vp); continue; - mutex_enter(vp->v_interlock); + } ip = VTOI(vp); - if (ip == NULL || (vp->v_iflag & (VI_XLOCK|VI_CLEAN)) != 0 || - vp->v_type == VNON || - ((ip->i_flag & - (IN_CHANGE | IN_UPDATE | IN_MODIFIED)) == 0 && - LIST_EMPTY(&vp->v_dirtyblkhd) && - UVM_OBJ_IS_CLEAN(&vp->v_uobj))) - { - mutex_exit(vp->v_interlock); + /* + * Skip the vnode/inode if inaccessible. + */ + if (ip == NULL || vp->v_type == VNON) { + vput(vp); continue; } - mutex_exit(&mntvnode_lock); - error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT); - if (error) { - mutex_enter(&mntvnode_lock); - if (error == ENOENT) { -mutex_enter(&mntvnode_lock); -(void)vunmark(mvp); -goto loop; - } + + if (((ip->i_flag & + (IN_CHANGE | IN_UPDATE | IN_MODIFIED)) == 0 && + LIST_EMPTY(&vp->v_dirtyblkhd) && + UVM_OBJ_IS_CLEAN(&vp->v_uobj))) { + vput(vp); continue; } if (vp->v_type == VREG && waitfor == MNT_LAZY) @@ -930,10 +918,8 @@ loop: if (error) allerror = error; vput(vp); - mutex_enter(&mntvnode_lock); } - mutex_exit(&mntvnode_lock); - vnfree(mvp); + vfs_vnode_iterator_destroy(marker); /* * Force stale file system control information to be flushed. */
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: martin Date: Tue Jan 28 13:02:56 UTC 2014 Modified Files: src/sys/ufs/ext2fs: ext2fs_rename.c Log Message: Quell a (bogus) "may be used unintialized" warning from gcc 4.8 To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/ufs/ext2fs/ext2fs_rename.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_rename.c diff -u src/sys/ufs/ext2fs/ext2fs_rename.c:1.5 src/sys/ufs/ext2fs/ext2fs_rename.c:1.6 --- src/sys/ufs/ext2fs/ext2fs_rename.c:1.5 Tue Jan 22 09:39:15 2013 +++ src/sys/ufs/ext2fs/ext2fs_rename.c Tue Jan 28 13:02:56 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_rename.c,v 1.5 2013/01/22 09:39:15 dholland Exp $ */ +/* $NetBSD: ext2fs_rename.c,v 1.6 2014/01/28 13:02:56 martin Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_rename.c,v 1.5 2013/01/22 09:39:15 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_rename.c,v 1.6 2014/01/28 13:02:56 martin Exp $"); #include #include @@ -793,7 +793,7 @@ ext2fs_gro_genealogy(struct mount *mp, k struct vnode **intermediate_node_ret) { struct vnode *vp, *dvp; - ino_t dotdot_ino; + ino_t dotdot_ino = -1; /* XXX gcc 4.8.3: maybe-uninitialized */ int error; KASSERT(mp != NULL);
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: hannken Date: Tue Jan 21 07:53:38 UTC 2014 Modified Files: src/sys/ufs/ext2fs: ext2fs_vnops.c Log Message: Move VOP_UNLOCK() after setting type to VNON like all other UFS file systems. To generate a diff of this commit: cvs rdiff -u -r1.108 -r1.109 src/sys/ufs/ext2fs/ext2fs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vnops.c diff -u src/sys/ufs/ext2fs/ext2fs_vnops.c:1.108 src/sys/ufs/ext2fs/ext2fs_vnops.c:1.109 --- src/sys/ufs/ext2fs/ext2fs_vnops.c:1.108 Fri Jan 17 10:55:03 2014 +++ src/sys/ufs/ext2fs/ext2fs_vnops.c Tue Jan 21 07:53:38 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vnops.c,v 1.108 2014/01/17 10:55:03 hannken Exp $ */ +/* $NetBSD: ext2fs_vnops.c,v 1.109 2014/01/21 07:53:38 hannken Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.108 2014/01/17 10:55:03 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.109 2014/01/21 07:53:38 hannken Exp $"); #include #include @@ -184,8 +184,8 @@ ext2fs_mknod(void *v) * checked to see if it is an alias of an existing entry in * the inode cache. */ - VOP_UNLOCK(*vpp); (*vpp)->v_type = VNON; + VOP_UNLOCK(*vpp); vgone(*vpp); error = VFS_VGET(mp, ino, vpp); if (error != 0) {
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jakllsch Date: Wed Nov 21 23:11:24 UTC 2012 Modified Files: src/sys/ufs/ext2fs: ext2fs.h ext2fs_alloc.c ext2fs_balloc.c ext2fs_extern.h ext2fs_inode.c ext2fs_readwrite.c ext2fs_vfsops.c ext2fs_vnops.c Log Message: Write support for the Ext4 Read-only Compatible Feature "huge_file". Primarily, this feature extends the inode block count field to 48 bits. Additionally, this feature allows this field to be represented in file system block size units rather than DEV_BSIZE units. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/ufs/ext2fs/ext2fs.h cvs rdiff -u -r1.42 -r1.43 src/sys/ufs/ext2fs/ext2fs_alloc.c cvs rdiff -u -r1.34 -r1.35 src/sys/ufs/ext2fs/ext2fs_balloc.c cvs rdiff -u -r1.45 -r1.46 src/sys/ufs/ext2fs/ext2fs_extern.h cvs rdiff -u -r1.75 -r1.76 src/sys/ufs/ext2fs/ext2fs_inode.c cvs rdiff -u -r1.61 -r1.62 src/sys/ufs/ext2fs/ext2fs_readwrite.c cvs rdiff -u -r1.166 -r1.167 src/sys/ufs/ext2fs/ext2fs_vfsops.c cvs rdiff -u -r1.104 -r1.105 src/sys/ufs/ext2fs/ext2fs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs.h diff -u src/sys/ufs/ext2fs/ext2fs.h:1.32 src/sys/ufs/ext2fs/ext2fs.h:1.33 --- src/sys/ufs/ext2fs/ext2fs.h:1.32 Wed Nov 21 20:45:35 2012 +++ src/sys/ufs/ext2fs/ext2fs.h Wed Nov 21 23:11:23 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.32 2012/11/21 20:45:35 jakllsch Exp $ */ +/* $NetBSD: ext2fs.h,v 1.33 2012/11/21 23:11:23 jakllsch Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -265,7 +265,8 @@ struct m_ext2fs { */ #define EXT2F_COMPAT_SUPP 0x #define EXT2F_ROCOMPAT_SUPP (EXT2F_ROCOMPAT_SPARSESUPER \ - | EXT2F_ROCOMPAT_LARGEFILE) + | EXT2F_ROCOMPAT_LARGEFILE \ + | EXT2F_ROCOMPAT_HUGE_FILE) #define EXT2F_INCOMPAT_SUPP EXT2F_INCOMPAT_FTYPE /* Index: src/sys/ufs/ext2fs/ext2fs_alloc.c diff -u src/sys/ufs/ext2fs/ext2fs_alloc.c:1.42 src/sys/ufs/ext2fs/ext2fs_alloc.c:1.43 --- src/sys/ufs/ext2fs/ext2fs_alloc.c:1.42 Sun Mar 6 04:46:26 2011 +++ src/sys/ufs/ext2fs/ext2fs_alloc.c Wed Nov 21 23:11:23 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_alloc.c,v 1.42 2011/03/06 04:46:26 rmind Exp $ */ +/* $NetBSD: ext2fs_alloc.c,v 1.43 2012/11/21 23:11:23 jakllsch Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.42 2011/03/06 04:46:26 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.43 2012/11/21 23:11:23 jakllsch Exp $"); #include #include @@ -135,7 +135,7 @@ ext2fs_alloc(struct inode *ip, daddr_t l bno = (daddr_t)ext2fs_hashalloc(ip, cg, bpref, fs->e2fs_bsize, ext2fs_alloccg); if (bno > 0) { - ip->i_e2fs_nblock += btodb(fs->e2fs_bsize); + ext2fs_setnblock(ip, ext2fs_nblock(ip) + btodb(fs->e2fs_bsize)); ip->i_flag |= IN_CHANGE | IN_UPDATE; *bnp = bno; return (0); Index: src/sys/ufs/ext2fs/ext2fs_balloc.c diff -u src/sys/ufs/ext2fs/ext2fs_balloc.c:1.34 src/sys/ufs/ext2fs/ext2fs_balloc.c:1.35 --- src/sys/ufs/ext2fs/ext2fs_balloc.c:1.34 Mon Oct 19 18:41:17 2009 +++ src/sys/ufs/ext2fs/ext2fs_balloc.c Wed Nov 21 23:11:23 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_balloc.c,v 1.34 2009/10/19 18:41:17 bouyer Exp $ */ +/* $NetBSD: ext2fs_balloc.c,v 1.35 2012/11/21 23:11:23 jakllsch Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_balloc.c,v 1.34 2009/10/19 18:41:17 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_balloc.c,v 1.35 2012/11/21 23:11:23 jakllsch Exp $"); #if defined(_KERNEL_OPT) #include "opt_uvmhist.h" @@ -343,7 +343,7 @@ fail: } } if (deallocated) { - ip->i_e2fs_nblock -= btodb(deallocated); + ext2fs_setnblock(ip, ext2fs_nblock(ip) - btodb(deallocated)); ip->i_e2fs_flags |= IN_CHANGE | IN_UPDATE; } return error; Index: src/sys/ufs/ext2fs/ext2fs_extern.h diff -u src/sys/ufs/ext2fs/ext2fs_extern.h:1.45 src/sys/ufs/ext2fs/ext2fs_extern.h:1.46 --- src/sys/ufs/ext2fs/ext2fs_extern.h:1.45 Sat Nov 17 16:03:48 2012 +++ src/sys/ufs/ext2fs/ext2fs_extern.h Wed Nov 21 23:11:23 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_extern.h,v 1.45 2012/11/17 16:03:48 jakllsch Exp $ */ +/* $NetBSD: ext2fs_extern.h,v 1.46 2012/11/21 23:11:23 jakllsch Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -110,6 +110,8 @@ int ext2fs_bmap(void *); /* ext2fs_inode.c */ uint64_t ext2fs_size(struct inode *); int ext2fs_setsize(struct inode *, uint64_t); +uint64_t ext2fs_nblock(struct inode *); +int ext2fs_setnblock(struct inode *, uint64_t); int ext2fs_update(struct vnode *, const struct timespec *, const struct timespec *, int); int ext2fs_truncate(struct vnode *, off_t, int, kauth_cred_t); Index: src/sys/ufs/ext2fs/ext2fs_inode.c diff -u src/sys/ufs/ext2fs/ext2fs_inode.c:1.75 src/sys/ufs/ext2fs/ext2fs_inode.c:1.76 --- src/sys/ufs/ext2fs/ext2fs_inode
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jakllsch Date: Wed Nov 21 20:45:36 UTC 2012 Modified Files: src/sys/ufs/ext2fs: ext2fs.h ext2fs_dinode.h Log Message: Add various newer Ext2 superblock feature bits and inode flag bits. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/ufs/ext2fs/ext2fs.h cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/ext2fs/ext2fs_dinode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs.h diff -u src/sys/ufs/ext2fs/ext2fs.h:1.31 src/sys/ufs/ext2fs/ext2fs.h:1.32 --- src/sys/ufs/ext2fs/ext2fs.h:1.31 Mon Nov 19 03:04:23 2012 +++ src/sys/ufs/ext2fs/ext2fs.h Wed Nov 21 20:45:35 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.31 2012/11/19 03:04:23 jakllsch Exp $ */ +/* $NetBSD: ext2fs.h,v 1.32 2012/11/21 20:45:35 jakllsch Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -205,7 +205,7 @@ struct m_ext2fs { #define EXT2F_COMPAT_DIRHASHINDEX 0x0020 #define EXT2F_COMPAT_BITS \ "\20" \ -"\06COMPAT_DIRHASHINDEX" \ + "\06COMPAT_DIRHASHINDEX" \ "\05COMPAT_RESIZE" \ "\04COMPAT_EXTATTR" \ "\03COMPAT_HASJOURNAL" \ @@ -215,8 +215,16 @@ struct m_ext2fs { #define EXT2F_ROCOMPAT_SPARSESUPER 0x0001 #define EXT2F_ROCOMPAT_LARGEFILE 0x0002 #define EXT2F_ROCOMPAT_BTREE_DIR 0x0004 +#define EXT2F_ROCOMPAT_HUGE_FILE 0x0008 +#define EXT2F_ROCOMPAT_GDT_CSUM 0x0010 +#define EXT2F_ROCOMPAT_DIR_NLINK 0x0020 +#define EXT2F_ROCOMPAT_EXTRA_ISIZE 0x0040 #define EXT2F_ROCOMPAT_BITS \ "\20" \ + "\07ROCOMPAT_EXTRA_ISIZE" \ + "\06ROCOMPAT_DIR_NLINK" \ + "\05ROCOMPAT_GDT_CSUM" \ + "\04ROCOMPAT_HUGE_FILE" \ "\03ROCOMPAT_BTREE_DIR" \ "\02ROCOMPAT_LARGEFILE" \ "\01ROCOMPAT_SPARSESUPER" @@ -225,8 +233,18 @@ struct m_ext2fs { #define EXT2F_INCOMPAT_FTYPE 0x0002 #define EXT2F_INCOMPAT_REPLAY_JOURNAL 0x0004 #define EXT2F_INCOMPAT_USES_JOURNAL 0x0008 +#define EXT2F_INCOMPAT_META_BG 0x0010 +#define EXT2F_INCOMPAT_EXTENTS 0x0040 +#define EXT2F_INCOMPAT_64BIT 0x0080 +#define EXT2F_INCOMPAT_MMP 0x0100 +#define EXT2F_INCOMPAT_FLEX_BG 0x0200 #define EXT2F_INCOMPAT_BITS \ "\20" \ + "\012INCOMPAT_FLEX_BG" \ + "\011INCOMPAT_MMP" \ + "\010INCOMPAT_64BIT" \ + "\07INCOMPAT_EXTENTS" \ + "\05INCOMPAT_META_BG" \ "\04INCOMPAT_USES_JOURNAL" \ "\03INCOMPAT_REPLAY_JOURNAL" \ "\02INCOMPAT_FTYPE" \ Index: src/sys/ufs/ext2fs/ext2fs_dinode.h diff -u src/sys/ufs/ext2fs/ext2fs_dinode.h:1.24 src/sys/ufs/ext2fs/ext2fs_dinode.h:1.25 --- src/sys/ufs/ext2fs/ext2fs_dinode.h:1.24 Mon Nov 19 00:36:21 2012 +++ src/sys/ufs/ext2fs/ext2fs_dinode.h Wed Nov 21 20:45:36 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_dinode.h,v 1.24 2012/11/19 00:36:21 jakllsch Exp $ */ +/* $NetBSD: ext2fs_dinode.h,v 1.25 2012/11/21 20:45:36 jakllsch Exp $ */ /* * Copyright (c) 1982, 1989, 1993 @@ -145,13 +145,23 @@ struct ext2fs_dinode { #define EXT2_IFSOCK 014 /* UNIX domain socket. */ /* file flags */ -#define EXT2_SECRM 0x0001 /* Secure deletion */ -#define EXT2_UNRM 0x0002 /* Undelete */ -#define EXT2_COMPR 0x0004 /* Compress file */ -#define EXT2_SYNC 0x0008 /* Synchronous updates */ -#define EXT2_IMMUTABLE 0x0010 /* Immutable file */ +#define EXT2_SECRM 0x0001 /* Secure deletion */ +#define EXT2_UNRM 0x0002 /* Undelete */ +#define EXT2_COMPR 0x0004 /* Compress file */ +#define EXT2_SYNC 0x0008 /* Synchronous updates */ +#define EXT2_IMMUTABLE 0x0010 /* Immutable file */ #define EXT2_APPEND 0x0020 /* writes to file may only append */ -#define EXT2_NODUMP 0x0040 /* do not dump file */ +#define EXT2_NODUMP 0x0040 /* do not dump file */ +#define EXT2_NOATIME 0x0080 /* do not update atime */ +#define EXT2_INDEX 0x1000 /* hash-indexed directory */ +#define EXT2_IMAGIC 0x2000 /* AFS directory */ +#define EXT2_JOURNAL_DATA 0x4000 /* file data should be journaled */ +#define EXT2_NOTAIL 0x8000 /* file tail should not be merged */ +#define EXT2_DIRSYNC 0x0001 /* dirsync behaviour */ +#define EXT2_TOPDIR 0x0002 /* Top of directory hierarchies*/ +#define EXT2_HUGE_FILE 0x0004 /* Set to each huge file */ +#define EXT2_EXTENTS 0x0008 /* Inode uses extents */ +#define EXT2_EOFBLOCKS 0x0040 /* Blocks allocated beyond EOF */ /* Size of on-disk inode. */ #define EXT2_REV0_DINODE_SIZE sizeof(struct ext2fs_dinode)
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jakllsch Date: Mon Nov 19 03:04:23 UTC 2012 Modified Files: src/sys/ufs/ext2fs: ext2fs.h Log Message: snprintb EXT2F_ROCOMPAT_SPARSESUPER as such. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/ufs/ext2fs/ext2fs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs.h diff -u src/sys/ufs/ext2fs/ext2fs.h:1.30 src/sys/ufs/ext2fs/ext2fs.h:1.31 --- src/sys/ufs/ext2fs/ext2fs.h:1.30 Sat Sep 1 17:01:24 2012 +++ src/sys/ufs/ext2fs/ext2fs.h Mon Nov 19 03:04:23 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.30 2012/09/01 17:01:24 christos Exp $ */ +/* $NetBSD: ext2fs.h,v 1.31 2012/11/19 03:04:23 jakllsch Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -219,7 +219,7 @@ struct m_ext2fs { "\20" \ "\03ROCOMPAT_BTREE_DIR" \ "\02ROCOMPAT_LARGEFILE" \ - "\01ROCOMPAT_SPARSEBUFFER" + "\01ROCOMPAT_SPARSESUPER" #define EXT2F_INCOMPAT_COMP 0x0001 #define EXT2F_INCOMPAT_FTYPE 0x0002
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jakllsch Date: Sun Nov 18 18:20:56 UTC 2012 Modified Files: src/sys/ufs/ext2fs: ext2fs_dinode.h Log Message: stylistic adjustment in comments To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/ext2fs/ext2fs_dinode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_dinode.h diff -u src/sys/ufs/ext2fs/ext2fs_dinode.h:1.22 src/sys/ufs/ext2fs/ext2fs_dinode.h:1.23 --- src/sys/ufs/ext2fs/ext2fs_dinode.h:1.22 Fri Nov 27 11:16:54 2009 +++ src/sys/ufs/ext2fs/ext2fs_dinode.h Sun Nov 18 18:20:56 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_dinode.h,v 1.22 2009/11/27 11:16:54 tsutsui Exp $ */ +/* $NetBSD: ext2fs_dinode.h,v 1.23 2012/11/18 18:20:56 jakllsch Exp $ */ /* * Copyright (c) 1982, 1989, 1993 @@ -100,11 +100,11 @@ struct ext2fs_dinode { uint16_t e2di_mode; /* 0: IFMT, permissions; see below. */ uint16_t e2di_uid; /* 2: Owner UID */ - uint32_t e2di_size; /* 4: Size (in bytes) */ - uint32_t e2di_atime; /* 8: Acces time */ - uint32_t e2di_ctime; /* 12: Create time */ - uint32_t e2di_mtime; /* 16: Modification time */ - uint32_t e2di_dtime; /* 20: Deletion time */ + uint32_t e2di_size; /* 4: Size (in bytes) */ + uint32_t e2di_atime; /* 8: Access time */ + uint32_t e2di_ctime; /* 12: Create time */ + uint32_t e2di_mtime; /* 16: Modification time */ + uint32_t e2di_dtime; /* 20: Deletion time */ uint16_t e2di_gid; /* 24: Owner GID */ uint16_t e2di_nlink; /* 26: File link count */ uint32_t e2di_nblock; /* 28: Blocks count */
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jakllsch Date: Sun Nov 18 17:59:56 UTC 2012 Modified Files: src/sys/ufs/ext2fs: ext2fs_bswap.c Log Message: correct comment to match code To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/ufs/ext2fs/ext2fs_bswap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_bswap.c diff -u src/sys/ufs/ext2fs/ext2fs_bswap.c:1.16 src/sys/ufs/ext2fs/ext2fs_bswap.c:1.17 --- src/sys/ufs/ext2fs/ext2fs_bswap.c:1.16 Mon Oct 19 18:41:17 2009 +++ src/sys/ufs/ext2fs/ext2fs_bswap.c Sun Nov 18 17:59:56 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_bswap.c,v 1.16 2009/10/19 18:41:17 bouyer Exp $ */ +/* $NetBSD: ext2fs_bswap.c,v 1.17 2012/11/18 17:59:56 jakllsch Exp $ */ /* * Copyright (c) 1997 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_bswap.c,v 1.16 2009/10/19 18:41:17 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_bswap.c,v 1.17 2012/11/18 17:59:56 jakllsch Exp $"); #include #include @@ -38,7 +38,7 @@ __KERNEL_RCSID(0, "$NetBSD: ext2fs_bswap #include #endif -/* These functions are only needed if native byte order is not big endian */ +/* These functions are only needed if native byte order is not little endian */ #if BYTE_ORDER == BIG_ENDIAN void e2fs_sb_bswap(struct ext2fs *old, struct ext2fs *new)
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jakllsch Date: Sat Nov 17 16:03:48 UTC 2012 Modified Files: src/sys/ufs/ext2fs: ext2fs_extern.h Log Message: Match prototype types to function types (u_int64_t vs. uint64_t). To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/ufs/ext2fs/ext2fs_extern.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_extern.h diff -u src/sys/ufs/ext2fs/ext2fs_extern.h:1.44 src/sys/ufs/ext2fs/ext2fs_extern.h:1.45 --- src/sys/ufs/ext2fs/ext2fs_extern.h:1.44 Wed May 9 00:21:18 2012 +++ src/sys/ufs/ext2fs/ext2fs_extern.h Sat Nov 17 16:03:48 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_extern.h,v 1.44 2012/05/09 00:21:18 riastradh Exp $ */ +/* $NetBSD: ext2fs_extern.h,v 1.45 2012/11/17 16:03:48 jakllsch Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -108,8 +108,8 @@ int ext2fs_gop_alloc(struct vnode *, off int ext2fs_bmap(void *); /* ext2fs_inode.c */ -u_int64_t ext2fs_size(struct inode *); -int ext2fs_setsize(struct inode *, u_int64_t); +uint64_t ext2fs_size(struct inode *); +int ext2fs_setsize(struct inode *, uint64_t); int ext2fs_update(struct vnode *, const struct timespec *, const struct timespec *, int); int ext2fs_truncate(struct vnode *, off_t, int, kauth_cred_t);
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Sat Sep 1 17:01:24 UTC 2012 Modified Files: src/sys/ufs/ext2fs: ext2fs.h ext2fs_vfsops.c Log Message: really print the incompatible bits. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/ufs/ext2fs/ext2fs.h cvs rdiff -u -r1.165 -r1.166 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs.h diff -u src/sys/ufs/ext2fs/ext2fs.h:1.29 src/sys/ufs/ext2fs/ext2fs.h:1.30 --- src/sys/ufs/ext2fs/ext2fs.h:1.29 Fri Nov 27 06:16:54 2009 +++ src/sys/ufs/ext2fs/ext2fs.h Sat Sep 1 13:01:24 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.29 2009/11/27 11:16:54 tsutsui Exp $ */ +/* $NetBSD: ext2fs.h,v 1.30 2012/09/01 17:01:24 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -198,15 +198,39 @@ struct m_ext2fs { /* compatible/incompatible features */ #define EXT2F_COMPAT_PREALLOC 0x0001 +#define EXT2F_COMPAT_AFS 0x0002 #define EXT2F_COMPAT_HASJOURNAL 0x0004 +#define EXT2F_COMPAT_EXTATTR 0x0008 #define EXT2F_COMPAT_RESIZE 0x0010 +#define EXT2F_COMPAT_DIRHASHINDEX 0x0020 +#define EXT2F_COMPAT_BITS \ + "\20" \ +"\06COMPAT_DIRHASHINDEX" \ + "\05COMPAT_RESIZE" \ + "\04COMPAT_EXTATTR" \ + "\03COMPAT_HASJOURNAL" \ + "\02COMPAT_AFS" \ + "\01COMPAT_PREALLOC" #define EXT2F_ROCOMPAT_SPARSESUPER 0x0001 #define EXT2F_ROCOMPAT_LARGEFILE 0x0002 #define EXT2F_ROCOMPAT_BTREE_DIR 0x0004 +#define EXT2F_ROCOMPAT_BITS \ + "\20" \ + "\03ROCOMPAT_BTREE_DIR" \ + "\02ROCOMPAT_LARGEFILE" \ + "\01ROCOMPAT_SPARSEBUFFER" #define EXT2F_INCOMPAT_COMP 0x0001 #define EXT2F_INCOMPAT_FTYPE 0x0002 +#define EXT2F_INCOMPAT_REPLAY_JOURNAL 0x0004 +#define EXT2F_INCOMPAT_USES_JOURNAL 0x0008 +#define EXT2F_INCOMPAT_BITS \ + "\20" \ + "\04INCOMPAT_USES_JOURNAL" \ + "\03INCOMPAT_REPLAY_JOURNAL" \ + "\02INCOMPAT_FTYPE" \ + "\01INCOMPAT_COMP" /* * Features supported in this implementation Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.165 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.166 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.165 Sat Sep 1 11:46:11 2012 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Sat Sep 1 13:01:24 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.165 2012/09/01 15:46:11 chs Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.166 2012/09/01 17:01:24 christos Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.165 2012/09/01 15:46:11 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.166 2012/09/01 17:01:24 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -1249,21 +1249,24 @@ ext2fs_checksb(struct ext2fs *fs, int ro return (EINVAL); /* XXX needs translation */ } if (fs2h32(fs->e2fs_rev) > E2FS_REV0) { + char buf[256]; if (fs2h32(fs->e2fs_first_ino) != EXT2_FIRSTINO) { printf("ext2fs: unsupported first inode position\n"); return (EINVAL); /* XXX needs translation */ } u32 = fs2h32(fs->e2fs_features_incompat) & ~EXT2F_INCOMPAT_SUPP; if (u32) { - printf("ext2fs: unsupported incompat feature 0x%x\n", - u32); - return (EINVAL); /* XXX needs translation */ + snprintb(buf, sizeof(buf), EXT2F_INCOMPAT_BITS, u32); + printf("ext2fs: unsupported incompat features: %s\n", + buf); + return EINVAL; /* XXX needs translation */ } u32 = fs2h32(fs->e2fs_features_rocompat) & ~EXT2F_ROCOMPAT_SUPP; if (!ronly && u32) { - printf("ext2fs: unsupported ro-incompat feature 0x%x\n", - u32); - return (EROFS); /* XXX needs translation */ + snprintb(buf, sizeof(buf), EXT2F_ROCOMPAT_BITS, u32); + printf("ext2fs: unsupported ro-incompat features: %s\n", + buf); + return EROFS; /* XXX needs translation */ } } return (0);
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: chs Date: Sat Sep 1 15:46:11 UTC 2012 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: when failing a mount due to unsupported features, print which features are involved. To generate a diff of this commit: cvs rdiff -u -r1.164 -r1.165 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.164 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.165 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.164 Mon Apr 30 22:51:28 2012 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Sat Sep 1 15:46:11 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.164 2012/04/30 22:51:28 rmind Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.165 2012/09/01 15:46:11 chs Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.164 2012/04/30 22:51:28 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.165 2012/09/01 15:46:11 chs Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -1228,20 +1228,21 @@ ext2fs_cgupdate(struct ufsmount *mp, int static int ext2fs_checksb(struct ext2fs *fs, int ronly) { + uint32_t u32; if (fs2h16(fs->e2fs_magic) != E2FS_MAGIC) { return (EINVAL); /* XXX needs translation */ } if (fs2h32(fs->e2fs_rev) > E2FS_REV1) { #ifdef DIAGNOSTIC - printf("Ext2 fs: unsupported revision number: %x\n", + printf("ext2fs: unsupported revision number: %x\n", fs2h32(fs->e2fs_rev)); #endif return (EINVAL); /* XXX needs translation */ } if (fs2h32(fs->e2fs_log_bsize) > 2) { /* block size = 1024|2048|4096 */ #ifdef DIAGNOSTIC - printf("Ext2 fs: bad block size: %d " + printf("ext2fs: bad block size: %d " "(expected <= 2 for ext2 fs)\n", fs2h32(fs->e2fs_log_bsize)); #endif @@ -1249,16 +1250,19 @@ ext2fs_checksb(struct ext2fs *fs, int ro } if (fs2h32(fs->e2fs_rev) > E2FS_REV0) { if (fs2h32(fs->e2fs_first_ino) != EXT2_FIRSTINO) { - printf("Ext2 fs: unsupported first inode position\n"); + printf("ext2fs: unsupported first inode position\n"); return (EINVAL); /* XXX needs translation */ } - if (fs2h32(fs->e2fs_features_incompat) & - ~EXT2F_INCOMPAT_SUPP) { - printf("Ext2 fs: unsupported optional feature\n"); + u32 = fs2h32(fs->e2fs_features_incompat) & ~EXT2F_INCOMPAT_SUPP; + if (u32) { + printf("ext2fs: unsupported incompat feature 0x%x\n", + u32); return (EINVAL); /* XXX needs translation */ } - if (!ronly && fs2h32(fs->e2fs_features_rocompat) & - ~EXT2F_ROCOMPAT_SUPP) { + u32 = fs2h32(fs->e2fs_features_rocompat) & ~EXT2F_ROCOMPAT_SUPP; + if (!ronly && u32) { + printf("ext2fs: unsupported ro-incompat feature 0x%x\n", + u32); return (EROFS); /* XXX needs translation */ } }
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: riastradh Date: Mon Jun 4 19:46:00 UTC 2012 Modified Files: src/sys/ufs/ext2fs: ext2fs_rename.c Log Message: Fix ext2fs's scary cross-block directory message too. (See rev. 1.3 of sys/ufs/ufs/ufs_rename.c for the analysis.) To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/ufs/ext2fs/ext2fs_rename.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_rename.c diff -u src/sys/ufs/ext2fs/ext2fs_rename.c:1.2 src/sys/ufs/ext2fs/ext2fs_rename.c:1.3 --- src/sys/ufs/ext2fs/ext2fs_rename.c:1.2 Thu May 10 19:08:34 2012 +++ src/sys/ufs/ext2fs/ext2fs_rename.c Mon Jun 4 19:45:59 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_rename.c,v 1.2 2012/05/10 19:08:34 riastradh Exp $ */ +/* $NetBSD: ext2fs_rename.c,v 1.3 2012/06/04 19:45:59 riastradh Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_rename.c,v 1.2 2012/05/10 19:08:34 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_rename.c,v 1.3 2012/06/04 19:45:59 riastradh Exp $"); #include #include @@ -487,10 +487,9 @@ ext2fs_gro_rename(struct mount *mp, kaut * inserting a new entry. That may invalidate fulr, which we * need in order to remove the old entry. In that case, we * need to recalculate what fulr should be. - * - * XXX I believe this is necessary only if tvp == NULL as well. */ - if (!reparent_p && ext2fs_rename_ulr_overlap_p(fulr, tulr)) { + if (!reparent_p && (tvp == NULL) && + ext2fs_rename_ulr_overlap_p(fulr, tulr)) { error = ext2fs_rename_recalculate_fulr(fdvp, fulr, tulr, fcnp); #if 0/* XXX */ if (error) /* XXX Try to back out changes? */ @@ -571,13 +570,11 @@ ext2fs_rename_recalculate_fulr(struct vn struct mount *mp; struct ufsmount *ump; /* XXX int is a silly type for this; blame ufsmount::um_dirblksiz. */ - int directory_block_mask; - unsigned long io_block_mask; + int dirblksiz; + doff_t search_start, search_end; doff_t offset; /* Offset of entry we're examining. */ - doff_t search_end; /* Limit to our search. */ struct buf *bp; /* I/O block we're examining. */ - char *dirbuf; /* Pointer into bp's data. */ - doff_t dirbuf_offset; /* Offset of dirbuf from directory start. */ + char *dirbuf; /* Pointer into directory at search_start. */ struct ext2fs_direct *ep; /* Pointer to the entry we're examining. */ /* XXX direct::d_reclen is 16-bit; * ufs_lookup_results::ulr_reclen is 32-bit. Blah. */ @@ -598,66 +595,55 @@ ext2fs_rename_recalculate_fulr(struct vn KASSERT(ump != NULL); KASSERT(ump == VTOI(dvp)->i_ump); - KASSERT(0 < ump->um_dirblksiz); - KASSERT((ump->um_dirblksiz & (ump->um_dirblksiz - 1)) == 0); - directory_block_mask = (ump->um_dirblksiz - 1); - - KASSERT(0 < mp->mnt_stat.f_iosize); - KASSERT((mp->mnt_stat.f_iosize & (mp->mnt_stat.f_iosize - 1)) == 0); - io_block_mask = (mp->mnt_stat.f_iosize - 1); + dirblksiz = ump->um_dirblksiz; + KASSERT(0 < dirblksiz); + KASSERT((dirblksiz & (dirblksiz - 1)) == 0); - offset = tulr->ulr_offset; + /* A directory block may not span across multiple I/O blocks. */ + KASSERT(dirblksiz <= mp->mnt_stat.f_iosize); + + /* Find the bounds of the search. */ + search_start = tulr->ulr_offset; KASSERT(fulr->ulr_reclen < (EXT2FS_MAXDIRSIZE - fulr->ulr_offset)); search_end = (fulr->ulr_offset + fulr->ulr_reclen); + /* Compaction must happen only within a directory block. (*) */ + KASSERT(search_start <= search_end); + KASSERT((search_end - (search_start &~ (dirblksiz - 1))) <= dirblksiz); + dirbuf = NULL; bp = NULL; - dirbuf_offset = offset; - error = ext2fs_blkatoff(dvp, (off_t)dirbuf_offset, &dirbuf, &bp); + error = ext2fs_blkatoff(dvp, (off_t)search_start, &dirbuf, &bp); if (error) return error; KASSERT(dirbuf != NULL); KASSERT(bp != NULL); + /* + * Guarantee we sha'n't go past the end of the buffer we got. + * dirbuf is bp->b_data + (search_start & (iosize - 1)), and + * the valid range is [bp->b_data, bp->b_data + bp->b_bcount). + */ + KASSERT((search_end - search_start) <= + (bp->b_bcount - (search_start & (mp->mnt_stat.f_iosize - 1; + prev_reclen = fulr->ulr_count; + offset = search_start; /* - * Search from offset to search_end for the entry matching + * Search from search_start to search_end for the entry matching * fcnp, which must be there because we found it before and it * should only at most have moved earlier. */ for (;;) { + KASSERT(search_start <= offset); KASSERT(offset < search_end); /* - * If we are at an I/O block boundary, fetch the next block. - */ - if ((offset & io_block_mask) == 0) { -#ifdef DIAGNOSTIC /* XXX */ - printf("%s: directory block of inode 0x%llx" - " extends across I/O block boundary," - " which shouldn't happen!\n", - mp->mnt_stat.f_mntonname, -
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: riastradh Date: Thu May 10 19:08:34 UTC 2012 Modified Files: src/sys/ufs/ext2fs: ext2fs_rename.c Log Message: Swap byte order of ext2fs_direct fields in ext2fs_rename_recalculate_fulr. Symptom found and fix tested by martin. ok martin To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/ext2fs/ext2fs_rename.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_rename.c diff -u src/sys/ufs/ext2fs/ext2fs_rename.c:1.1 src/sys/ufs/ext2fs/ext2fs_rename.c:1.2 --- src/sys/ufs/ext2fs/ext2fs_rename.c:1.1 Wed May 9 00:21:18 2012 +++ src/sys/ufs/ext2fs/ext2fs_rename.c Thu May 10 19:08:34 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_rename.c,v 1.1 2012/05/09 00:21:18 riastradh Exp $ */ +/* $NetBSD: ext2fs_rename.c,v 1.2 2012/05/10 19:08:34 riastradh Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_rename.c,v 1.1 2012/05/09 00:21:18 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_rename.c,v 1.2 2012/05/10 19:08:34 riastradh Exp $"); #include #include @@ -658,12 +658,12 @@ ext2fs_rename_recalculate_fulr(struct vn KASSERT(dirbuf_offset <= offset); ep = (struct ext2fs_direct *) (dirbuf + (offset - dirbuf_offset)); - reclen = ep->e2d_reclen; + reclen = fs2h16(ep->e2d_reclen); if (ep->e2d_ino == 0) goto next; /* Entry is unused. */ - if (ep->e2d_ino == WINO) + if (fs2h32(ep->e2d_ino) == WINO) goto next; /* Entry is whiteout. */ if (fcnp->cn_namelen != ep->e2d_namlen)
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: jakllsch Date: Tue Jul 27 05:15:56 UTC 2010 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: Make DEBUG_EXT2 work with 64-bit size_t. To generate a diff of this commit: cvs rdiff -u -r1.158 -r1.159 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.158 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.159 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.158 Wed Jul 21 17:52:13 2010 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Tue Jul 27 05:15:56 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.158 2010/07/21 17:52:13 hannken Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.159 2010/07/27 05:15:56 jakllsch Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.158 2010/07/21 17:52:13 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.159 2010/07/27 05:15:56 jakllsch Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -682,7 +682,7 @@ ump = NULL; #ifdef DEBUG_EXT2 - printf("ext2 sb size: %d\n", sizeof(struct ext2fs)); + printf("ext2 sb size: %zu\n", sizeof(struct ext2fs)); #endif error = bread(devvp, SBLOCK, SBSIZE, cred, 0, &bp); if (error) @@ -704,7 +704,7 @@ m_fs->e2fs_ronly = ronly; #ifdef DEBUG_EXT2 - printf("ext2 ino size %d\n", EXT2_DINODE_SIZE(m_fs)); + printf("ext2 ino size %zu\n", EXT2_DINODE_SIZE(m_fs)); #endif if (ronly == 0) { if (m_fs->e2fs.e2fs_state == E2FS_ISCLEAN)
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: mlelstv Date: Thu Feb 11 19:50:34 UTC 2010 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: There is no code left that uses disk size data, so don't query it. To generate a diff of this commit: cvs rdiff -u -r1.155 -r1.156 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.155 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.156 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.155 Sun Jan 31 10:37:57 2010 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Thu Feb 11 19:50:34 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.155 2010/01/31 10:37:57 mlelstv Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.156 2010/02/11 19:50:34 mlelstv Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.155 2010/01/31 10:37:57 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.156 2010/02/11 19:50:34 mlelstv Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -522,8 +522,6 @@ struct m_ext2fs *fs; struct ext2fs *newfs; int i, error; - uint64_t numsecs; - unsigned secsize; void *cp; struct ufsmount *ump; @@ -543,11 +541,6 @@ /* * Step 2: re-read superblock from disk. */ - error = getdisksize(devvp, &numsecs, &secsize); - if (error) { - brelse(bp, 0); - return (error); - } error = bread(devvp, SBLOCK, SBSIZE, NOCRED, 0, &bp); if (error) { brelse(bp, 0); @@ -669,8 +662,6 @@ struct m_ext2fs *m_fs; dev_t dev; int error, i, ronly; - uint64_t numsecs; - unsigned secsize; kauth_cred_t cred; struct proc *p; @@ -686,9 +677,6 @@ return (error); ronly = (mp->mnt_flag & MNT_RDONLY) != 0; - error = getdisksize(devvp, &numsecs, &secsize); - if (error) - return (error); bp = NULL; ump = NULL;
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: mlelstv Date: Sun Jan 31 10:37:57 UTC 2010 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: Fix block shift to work with different device block sizes. To generate a diff of this commit: cvs rdiff -u -r1.154 -r1.155 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.154 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.155 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.154 Sun Jan 31 10:36:20 2010 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Sun Jan 31 10:37:57 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.154 2010/01/31 10:36:20 mlelstv Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.155 2010/01/31 10:37:57 mlelstv Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.154 2010/01/31 10:36:20 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.155 2010/01/31 10:37:57 mlelstv Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -548,7 +548,7 @@ brelse(bp, 0); return (error); } - error = bread(devvp, (daddr_t)(SBOFF / secsize), SBSIZE, NOCRED, 0, &bp); + error = bread(devvp, SBLOCK, SBSIZE, NOCRED, 0, &bp); if (error) { brelse(bp, 0); return (error); @@ -568,8 +568,7 @@ fs->e2fs_ncg = howmany(fs->e2fs.e2fs_bcount - fs->e2fs.e2fs_first_dblock, fs->e2fs.e2fs_bpg); - /* XXX assume hw bsize = 512 */ - fs->e2fs_fsbtodb = fs->e2fs.e2fs_log_bsize + 1; + fs->e2fs_fsbtodb = fs->e2fs.e2fs_log_bsize + LOG_MINBSIZE - DEV_BSHIFT; fs->e2fs_bsize = MINBSIZE << fs->e2fs.e2fs_log_bsize; fs->e2fs_bshift = LOG_MINBSIZE + fs->e2fs.e2fs_log_bsize; fs->e2fs_qbmask = fs->e2fs_bsize - 1; @@ -697,7 +696,7 @@ #ifdef DEBUG_EXT2 printf("ext2 sb size: %d\n", sizeof(struct ext2fs)); #endif - error = bread(devvp, (SBOFF / secsize), SBSIZE, cred, 0, &bp); + error = bread(devvp, SBLOCK, SBSIZE, cred, 0, &bp); if (error) goto out; fs = (struct ext2fs *)bp->b_data; @@ -731,8 +730,7 @@ m_fs->e2fs_ncg = howmany(m_fs->e2fs.e2fs_bcount - m_fs->e2fs.e2fs_first_dblock, m_fs->e2fs.e2fs_bpg); - /* XXX assume hw bsize = 512 */ - m_fs->e2fs_fsbtodb = m_fs->e2fs.e2fs_log_bsize + 1; + m_fs->e2fs_fsbtodb = m_fs->e2fs.e2fs_log_bsize + LOG_MINBSIZE - DEV_BSHIFT; m_fs->e2fs_bsize = MINBSIZE << m_fs->e2fs.e2fs_log_bsize; m_fs->e2fs_bshift = LOG_MINBSIZE + m_fs->e2fs.e2fs_log_bsize; m_fs->e2fs_qbmask = m_fs->e2fs_bsize - 1;
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: mlelstv Date: Sun Jan 31 10:36:20 UTC 2010 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: Replace individual queries for partition information with new helper function. To generate a diff of this commit: cvs rdiff -u -r1.153 -r1.154 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.153 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.154 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.153 Fri Jan 8 11:35:11 2010 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Sun Jan 31 10:36:20 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.153 2010/01/08 11:35:11 pooka Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.154 2010/01/31 10:36:20 mlelstv Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.153 2010/01/08 11:35:11 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.154 2010/01/31 10:36:20 mlelstv Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -521,8 +521,9 @@ struct buf *bp; struct m_ext2fs *fs; struct ext2fs *newfs; - struct partinfo dpart; - int i, size, error; + int i, error; + uint64_t numsecs; + unsigned secsize; void *cp; struct ufsmount *ump; @@ -542,11 +543,12 @@ /* * Step 2: re-read superblock from disk. */ - if (VOP_IOCTL(devvp, DIOCGPART, &dpart, FREAD, NOCRED) != 0) - size = DEV_BSIZE; - else - size = dpart.disklab->d_secsize; - error = bread(devvp, (daddr_t)(SBOFF / size), SBSIZE, NOCRED, 0, &bp); + error = getdisksize(devvp, &numsecs, &secsize); + if (error) { + brelse(bp, 0); + return (error); + } + error = bread(devvp, (daddr_t)(SBOFF / secsize), SBSIZE, NOCRED, 0, &bp); if (error) { brelse(bp, 0); return (error); @@ -667,8 +669,9 @@ struct ext2fs *fs; struct m_ext2fs *m_fs; dev_t dev; - struct partinfo dpart; - int error, i, size, ronly; + int error, i, ronly; + uint64_t numsecs; + unsigned secsize; kauth_cred_t cred; struct proc *p; @@ -684,10 +687,9 @@ return (error); ronly = (mp->mnt_flag & MNT_RDONLY) != 0; - if (VOP_IOCTL(devvp, DIOCGPART, &dpart, FREAD, cred) != 0) - size = DEV_BSIZE; - else - size = dpart.disklab->d_secsize; + error = getdisksize(devvp, &numsecs, &secsize); + if (error) + return (error); bp = NULL; ump = NULL; @@ -695,7 +697,7 @@ #ifdef DEBUG_EXT2 printf("ext2 sb size: %d\n", sizeof(struct ext2fs)); #endif - error = bread(devvp, (SBOFF / size), SBSIZE, cred, 0, &bp); + error = bread(devvp, (SBOFF / secsize), SBSIZE, cred, 0, &bp); if (error) goto out; fs = (struct ext2fs *)bp->b_data;
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: tsutsui Date: Fri Nov 27 11:16:54 UTC 2009 Modified Files: src/sys/ufs/ext2fs: ext2fs.h ext2fs_dinode.h Log Message: Add definitions for more reserved inodes. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/ufs/ext2fs/ext2fs.h cvs rdiff -u -r1.21 -r1.22 src/sys/ufs/ext2fs/ext2fs_dinode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs.h diff -u src/sys/ufs/ext2fs/ext2fs.h:1.28 src/sys/ufs/ext2fs/ext2fs.h:1.29 --- src/sys/ufs/ext2fs/ext2fs.h:1.28 Mon Oct 19 18:41:17 2009 +++ src/sys/ufs/ext2fs/ext2fs.h Fri Nov 27 11:16:54 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.28 2009/10/19 18:41:17 bouyer Exp $ */ +/* $NetBSD: ext2fs.h,v 1.29 2009/11/27 11:16:54 tsutsui Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -198,6 +198,7 @@ /* compatible/incompatible features */ #define EXT2F_COMPAT_PREALLOC 0x0001 +#define EXT2F_COMPAT_HASJOURNAL 0x0004 #define EXT2F_COMPAT_RESIZE 0x0010 #define EXT2F_ROCOMPAT_SPARSESUPER 0x0001 Index: src/sys/ufs/ext2fs/ext2fs_dinode.h diff -u src/sys/ufs/ext2fs/ext2fs_dinode.h:1.21 src/sys/ufs/ext2fs/ext2fs_dinode.h:1.22 --- src/sys/ufs/ext2fs/ext2fs_dinode.h:1.21 Mon Oct 19 18:41:17 2009 +++ src/sys/ufs/ext2fs/ext2fs_dinode.h Fri Nov 27 11:16:54 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_dinode.h,v 1.21 2009/10/19 18:41:17 bouyer Exp $ */ +/* $NetBSD: ext2fs_dinode.h,v 1.22 2009/11/27 11:16:54 tsutsui Exp $ */ /* * Copyright (c) 1982, 1989, 1993 @@ -75,9 +75,15 @@ * 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_BADBLKINO ((ino_t)1) +#define EXT2_ROOTINO ((ino_t)2) +#define EXT2_ACLIDXINO ((ino_t)3) +#define EXT2_ACLDATAINO ((ino_t)4) +#define EXT2_BOOTLOADERINO ((ino_t)5) +#define EXT2_UNDELDIRINO ((ino_t)6) +#define EXT2_RESIZEINO ((ino_t)7) +#define EXT2_JOURNALINO ((ino_t)8) +#define EXT2_FIRSTINO ((ino_t)11) /* * A dinode contains all the meta-data associated with a UFS file.
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: pooka Date: Wed Oct 21 17:37:21 UTC 2009 Modified Files: src/sys/ufs/ext2fs: ext2fs_extern.h ext2fs_vfsops.c ext2fs_vnops.c Log Message: update i_uid and i_gid after chown To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/ufs/ext2fs/ext2fs_extern.h cvs rdiff -u -r1.151 -r1.152 src/sys/ufs/ext2fs/ext2fs_vfsops.c cvs rdiff -u -r1.90 -r1.91 src/sys/ufs/ext2fs/ext2fs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_extern.h diff -u src/sys/ufs/ext2fs/ext2fs_extern.h:1.41 src/sys/ufs/ext2fs/ext2fs_extern.h:1.42 --- src/sys/ufs/ext2fs/ext2fs_extern.h:1.41 Mon Oct 19 18:41:17 2009 +++ src/sys/ufs/ext2fs/ext2fs_extern.h Wed Oct 21 17:37:21 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_extern.h,v 1.41 2009/10/19 18:41:17 bouyer Exp $ */ +/* $NetBSD: ext2fs_extern.h,v 1.42 2009/10/21 17:37:21 pooka Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -138,6 +138,7 @@ int ext2fs_flushfiles(struct mount *, int); int ext2fs_sbupdate(struct ufsmount *, int); int ext2fs_cgupdate(struct ufsmount *, int); +void ext2fs_set_inode_guid(struct inode *); /* ext2fs_readwrite.c */ int ext2fs_read(void *); Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.151 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.152 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.151 Mon Oct 19 18:41:17 2009 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Wed Oct 21 17:37:21 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.151 2009/10/19 18:41:17 bouyer Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.152 2009/10/21 17:37:21 pooka Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.151 2009/10/19 18:41:17 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.152 2009/10/21 17:37:21 pooka Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -106,7 +106,6 @@ int ext2fs_sbupdate(struct ufsmount *, int); static int ext2fs_checksb(struct ext2fs *, int); -static void ext2fs_set_inode_guid(struct inode *); static struct sysctllog *ext2fs_sysctl_log; @@ -164,7 +163,7 @@ }; /* Fill in the inode uid/gid from ext2 halves. */ -static void +void ext2fs_set_inode_guid(struct inode *ip) { Index: src/sys/ufs/ext2fs/ext2fs_vnops.c diff -u src/sys/ufs/ext2fs/ext2fs_vnops.c:1.90 src/sys/ufs/ext2fs/ext2fs_vnops.c:1.91 --- src/sys/ufs/ext2fs/ext2fs_vnops.c:1.90 Mon Oct 19 18:41:17 2009 +++ src/sys/ufs/ext2fs/ext2fs_vnops.c Wed Oct 21 17:37:21 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vnops.c,v 1.90 2009/10/19 18:41:17 bouyer Exp $ */ +/* $NetBSD: ext2fs_vnops.c,v 1.91 2009/10/21 17:37:21 pooka Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.90 2009/10/19 18:41:17 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.91 2009/10/21 17:37:21 pooka Exp $"); #include #include @@ -502,8 +502,10 @@ ip->i_e2fs_gid_high = 0; ip->i_e2fs_uid_high = 0; } - if (ouid != uid || ogid != gid) + if (ouid != uid || ogid != gid) { + ext2fs_set_inode_guid(ip); ip->i_flag |= IN_CHANGE; + } if (ouid != uid && kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, NULL) != 0) ip->i_e2fs_mode &= ~ISUID;
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: tsutsui Date: Sat Sep 12 14:59:59 UTC 2009 Modified Files: src/sys/ufs/ext2fs: ext2fs_dir.h Log Message: Use proper macro, some KNF, fix typo. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/ufs/ext2fs/ext2fs_dir.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_dir.h diff -u src/sys/ufs/ext2fs/ext2fs_dir.h:1.16 src/sys/ufs/ext2fs/ext2fs_dir.h:1.17 --- src/sys/ufs/ext2fs/ext2fs_dir.h:1.16 Sat Sep 12 11:27:39 2009 +++ src/sys/ufs/ext2fs/ext2fs_dir.h Sat Sep 12 14:59:59 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_dir.h,v 1.16 2009/09/12 11:27:39 tsutsui Exp $ */ +/* $NetBSD: ext2fs_dir.h,v 1.17 2009/09/12 14:59:59 tsutsui Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -78,7 +78,7 @@ * quantity to keep down the cost of doing lookup on a 32-bit machine. */ #define doff_t int32_t -#define EXT2FS_MAXDIRSIZE (0x7fff) +#define EXT2FS_MAXDIRSIZE INT32_MAX /* * A directory consists of some number of blocks of e2fs_bsize bytes. @@ -117,7 +117,7 @@ char e2d_name[EXT2FS_MAXNAMLEN];/* name with length<=EXT2FS_MAXNAMLEN */ }; -/* Ext2 directory file types (not the same as FFS. Sigh. */ +/* Ext2 directory file types (not the same as FFS. Sigh.) */ #define EXT2_FT_UNKNOWN 0 #define EXT2_FT_REG_FILE1 #define EXT2_FT_DIR 2 @@ -135,7 +135,8 @@ static __inline uint8_t inot2ext2dt(uint16_t type) { - switch(type) { + + switch (type) { case E2IFTODT(EXT2_IFIFO): return EXT2_FT_FIFO; case E2IFTODT(EXT2_IFCHR): @@ -162,7 +163,7 @@ * without the d_name field, plus enough space for the name without a * terminating null byte, rounded up to a 4 byte boundary. */ -#define EXT2FS_DIRSIZ(len) (( 8 + len + 3) & ~3) +#define EXT2FS_DIRSIZ(len) roundup2(8 + len, 4) /* * Template for manipulating directories. Should use struct direct's,
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: tsutsui Date: Sat Sep 12 11:35:46 UTC 2009 Modified Files: src/sys/ufs/ext2fs: ext2fs_alloc.c ext2fs_lookup.c ext2fs_vnops.c Log Message: Whitespace nits. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/ufs/ext2fs/ext2fs_alloc.c cvs rdiff -u -r1.59 -r1.60 src/sys/ufs/ext2fs/ext2fs_lookup.c cvs rdiff -u -r1.88 -r1.89 src/sys/ufs/ext2fs/ext2fs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_alloc.c diff -u src/sys/ufs/ext2fs/ext2fs_alloc.c:1.39 src/sys/ufs/ext2fs/ext2fs_alloc.c:1.40 --- src/sys/ufs/ext2fs/ext2fs_alloc.c:1.39 Thu May 7 19:26:08 2009 +++ src/sys/ufs/ext2fs/ext2fs_alloc.c Sat Sep 12 11:35:46 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_alloc.c,v 1.39 2009/05/07 19:26:08 elad Exp $ */ +/* $NetBSD: ext2fs_alloc.c,v 1.40 2009/09/12 11:35:46 tsutsui Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.39 2009/05/07 19:26:08 elad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.40 2009/09/12 11:35:46 tsutsui Exp $"); #include #include @@ -90,8 +90,7 @@ static u_long ext2fs_dirpref(struct m_ext2fs *); static void ext2fs_fserr(struct m_ext2fs *, u_int, const char *); static u_long ext2fs_hashalloc(struct inode *, int, long, int, - daddr_t (*)(struct inode *, int, daddr_t, - int)); + daddr_t (*)(struct inode *, int, daddr_t, int)); static daddr_t ext2fs_nodealloccg(struct inode *, int, daddr_t, int); static daddr_t ext2fs_mapsearch(struct m_ext2fs *, char *, daddr_t); @@ -139,7 +138,7 @@ else cg = dtog(fs, bpref); bno = (daddr_t)ext2fs_hashalloc(ip, cg, bpref, fs->e2fs_bsize, - ext2fs_alloccg); + ext2fs_alloccg); if (bno > 0) { ip->i_e2fs_nblock += btodb(fs->e2fs_bsize); ip->i_flag |= IN_CHANGE | IN_UPDATE; Index: src/sys/ufs/ext2fs/ext2fs_lookup.c diff -u src/sys/ufs/ext2fs/ext2fs_lookup.c:1.59 src/sys/ufs/ext2fs/ext2fs_lookup.c:1.60 --- src/sys/ufs/ext2fs/ext2fs_lookup.c:1.59 Sat Sep 12 11:27:39 2009 +++ src/sys/ufs/ext2fs/ext2fs_lookup.c Sat Sep 12 11:35:46 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_lookup.c,v 1.59 2009/09/12 11:27:39 tsutsui Exp $ */ +/* $NetBSD: ext2fs_lookup.c,v 1.60 2009/09/12 11:35:46 tsutsui Exp $ */ /* * Modified for NetBSD 1.2E @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.59 2009/09/12 11:27:39 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.60 2009/09/12 11:35:46 tsutsui Exp $"); #include #include @@ -267,7 +267,7 @@ struct vnode *vdp = ap->a_dvp; /* vnode for directory being searched */ struct inode *dp = VTOI(vdp); /* inode for directory being searched */ struct buf *bp; /* a buffer of directory entries */ - struct ext2fs_direct *ep; /* the current directory entry */ + struct ext2fs_direct *ep; /* the current directory entry */ int entryoffsetinblock; /* offset of ep in bp's buffer */ enum {NONE, COMPACT, FOUND} slotstatus; doff_t slotoffset; /* offset of area with free space */ Index: src/sys/ufs/ext2fs/ext2fs_vnops.c diff -u src/sys/ufs/ext2fs/ext2fs_vnops.c:1.88 src/sys/ufs/ext2fs/ext2fs_vnops.c:1.89 --- src/sys/ufs/ext2fs/ext2fs_vnops.c:1.88 Fri Jul 3 21:17:42 2009 +++ src/sys/ufs/ext2fs/ext2fs_vnops.c Sat Sep 12 11:35:46 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vnops.c,v 1.88 2009/07/03 21:17:42 elad Exp $ */ +/* $NetBSD: ext2fs_vnops.c,v 1.89 2009/09/12 11:35:46 tsutsui Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.88 2009/07/03 21:17:42 elad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.89 2009/09/12 11:35:46 tsutsui Exp $"); #include #include @@ -622,7 +622,7 @@ /* * Rename system call. - * rename("foo", "bar"); + * rename("foo", "bar"); * is essentially * unlink("bar"); * link("foo", "bar"); @@ -739,14 +739,14 @@ goto abortit; } if ((ip->i_e2fs_mode & IFMT) == IFDIR) { - error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred); - if (!error && tvp) - error = VOP_ACCESS(tvp, VWRITE, tcnp->cn_cred); - if (error) { - VOP_UNLOCK(fvp, 0); - error = EACCES; - goto abortit; - } + error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred); + if (!error && tvp) + error = VOP_ACCESS(tvp, VWRITE, tcnp->cn_cred); + if (error) { + VOP_UNLOCK(fvp, 0); + error = EACCES; + goto abortit; + } /* * Avoid ".", "..", and aliases of "." for obvious reasons. */ @@ -1653,7 +1653,7 @@ { &vop_pathconf_desc, fifo_pathconf }, /* pathconf */ { &vop_advlock_desc, fifo_advlock }, /* advlock */ { &vop_bwrite_desc, vn_bwrite }, /* bwrite */ - { &vop_putpages_desc, fifo_putpages }, /* putpages */ + { &vop_putpages_desc, fifo_putpage
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: tsutsui Date: Sat Sep 12 11:27:39 UTC 2009 Modified Files: src/sys/ufs/ext2fs: ext2fs.h ext2fs_dinode.h ext2fs_dir.h ext2fs_inode.c ext2fs_lookup.c ext2fs_readwrite.c Log Message: Migrate from u_intNN_t to uintNN_t. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/ufs/ext2fs/ext2fs.h cvs rdiff -u -r1.19 -r1.20 src/sys/ufs/ext2fs/ext2fs_dinode.h cvs rdiff -u -r1.15 -r1.16 src/sys/ufs/ext2fs/ext2fs_dir.h cvs rdiff -u -r1.68 -r1.69 src/sys/ufs/ext2fs/ext2fs_inode.c cvs rdiff -u -r1.58 -r1.59 src/sys/ufs/ext2fs/ext2fs_lookup.c cvs rdiff -u -r1.53 -r1.54 src/sys/ufs/ext2fs/ext2fs_readwrite.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs.h diff -u src/sys/ufs/ext2fs/ext2fs.h:1.26 src/sys/ufs/ext2fs/ext2fs.h:1.27 --- src/sys/ufs/ext2fs/ext2fs.h:1.26 Tue Dec 25 18:33:49 2007 +++ src/sys/ufs/ext2fs/ext2fs.h Sat Sep 12 11:27:39 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.26 2007/12/25 18:33:49 perry Exp $ */ +/* $NetBSD: ext2fs.h,v 1.27 2009/09/12 11:27:39 tsutsui Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -131,46 +131,46 @@ * Super block for an ext2fs file system. */ struct ext2fs { - u_int32_t e2fs_icount; /* Inode count */ - u_int32_t e2fs_bcount; /* blocks count */ - u_int32_t e2fs_rbcount; /* reserved blocks count */ - u_int32_t e2fs_fbcount; /* free blocks count */ - u_int32_t e2fs_ficount; /* free inodes count */ - u_int32_t e2fs_first_dblock; /* first data block */ - u_int32_t e2fs_log_bsize; /* block size = 1024*(2^e2fs_log_bsize) */ - u_int32_t e2fs_fsize; /* fragment size */ - u_int32_t e2fs_bpg; /* blocks per group */ - u_int32_t e2fs_fpg; /* frags per group */ - u_int32_t e2fs_ipg; /* inodes per group */ - u_int32_t e2fs_mtime; /* mount time */ - u_int32_t e2fs_wtime; /* write time */ - u_int16_t e2fs_mnt_count; /* mount count */ - u_int16_t e2fs_max_mnt_count; /* max mount count */ - u_int16_t e2fs_magic; /* magic number */ - u_int16_t e2fs_state; /* file system state */ - u_int16_t e2fs_beh; /* behavior on errors */ - u_int16_t e2fs_minrev; /* minor revision level */ - u_int32_t e2fs_lastfsck; /* time of last fsck */ - u_int32_t e2fs_fsckintv; /* max time between fscks */ - u_int32_t e2fs_creator; /* creator OS */ - u_int32_t e2fs_rev; /* revision level */ - u_int16_t e2fs_ruid; /* default uid for reserved blocks */ - u_int16_t e2fs_rgid; /* default gid for reserved blocks */ + uint32_t e2fs_icount; /* Inode count */ + uint32_t e2fs_bcount; /* blocks count */ + uint32_t e2fs_rbcount; /* reserved blocks count */ + uint32_t e2fs_fbcount; /* free blocks count */ + uint32_t e2fs_ficount; /* free inodes count */ + uint32_t e2fs_first_dblock; /* first data block */ + uint32_t e2fs_log_bsize; /* block size = 1024*(2^e2fs_log_bsize) */ + uint32_t e2fs_fsize; /* fragment size */ + uint32_t e2fs_bpg; /* blocks per group */ + uint32_t e2fs_fpg; /* frags per group */ + uint32_t e2fs_ipg; /* inodes per group */ + uint32_t e2fs_mtime; /* mount time */ + uint32_t e2fs_wtime; /* write time */ + uint16_t e2fs_mnt_count; /* mount count */ + uint16_t e2fs_max_mnt_count; /* max mount count */ + uint16_t e2fs_magic; /* magic number */ + uint16_t e2fs_state; /* file system state */ + uint16_t e2fs_beh; /* behavior on errors */ + uint16_t e2fs_minrev; /* minor revision level */ + uint32_t e2fs_lastfsck; /* time of last fsck */ + uint32_t e2fs_fsckintv; /* max time between fscks */ + uint32_t e2fs_creator; /* creator OS */ + uint32_t e2fs_rev; /* revision level */ + uint16_t e2fs_ruid; /* default uid for reserved blocks */ + uint16_t e2fs_rgid; /* default gid for reserved blocks */ /* EXT2_DYNAMIC_REV superblocks */ - u_int32_t e2fs_first_ino; /* first non-reserved inode */ - u_int16_t e2fs_inode_size; /* size of inode structure */ - u_int16_t e2fs_block_group_nr; /* block grp number of this sblk*/ - u_int32_t e2fs_features_compat; /* compatible feature set */ - u_int32_t e2fs_features_incompat; /* incompatible feature set */ - u_int32_t e2fs_features_rocompat; /* RO-compatible feature set */ - u_int8_t e2fs_uuid[16]; /* 128-bit uuid for volume */ - char e2fs_vname[16]; /* volume name */ - char e2fs_fsmnt[64]; /* name mounted on */ - u_int32_t e2fs_algo; /* For compression */ - u_int8_t e2fs_prealloc; /* # of blocks to preallocate */ - u_int8_t e2fs_dir_prealloc; /* # of blocks to preallocate for dir */ - u_int16_t e2fs_reserved_ngdb; /* # of reserved gd blocks for resize */ - u_int32_t reserved2[204]; + uint32_t e2fs_first_ino; /* first non-reserved inode */ + uint16_t e2fs_inode_size; /* size of inode structure */ + uint16_t e2fs_block_group_nr; /* block grp number of this sblk*/ + uint32_t e2fs_features_compat; /* compatible feature set */ + uint32_t e2fs_features_incompat; /* inc
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: tsutsui Date: Sat Sep 12 02:50:38 UTC 2009 Modified Files: src/sys/ufs/ext2fs: ext2fs_extern.h ext2fs_vfsops.c Log Message: Reduce diffs a bit between ext2fs_reload() and ffs_reload(). To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/ufs/ext2fs/ext2fs_extern.h cvs rdiff -u -r1.148 -r1.149 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_extern.h diff -u src/sys/ufs/ext2fs/ext2fs_extern.h:1.39 src/sys/ufs/ext2fs/ext2fs_extern.h:1.40 --- src/sys/ufs/ext2fs/ext2fs_extern.h:1.39 Sat Jun 28 01:34:05 2008 +++ src/sys/ufs/ext2fs/ext2fs_extern.h Sat Sep 12 02:50:38 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_extern.h,v 1.39 2008/06/28 01:34:05 rumble Exp $ */ +/* $NetBSD: ext2fs_extern.h,v 1.40 2009/09/12 02:50:38 tsutsui Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -138,7 +138,7 @@ /* ext2fs_vfsops.c */ VFS_PROTOS(ext2fs); -int ext2fs_reload(struct mount *, kauth_cred_t); +int ext2fs_reload(struct mount *, kauth_cred_t, struct lwp *); int ext2fs_mountfs(struct vnode *, struct mount *); int ext2fs_flushfiles(struct mount *, int); int ext2fs_sbupdate(struct ufsmount *, int); Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.148 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.149 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.148 Sat Sep 12 02:32:14 2009 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Sat Sep 12 02:50:38 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.148 2009/09/12 02:32:14 tsutsui Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.149 2009/09/12 02:50:38 tsutsui Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.148 2009/09/12 02:32:14 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.149 2009/09/12 02:50:38 tsutsui Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -461,7 +461,7 @@ } if (mp->mnt_flag & MNT_RELOAD) { - error = ext2fs_reload(mp, l->l_cred); + error = ext2fs_reload(mp, l->l_cred, l); if (error) return (error); } @@ -522,9 +522,8 @@ * 6) re-read inode data for all active vnodes. */ int -ext2fs_reload(struct mount *mountp, kauth_cred_t cred) +ext2fs_reload(struct mount *mp, kauth_cred_t cred, struct lwp *l) { - struct lwp *l = curlwp; struct vnode *vp, *mvp, *devvp; struct inode *ip; struct buf *bp; @@ -533,14 +532,16 @@ struct partinfo dpart; int i, size, error; void *cp; + struct ufsmount *ump; - if ((mountp->mnt_flag & MNT_RDONLY) == 0) + if ((mp->mnt_flag & MNT_RDONLY) == 0) return (EINVAL); + ump = VFSTOUFS(mp); /* * Step 1: invalidate all cached meta-data. */ - devvp = VFSTOUFS(mountp)->um_devvp; + devvp = ump->um_devvp; vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); error = vinvalbuf(devvp, 0, cred, l, 0, 0); VOP_UNLOCK(devvp, 0); @@ -559,13 +560,13 @@ return (error); } newfs = (struct ext2fs *)bp->b_data; - error = ext2fs_checksb(newfs, (mountp->mnt_flag & MNT_RDONLY) != 0); + error = ext2fs_checksb(newfs, (mp->mnt_flag & MNT_RDONLY) != 0); if (error) { brelse(bp, 0); return (error); } - fs = VFSTOUFS(mountp)->um_e2fs; + fs = ump->um_e2fs; /* * copy in new superblock, and compute in-memory values */ @@ -605,17 +606,17 @@ } /* Allocate a marker vnode. */ - if ((mvp = vnalloc(mountp)) == NULL) - return (ENOMEM); + if ((mvp = vnalloc(mp)) == NULL) + return ENOMEM; /* * NOTE: not using the TAILQ_FOREACH here since in this loop vgone() * and vclean() can be called indirectly */ mutex_enter(&mntvnode_lock); loop: - for (vp = TAILQ_FIRST(&mountp->mnt_vnodelist); vp; vp = vunmark(mvp)) { + for (vp = TAILQ_FIRST(&mp->mnt_vnodelist); vp; vp = vunmark(mvp)) { vmark(mvp, vp); - if (vp->v_mount != mountp || vismarker(vp)) + if (vp->v_mount != mp || vismarker(vp)) continue; /* * Step 4: invalidate all inactive vnodes.
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: tsutsui Date: Sat Sep 12 02:32:14 UTC 2009 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: Add a missed brelse(9) call after bread(9) in ext2fs_reload(). This may close PR kern/28712 (ext2fs hang on mount after fsck). To generate a diff of this commit: cvs rdiff -u -r1.147 -r1.148 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.147 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.148 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.147 Sat Sep 12 02:25:39 2009 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Sat Sep 12 02:32:14 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.147 2009/09/12 02:25:39 tsutsui Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.148 2009/09/12 02:32:14 tsutsui Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.147 2009/09/12 02:25:39 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.148 2009/09/12 02:32:14 tsutsui Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -583,6 +583,7 @@ howmany(fs->e2fs_ncg, fs->e2fs_bsize / sizeof(struct ext2_gd)); fs->e2fs_ipb = fs->e2fs_bsize / EXT2_DINODE_SIZE(fs); fs->e2fs_itpg = fs->e2fs.e2fs_ipg / fs->e2fs_ipb; + brelse(bp, 0); /* * Step 3: re-read summary information from disk.
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: tsutsui Date: Sat Sep 12 02:25:39 UTC 2009 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: Pull a fix from ffs_vfsops.c rev 1.248: > Fix bug introduced in revision 1.174(*) where a NULL fspec with an MNT_UPDATE > command would always return EINVAL. This broke fsck on root, where fsck'ing > a dirty root would always return an error causing rc to resort in a reboot. (*) This is "Apply the NFS exports list rototill patch" change in ext2fs_vfsops.c rev 1.91. To generate a diff of this commit: cvs rdiff -u -r1.146 -r1.147 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.146 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.147 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.146 Sat Sep 12 01:43:52 2009 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Sat Sep 12 02:25:39 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.146 2009/09/12 01:43:52 tsutsui Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.147 2009/09/12 02:25:39 tsutsui Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.146 2009/09/12 01:43:52 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.147 2009/09/12 02:25:39 tsutsui Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -478,7 +478,7 @@ fs->e2fs_fmod = 1; } if (args->fspec == NULL) - return EINVAL; + return 0; } error = set_statvfs_info(path, UIO_USERSPACE, args->fspec,
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: tsutsui Date: Sat Sep 12 01:43:52 UTC 2009 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: Pull a fix for mount function from ffs_vfsops.c rev1.186: > Change ffs_mount, in MNT_UPDATE case, to check dev_t's for equality > instead of just vnode pointers. Fixes erroneous "does not match mounted > device" errors from mount(8) in the presence of MFS /dev, init.root, &c. To generate a diff of this commit: cvs rdiff -u -r1.145 -r1.146 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.145 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.146 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.145 Fri Sep 11 15:59:07 2009 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Sat Sep 12 01:43:52 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.145 2009/09/11 15:59:07 tsutsui Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.146 2009/09/12 01:43:52 tsutsui Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.145 2009/09/11 15:59:07 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.146 2009/09/12 01:43:52 tsutsui Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -362,8 +362,15 @@ * used for our initial mount */ ump = VFSTOUFS(mp); - if (devvp != ump->um_devvp) -error = EINVAL; + if (devvp != ump->um_devvp) { +if (devvp->v_rdev != ump->um_devvp->v_rdev) + error = EINVAL; +else { + vrele(devvp); + devvp = ump->um_devvp; + vref(devvp); +} + } } } else { if (!update) {
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: tsutsui Date: Fri Sep 11 15:59:07 UTC 2009 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: Fix botch around argument check in ext2fs_mount(). Taken from ffs_vfsops.c. Fixes LOCKDEBUG panic which is the same one mentioned in PR kern/41078 on trying to mount_ext2fs against a raw device, while that panic seems to have another route cause around module_autoload() in sys/miscfs/specfs/spec_vnops.c:spec_open(). To generate a diff of this commit: cvs rdiff -u -r1.144 -r1.145 src/sys/ufs/ext2fs/ext2fs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.144 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.145 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.144 Mon Jun 29 05:08:18 2009 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Fri Sep 11 15:59:07 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.144 2009/06/29 05:08:18 dholland Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.145 2009/09/11 15:59:07 tsutsui Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.144 2009/06/29 05:08:18 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.145 2009/09/11 15:59:07 tsutsui Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -384,14 +384,16 @@ * updating the mount is okay (for example, as far as securelevel goes) * which leaves us with the normal check. */ - accessmode = VREAD; - if (update ? - (mp->mnt_iflag & IMNT_WANTRDWR) != 0 : - (mp->mnt_flag & MNT_RDONLY) == 0) - accessmode |= VWRITE; - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); - error = genfs_can_mount(devvp, accessmode, l->l_cred); - VOP_UNLOCK(devvp, 0); + if (error == 0) { + accessmode = VREAD; + if (update ? + (mp->mnt_iflag & IMNT_WANTRDWR) != 0 : + (mp->mnt_flag & MNT_RDONLY) == 0) + accessmode |= VWRITE; + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); + error = genfs_can_mount(devvp, accessmode, l->l_cred); + VOP_UNLOCK(devvp, 0); + } if (error) { vrele(devvp);
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: lukem Date: Tue Apr 14 09:30:25 UTC 2009 Modified Files: src/sys/ufs/ext2fs: ext2fs_bswap.c Log Message: fix -Wsign-compare issue on bigendian platforms To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/ufs/ext2fs/ext2fs_bswap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_bswap.c diff -u src/sys/ufs/ext2fs/ext2fs_bswap.c:1.14 src/sys/ufs/ext2fs/ext2fs_bswap.c:1.15 --- src/sys/ufs/ext2fs/ext2fs_bswap.c:1.14 Sun Nov 23 10:09:25 2008 +++ src/sys/ufs/ext2fs/ext2fs_bswap.c Tue Apr 14 09:30:25 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_bswap.c,v 1.14 2008/11/23 10:09:25 mrg Exp $ */ +/* $NetBSD: ext2fs_bswap.c,v 1.15 2009/04/14 09:30:25 lukem Exp $ */ /* * Copyright (c) 1997 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_bswap.c,v 1.14 2008/11/23 10:09:25 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_bswap.c,v 1.15 2009/04/14 09:30:25 lukem Exp $"); #include #include @@ -90,7 +90,7 @@ { int i; - for (i = 0; i < (size / sizeof(struct ext2_gd)); i++) { + for (i = 0; i < (size / (int)sizeof(struct ext2_gd)); i++) { new[i].ext2bgd_b_bitmap = bswap32(old[i].ext2bgd_b_bitmap); new[i].ext2bgd_i_bitmap = bswap32(old[i].ext2bgd_i_bitmap); new[i].ext2bgd_i_tables = bswap32(old[i].ext2bgd_i_tables);