CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Sun Mar 10 17:36:33 UTC 2024 Modified Files: src/sys/ufs/ext2fs: ext2fs_dir.h Log Message: PR/58018: Damir Holovati: ext2fs readdir (d_type conversion error) To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 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.
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Sun Mar 10 17:36:33 UTC 2024 Modified Files: src/sys/ufs/ext2fs: ext2fs_dir.h Log Message: PR/58018: Damir Holovati: ext2fs readdir (d_type conversion error) To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 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.22 src/sys/ufs/ext2fs/ext2fs_dir.h:1.23 --- src/sys/ufs/ext2fs/ext2fs_dir.h:1.22 Sat Aug 6 21:47:11 2016 +++ src/sys/ufs/ext2fs/ext2fs_dir.h Sun Mar 10 13:36:33 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_dir.h,v 1.22 2016/08/07 01:47:11 kre Exp $ */ +/* $NetBSD: ext2fs_dir.h,v 1.23 2024/03/10 17:36:33 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -174,7 +174,7 @@ ext2dt2dt(uint8_t type) { switch (type) { case EXT2_FT_REG_FILE: - return DT_FIFO; + return DT_REG; case EXT2_FT_DIR: return DT_DIR; case EXT2_FT_CHRDEV:
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Sun Aug 27 16:35:51 UTC 2023 Modified Files: src/sys/ufs/ext2fs: ext2fs.h ext2fs_vfsops.c Log Message: - fix cgload/cgsave inconsistencies - add a constant for the rev 0 group descriptor size To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/ufs/ext2fs/ext2fs.h cvs rdiff -u -r1.224 -r1.225 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.
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Sun Aug 27 16:35:51 UTC 2023 Modified Files: src/sys/ufs/ext2fs: ext2fs.h ext2fs_vfsops.c Log Message: - fix cgload/cgsave inconsistencies - add a constant for the rev 0 group descriptor size To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/ufs/ext2fs/ext2fs.h cvs rdiff -u -r1.224 -r1.225 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.51 src/sys/ufs/ext2fs/ext2fs.h:1.52 --- src/sys/ufs/ext2fs/ext2fs.h:1.51 Sat Aug 26 01:22:50 2023 +++ src/sys/ufs/ext2fs/ext2fs.h Sun Aug 27 12:35:51 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.51 2023/08/26 05:22:50 riastradh Exp $ */ +/* $NetBSD: ext2fs.h,v 1.52 2023/08/27 16:35:51 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -444,6 +444,7 @@ struct ext2_gd { uint32_t reserved2_hi[3]; }; +#define E2FS_REV0_GD_SIZE (sizeof(struct ext2_gd) / 2) /* 32 */ #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 */ Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.224 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.225 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.224 Sat Aug 26 17:56:23 2023 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Sun Aug 27 12:35:51 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.224 2023/08/26 21:56:23 christos Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.225 2023/08/27 16:35:51 christos Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.224 2023/08/26 21:56:23 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.225 2023/08/27 16:35:51 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -179,8 +179,9 @@ e2fs_cgload(const char *ondisk, struct e } } else { for (int i = 0; i < lim; i++, optr++, iptr += sh) { - memcpy(optr, iptr, 32); - memset((char *)optr + 32, 0, sizeof(*optr) - 32); + memcpy(optr, iptr, E2FS_REV0_GD_SIZE); + memset((char *)optr + E2FS_REV0_GD_SIZE, 0, + sizeof(*optr) - E2FS_REV0_GD_SIZE); } } } @@ -202,11 +203,11 @@ e2fs_cgsave(const struct ext2_gd *inmemo if (shift_cg_entry_size > 6) { for (int i = 0; i < lim; i++, iptr++, optr += sh) { memcpy(optr, iptr, sizeof(*iptr)); - memset(optr + sizeof(*optr), 0, sh - sizeof(*iptr)); + memset(optr + sizeof(*iptr), 0, sh - sizeof(*iptr)); } } else { for (int i = 0; i < lim; i++, iptr++, optr += sh) { - memcpy(optr, iptr, 32); + memcpy(optr, iptr, E2FS_REV0_GD_SIZE); } } } @@ -653,7 +654,7 @@ ext2fs_reload(struct mount *mp, kauth_cr } e2fs_cgload(bp->b_data, >e2fs_gd[i * fs->e2fs_bsize / sizeof(struct ext2_gd)], - fs->e2fs_bsize, 1 << fs->e2fs_group_desc_shift); + fs->e2fs_bsize, fs->e2fs_group_desc_shift); brelse(bp, 0); } @@ -769,7 +770,8 @@ ext2fs_mountfs(struct vnode *devvp, stru m_fs->e2fs_bsize, 0, ); if (error) goto out1; - e2fs_cgload(bp->b_data, _fs->e2fs_gd[i * sh], + e2fs_cgload(bp->b_data, _fs->e2fs_gd[i * m_fs->e2fs_bsize + / sizeof(struct ext2_gd)], m_fs->e2fs_bsize, m_fs->e2fs_group_desc_shift); brelse(bp, 0); bp = NULL;
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Sat Aug 26 22:08:22 UTC 2023 Modified Files: src/sys/ufs/ext2fs: ext2fs_alloc.c Log Message: fix incorrect test To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 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.55 src/sys/ufs/ext2fs/ext2fs_alloc.c:1.56 --- src/sys/ufs/ext2fs/ext2fs_alloc.c:1.55 Sat Aug 26 17:37:28 2023 +++ src/sys/ufs/ext2fs/ext2fs_alloc.c Sat Aug 26 18:08:22 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_alloc.c,v 1.55 2023/08/26 21:37:28 christos Exp $ */ +/* $NetBSD: ext2fs_alloc.c,v 1.56 2023/08/26 22:08:22 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.55 2023/08/26 21:37:28 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.56 2023/08/26 22:08:22 christos Exp $"); #include #include @@ -448,7 +448,7 @@ ext2fs_nodealloccg(struct inode *ip, int if (ipref == -1) ipref = 0; fs = ip->i_e2fs; - if (fs->e2fs_gd[cg].ext2bgd_nifree == 0 || + if (fs->e2fs_gd[cg].ext2bgd_nifree == 0 && fs->e2fs_gd[cg].ext2bgd_nifree_hi == 0) return 0; error = bread(ip->i_devvp, EXT2_FSBTODB64(fs,
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Sat Aug 26 22:08:22 UTC 2023 Modified Files: src/sys/ufs/ext2fs: ext2fs_alloc.c Log Message: fix incorrect test To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 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.
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Sat Aug 26 21:56:23 UTC 2023 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: fix kmem_free size for e2fs_gd To generate a diff of this commit: cvs rdiff -u -r1.223 -r1.224 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.223 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.224 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.223 Sat Aug 26 01:22:50 2023 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Sat Aug 26 17:56:23 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.223 2023/08/26 05:22:50 riastradh Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.224 2023/08/26 21:56:23 christos Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.223 2023/08/26 05:22:50 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.224 2023/08/26 21:56:23 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -767,11 +767,8 @@ ext2fs_mountfs(struct vnode *devvp, stru EXT2_FSBTODB(m_fs, m_fs->e2fs.e2fs_first_dblock + 1 /* superblock */ + i), m_fs->e2fs_bsize, 0, ); - if (error) { - kmem_free(m_fs->e2fs_gd, - m_fs->e2fs_ngdb * m_fs->e2fs_bsize); - goto out; - } + if (error) + goto out1; e2fs_cgload(bp->b_data, _fs->e2fs_gd[i * sh], m_fs->e2fs_bsize, m_fs->e2fs_group_desc_shift); brelse(bp, 0); @@ -779,10 +776,8 @@ ext2fs_mountfs(struct vnode *devvp, stru } error = ext2fs_cg_verify_and_initialize(devvp, m_fs, ronly); - if (error) { - kmem_free(m_fs->e2fs_gd, m_fs->e2fs_ngdb * m_fs->e2fs_bsize); - goto out; - } + if (error) + goto out1; mp->mnt_data = ump; mp->mnt_stat.f_fsidx.__fsid_val[0] = (long)dev; @@ -807,6 +802,8 @@ ext2fs_mountfs(struct vnode *devvp, stru spec_node_setmountedfs(devvp, mp); return 0; +out1: + kmem_free(m_fs->e2fs_gd, m_fs->e2fs_ngdb * sh * sizeof(struct ext2_gd)); out: if (bp != NULL) brelse(bp, 0); @@ -847,7 +844,8 @@ ext2fs_unmount(struct mount *mp, int mnt error = VOP_CLOSE(ump->um_devvp, fs->e2fs_ronly ? FREAD : FREAD|FWRITE, NOCRED); vput(ump->um_devvp); - kmem_free(fs->e2fs_gd, fs->e2fs_ngdb * fs->e2fs_bsize); + int32_t sh = fs->e2fs_bsize >> fs->e2fs_group_desc_shift; + kmem_free(fs->e2fs_gd, fs->e2fs_ngdb * sh * sizeof(struct ext2_gd)); kmem_free(fs, sizeof(*fs)); kmem_free(ump, sizeof(*ump)); mp->mnt_data = NULL;
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Sat Aug 26 21:56:23 UTC 2023 Modified Files: src/sys/ufs/ext2fs: ext2fs_vfsops.c Log Message: fix kmem_free size for e2fs_gd To generate a diff of this commit: cvs rdiff -u -r1.223 -r1.224 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.
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Sat Aug 26 21:37:28 UTC 2023 Modified Files: src/sys/ufs/ext2fs: ext2fs_alloc.c Log Message: Fix metadata_cksum (Vladimir Serbinenko) Current code always assumes that CG uses crc16. Yet when metadata_cksum is enabled then it uses truncated crc32c. This patch doesn't implement full metadata_cksum, just allows volumes with metadata_cksum to be mounted read-only. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 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.54 src/sys/ufs/ext2fs/ext2fs_alloc.c:1.55 --- src/sys/ufs/ext2fs/ext2fs_alloc.c:1.54 Sat Aug 26 01:22:50 2023 +++ src/sys/ufs/ext2fs/ext2fs_alloc.c Sat Aug 26 17:37:28 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_alloc.c,v 1.54 2023/08/26 05:22:50 riastradh Exp $ */ +/* $NetBSD: ext2fs_alloc.c,v 1.55 2023/08/26 21:37:28 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.54 2023/08/26 05:22:50 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.55 2023/08/26 21:37:28 christos Exp $"); #include #include @@ -710,6 +710,85 @@ ext2fs_cg_update(struct m_ext2fs *fs, in gd->ext2bgd_checksum = ext2fs_cg_get_csum(fs, cg, gd); } +static const uint32_t ext2fs_crc32c_table[256] = { + 0x, 0xf26b8303, 0xe13b70f7, 0x1350f3f4, + 0xc79a971f, 0x35f1141c, 0x26a1e7e8, 0xd4ca64eb, + 0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b, + 0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24, + 0x105ec76f, 0xe235446c, 0xf165b798, 0x030e349b, + 0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384, + 0x9a879fa0, 0x68ec1ca3, 0x7bbcef57, 0x89d76c54, + 0x5d1d08bf, 0xaf768bbc, 0xbc267848, 0x4e4dfb4b, + 0x20bd8ede, 0xd2d60ddd, 0xc186fe29, 0x33ed7d2a, + 0xe72719c1, 0x154c9ac2, 0x061c6936, 0xf477ea35, + 0xaa64d611, 0x580f5512, 0x4b5fa6e6, 0xb93425e5, + 0x6dfe410e, 0x9f95c20d, 0x8cc531f9, 0x7eaeb2fa, + 0x30e349b1, 0xc288cab2, 0xd1d83946, 0x23b3ba45, + 0xf779deae, 0x05125dad, 0x1642ae59, 0xe4292d5a, + 0xba3a117e, 0x4851927d, 0x5b016189, 0xa96ae28a, + 0x7da08661, 0x8fcb0562, 0x9c9bf696, 0x6ef07595, + 0x417b1dbc, 0xb3109ebf, 0xa0406d4b, 0x522bee48, + 0x86e18aa3, 0x748a09a0, 0x67dafa54, 0x95b17957, + 0xcba24573, 0x39c9c670, 0x2a993584, 0xd8f2b687, + 0x0c38d26c, 0xfe53516f, 0xed03a29b, 0x1f682198, + 0x5125dad3, 0xa34e59d0, 0xb01eaa24, 0x42752927, + 0x96bf4dcc, 0x64d4cecf, 0x77843d3b, 0x85efbe38, + 0xdbfc821c, 0x2997011f, 0x3ac7f2eb, 0xc8ac71e8, + 0x1c661503, 0xee0d9600, 0xfd5d65f4, 0x0f36e6f7, + 0x61c69362, 0x93ad1061, 0x80fde395, 0x72966096, + 0xa65c047d, 0x5437877e, 0x4767748a, 0xb50cf789, + 0xeb1fcbad, 0x197448ae, 0x0a24bb5a, 0xf84f3859, + 0x2c855cb2, 0xdeeedfb1, 0xcdbe2c45, 0x3fd5af46, + 0x7198540d, 0x83f3d70e, 0x90a324fa, 0x62c8a7f9, + 0xb602c312, 0x44694011, 0x5739b3e5, 0xa55230e6, + 0xfb410cc2, 0x092a8fc1, 0x1a7a7c35, 0xe811ff36, + 0x3cdb9bdd, 0xceb018de, 0xdde0eb2a, 0x2f8b6829, + 0x82f63b78, 0x709db87b, 0x63cd4b8f, 0x91a6c88c, + 0x456cac67, 0xb7072f64, 0xa457dc90, 0x563c5f93, + 0x082f63b7, 0xfa44e0b4, 0xe9141340, 0x1b7f9043, + 0xcfb5f4a8, 0x3dde77ab, 0x2e8e845f, 0xdce5075c, + 0x92a8fc17, 0x60c37f14, 0x73938ce0, 0x81f80fe3, + 0x55326b08, 0xa759e80b, 0xb4091bff, 0x466298fc, + 0x1871a4d8, 0xea1a27db, 0xf94ad42f, 0x0b21572c, + 0xdfeb33c7, 0x2d80b0c4, 0x3ed04330, 0xccbbc033, + 0xa24bb5a6, 0x502036a5, 0x4370c551, 0xb11b4652, + 0x65d122b9, 0x97baa1ba, 0x84ea524e, 0x7681d14d, + 0x2892ed69, 0xdaf96e6a, 0xc9a99d9e, 0x3bc21e9d, + 0xef087a76, 0x1d63f975, 0x0e330a81, 0xfc588982, + 0xb21572c9, 0x407ef1ca, 0x532e023e, 0xa145813d, + 0x758fe5d6, 0x87e466d5, 0x94b49521, 0x66df1622, + 0x38cc2a06, 0xcaa7a905, 0xd9f75af1, 0x2b9cd9f2, + 0xff56bd19, 0x0d3d3e1a, 0x1e6dcdee, 0xec064eed, + 0xc38d26c4, 0x31e6a5c7, 0x22b65633, 0xd0ddd530, + 0x0417b1db, 0xf67c32d8, 0xe52cc12c, 0x1747422f, + 0x49547e0b, 0xbb3ffd08, 0xa86f0efc, 0x5a048dff, + 0x8ecee914, 0x7ca56a17, 0x6ff599e3, 0x9d9e1ae0, + 0xd3d3e1ab, 0x21b862a8, 0x32e8915c, 0xc083125f, + 0x144976b4, 0xe622f5b7, 0xf5720643, 0x07198540, + 0x590ab964, 0xab613a67, 0xb831c993, 0x4a5a4a90, + 0x9e902e7b, 0x6cfbad78, 0x7fab5e8c, 0x8dc0dd8f, + 0xe330a81a, 0x115b2b19, 0x020bd8ed, 0xf0605bee, + 0x24aa3f05, 0xd6c1bc06, 0xc5914ff2, 0x37faccf1, + 0x69e9f0d5, 0x9b8273d6, 0x88d28022, 0x7ab90321, + 0xae7367ca, 0x5c18e4c9, 0x4f48173d, 0xbd23943e, + 0xf36e6f75, 0x0105ec76, 0x12551f82, 0xe03e9c81, + 0x34f4f86a, 0xc69f7b69, 0xd5cf889d, 0x27a40b9e, + 0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e, + 0xbe2da0a5, 0x4c4623a6, 0x5f16d052, 0xad7d5351, +}; + +static uint32_t +ext2fs_crc32c(uint32_t last, const void *vbuf, size_t len) +{ + uint32_t crc = last; + const uint8_t *buf = vbuf; + + while (len--) + crc = ext2fs_crc32c_table[(crc ^ *buf++) & 0xff] ^ (crc >> 8); + + return crc; +} + /* *
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Sat Aug 26 21:37:28 UTC 2023 Modified Files: src/sys/ufs/ext2fs: ext2fs_alloc.c Log Message: Fix metadata_cksum (Vladimir Serbinenko) Current code always assumes that CG uses crc16. Yet when metadata_cksum is enabled then it uses truncated crc32c. This patch doesn't implement full metadata_cksum, just allows volumes with metadata_cksum to be mounted read-only. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 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.
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: riastradh Date: Sat Aug 26 05:22:50 UTC 2023 Modified Files: src/sys/ufs/ext2fs: ext2fs.h ext2fs_alloc.c ext2fs_bmap.c ext2fs_bswap.c ext2fs_extents.h ext2fs_extern.h ext2fs_htree.c ext2fs_inode.c ext2fs_lookup.c ext2fs_rename.c ext2fs_vfsops.c ext2fs_vnops.c Log Message: ext2fs: Nix trailing whitespace. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/ufs/ext2fs/ext2fs.h cvs rdiff -u -r1.53 -r1.54 src/sys/ufs/ext2fs/ext2fs_alloc.c cvs rdiff -u -r1.30 -r1.31 src/sys/ufs/ext2fs/ext2fs_bmap.c cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/ext2fs/ext2fs_bswap.c cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/ext2fs/ext2fs_extents.h cvs rdiff -u -r1.56 -r1.57 src/sys/ufs/ext2fs/ext2fs_extern.h cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/ext2fs/ext2fs_htree.c cvs rdiff -u -r1.90 -r1.91 src/sys/ufs/ext2fs/ext2fs_inode.c cvs rdiff -u -r1.93 -r1.94 src/sys/ufs/ext2fs/ext2fs_lookup.c cvs rdiff -u -r1.12 -r1.13 src/sys/ufs/ext2fs/ext2fs_rename.c cvs rdiff -u -r1.222 -r1.223 src/sys/ufs/ext2fs/ext2fs_vfsops.c cvs rdiff -u -r1.137 -r1.138 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.50 src/sys/ufs/ext2fs/ext2fs.h:1.51 --- src/sys/ufs/ext2fs/ext2fs.h:1.50 Sat Aug 26 05:18:17 2023 +++ src/sys/ufs/ext2fs/ext2fs.h Sat Aug 26 05:22:50 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.50 2023/08/26 05:18:17 riastradh Exp $ */ +/* $NetBSD: ext2fs.h,v 1.51 2023/08/26 05:22:50 riastradh Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -177,7 +177,7 @@ 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 */ - + /* Additional fields */ char e3fs_journal_uuid[16];/* uuid of journal superblock */ uint32_t e3fs_journal_inum; /* inode number of journal file */ @@ -356,7 +356,7 @@ struct m_ext2fs { * - EXT2F_ROCOMPAT_SPARSESUPER *superblock backups stored only in cg_has_sb(bno) groups * - EXT2F_ROCOMPAT_LARGEFILE - *use e2di_size_high in struct ext2fs_dinode to store + *use e2di_size_high in struct ext2fs_dinode to store *upper 32bit of size for >2GB files * - EXT2F_INCOMPAT_FTYPE *store file type to e2d_type in struct ext2fs_direct @@ -424,7 +424,7 @@ struct ext2_gd { uint16_t ext2bgd_ndirs; /* number of directories */ /* - * Following only valid when either GDT_CSUM (AKA uninit_bg) + * 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, ...)*/ @@ -450,7 +450,7 @@ struct ext2_gd { #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 Index: src/sys/ufs/ext2fs/ext2fs_alloc.c diff -u src/sys/ufs/ext2fs/ext2fs_alloc.c:1.53 src/sys/ufs/ext2fs/ext2fs_alloc.c:1.54 --- src/sys/ufs/ext2fs/ext2fs_alloc.c:1.53 Fri Aug 25 16:50:23 2023 +++ src/sys/ufs/ext2fs/ext2fs_alloc.c Sat Aug 26 05:22:50 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_alloc.c,v 1.53 2023/08/25 16:50:23 christos Exp $ */ +/* $NetBSD: ext2fs_alloc.c,v 1.54 2023/08/26 05:22:50 riastradh Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.53 2023/08/25 16:50:23 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.54 2023/08/26 05:22:50 riastradh Exp $"); #include #include @@ -667,7 +667,7 @@ ext2fs_cg_update(struct m_ext2fs *fs, in if (nifree) { uint32_t ext2bgd_nifree = fs2h16(gd->ext2bgd_nifree) | (fs2h16(gd->ext2bgd_nifree_hi) << 16); - ext2bgd_nifree += nifree; + ext2bgd_nifree += nifree; gd->ext2bgd_nifree = h2fs16(ext2bgd_nifree); gd->ext2bgd_nifree_hi = h2fs16(ext2bgd_nifree >> 16); /* @@ -696,7 +696,6 @@ ext2fs_cg_update(struct m_ext2fs *fs, in ext2bgd_nbfree += nbfree; gd->ext2bgd_nbfree = h2fs16(ext2bgd_nbfree); gd->ext2bgd_nbfree_hi = h2fs16(ext2bgd_nbfree >> 16); - } if (ndirs) { @@ -821,7 +820,7 @@ ext2fs_cg_verify_and_initialize(struct v (int)fs->e2fs_bsize, 0, 0); clrbuf(bp); } - + bdwrite(bp); } Index: src/sys/ufs/ext2fs/ext2fs_bmap.c diff -u src/sys/ufs/ext2fs/ext2fs_bmap.c:1.30 src/sys/ufs/ext2fs/ext2fs_bmap.c:1.31 --- src/sys/ufs/ext2fs/ext2fs_bmap.c:1.30 Sun Aug 14 11:26:35 2016 +++ src/sys/ufs/ext2fs/ext2fs_bmap.c Sat Aug 26 05:22:50 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_bmap.c,v 1.30 2016/08/14 11:26:35 jdolecek Exp $ */ +/* $NetBSD: ext2fs_bmap.c,v 1.31
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: riastradh Date: Sat Aug 26 05:22:50 UTC 2023 Modified Files: src/sys/ufs/ext2fs: ext2fs.h ext2fs_alloc.c ext2fs_bmap.c ext2fs_bswap.c ext2fs_extents.h ext2fs_extern.h ext2fs_htree.c ext2fs_inode.c ext2fs_lookup.c ext2fs_rename.c ext2fs_vfsops.c ext2fs_vnops.c Log Message: ext2fs: Nix trailing whitespace. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/ufs/ext2fs/ext2fs.h cvs rdiff -u -r1.53 -r1.54 src/sys/ufs/ext2fs/ext2fs_alloc.c cvs rdiff -u -r1.30 -r1.31 src/sys/ufs/ext2fs/ext2fs_bmap.c cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/ext2fs/ext2fs_bswap.c cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/ext2fs/ext2fs_extents.h cvs rdiff -u -r1.56 -r1.57 src/sys/ufs/ext2fs/ext2fs_extern.h cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/ext2fs/ext2fs_htree.c cvs rdiff -u -r1.90 -r1.91 src/sys/ufs/ext2fs/ext2fs_inode.c cvs rdiff -u -r1.93 -r1.94 src/sys/ufs/ext2fs/ext2fs_lookup.c cvs rdiff -u -r1.12 -r1.13 src/sys/ufs/ext2fs/ext2fs_rename.c cvs rdiff -u -r1.222 -r1.223 src/sys/ufs/ext2fs/ext2fs_vfsops.c cvs rdiff -u -r1.137 -r1.138 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.
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: riastradh Date: Sat Aug 26 05:18:17 UTC 2023 Modified Files: src/sys/ufs/ext2fs: ext2fs.h Log Message: ext2fs.h: Restore e2fs_cgload/cgsave for libsa and userland use. Stop-gap until they can be taught to handle the new version that was moved to ext2fs_vfsops.c, presumably. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 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.49 src/sys/ufs/ext2fs/ext2fs.h:1.50 --- src/sys/ufs/ext2fs/ext2fs.h:1.49 Fri Aug 25 16:50:23 2023 +++ src/sys/ufs/ext2fs/ext2fs.h Sat Aug 26 05:18:17 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.49 2023/08/25 16:50:23 christos Exp $ */ +/* $NetBSD: ext2fs.h,v 1.50 2023/08/26 05:18:17 riastradh Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -498,6 +498,12 @@ void e2fs_sb_bswap(struct ext2fs *, stru # define e2fs_sbsave(old, new) e2fs_sb_bswap((old), (new)) #endif +#ifndef _KERNEL /* XXX */ +/* Group descriptors are not byte swapped */ +#define e2fs_cgload(old, new, size) memcpy((new), (old), (size)) +#define e2fs_cgsave(old, new, size) memcpy((new), (old), (size)) +#endif + /* * Turn file system block numbers into disk block addresses. * This maps file system blocks to device size blocks.
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: riastradh Date: Sat Aug 26 05:18:17 UTC 2023 Modified Files: src/sys/ufs/ext2fs: ext2fs.h Log Message: ext2fs.h: Restore e2fs_cgload/cgsave for libsa and userland use. Stop-gap until they can be taught to handle the new version that was moved to ext2fs_vfsops.c, presumably. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 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.
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Fri Aug 25 16:50:23 UTC 2023 Modified Files: src/sys/ufs/ext2fs: ext2fs.h ext2fs_alloc.c ext2fs_vfsops.c Log Message: Support INCOMPAT_64BIT on ext4 (Vladimir 'phcoder' Serbinenko) To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/ufs/ext2fs/ext2fs.h cvs rdiff -u -r1.52 -r1.53 src/sys/ufs/ext2fs/ext2fs_alloc.c cvs rdiff -u -r1.221 -r1.222 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.48 src/sys/ufs/ext2fs/ext2fs.h:1.49 --- src/sys/ufs/ext2fs/ext2fs.h:1.48 Sat Aug 20 15:47:44 2016 +++ src/sys/ufs/ext2fs/ext2fs.h Fri Aug 25 12:50:23 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.h,v 1.48 2016/08/20 19:47:44 jdolecek Exp $ */ +/* $NetBSD: ext2fs.h,v 1.49 2023/08/25 16:50:23 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -252,6 +252,7 @@ struct m_ext2fs { 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 blocks per group */ + uint8_t e2fs_group_desc_shift; /* binary log group desc size */ struct ext2_gd *e2fs_gd; /* group descriptors (data not byteswapped) */ }; @@ -370,7 +371,8 @@ struct m_ext2fs { | EXT2F_ROCOMPAT_GDT_CSUM) #define EXT2F_INCOMPAT_SUPP (EXT2F_INCOMPAT_FTYPE \ | EXT2F_INCOMPAT_EXTENTS \ - | EXT2F_INCOMPAT_FLEX_BG) + | EXT2F_INCOMPAT_FLEX_BG \ + | EXT2F_INCOMPAT_64BIT) /* * Feature set definitions @@ -432,10 +434,14 @@ struct ext2_gd { 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. - */ + uint32_t ext2bgd_b_bitmap_hi; /* blocks bitmap block (high bits) */ + uint32_t ext2bgd_i_bitmap_hi; /* inodes bitmap block (high bits) */ + uint32_t ext2bgd_i_tables_hi; /* inodes table block (high bits) */ + uint16_t ext2bgd_nbfree_hi; /* number of free blocks (high bits) */ + uint16_t ext2bgd_nifree_hi; /* number of free inodes (high bits) */ + uint16_t ext2bgd_ndirs_hi; /* number of directories (high bits) */ + uint16_t reserved_hi; + uint32_t reserved2_hi[3]; }; #define E2FS_BG_INODE_UNINIT 0x0001 /* Inode bitmap not used/initialized */ @@ -492,15 +498,15 @@ void e2fs_sb_bswap(struct ext2fs *, stru # define e2fs_sbsave(old, new) e2fs_sb_bswap((old), (new)) #endif -/* Group descriptors are not byte swapped */ -#define e2fs_cgload(old, new, size) memcpy((new), (old), (size)) -#define e2fs_cgsave(old, new, size) memcpy((new), (old), (size)) - /* * Turn file system block numbers into disk block addresses. * This maps file system blocks to device size blocks. */ #define EXT2_FSBTODB(fs, b) ((b) << (fs)->e2fs_fsbtodb) +#define EXT2_FSBTODB64(fs, b, b_hi) \ +(uint64_t)(b_hi)) << 32) | (b)) << (fs)->e2fs_fsbtodb) +#define EXT2_FSBTODB64OFF(fs, b, b_hi, off) \ +((uint64_t)(b_hi)) << 32) | (b)) + (off)) << (fs)->e2fs_fsbtodb) #define EXT2_DBTOFSB(fs, b) ((b) >> (fs)->e2fs_fsbtodb) /* @@ -510,9 +516,11 @@ void e2fs_sb_bswap(struct ext2fs *, stru * inode number to file system block address. */ #define ino_to_cg(fs, x) (((x) - 1) / (fs)->e2fs.e2fs_ipg) -#define ino_to_fsba(fs, x) \ - (fs2h32((fs)->e2fs_gd[ino_to_cg((fs), (x))].ext2bgd_i_tables) + \ - (((x) - 1) % (fs)->e2fs.e2fs_ipg) / (fs)->e2fs_ipb) +#define _e2fs_gd(fs, x) (fs)->e2fs_gd[ino_to_cg((fs), (x))] +#define ino_to_fsba(fs, x) \ +(fs2h32(_e2fs_gd(fs, x).ext2bgd_i_tables) + \ + (((uint64_t)fs2h32(_e2fs_gd(fs, x).ext2bgd_i_tables_hi)) << 32) + \ + (((x) - 1) % (fs)->e2fs.e2fs_ipg) / (fs)->e2fs_ipb) #define ino_to_fsbo(fs, x) (((x) - 1) % (fs)->e2fs_ipb) /* Index: src/sys/ufs/ext2fs/ext2fs_alloc.c diff -u src/sys/ufs/ext2fs/ext2fs_alloc.c:1.52 src/sys/ufs/ext2fs/ext2fs_alloc.c:1.53 --- src/sys/ufs/ext2fs/ext2fs_alloc.c:1.52 Sun May 28 12:38:55 2017 +++ src/sys/ufs/ext2fs/ext2fs_alloc.c Fri Aug 25 12:50:23 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_alloc.c,v 1.52 2017/05/28 16:38:55 hannken Exp $ */ +/* $NetBSD: ext2fs_alloc.c,v 1.53 2023/08/25 16:50:23 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.52 2017/05/28 16:38:55 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.53 2023/08/25 16:50:23 christos Exp $"); #include #include @@ -90,9 +90,11 @@ static u_long ext2fs_hashalloc(struct in 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); -static __inline void ext2fs_cg_update(struct m_ext2fs *,
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: christos Date: Fri Aug 25 16:50:23 UTC 2023 Modified Files: src/sys/ufs/ext2fs: ext2fs.h ext2fs_alloc.c ext2fs_vfsops.c Log Message: Support INCOMPAT_64BIT on ext4 (Vladimir 'phcoder' Serbinenko) To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/ufs/ext2fs/ext2fs.h cvs rdiff -u -r1.52 -r1.53 src/sys/ufs/ext2fs/ext2fs_alloc.c cvs rdiff -u -r1.221 -r1.222 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.
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: andvar Date: Wed May 4 07:34:29 UTC 2022 Modified Files: src/sys/ufs/ext2fs: ext2fs_htree.c Log Message: s/entires/entries/ in local variable definition. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 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.9 src/sys/ufs/ext2fs/ext2fs_htree.c:1.10 --- src/sys/ufs/ext2fs/ext2fs_htree.c:1.9 Tue Aug 23 06:23:26 2016 +++ src/sys/ufs/ext2fs/ext2fs_htree.c Wed May 4 07:34:28 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_htree.c,v 1.9 2016/08/23 06:23:26 christos Exp $ */ +/* $NetBSD: ext2fs_htree.c,v 1.10 2022/05/04 07:34:28 andvar 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.9 2016/08/23 06:23:26 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.10 2022/05/04 07:34:28 andvar Exp $"); #include #include @@ -495,7 +495,7 @@ ext2fs_htree_add_entry(struct vnode *dvp char *newidxblock = NULL; struct ext2fs_htree_node *dst_node; struct ext2fs_htree_entry *dst_entries; - struct ext2fs_htree_entry *root_entires; + struct ext2fs_htree_entry *root_entries; struct buf *dst_bp = NULL; int error, write_bp = 0, write_dst_bp = 0, write_info = 0; @@ -517,7 +517,7 @@ ext2fs_htree_add_entry(struct vnode *dvp ent_num = ext2fs_htree_get_count(entries); if (ent_num == ext2fs_htree_get_limit(entries)) { /* Split the index node. */ - root_entires = info.h_levels[0].h_entries; + root_entries = info.h_levels[0].h_entries; newidxblock = malloc(blksize, M_TEMP, M_WAITOK | M_ZERO); dst_node = (struct ext2fs_htree_node *)newidxblock; dst_entries = dst_node->h_entries; @@ -543,8 +543,8 @@ ext2fs_htree_add_entry(struct vnode *dvp if (info.h_levels_num == 2) { uint16_t src_ent_num, dst_ent_num; - if (ext2fs_htree_get_count(root_entires) == - ext2fs_htree_get_limit(root_entires)) { + if (ext2fs_htree_get_count(root_entries) == + ext2fs_htree_get_limit(root_entries)) { /* Directory index is full */ error = EIO; goto finish;
CVS commit: src/sys/ufs/ext2fs
Module Name:src Committed By: andvar Date: Wed May 4 07:34:29 UTC 2022 Modified Files: src/sys/ufs/ext2fs: ext2fs_htree.c Log Message: s/entires/entries/ in local variable definition. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 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.
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(); 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: 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.
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.
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, _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
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.
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: 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.
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.
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++;
Re: CVS commit: src/sys/ufs/ext2fs
On Tue, Aug 23, 2016 at 02:24:30AM -0400, Christos Zoulas wrote: > Modified Files: > src/sys/ufs/ext2fs: ext2fs_vfsops.c > > Log Message: > CID 1371644: use strlcpy, remove dup copy. You sure about the dup copy? Those are different string buffers. -- David A. Holland dholl...@netbsd.org
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.
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.
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 = [value_offs]; + value_len = fs2h32(e->e_value_size); + value = [value_offs]; /* make sure the value offset are sane */ if ([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, ); + error = bread(ip->i_devvp, fsbtodb(ip->i_e2fs, xblk), + (int)ip->i_e2fs->e2fs_bsize, 0, ); 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 (bp) brelse(bp, 0);
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) , , ); 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, - ); + error = ext2fs_blkatoff(vdp, (off_t)results->ulr_offset, + NULL, ); 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: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.
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: 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.
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(_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, >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, ); - 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, ); - 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 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.
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.
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: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.
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.
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
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.
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,); + ext2fs_htree_cmp_sort_entry, ); /* * Count the number of entries to move to directory block 2.
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.
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(, 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,
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.
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.
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.
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 = (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, )) != 0) + error = ext2fs_makeinode(IFDIR | ap->a_vap->va_mode, ap->a_dvp, + , 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 =
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.
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: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.
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 >
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.
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: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.
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: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.
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: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.
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.
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, ); 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,
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.
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: 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.
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.
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.
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 =
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.
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.
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, , 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, ,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_entry (struct
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.
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; -
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.
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.
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,
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.
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, _lbn, _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.
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 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.
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: 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.
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 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.
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.
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(>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");