CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: riastradh Date: Wed Feb 22 21:49:45 UTC 2023 Modified Files: src/sys/ufs/ufs: quota1_subr.c quota2.h quota2_subr.c ufs_acl.c ufs_extattr.c ufs_lookup.c ufs_quota.c ufs_quota1.c ufs_quota2.c ufs_vfsops.c Log Message: ufs: Nix trailing whitespace and tidy up some other minor KNF. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/ufs/ufs/quota1_subr.c cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/ufs/quota2.h cvs rdiff -u -r1.5 -r1.6 src/sys/ufs/ufs/quota2_subr.c cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/ufs/ufs_acl.c cvs rdiff -u -r1.53 -r1.54 src/sys/ufs/ufs/ufs_extattr.c cvs rdiff -u -r1.156 -r1.157 src/sys/ufs/ufs/ufs_lookup.c cvs rdiff -u -r1.117 -r1.118 src/sys/ufs/ufs/ufs_quota.c cvs rdiff -u -r1.25 -r1.26 src/sys/ufs/ufs/ufs_quota1.c cvs rdiff -u -r1.45 -r1.46 src/sys/ufs/ufs/ufs_quota2.c cvs rdiff -u -r1.60 -r1.61 src/sys/ufs/ufs/ufs_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/ufs/quota1_subr.c diff -u src/sys/ufs/ufs/quota1_subr.c:1.7 src/sys/ufs/ufs/quota1_subr.c:1.8 --- src/sys/ufs/ufs/quota1_subr.c:1.7 Sun Jan 29 06:23:20 2012 +++ src/sys/ufs/ufs/quota1_subr.c Wed Feb 22 21:49:45 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: quota1_subr.c,v 1.7 2012/01/29 06:23:20 dholland Exp $ */ +/* $NetBSD: quota1_subr.c,v 1.8 2023/02/22 21:49:45 riastradh Exp $ */ /*- * Copyright (c) 2010 Manuel Bouyer * All rights reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: quota1_subr.c,v 1.7 2012/01/29 06:23:20 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: quota1_subr.c,v 1.8 2023/02/22 21:49:45 riastradh Exp $"); #include #include @@ -54,7 +54,7 @@ q2e2dqblk_limit(uint64_t lim) void dqblk_to_quotavals(const struct dqblk *dqblk, - struct quotaval *blocks, struct quotaval *files) +struct quotaval *blocks, struct quotaval *files) { /* XXX is qv_grace getting handled correctly? */ @@ -71,7 +71,7 @@ dqblk_to_quotavals(const struct dqblk *d void quotavals_to_dqblk(const struct quotaval *blocks, const struct quotaval *files, - struct dqblk *dqblk) +struct dqblk *dqblk) { /* XXX is qv_grace getting handled correctly? */ @@ -85,4 +85,3 @@ quotavals_to_dqblk(const struct quotaval dqblk->dqb_curinodes = files->qv_usage; dqblk->dqb_itime = files->qv_expiretime; } - Index: src/sys/ufs/ufs/quota2.h diff -u src/sys/ufs/ufs/quota2.h:1.10 src/sys/ufs/ufs/quota2.h:1.11 --- src/sys/ufs/ufs/quota2.h:1.10 Wed Oct 25 18:06:01 2017 +++ src/sys/ufs/ufs/quota2.h Wed Feb 22 21:49:45 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: quota2.h,v 1.10 2017/10/25 18:06:01 jdolecek Exp $ */ +/* $NetBSD: quota2.h,v 1.11 2023/02/22 21:49:45 riastradh Exp $ */ /*- * Copyright (c) 2010 Manuel Bouyer * All rights reserved. @@ -115,7 +115,7 @@ void quota2_ufs_rwq2e(const struct quota #define QL_S_ALLOW_SOFT 0x01 /* over soft limit */ #define QL_S_DENY_GRACE 0x02 /* over soft limit, grace time expired */ #define QL_S_DENY_HARD 0x03 /* over hard limit */ - + #define QL_F_CROSS 0x80 /* crossing soft limit */ #define QL_STATUS(x) ((x) & 0x0f) Index: src/sys/ufs/ufs/quota2_subr.c diff -u src/sys/ufs/ufs/quota2_subr.c:1.5 src/sys/ufs/ufs/quota2_subr.c:1.6 --- src/sys/ufs/ufs/quota2_subr.c:1.5 Sun Feb 5 14:19:04 2012 +++ src/sys/ufs/ufs/quota2_subr.c Wed Feb 22 21:49:45 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: quota2_subr.c,v 1.5 2012/02/05 14:19:04 dholland Exp $ */ +/* $NetBSD: quota2_subr.c,v 1.6 2023/02/22 21:49:45 riastradh Exp $ */ /*- * Copyright (c) 2010, 2011 Manuel Bouyer * All rights reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: quota2_subr.c,v 1.5 2012/02/05 14:19:04 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: quota2_subr.c,v 1.6 2023/02/22 21:49:45 riastradh Exp $"); #include #include @@ -87,7 +87,8 @@ quota2_create_blk0(uint64_t bsize, void } void -quota2_ufs_rwq2v(const struct quota2_val *s, struct quota2_val *d, int needswap) +quota2_ufs_rwq2v(const struct quota2_val *s, struct quota2_val *d, +int needswap) { d->q2v_hardlimit = ufs_rw64(s->q2v_hardlimit, needswap); d->q2v_softlimit = ufs_rw64(s->q2v_softlimit, needswap); @@ -98,7 +99,7 @@ quota2_ufs_rwq2v(const struct quota2_val void quota2_ufs_rwq2e(const struct quota2_entry *s, struct quota2_entry *d, -int needswap) +int needswap) { quota2_ufs_rwq2v(>q2e_val[QL_BLOCK], >q2e_val[QL_BLOCK], needswap); @@ -110,7 +111,7 @@ int needswap) int quota_check_limit(uint64_t cur, uint64_t change, uint64_t soft, uint64_t hard, time_t expire, time_t now) -{ +{ if (cur + change > hard) { if (cur <= soft) return (QL_F_CROSS | QL_S_DENY_HARD); @@ -124,4 +125,4 @@ quota_check_limit(uint64_t cur, uint64_t return QL_S_ALLOW_SOFT; } return QL_S_ALLOW_OK; -} +} Index: src/sys/ufs/ufs/ufs_acl.c diff -u src/sys/ufs/ufs/ufs_acl.c:1.4
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: riastradh Date: Wed Feb 22 21:49:45 UTC 2023 Modified Files: src/sys/ufs/ufs: quota1_subr.c quota2.h quota2_subr.c ufs_acl.c ufs_extattr.c ufs_lookup.c ufs_quota.c ufs_quota1.c ufs_quota2.c ufs_vfsops.c Log Message: ufs: Nix trailing whitespace and tidy up some other minor KNF. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/ufs/ufs/quota1_subr.c cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/ufs/quota2.h cvs rdiff -u -r1.5 -r1.6 src/sys/ufs/ufs/quota2_subr.c cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/ufs/ufs_acl.c cvs rdiff -u -r1.53 -r1.54 src/sys/ufs/ufs/ufs_extattr.c cvs rdiff -u -r1.156 -r1.157 src/sys/ufs/ufs/ufs_lookup.c cvs rdiff -u -r1.117 -r1.118 src/sys/ufs/ufs/ufs_quota.c cvs rdiff -u -r1.25 -r1.26 src/sys/ufs/ufs/ufs_quota1.c cvs rdiff -u -r1.45 -r1.46 src/sys/ufs/ufs/ufs_quota2.c cvs rdiff -u -r1.60 -r1.61 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: andvar Date: Mon Jan 30 13:45:26 UTC 2023 Modified Files: src/sys/ufs/ufs: README.acls Log Message: s/isses/issues/ To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/ufs/README.acls 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/ufs/README.acls diff -u src/sys/ufs/ufs/README.acls:1.1 src/sys/ufs/ufs/README.acls:1.2 --- src/sys/ufs/ufs/README.acls:1.1 Sat May 16 18:31:54 2020 +++ src/sys/ufs/ufs/README.acls Mon Jan 30 13:45:26 2023 @@ -45,7 +45,7 @@ will result in incorrect application of the kernel is not configured for ACL support, a warning will be printed by the kernel at mount-time. For reliability purposes, it is recommended that the superblock flag be used instead of the -mount-time flag, as this will avoid re-mount isses with the root file +mount-time flag, as this will avoid re-mount issues with the root file system. For reliability and performance reasons, the use of ACLs on UFS1 is discouraged; UFS2 extended attributes provide a more reliable storage mechanism for ACLs.
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: andvar Date: Mon Jan 30 13:45:26 UTC 2023 Modified Files: src/sys/ufs/ufs: README.acls Log Message: s/isses/issues/ To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/ufs/README.acls Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: hannken Date: Tue Apr 26 15:37:25 UTC 2022 Modified Files: src/sys/ufs/ufs: ufs_quota1.c Log Message: Keep flag "UFS_QUOTA" set until the last quota is closed. Prevents a live lock when dqrele() finds a struct with "dq_cnt == 1" and flag "DQ_MOD" and cannot sync as flag UFS_QUOTA is unset. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/ufs/ufs_quota1.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/ufs/ufs_quota1.c diff -u src/sys/ufs/ufs/ufs_quota1.c:1.24 src/sys/ufs/ufs/ufs_quota1.c:1.25 --- src/sys/ufs/ufs/ufs_quota1.c:1.24 Tue Jun 29 22:40:54 2021 +++ src/sys/ufs/ufs/ufs_quota1.c Tue Apr 26 15:37:25 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_quota1.c,v 1.24 2021/06/29 22:40:54 dholland Exp $ */ +/* $NetBSD: ufs_quota1.c,v 1.25 2022/04/26 15:37:25 hannken Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993, 1995 @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.24 2021/06/29 22:40:54 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.25 2022/04/26 15:37:25 hannken Exp $"); #include #include @@ -433,7 +433,6 @@ quota1_handle_cmd_quotaoff(struct lwp *l return (0); } ump->umq1_qflags[type] |= QTF_CLOSING; - ump->um_flags &= ~UFS_QUOTA; mutex_exit(); /* * Search vnodes associated with this mount point, @@ -470,6 +469,8 @@ quota1_handle_cmd_quotaoff(struct lwp *l if (ump->um_quotas[i] != NULLVP) break; ump->umq1_qflags[type] &= ~QTF_CLOSING; + if (i == MAXQUOTAS) + ump->um_flags &= ~UFS_QUOTA; cv_broadcast(); mutex_exit(); kauth_cred_free(cred);
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: hannken Date: Tue Apr 26 15:37:25 UTC 2022 Modified Files: src/sys/ufs/ufs: ufs_quota1.c Log Message: Keep flag "UFS_QUOTA" set until the last quota is closed. Prevents a live lock when dqrele() finds a struct with "dq_cnt == 1" and flag "DQ_MOD" and cannot sync as flag UFS_QUOTA is unset. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/ufs/ufs_quota1.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/ufs
Module Name:src Committed By: hannken Date: Mon Feb 21 17:07:45 UTC 2022 Modified Files: src/sys/ufs/ufs: ufs_readwrite.c Log Message: Fix wrong assertion, the negatiopn of "a && b" is "!a || !b" so we need "DIP(ip, blocks) != 0" here. Should fix PR kern/56725 (Panic when ls directory with device nodes on an older ffs) To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/sys/ufs/ufs/ufs_readwrite.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ufs/ufs_readwrite.c diff -u src/sys/ufs/ufs/ufs_readwrite.c:1.127 src/sys/ufs/ufs/ufs_readwrite.c:1.128 --- src/sys/ufs/ufs/ufs_readwrite.c:1.127 Wed Oct 20 03:08:19 2021 +++ src/sys/ufs/ufs/ufs_readwrite.c Mon Feb 21 17:07:45 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_readwrite.c,v 1.127 2021/10/20 03:08:19 thorpej Exp $ */ +/* $NetBSD: ufs_readwrite.c,v 1.128 2022/02/21 17:07:45 hannken Exp $ */ /*- * Copyright (c) 1993 @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.127 2021/10/20 03:08:19 thorpej Exp $"); +__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.128 2022/02/21 17:07:45 hannken Exp $"); #define FS struct fs #define I_FS i_fs @@ -142,7 +142,7 @@ BUFRD(struct vnode *vp, struct uio *uio, KASSERT(vp->v_type != VLNK || ip->i_size >= ump->um_maxsymlinklen); KASSERT(vp->v_type != VLNK || ump->um_maxsymlinklen != 0 || - DIP(ip, blocks) == 0); + DIP(ip, blocks) != 0); if (uio->uio_offset > ump->um_maxfilesize) return EFBIG;
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: hannken Date: Mon Feb 21 17:07:45 UTC 2022 Modified Files: src/sys/ufs/ufs: ufs_readwrite.c Log Message: Fix wrong assertion, the negatiopn of "a && b" is "!a || !b" so we need "DIP(ip, blocks) != 0" here. Should fix PR kern/56725 (Panic when ls directory with device nodes on an older ffs) To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/sys/ufs/ufs/ufs_readwrite.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/ufs
Module Name:src Committed By: christos Date: Fri Nov 26 17:35:12 UTC 2021 Modified Files: src/sys/ufs/ufs: ufs_acl.c ufs_vnops.c Log Message: use MNT_NFS4ACLS instead of MNT_ACLS (which was changed before to mean MNT_POSIX1EACLS) To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/ufs/ufs/ufs_acl.c cvs rdiff -u -r1.260 -r1.261 src/sys/ufs/ufs/ufs_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/ufs/ufs_acl.c diff -u src/sys/ufs/ufs/ufs_acl.c:1.3 src/sys/ufs/ufs/ufs_acl.c:1.4 --- src/sys/ufs/ufs/ufs_acl.c:1.3 Tue Oct 19 23:08:19 2021 +++ src/sys/ufs/ufs/ufs_acl.c Fri Nov 26 12:35:12 2021 @@ -36,7 +36,7 @@ #if 0 __FBSDID("$FreeBSD: head/sys/ufs/ufs/ufs_acl.c 356669 2020-01-13 02:31:51Z mjg $"); #endif -__KERNEL_RCSID(0, "$NetBSD: ufs_acl.c,v 1.3 2021/10/20 03:08:19 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_acl.c,v 1.4 2021/11/26 17:35:12 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -215,7 +215,7 @@ ufs_getacl_nfs4(struct vop_getacl_args * { int error; - if ((ap->a_vp->v_mount->mnt_flag & MNT_ACLS) == 0) + if ((ap->a_vp->v_mount->mnt_flag & MNT_NFS4ACLS) == 0) return (EINVAL); error = VOP_ACCESSX(ap->a_vp, VREAD_ACL, ap->a_cred); @@ -362,7 +362,7 @@ ufs_getacl(void *v) { struct vop_getacl_args *ap = v; - if ((ap->a_vp->v_mount->mnt_flag & (MNT_POSIX1EACLS | MNT_ACLS)) == 0) + if ((ap->a_vp->v_mount->mnt_flag & (MNT_POSIX1EACLS | MNT_NFS4ACLS)) == 0) return (EOPNOTSUPP); if (ap->a_type == ACL_TYPE_NFS4) @@ -438,7 +438,7 @@ ufs_setacl_nfs4(struct vop_setacl_args * int error; struct inode *ip = VTOI(ap->a_vp); - if ((ap->a_vp->v_mount->mnt_flag & MNT_ACLS) == 0) + if ((ap->a_vp->v_mount->mnt_flag & MNT_NFS4ACLS) == 0) return (EINVAL); if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY) @@ -612,7 +612,7 @@ int ufs_setacl(void *v) { struct vop_setacl_args *ap = v; - if ((ap->a_vp->v_mount->mnt_flag & (MNT_POSIX1EACLS | MNT_ACLS)) == 0) + if ((ap->a_vp->v_mount->mnt_flag & (MNT_POSIX1EACLS | MNT_NFS4ACLS)) == 0) return (EOPNOTSUPP); if (ap->a_type == ACL_TYPE_NFS4) @@ -627,7 +627,7 @@ ufs_aclcheck_nfs4(struct vop_aclcheck_ar { int is_directory = 0; - if ((ap->a_vp->v_mount->mnt_flag & MNT_ACLS) == 0) + if ((ap->a_vp->v_mount->mnt_flag & MNT_NFS4ACLS) == 0) return (EINVAL); /* @@ -683,7 +683,7 @@ ufs_aclcheck(void *v) { struct vop_aclcheck_args *ap = v; - if ((ap->a_vp->v_mount->mnt_flag & (MNT_POSIX1EACLS | MNT_ACLS)) == 0) + if ((ap->a_vp->v_mount->mnt_flag & (MNT_POSIX1EACLS | MNT_NFS4ACLS)) == 0) return (EOPNOTSUPP); if (ap->a_type == ACL_TYPE_NFS4) Index: src/sys/ufs/ufs/ufs_vnops.c diff -u src/sys/ufs/ufs/ufs_vnops.c:1.260 src/sys/ufs/ufs/ufs_vnops.c:1.261 --- src/sys/ufs/ufs/ufs_vnops.c:1.260 Tue Oct 19 23:08:19 2021 +++ src/sys/ufs/ufs/ufs_vnops.c Fri Nov 26 12:35:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vnops.c,v 1.260 2021/10/20 03:08:19 thorpej Exp $ */ +/* $NetBSD: ufs_vnops.c,v 1.261 2021/11/26 17:35:12 christos Exp $ */ /*- * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.260 2021/10/20 03:08:19 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.261 2021/11/26 17:35:12 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -345,8 +345,8 @@ ufs_accessx(void *v) return error; #ifdef UFS_ACL - if ((vp->v_mount->mnt_flag & (MNT_POSIX1EACLS | MNT_ACLS)) != 0) { - if (vp->v_mount->mnt_flag & MNT_ACLS) + if ((vp->v_mount->mnt_flag & (MNT_POSIX1EACLS | MNT_NFS4ACLS)) != 0) { + if (vp->v_mount->mnt_flag & MNT_NFS4ACLS) type = ACL_TYPE_NFS4; else type = ACL_TYPE_ACCESS; @@ -730,7 +730,7 @@ ufs_chmod(struct vnode *vp, int mode, ka return (error); #ifdef UFS_ACL - if ((vp->v_mount->mnt_flag & MNT_ACLS) != 0) { + if ((vp->v_mount->mnt_flag & MNT_NFS4ACLS) != 0) { error = ufs_update_nfs4_acl_after_mode_change(vp, mode, ip->i_uid, cred, l); if (error) @@ -1291,7 +1291,7 @@ ufs_mkdir(void *v) cnp->cn_cred, l); if (error) goto bad; - } else if (dvp->v_mount->mnt_flag & MNT_ACLS) { + } else if (dvp->v_mount->mnt_flag & MNT_NFS4ACLS) { error = ufs_do_nfs4_acl_inheritance(dvp, tvp, dmode, cnp->cn_cred, l); if (error) @@ -2105,7 +2105,7 @@ ufs_pathconf(void *v) *ap->a_retval = 0; return 0; case _PC_ACL_NFS4: - if (ap->a_vp->v_mount->mnt_flag & MNT_ACLS) + if (ap->a_vp->v_mount->mnt_flag & MNT_NFS4ACLS) *ap->a_retval = 1; else *ap->a_retval = 0; @@ -2113,7 +2113,7 @@ ufs_pathconf(void *v) #endif case _PC_ACL_PATH_MAX: #ifdef UFS_ACL - if (ap->a_vp->v_mount->mnt_flag & (MNT_POSIX1EACLS | MNT_ACLS)) + if (ap->a_vp->v_mount->mnt_flag & (MNT_POSIX1EACLS | MNT_NFS4ACLS)) *ap->a_retval = ACL_MAX_ENTRIES; else *ap->a_retval = 3; @@ -2272,7 +2272,7 @@
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: christos Date: Fri Nov 26 17:35:12 UTC 2021 Modified Files: src/sys/ufs/ufs: ufs_acl.c ufs_vnops.c Log Message: use MNT_NFS4ACLS instead of MNT_ACLS (which was changed before to mean MNT_POSIX1EACLS) To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/ufs/ufs/ufs_acl.c cvs rdiff -u -r1.260 -r1.261 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: thorpej Date: Sun Oct 10 23:02:10 UTC 2021 Modified Files: src/sys/ufs/ufs: ufs_acl.c Log Message: Use VN_KNOTE() to send our NOTE_ATTRIB and NOTE_REVOKE events. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/ufs/ufs_acl.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/ufs/ufs_acl.c diff -u src/sys/ufs/ufs/ufs_acl.c:1.1 src/sys/ufs/ufs/ufs_acl.c:1.2 --- src/sys/ufs/ufs/ufs_acl.c:1.1 Sat May 16 18:31:54 2020 +++ src/sys/ufs/ufs/ufs_acl.c Sun Oct 10 23:02:10 2021 @@ -36,7 +36,7 @@ #if 0 __FBSDID("$FreeBSD: head/sys/ufs/ufs/ufs_acl.c 356669 2020-01-13 02:31:51Z mjg $"); #endif -__KERNEL_RCSID(0, "$NetBSD: ufs_acl.c,v 1.1 2020/05/16 18:31:54 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_acl.c,v 1.2 2021/10/10 23:02:10 thorpej Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -425,7 +425,7 @@ ufs_setacl_nfs4_internal(struct vnode *v DIP_ASSIGN(ip, mode, ip->i_mode); ip->i_flag |= IN_CHANGE; - KNOTE(>v_klist, NOTE_REVOKE); + VN_KNOTE(vp, NOTE_REVOKE); error = UFS_UPDATE(vp, NULL, NULL, 0); if (lock) @@ -607,7 +607,7 @@ ufs_setacl_posix1e(struct vnode *vp, int UFS_WAPBL_END(vp->v_mount); } - KNOTE(>v_klist, NOTE_ATTRIB); + VN_KNOTE(vp, NOTE_ATTRIB); return (error); }
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: thorpej Date: Sun Oct 10 23:02:10 UTC 2021 Modified Files: src/sys/ufs/ufs: ufs_acl.c Log Message: Use VN_KNOTE() to send our NOTE_ATTRIB and NOTE_REVOKE events. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/ufs/ufs_acl.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/ufs
Module Name:src Committed By: nia Date: Fri Dec 25 10:00:40 UTC 2020 Modified Files: src/sys/ufs/ufs: ufs_quota1.c Log Message: Avoid potentially accessing an array with an index out of range. Reported-by: syzbot+8832f540234b996bc...@syzkaller.appspotmail.com Reported-by: syzbot+0b785dd10d987350e...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/ufs/ufs_quota1.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/ufs/ufs_quota1.c diff -u src/sys/ufs/ufs/ufs_quota1.c:1.22 src/sys/ufs/ufs/ufs_quota1.c:1.23 --- src/sys/ufs/ufs/ufs_quota1.c:1.22 Mon Jun 20 00:52:04 2016 +++ src/sys/ufs/ufs/ufs_quota1.c Fri Dec 25 10:00:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_quota1.c,v 1.22 2016/06/20 00:52:04 dholland Exp $ */ +/* $NetBSD: ufs_quota1.c,v 1.23 2020/12/25 10:00:40 nia Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993, 1995 @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.22 2016/06/20 00:52:04 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.23 2020/12/25 10:00:40 nia Exp $"); #include #include @@ -311,6 +311,9 @@ quota1_handle_cmd_quotaon(struct lwp *l, struct pathbuf *pb; struct nameidata nd; + if (type < 0 || type >= MAXQUOTAS) + return EINVAL; + if (ump->um_flags & UFS_QUOTA2) { uprintf("%s: quotas v2 already enabled\n", mp->mnt_stat.f_mntonname); @@ -421,6 +424,9 @@ quota1_handle_cmd_quotaoff(struct lwp *l kauth_cred_t cred; int i, error; + if (type < 0 || type >= MAXQUOTAS) + return EINVAL; + mutex_enter(); while ((ump->umq1_qflags[type] & (QTF_CLOSING | QTF_OPENING)) != 0) cv_wait(, );
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: nia Date: Fri Dec 25 10:00:40 UTC 2020 Modified Files: src/sys/ufs/ufs: ufs_quota1.c Log Message: Avoid potentially accessing an array with an index out of range. Reported-by: syzbot+8832f540234b996bc...@syzkaller.appspotmail.com Reported-by: syzbot+0b785dd10d987350e...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/ufs/ufs_quota1.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/ufs
Module Name:src Committed By: hannken Date: Fri May 1 08:43:37 UTC 2020 Modified Files: src/sys/ufs/ufs: ufs_vfsops.c Log Message: There is no difference between a zero-sized and not yet reclaimed directory vnode and a non-existent vnode. Teach ufs_fhtovp() to treat zero-sized directories as stale. PR kern/55211 (fs/vfs/t_vnops:nfs_dir_rmdirdotdot test fails) To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: hannken Date: Fri May 1 08:43:37 UTC 2020 Modified Files: src/sys/ufs/ufs: ufs_vfsops.c Log Message: There is no difference between a zero-sized and not yet reclaimed directory vnode and a non-existent vnode. Teach ufs_fhtovp() to treat zero-sized directories as stale. PR kern/55211 (fs/vfs/t_vnops:nfs_dir_rmdirdotdot test fails) To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/sys/ufs/ufs/ufs_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/ufs/ufs_vfsops.c diff -u src/sys/ufs/ufs/ufs_vfsops.c:1.59 src/sys/ufs/ufs/ufs_vfsops.c:1.60 --- src/sys/ufs/ufs/ufs_vfsops.c:1.59 Fri Jan 17 20:08:10 2020 +++ src/sys/ufs/ufs/ufs_vfsops.c Fri May 1 08:43:37 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vfsops.c,v 1.59 2020/01/17 20:08:10 ad Exp $ */ +/* $NetBSD: ufs_vfsops.c,v 1.60 2020/05/01 08:43:37 hannken Exp $ */ /* * Copyright (c) 1991, 1993, 1994 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_vfsops.c,v 1.59 2020/01/17 20:08:10 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_vfsops.c,v 1.60 2020/05/01 08:43:37 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -247,7 +247,8 @@ ufs_fhtovp(struct mount *mp, struct ufid } ip = VTOI(nvp); KASSERT(ip != NULL); - if (ip->i_mode == 0 || ip->i_gen != ufhp->ufid_gen) { + if (ip->i_mode == 0 || ip->i_gen != ufhp->ufid_gen || + ((ip->i_mode & IFMT) == IFDIR && ip->i_size == 0)) { vput(nvp); *vpp = NULLVP; return (ESTALE);
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: christos Date: Mon Apr 20 03:57:02 UTC 2020 Modified Files: src/sys/ufs/ufs: ufs_bmap.c Log Message: handle negative small block numbers for extattr To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: christos Date: Mon Apr 20 03:57:02 UTC 2020 Modified Files: src/sys/ufs/ufs: ufs_bmap.c Log Message: handle negative small block numbers for extattr To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/ufs/ufs/ufs_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/ufs/ufs_bmap.c diff -u src/sys/ufs/ufs/ufs_bmap.c:1.52 src/sys/ufs/ufs/ufs_bmap.c:1.53 --- src/sys/ufs/ufs/ufs_bmap.c:1.52 Sat Mar 18 01:33:06 2017 +++ src/sys/ufs/ufs/ufs_bmap.c Sun Apr 19 23:57:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_bmap.c,v 1.52 2017/03/18 05:33:06 riastradh Exp $ */ +/* $NetBSD: ufs_bmap.c,v 1.53 2020/04/20 03:57:02 christos Exp $ */ /* * Copyright (c) 1989, 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_bmap.c,v 1.52 2017/03/18 05:33:06 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_bmap.c,v 1.53 2020/04/20 03:57:02 christos Exp $"); #include #include @@ -190,6 +190,13 @@ ufs_bmaparray(struct vnode *vp, daddr_t } } return (0); + } else if (bn < 0 && bn >= -UFS_NXADDR) { + KASSERT(ump->um_fstype == UFS2); + daddr = ufs_rw64(ip->i_ffs2_extb[-1 - bn], UFS_MPNEEDSWAP(ump)); + *bnp = blkptrtodb(ump, daddr); + if (*bnp == 0) + *bnp = -1; + return 0; } xap = ap == NULL ? a : ap;
Re: CVS commit: src/sys/ufs/ufs
Le 27/02/2020 à 01:36, Simon Burge a écrit : > "Maxime Villard" wrote: > >> Module Name: src >> Committed By:maxv >> Date:Wed Feb 26 18:00:12 UTC 2020 >> >> Modified Files: >> >> src/sys/ufs/ufs: ufs_vnops.c >> >> Log Message: >> >> Zero out the padding in 'd_namlen', to prevent info leaks. Same logic as >> ufs_makedirentry(). > > Is it cleaner to just call pool_cache_get() with PR_ZERO? > > Cheers, > Simon. In this specific case there is already a clean macro that gives the number of padding bytes, so using it is cleaner/faster than zeroing the whole buffer. Maxime
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: chs Date: Sun Mar 8 00:23:59 UTC 2020 Modified Files: src/sys/ufs/ufs: ufs_dirhash.c Log Message: in ufsdirhash_free(), only examine dh->dh_onlist after taking the dirhashlist lock. if we skip the lock then we might see that dh_onlist is zero while ufsdirhash_recycle() is still working on the dirhash. the symptom I saw was that ufsdirhash_free() would try to destroy the dh_lock mutex while it was still held. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/ufs/ufs/ufs_dirhash.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/ufs
Module Name:src Committed By: chs Date: Sun Mar 8 00:23:59 UTC 2020 Modified Files: src/sys/ufs/ufs: ufs_dirhash.c Log Message: in ufsdirhash_free(), only examine dh->dh_onlist after taking the dirhashlist lock. if we skip the lock then we might see that dh_onlist is zero while ufsdirhash_recycle() is still working on the dirhash. the symptom I saw was that ufsdirhash_free() would try to destroy the dh_lock mutex while it was still held. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/ufs/ufs/ufs_dirhash.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/ufs/ufs_dirhash.c diff -u src/sys/ufs/ufs/ufs_dirhash.c:1.37 src/sys/ufs/ufs/ufs_dirhash.c:1.38 --- src/sys/ufs/ufs/ufs_dirhash.c:1.37 Sat Dec 20 00:28:05 2014 +++ src/sys/ufs/ufs/ufs_dirhash.c Sun Mar 8 00:23:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_dirhash.c,v 1.37 2014/12/20 00:28:05 christos Exp $ */ +/* $NetBSD: ufs_dirhash.c,v 1.38 2020/03/08 00:23:59 chs Exp $ */ /* * Copyright (c) 2001, 2002 Ian Dowse. All rights reserved. @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_dirhash.c,v 1.37 2014/12/20 00:28:05 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_dirhash.c,v 1.38 2020/03/08 00:23:59 chs Exp $"); /* * This implements a hash-based lookup scheme for UFS directories. @@ -285,12 +285,10 @@ ufsdirhash_free(struct inode *ip) ip->i_dirhash = NULL; - if (dh->dh_onlist) { - DIRHASHLIST_LOCK(); - if (dh->dh_onlist) - TAILQ_REMOVE(_list, dh, dh_list); - DIRHASHLIST_UNLOCK(); - } + DIRHASHLIST_LOCK(); + if (dh->dh_onlist) + TAILQ_REMOVE(_list, dh, dh_list); + DIRHASHLIST_UNLOCK(); /* The dirhash pointed to by 'dh' is exclusively ours now. */ mem = sizeof(*dh);
Re: CVS commit: src/sys/ufs/ufs
"Maxime Villard" wrote: > Module Name: src > Committed By: maxv > Date: Wed Feb 26 18:00:12 UTC 2020 > > Modified Files: > > src/sys/ufs/ufs: ufs_vnops.c > > Log Message: > > Zero out the padding in 'd_namlen', to prevent info leaks. Same logic as > ufs_makedirentry(). Is it cleaner to just call pool_cache_get() with PR_ZERO? Cheers, Simon.
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: maxv Date: Wed Feb 26 18:00:12 UTC 2020 Modified Files: src/sys/ufs/ufs: ufs_vnops.c Log Message: Zero out the padding in 'd_namlen', to prevent info leaks. Same logic as ufs_makedirentry(). Found by kMSan: the unzeroed bytes of the pool_cache were getting copied to the disk via a DMA write operation, and there kMSan was noticing uninitialized memory leaving the system. Reported-by: syzbot+382c9dffc06a9683a...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.248 -r1.249 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: maxv Date: Wed Feb 26 18:00:12 UTC 2020 Modified Files: src/sys/ufs/ufs: ufs_vnops.c Log Message: Zero out the padding in 'd_namlen', to prevent info leaks. Same logic as ufs_makedirentry(). Found by kMSan: the unzeroed bytes of the pool_cache were getting copied to the disk via a DMA write operation, and there kMSan was noticing uninitialized memory leaving the system. Reported-by: syzbot+382c9dffc06a9683a...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.248 -r1.249 src/sys/ufs/ufs/ufs_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/ufs/ufs_vnops.c diff -u src/sys/ufs/ufs/ufs_vnops.c:1.248 src/sys/ufs/ufs/ufs_vnops.c:1.249 --- src/sys/ufs/ufs/ufs_vnops.c:1.248 Wed Sep 18 17:59:15 2019 +++ src/sys/ufs/ufs/ufs_vnops.c Wed Feb 26 18:00:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vnops.c,v 1.248 2019/09/18 17:59:15 christos Exp $ */ +/* $NetBSD: ufs_vnops.c,v 1.249 2020/02/26 18:00:12 maxv Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.248 2019/09/18 17:59:15 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.249 2020/02/26 18:00:12 maxv Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -873,7 +873,11 @@ ufs_whiteout(void *v) newdir->d_namlen = cnp->cn_namelen; memcpy(newdir->d_name, cnp->cn_nameptr, (size_t)cnp->cn_namelen); - newdir->d_name[cnp->cn_namelen] = '\0'; + + /* NUL terminate and zero out padding */ + memset(>d_name[cnp->cn_namelen], 0, + UFS_NAMEPAD(cnp->cn_namelen)); + newdir->d_type = DT_WHT; error = ufs_direnter(dvp, ulr, NULL, newdir, cnp, NULL); pool_cache_put(ufs_direct_cache, newdir);
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: christos Date: Mon Aug 19 14:09:12 UTC 2019 Modified Files: src/sys/ufs/ufs: ufs_extattr.c Log Message: - KNF more - print the full path in error messages To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/ufs/ufs/ufs_extattr.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/ufs/ufs_extattr.c diff -u src/sys/ufs/ufs/ufs_extattr.c:1.49 src/sys/ufs/ufs/ufs_extattr.c:1.50 --- src/sys/ufs/ufs/ufs_extattr.c:1.49 Mon Aug 19 05:30:30 2019 +++ src/sys/ufs/ufs/ufs_extattr.c Mon Aug 19 10:09:12 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_extattr.c,v 1.49 2019/08/19 09:30:30 christos Exp $ */ +/* $NetBSD: ufs_extattr.c,v 1.50 2019/08/19 14:09:12 christos Exp $ */ /*- * Copyright (c) 1999-2002 Robert N. M. Watson @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.49 2019/08/19 09:30:30 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.50 2019/08/19 14:09:12 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_ffs.h" @@ -238,17 +238,13 @@ ufs_extattr_autocreate_attr(struct vnode switch (attrnamespace) { case EXTATTR_NAMESPACE_SYSTEM: (void)snprintf(path, PATH_MAX, "%s/%s/%s/%s", - mp->mnt_stat.f_mntonname, - UFS_EXTATTR_FSROOTSUBDIR, - UFS_EXTATTR_SUBDIR_SYSTEM, - attrname); + mp->mnt_stat.f_mntonname, UFS_EXTATTR_FSROOTSUBDIR, + UFS_EXTATTR_SUBDIR_SYSTEM, attrname); break; case EXTATTR_NAMESPACE_USER: (void)snprintf(path, PATH_MAX, "%s/%s/%s/%s", - mp->mnt_stat.f_mntonname, - UFS_EXTATTR_FSROOTSUBDIR, - UFS_EXTATTR_SUBDIR_USER, - attrname); + mp->mnt_stat.f_mntonname, UFS_EXTATTR_FSROOTSUBDIR, + UFS_EXTATTR_SUBDIR_USER, attrname); break; default: PNBUF_PUT(path); @@ -666,16 +662,18 @@ ufs_extattr_subdir(struct lwp *l, struct error = ufs_extattr_lookup(attr_dvp, LOCKPARENT, subdir, _sub, l); KASSERT(VOP_ISLOCKED(attr_dvp) == LK_EXCLUSIVE); if (error) { - printf("%s: Can't find `%s/%s' (%d)\n", - __func__, UFS_EXTATTR_FSROOTSUBDIR, subdir, error); + printf("%s: Can't find `%s/%s/%s' (%d)\n", + __func__, mp->mnt_stat.f_mntonname, + UFS_EXTATTR_FSROOTSUBDIR, subdir, error); return error; } KASSERT(VOP_ISLOCKED(attr_sub) == LK_EXCLUSIVE); error = ufs_extattr_iterate_directory(VFSTOUFS(mp), attr_sub, namespace, l); if (error) { - printf("%s: ufs_extattr_iterate_directory for `%s/%s' (%d)\n", - __func__, UFS_EXTATTR_FSROOTSUBDIR, subdir, error); + printf("%s: ufs_extattr_iterate_directory `%s/%s/%s' (%d)\n", + __func__, mp->mnt_stat.f_mntonname, + UFS_EXTATTR_FSROOTSUBDIR, subdir, error); } KASSERT(VOP_ISLOCKED(attr_sub) == LK_EXCLUSIVE); vput(attr_sub); @@ -710,8 +708,8 @@ ufs_extattr_autostart(struct mount *mp, /* rvp ref'd but now unlocked */ KASSERT(VOP_ISLOCKED(rvp) == 0); vrele(rvp); - printf("%s: lookup `%s' (%d)\n", __func__, - UFS_EXTATTR_FSROOTSUBDIR, error); + printf("%s: lookup `%s/%s' (%d)\n", __func__, + mp->mnt_stat.f_mntonname, UFS_EXTATTR_FSROOTSUBDIR, error); return error; } if (rvp == attr_dvp) { @@ -719,8 +717,8 @@ ufs_extattr_autostart(struct mount *mp, KASSERT(VOP_ISLOCKED(rvp) == LK_EXCLUSIVE); vrele(attr_dvp); vput(rvp); - printf("%s: `/' == `%s' (%d)\n", __func__, - UFS_EXTATTR_FSROOTSUBDIR, EINVAL); + printf("%s: `/' == `%s/%s' (%d)\n", __func__, + mp->mnt_stat.f_mntonname, UFS_EXTATTR_FSROOTSUBDIR, EINVAL); return EINVAL; } KASSERT(VOP_ISLOCKED(rvp) == 0); @@ -729,8 +727,9 @@ ufs_extattr_autostart(struct mount *mp, KASSERT(VOP_ISLOCKED(attr_dvp) == LK_EXCLUSIVE); if (attr_dvp->v_type != VDIR) { - printf("%s: `%s' is not a directory\n", - __func__, UFS_EXTATTR_FSROOTSUBDIR); + printf("%s: `%s/%s' is not a directory\n", + __func__, mp->mnt_stat.f_mntonname, + UFS_EXTATTR_FSROOTSUBDIR); goto return_vput_attr_dvp; }
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: christos Date: Mon Aug 19 14:09:12 UTC 2019 Modified Files: src/sys/ufs/ufs: ufs_extattr.c Log Message: - KNF more - print the full path in error messages To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/ufs/ufs/ufs_extattr.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/ufs
Module Name:src Committed By: christos Date: Mon Aug 19 09:30:30 UTC 2019 Modified Files: src/sys/ufs/ufs: ufs_extattr.c Log Message: - return (foo) -> return foo - normalize all error messages to use __func__ - add more messages for startup failure (should perhaps auto-create the attributes directory and the user and system subdirs?) - factor out common code To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/ufs/ufs/ufs_extattr.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/ufs
Module Name:src Committed By: christos Date: Mon Aug 19 09:30:30 UTC 2019 Modified Files: src/sys/ufs/ufs: ufs_extattr.c Log Message: - return (foo) -> return foo - normalize all error messages to use __func__ - add more messages for startup failure (should perhaps auto-create the attributes directory and the user and system subdirs?) - factor out common code To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/ufs/ufs/ufs_extattr.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/ufs/ufs_extattr.c diff -u src/sys/ufs/ufs/ufs_extattr.c:1.48 src/sys/ufs/ufs/ufs_extattr.c:1.49 --- src/sys/ufs/ufs/ufs_extattr.c:1.48 Wed Nov 9 00:08:35 2016 +++ src/sys/ufs/ufs/ufs_extattr.c Mon Aug 19 05:30:30 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_extattr.c,v 1.48 2016/11/09 05:08:35 dholland Exp $ */ +/* $NetBSD: ufs_extattr.c,v 1.49 2019/08/19 09:30:30 christos Exp $ */ /*- * Copyright (c) 1999-2002 Robert N. M. Watson @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.48 2016/11/09 05:08:35 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.49 2019/08/19 09:30:30 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_ffs.h" @@ -207,10 +207,10 @@ ufs_extattr_valid_attrname(int attrnames { if (attrname == NULL) - return (0); + return 0; if (strlen(attrname) == 0) - return (0); - return (1); + return 0; + return 1; } /* @@ -321,8 +321,8 @@ ufs_extattr_autocreate_attr(struct vnode VOP_UNLOCK(backing_vp); if (error != 0) { - printf("%s: write uef header failed for %s, error = %d\n", - __func__, attrname, error); + printf("%s: write uef header failed for `%s' (%d)\n", + __func__, attrname, error); vn_close(backing_vp, FREAD|FWRITE, l->l_cred); *uelep = NULL; return error; @@ -335,8 +335,8 @@ ufs_extattr_autocreate_attr(struct vnode KASSERT(VOP_ISLOCKED(backing_vp) == 0); if (error != 0) { - printf("%s: enable %s failed, error %d\n", - __func__, attrname, error); + printf("%s: enable `%s' failed (%d)\n", + __func__, attrname, error); vn_close(backing_vp, FREAD|FWRITE, l->l_cred); *uelep = NULL; return error; @@ -344,7 +344,7 @@ ufs_extattr_autocreate_attr(struct vnode uele = ufs_extattr_find_attr(ump, attrnamespace, attrname); if (uele == NULL) { - printf("%s: atttribute %s created but not found!\n", + printf("%s: atttribute `%s' created but not found!\n", __func__, attrname); vn_close(backing_vp, FREAD|FWRITE, l->l_cred); *uelep = NULL; @@ -352,7 +352,7 @@ ufs_extattr_autocreate_attr(struct vnode } printf("%s: EA backing store autocreated for %s\n", - mp->mnt_stat.f_mntonname, attrname); + mp->mnt_stat.f_mntonname, attrname); *uelep = uele; return 0; @@ -374,11 +374,11 @@ ufs_extattr_find_attr(struct ufsmount *u if (!(strncmp(attrname, search_attribute->uele_attrname, UFS_EXTATTR_MAXEXTATTRNAME)) && (attrnamespace == search_attribute->uele_attrnamespace)) { - return (search_attribute); + return search_attribute; } } - return (0); + return 0; } /* @@ -453,8 +453,7 @@ ufs_extattr_start(struct mount *mp, stru unlock: ufs_extattr_uepm_unlock(ump); - - return (error); + return error; } /* @@ -490,8 +489,8 @@ ufs_extattr_lookup(struct vnode *start_d VOP_UNLOCK(start_dvp); } PNBUF_PUT(pnbuf); - printf("ufs_extattr_lookup: copystr failed\n"); - return (error); + printf("%s: copystr failed (%d)\n", __func__, error); + return error; } cnp.cn_namelen--; /* trim nul termination */ vargs.a_desc = NULL; @@ -504,11 +503,11 @@ ufs_extattr_lookup(struct vnode *start_d if (lockparent == 0) { VOP_UNLOCK(start_dvp); } - return (error); + return error; } #if 0 if (target_vp == start_dvp) - panic("ufs_extattr_lookup: target_vp == start_dvp"); + panic("%s: target_vp == start_dvp", __func__); #endif if (target_vp != start_dvp) { @@ -523,7 +522,7 @@ ufs_extattr_lookup(struct vnode *start_d KASSERT(VOP_ISLOCKED(target_vp) == LK_EXCLUSIVE); *vp = target_vp; - return (0); + return 0; } /* @@ -541,10 +540,9 @@ ufs_extattr_enable_with_open(struct ufsm error = VOP_OPEN(vp, FREAD|FWRITE, l->l_cred); if (error) { - printf("ufs_extattr_enable_with_open.VOP_OPEN(): failed " - "with %d\n", error); + printf("%s: VOP_OPEN(): failed (%d)\n", __func__, error); VOP_UNLOCK(vp); - return (error); + return error; } mutex_enter(vp->v_interlock); @@ -558,7 +556,7 @@ ufs_extattr_enable_with_open(struct ufsm error = ufs_extattr_enable(ump, attrnamespace, attrname, vp, l); if (error != 0) vn_close(vp, FREAD|FWRITE, l->l_cred); - return (error); + return error; } /* @@ -582,7 +580,7 @@ ufs_extattr_iterate_directory(struct ufs int error, eofflag = 0; if (dvp->v_type != VDIR) - return (ENOTDIR); + return ENOTDIR; dirbuf
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: dholland Date: Mon Jul 1 00:57:06 UTC 2019 Modified Files: src/sys/ufs/ufs: ufs_vnops.c Log Message: Lay down some comments related to the previous few revisions of ufs_vnops.c. To generate a diff of this commit: cvs rdiff -u -r1.246 -r1.247 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: dholland Date: Mon Jul 1 00:57:06 UTC 2019 Modified Files: src/sys/ufs/ufs: ufs_vnops.c Log Message: Lay down some comments related to the previous few revisions of ufs_vnops.c. To generate a diff of this commit: cvs rdiff -u -r1.246 -r1.247 src/sys/ufs/ufs/ufs_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/ufs/ufs_vnops.c diff -u src/sys/ufs/ufs/ufs_vnops.c:1.246 src/sys/ufs/ufs/ufs_vnops.c:1.247 --- src/sys/ufs/ufs/ufs_vnops.c:1.246 Mon Feb 25 06:00:40 2019 +++ src/sys/ufs/ufs/ufs_vnops.c Mon Jul 1 00:57:06 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vnops.c,v 1.246 2019/02/25 06:00:40 dholland Exp $ */ +/* $NetBSD: ufs_vnops.c,v 1.247 2019/07/01 00:57:06 dholland Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.246 2019/02/25 06:00:40 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.247 2019/07/01 00:57:06 dholland Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -1257,7 +1257,12 @@ ufs_readdir(void *v) KASSERT(VOP_ISLOCKED(vp)); - /* figure out where we want to read */ + /* + * Figure out where the user wants us to read and how much. + * + * XXX: there should probably be an upper bound on callerbytes + * to avoid silliness trying to do large kernel allocations. + */ callerbytes = calleruio->uio_resid; startoffset = calleruio->uio_offset; endoffset = startoffset + callerbytes; @@ -1267,7 +1272,39 @@ ufs_readdir(void *v) return EINVAL; } - /* round start and end down to block boundaries */ + /* + * Now figure out where to actually start reading. Round the + * start down to a block boundary: we need to start at the + * beginning of a block in order to read the directory + * correctly. + * + * We also want to always read a whole number of blocks so + * that the copying code below doesn't have to worry about + * partial entries. (It used to try at one point, and was a + * horrible mess.) + * + * Furthermore, since blocks have to be scanned from the + * beginning, if we go partially into another block now we'll + * just have to rescan it on the next readdir call, which + * doesn't really serve any useful purpose. + * + * So, round down the end as well. It's ok to underpopulate + * the transfer buffer, as long as we send back at least one + * dirent so as to avoid giving a bogus EOF indication. + * + * Note that because dirents are larger than ffs struct + * directs, despite the rounding down we may not be able to + * send all the entries in the blocks we read and may have to + * rescan some of them on the next call anyway. Alternatively + * if there's empty space on disk we might have actually been + * able to fit the next block in, and so forth. None of this + * actually matters that much in practice. + * + * XXX: what does ffs do if a directory block becomes + * completely empty, and what happens if all the blocks we + * read are completely empty even though we aren't at EOF? As + * of this writing I (dholland) can't remember the details. + */ physstart = rounddown2(startoffset, ump->um_dirblksiz); physend = rounddown2(endoffset, ump->um_dirblksiz); @@ -1276,10 +1313,42 @@ ufs_readdir(void *v) return EINVAL; } + /* + * skipstart is the number of bytes we need to read in + * (because we need to start at the beginning of a block) but + * not transfer to the user. + * + * dropend is the number of bytes to ignore at the end of the + * user's buffer. + */ skipstart = startoffset - physstart; dropend = endoffset - physend; - /* how much to actually read */ + /* + * Make a transfer buffer. + * + * Note: rawbufmax = physend - physstart. Proof: + * + * physend - physstart = physend - physstart + * = physend - physstart + startoffset - startoffset + * = physend + (startoffset - physstart) - startoffset + * = physend + skipstart - startoffset + * = physend + skipstart - startoffset + endoffset - endoffset + * = skipstart - startoffset + endoffset - (endoffset - physend) + * = skipstart - startoffset + endoffset - dropend + * = skipstart - startoffset + (startoffset + callerbytes) - dropend + * = skipstart + callerbytes - dropend + * = rawbufmax + * Qed. + * + * XXX: this should just use physend - physstart. + * + * XXX: this should be rewritten to read the directs straight + * out of bufferio buffers instead of copying twice. This would + * also let us adapt better to the user's buffer size. + */ + + /* Base buffer space for CALLERBYTES of new data */ rawbufmax = callerbytes + skipstart; if (rawbufmax < callerbytes) return EINVAL;
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: christos Date: Thu Jun 20 00:52:05 UTC 2019 Modified Files: src/sys/ufs/ufs: ufs_readwrite.c Log Message: unifdef -ULFS_READWRITE ufs_readwrite.c To generate a diff of this commit: cvs rdiff -u -r1.123 -r1.124 src/sys/ufs/ufs/ufs_readwrite.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/ufs
Module Name:src Committed By: christos Date: Thu Jun 20 00:52:05 UTC 2019 Modified Files: src/sys/ufs/ufs: ufs_readwrite.c Log Message: unifdef -ULFS_READWRITE ufs_readwrite.c To generate a diff of this commit: cvs rdiff -u -r1.123 -r1.124 src/sys/ufs/ufs/ufs_readwrite.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ufs/ufs_readwrite.c diff -u src/sys/ufs/ufs/ufs_readwrite.c:1.123 src/sys/ufs/ufs/ufs_readwrite.c:1.124 --- src/sys/ufs/ufs/ufs_readwrite.c:1.123 Mon Dec 10 15:48:34 2018 +++ src/sys/ufs/ufs/ufs_readwrite.c Wed Jun 19 20:52:05 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_readwrite.c,v 1.123 2018/12/10 20:48:34 jdolecek Exp $ */ +/* $NetBSD: ufs_readwrite.c,v 1.124 2019/06/20 00:52:05 christos Exp $ */ /*- * Copyright (c) 1993 @@ -32,28 +32,8 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.123 2018/12/10 20:48:34 jdolecek Exp $"); +__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.124 2019/06/20 00:52:05 christos Exp $"); -#ifdef LFS_READWRITE -#define FS struct lfs -#define I_FS i_lfs -#define READ lfs_read -#define READ_S "lfs_read" -#define WRITE lfs_write -#define WRITE_S "lfs_write" -#define BUFRD lfs_bufrd -#define BUFWR lfs_bufwr -#define fs_bsize lfs_bsize -#define fs_bmask lfs_bmask -#define UFS_WAPBL_BEGIN(mp) 0 -#define UFS_WAPBL_END(mp) do { } while (0) -#define UFS_WAPBL_UPDATE(vp, access, modify, flags) do { } while (0) -#define ufs_blkoff lfs_blkoff -#define ufs_blksize lfs_blksize -#define ufs_lblkno lfs_lblkno -#define ufs_lblktosize lfs_lblktosize -#define ufs_blkroundup lfs_blkroundup -#else #define FS struct fs #define I_FS i_fs #define READ ffs_read @@ -67,7 +47,6 @@ __KERNEL_RCSID(1, "$NetBSD: ufs_readwrit #define ufs_lblkno ffs_lblkno #define ufs_lblktosize ffs_lblktosize #define ufs_blkroundup ffs_blkroundup -#endif static int ufs_post_read_update(struct vnode *, int, int); static int ufs_post_write_update(struct vnode *, struct uio *, int, @@ -106,20 +85,13 @@ READ(void *v) /* XXX Eliminate me by refusing directory reads from userland. */ if (vp->v_type == VDIR) return BUFRD(vp, uio, ioflag, ap->a_cred); -#ifdef LFS_READWRITE - /* XXX Eliminate me by using ufs_bufio in lfs. */ - if (vp->v_type == VREG && ip->i_number == LFS_IFILE_INUM) - return BUFRD(vp, uio, ioflag, ap->a_cred); -#endif if ((u_int64_t)uio->uio_offset > ump->um_maxfilesize) return (EFBIG); if (uio->uio_resid == 0) return (0); -#ifndef LFS_READWRITE if ((ip->i_flags & (SF_SNAPSHOT | SF_SNAPINVAL)) == SF_SNAPSHOT) return ffs_snapshot_read(vp, uio, ioflag); -#endif /* !LFS_READWRITE */ if (uio->uio_offset >= ip->i_size) goto out; @@ -177,9 +149,7 @@ BUFRD(struct vnode *vp, struct uio *uio, if (uio->uio_resid == 0) return 0; -#ifndef LFS_READWRITE KASSERT(!ISSET(ip->i_flags, (SF_SNAPSHOT | SF_SNAPINVAL))); -#endif if (uio->uio_offset >= ip->i_size) goto out; @@ -302,12 +272,6 @@ WRITE(void *v) if (uio->uio_offset < 0 || (u_int64_t)uio->uio_offset + uio->uio_resid > ump->um_maxfilesize) return (EFBIG); -#ifdef LFS_READWRITE - /* Disallow writes to the Ifile, even if noschg flag is removed */ - /* XXX can this go away when the Ifile is no longer in the namespace? */ - if (vp == fs->lfs_ivnode) - return (EPERM); -#endif if (uio->uio_resid == 0) return (0); @@ -352,11 +316,6 @@ WRITE(void *v) return error; } -#ifdef LFS_READWRITE - async = true; - lfs_availwait(fs, btofsb(fs, uio->uio_resid)); - lfs_check(vp, LFS_UNUSED_LBN, 0); -#endif /* !LFS_READWRITE */ preallocoff = round_page(ufs_blkroundup(fs, MAX(osize, uio->uio_offset))); aflag = ioflag & IO_SYNC ? B_SYNC : 0; @@ -471,7 +430,6 @@ WRITE(void *v) * XXXUBC simplistic async flushing. */ -#ifndef LFS_READWRITE if (!async && oldoff >> 16 != uio->uio_offset >> 16) { mutex_enter(vp->v_interlock); error = VOP_PUTPAGES(vp, (oldoff >> 16) << 16, @@ -480,7 +438,6 @@ WRITE(void *v) if (error) break; } -#endif } if (error == 0 && ioflag & IO_SYNC) { mutex_enter(vp->v_interlock); @@ -513,9 +470,6 @@ BUFWR(struct vnode *vp, struct uio *uio, daddr_t lbn; int extended=0; int error; -#ifdef LFS_READWRITE - bool need_unreserve = false; -#endif KASSERT(ISSET(ioflag, IO_NODELOCKED)); KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE); @@ -535,9 +489,6 @@ BUFWR(struct vnode *vp, struct uio *uio, uio->uio_resid > ump->um_maxfilesize || uio->uio_offset > (ump->um_maxfilesize - uio->uio_resid)) return EFBIG; -#ifdef LFS_READWRITE - KASSERT(vp != fs->lfs_ivnode); -#endif if (uio->uio_resid == 0) return 0; @@ -548,10 +499,6 @@ BUFWR(struct vnode *vp, struct uio *uio, KASSERT(vp->v_type != VREG); -#ifdef LFS_READWRITE - lfs_availwait(fs, btofsb(fs, uio->uio_resid)); - lfs_check(vp, LFS_UNUSED_LBN, 0); -#endif /* !LFS_READWRITE */ /* XXX
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: christos Date: Sun May 5 15:07:12 UTC 2019 Modified Files: src/sys/ufs/ufs: dir.h ufs_lookup.c Log Message: Add more comments to explain what we are doing. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/ufs/ufs/dir.h cvs rdiff -u -r1.149 -r1.150 src/sys/ufs/ufs/ufs_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/ufs/dir.h diff -u src/sys/ufs/ufs/dir.h:1.26 src/sys/ufs/ufs/dir.h:1.27 --- src/sys/ufs/ufs/dir.h:1.26 Sat May 4 21:48:53 2019 +++ src/sys/ufs/ufs/dir.h Sun May 5 11:07:12 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.h,v 1.26 2019/05/05 01:48:53 christos Exp $ */ +/* $NetBSD: dir.h,v 1.27 2019/05/05 15:07:12 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -109,7 +109,9 @@ struct direct { * The UFS_DIRSIZ macro gives the minimum record length which will hold * the directory entry. This requires the amount of space in struct direct * without the d_name field, plus enough space for the name with a terminating - * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary. + * NUL byte (dp->d_namlen+1), rounded up to a 4 byte boundary. + * The UFS_NAMEPAD macro gives the number bytes of padding needed including + * the NUL terminating byte. */ #define DIR_ROUNDUP 4 #define UFS_NAMEROUNDUP(namlen) (((namlen) + DIR_ROUNDUP) & ~(DIR_ROUNDUP - 1)) Index: src/sys/ufs/ufs/ufs_lookup.c diff -u src/sys/ufs/ufs/ufs_lookup.c:1.149 src/sys/ufs/ufs/ufs_lookup.c:1.150 --- src/sys/ufs/ufs/ufs_lookup.c:1.149 Sat May 4 21:48:53 2019 +++ src/sys/ufs/ufs/ufs_lookup.c Sun May 5 11:07:12 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_lookup.c,v 1.149 2019/05/05 01:48:53 christos Exp $ */ +/* $NetBSD: ufs_lookup.c,v 1.150 2019/05/05 15:07:12 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.149 2019/05/05 01:48:53 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.150 2019/05/05 15:07:12 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_ffs.h" @@ -799,7 +799,7 @@ ufs_makedirentry(struct inode *ip, struc newdirp->d_namlen = namelen; memcpy(newdirp->d_name, cnp->cn_nameptr, namelen); - /* Zero out padding */ + /* NUL terminate and zero out padding */ memset(>d_name[namelen], 0, UFS_NAMEPAD(namelen)); if (FSFMT(ITOV(ip)))
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: christos Date: Sun May 5 15:07:12 UTC 2019 Modified Files: src/sys/ufs/ufs: dir.h ufs_lookup.c Log Message: Add more comments to explain what we are doing. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/ufs/ufs/dir.h cvs rdiff -u -r1.149 -r1.150 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: christos Date: Sun May 5 01:48:53 UTC 2019 Modified Files: src/sys/ufs/ufs: dir.h ufs_lookup.c Log Message: Zero out all the dirent padding not just one byte, to avoid kernel memory disclosure (from https://svnweb.freebsd.org/base?view=revision=347066) To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/ufs/ufs/dir.h cvs rdiff -u -r1.148 -r1.149 src/sys/ufs/ufs/ufs_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/ufs/dir.h diff -u src/sys/ufs/ufs/dir.h:1.25 src/sys/ufs/ufs/dir.h:1.26 --- src/sys/ufs/ufs/dir.h:1.25 Tue Sep 1 02:16:03 2015 +++ src/sys/ufs/ufs/dir.h Sat May 4 21:48:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.h,v 1.25 2015/09/01 06:16:03 dholland Exp $ */ +/* $NetBSD: dir.h,v 1.26 2019/05/05 01:48:53 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -111,8 +111,11 @@ struct direct { * without the d_name field, plus enough space for the name with a terminating * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary. */ +#define DIR_ROUNDUP 4 +#define UFS_NAMEROUNDUP(namlen) (((namlen) + DIR_ROUNDUP) & ~(DIR_ROUNDUP - 1)) +#define UFS_NAMEPAD(namlen) (DIR_ROUNDUP - ((namlen) & (DIR_ROUNDUP - 1))) #define UFS_DIRECTSIZ(namlen) \ - ((sizeof(struct direct) - (FFS_MAXNAMLEN+1)) + (((namlen)+1 + 3) &~ 3)) + ((sizeof(struct direct) - (FFS_MAXNAMLEN+1)) + UFS_NAMEROUNDUP(namlen)) #if (BYTE_ORDER == LITTLE_ENDIAN) #define UFS_DIRSIZ(oldfmt, dp, needswap) \ Index: src/sys/ufs/ufs/ufs_lookup.c diff -u src/sys/ufs/ufs/ufs_lookup.c:1.148 src/sys/ufs/ufs/ufs_lookup.c:1.149 --- src/sys/ufs/ufs/ufs_lookup.c:1.148 Fri Oct 27 08:25:15 2017 +++ src/sys/ufs/ufs/ufs_lookup.c Sat May 4 21:48:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_lookup.c,v 1.148 2017/10/27 12:25:15 joerg Exp $ */ +/* $NetBSD: ufs_lookup.c,v 1.149 2019/05/05 01:48:53 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.148 2017/10/27 12:25:15 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.149 2019/05/05 01:48:53 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_ffs.h" @@ -793,10 +793,15 @@ void ufs_makedirentry(struct inode *ip, struct componentname *cnp, struct direct *newdirp) { + size_t namelen = cnp->cn_namelen; + newdirp->d_ino = ip->i_number; - newdirp->d_namlen = cnp->cn_namelen; - memcpy(newdirp->d_name, cnp->cn_nameptr, (size_t)cnp->cn_namelen); - newdirp->d_name[cnp->cn_namelen] = '\0'; + newdirp->d_namlen = namelen; + memcpy(newdirp->d_name, cnp->cn_nameptr, namelen); + + /* Zero out padding */ + memset(>d_name[namelen], 0, UFS_NAMEPAD(namelen)); + if (FSFMT(ITOV(ip))) newdirp->d_type = 0; else
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: christos Date: Sun May 5 01:48:53 UTC 2019 Modified Files: src/sys/ufs/ufs: dir.h ufs_lookup.c Log Message: Zero out all the dirent padding not just one byte, to avoid kernel memory disclosure (from https://svnweb.freebsd.org/base?view=revision=347066) To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/ufs/ufs/dir.h cvs rdiff -u -r1.148 -r1.149 src/sys/ufs/ufs/ufs_lookup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys/ufs/ufs
On Sun, Feb 24, 2019 at 10:13:40PM +0100, Tobias Nygren wrote: > On Sun, 24 Feb 2019 19:06:40 + > Michael van Elst wrote: > > > To generate a diff of this commit: > > cvs rdiff -u -r1.242 -r1.243 src/sys/ufs/ufs/ufs_vnops.c > > > + rawbuf -= dropend; > > I guess this should be rawbufmax, not rawbuf. Yes, already fixed. -- Michael van Elst Internet: mlel...@serpens.de "A potential Snark may lurk in every tree."
Re: CVS commit: src/sys/ufs/ufs
On Mon, Feb 25, 2019 at 06:07:23AM +, David Holland wrote: > that one doesn't set dropend correctly for small buffers, outsmarted > myself while writing it. Better change (still against 1.242) that makes the logic much simpler. Will test this overnight... Index: ufs_vnops.c === RCS file: /cvsroot/src/sys/ufs/ufs/ufs_vnops.c,v retrieving revision 1.239 diff -u -p -r1.239 ufs_vnops.c --- ufs_vnops.c 28 Oct 2017 00:37:13 - 1.239 +++ ufs_vnops.c 25 Feb 2019 06:58:52 - @@ -1233,7 +1233,7 @@ ufs_readdir(void *v) #endif /* caller's buffer */ struct uio *calleruio = ap->a_uio; - off_t startoffset, endoffset; + off_t startoffset; size_t callerbytes; off_t curoffset; /* dirent production buffer */ @@ -1244,8 +1244,8 @@ ufs_readdir(void *v) off_t *cookies; size_t numcookies, maxcookies; /* disk buffer */ - off_t physstart, physend; - size_t skipstart, dropend; + off_t physstart; + size_t skipstart; char*rawbuf; size_t rawbufmax, rawbytes; struct uio rawuio; @@ -1256,29 +1256,60 @@ ufs_readdir(void *v) KASSERT(VOP_ISLOCKED(vp)); - /* figure out where we want to read */ +#define UFS_READDIR_ARBITRARY_MAX (1024*1024) callerbytes = calleruio->uio_resid; - startoffset = calleruio->uio_offset; - endoffset = startoffset + callerbytes; - if (callerbytes < _DIRENT_MINSIZE(dirent)) { /* no room for even one struct dirent */ return EINVAL; } + if (callerbytes > UFS_READDIR_ARBITRARY_MAX) { + callerbytes = UFS_READDIR_ARBITRARY_MAX; + } - /* round start and end down to block boundaries */ + /* +* Figure out where to start reading. Round the start down to +* a block boundary: we need to start at the beginning of a +* block in order to read the directory correctly. +* +* skipstart is the number of bytes we need to read in +* (because we need to start at the beginning of a block) but +* not transfer to the user. +*/ + startoffset = calleruio->uio_offset; physstart = startoffset & ~(off_t)(ump->um_dirblksiz - 1); - physend = endoffset & ~(off_t)(ump->um_dirblksiz - 1); skipstart = startoffset - physstart; - dropend = endoffset - physend; - if (callerbytes - dropend < _DIRENT_MINSIZE(rawdp)) { - /* no room for even one struct direct */ - return EINVAL; - } + /* +* Now figure out how much to read. +* +* callerbytes tells us how much data we can send back to the +* user. Assume as a starting point that we want to read +* roughly the same volume of struct directs from disk as the +* volume of struct dirents we want to send to the user; this +* is not super accurate for large numbers of small names but +* will serve well enough. It's ok to underpopulate the user's +* buffer, and most directories are only a couple blocks +* anyway. +* +* However much we decide we want, stop on a block boundary. +* That way the copying code below doesn't need to worry about +* finding partial entries in the transfer buffer. +* +* Do this by rounding down (not up) by default as that will +* with luck avoid needing to scan the next block twice; but +* always read in at least one block. +*/ - /* how much to actually read */ - rawbufmax = callerbytes + skipstart - dropend; + /* Base buffer space for CALLERBYTES of new data */ + rawbufmax = callerbytes + skipstart; + + /* Round down to an integral number of blocks */ + rawbufmax &= ~(off_t)(ump->um_dirblksiz - 1); + + /* but always at least one block */ + if (rawbufmax == 0) { + rawbufmax = ump->um_dirblksiz; + } /* read it */ rawbuf = kmem_alloc(rawbufmax, KM_SLEEP); -- David A. Holland dholl...@netbsd.org
Re: CVS commit: src/sys/ufs/ufs
On Mon, Feb 25, 2019 at 05:50:08AM +, David Holland wrote: > Furthermore, this: > > > + rawbuf -= dropend; > > is entirely wrong (it needs to be "rawbufmax") and without that bound > on rawbufmax the code is unsafe... I repaired this bit just now, so it's not an overt hazard any more. I still don't like this change all that much but whatever, I suppose... > Here's the fix I got bogged down trying to build and test, which also > adds a missing upper bound on callerbytes: that one doesn't set dropend correctly for small buffers, outsmarted myself while writing it. -- David A. Holland dholl...@netbsd.org
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: dholland Date: Mon Feb 25 06:00:40 UTC 2019 Modified Files: src/sys/ufs/ufs: ufs_vnops.c Log Message: Revert -r1.244-245 of ufs_vnops.c; they are wrong. Fix the mistake in -r1.243 that made them look like reasonable changes. (this does not affect whether the -r1.243 change works with the union mount path in libc, but fixes an immediate hazard) To generate a diff of this commit: cvs rdiff -u -r1.245 -r1.246 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: dholland Date: Mon Feb 25 06:00:40 UTC 2019 Modified Files: src/sys/ufs/ufs: ufs_vnops.c Log Message: Revert -r1.244-245 of ufs_vnops.c; they are wrong. Fix the mistake in -r1.243 that made them look like reasonable changes. (this does not affect whether the -r1.243 change works with the union mount path in libc, but fixes an immediate hazard) To generate a diff of this commit: cvs rdiff -u -r1.245 -r1.246 src/sys/ufs/ufs/ufs_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/ufs/ufs_vnops.c diff -u src/sys/ufs/ufs/ufs_vnops.c:1.245 src/sys/ufs/ufs/ufs_vnops.c:1.246 --- src/sys/ufs/ufs/ufs_vnops.c:1.245 Mon Feb 25 00:51:24 2019 +++ src/sys/ufs/ufs/ufs_vnops.c Mon Feb 25 06:00:40 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vnops.c,v 1.245 2019/02/25 00:51:24 christos Exp $ */ +/* $NetBSD: ufs_vnops.c,v 1.246 2019/02/25 06:00:40 dholland Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.245 2019/02/25 00:51:24 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.246 2019/02/25 06:00:40 dholland Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -1246,7 +1246,7 @@ ufs_readdir(void *v) size_t numcookies, maxcookies; /* disk buffer */ off_t physstart, physend; - size_t skipstart; + size_t skipstart, dropend; char *rawbuf; size_t rawbufmax, rawbytes; struct uio rawuio; @@ -1277,11 +1277,13 @@ ufs_readdir(void *v) } skipstart = startoffset - physstart; + dropend = endoffset - physend; /* how much to actually read */ rawbufmax = callerbytes + skipstart; if (rawbufmax < callerbytes) return EINVAL; + rawbufmax -= dropend; if (rawbufmax < _DIRENT_MINSIZE(rawdp)) { /* no room for even one struct direct */
Re: CVS commit: src/sys/ufs/ufs
On Sun, Feb 24, 2019 at 07:51:24PM -0500, Christos Zoulas wrote: > Module Name: src > Committed By:christos > Date:Mon Feb 25 00:51:24 UTC 2019 > > Modified Files: > src/sys/ufs/ufs: ufs_vnops.c > > Log Message: > drop unused dropping this logic is wrong... -- David A. Holland dholl...@netbsd.org
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: christos Date: Mon Feb 25 00:51:24 UTC 2019 Modified Files: src/sys/ufs/ufs: ufs_vnops.c Log Message: drop unused To generate a diff of this commit: cvs rdiff -u -r1.244 -r1.245 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: christos Date: Mon Feb 25 00:51:24 UTC 2019 Modified Files: src/sys/ufs/ufs: ufs_vnops.c Log Message: drop unused To generate a diff of this commit: cvs rdiff -u -r1.244 -r1.245 src/sys/ufs/ufs/ufs_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/ufs/ufs_vnops.c diff -u src/sys/ufs/ufs/ufs_vnops.c:1.244 src/sys/ufs/ufs/ufs_vnops.c:1.245 --- src/sys/ufs/ufs/ufs_vnops.c:1.244 Sun Feb 24 19:11:13 2019 +++ src/sys/ufs/ufs/ufs_vnops.c Sun Feb 24 19:51:24 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vnops.c,v 1.244 2019/02/25 00:11:13 christos Exp $ */ +/* $NetBSD: ufs_vnops.c,v 1.245 2019/02/25 00:51:24 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.244 2019/02/25 00:11:13 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.245 2019/02/25 00:51:24 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -1246,7 +1246,7 @@ ufs_readdir(void *v) size_t numcookies, maxcookies; /* disk buffer */ off_t physstart, physend; - size_t skipstart, dropend; + size_t skipstart; char *rawbuf; size_t rawbufmax, rawbytes; struct uio rawuio; @@ -1277,7 +1277,6 @@ ufs_readdir(void *v) } skipstart = startoffset - physstart; - dropend = endoffset - physend; /* how much to actually read */ rawbufmax = callerbytes + skipstart;
Re: CVS commit: src/sys/ufs/ufs
On Sun, 24 Feb 2019 19:06:40 + Michael van Elst wrote: > To generate a diff of this commit: > cvs rdiff -u -r1.242 -r1.243 src/sys/ufs/ufs/ufs_vnops.c > + rawbuf -= dropend; I guess this should be rawbufmax, not rawbuf.
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: christos Date: Mon Feb 25 00:11:13 UTC 2019 Modified Files: src/sys/ufs/ufs: ufs_vnops.c Log Message: remove junk assignment. To generate a diff of this commit: cvs rdiff -u -r1.243 -r1.244 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: christos Date: Mon Feb 25 00:11:13 UTC 2019 Modified Files: src/sys/ufs/ufs: ufs_vnops.c Log Message: remove junk assignment. To generate a diff of this commit: cvs rdiff -u -r1.243 -r1.244 src/sys/ufs/ufs/ufs_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/ufs/ufs_vnops.c diff -u src/sys/ufs/ufs/ufs_vnops.c:1.243 src/sys/ufs/ufs/ufs_vnops.c:1.244 --- src/sys/ufs/ufs/ufs_vnops.c:1.243 Sun Feb 24 14:06:40 2019 +++ src/sys/ufs/ufs/ufs_vnops.c Sun Feb 24 19:11:13 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vnops.c,v 1.243 2019/02/24 19:06:40 mlelstv Exp $ */ +/* $NetBSD: ufs_vnops.c,v 1.244 2019/02/25 00:11:13 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.243 2019/02/24 19:06:40 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.244 2019/02/25 00:11:13 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -1283,7 +1283,6 @@ ufs_readdir(void *v) rawbufmax = callerbytes + skipstart; if (rawbufmax < callerbytes) return EINVAL; - rawbuf -= dropend; if (rawbufmax < _DIRENT_MINSIZE(rawdp)) { /* no room for even one struct direct */
Re: CVS commit: src/sys/ufs/ufs
On Sun, Feb 24, 2019 at 07:41:59PM +, m...@netbsd.org wrote: > something like the overflow is undefined behaviour, so it cannot > happen, so the branch checking that it happened is eliminated. *Signed* integer overflow is undefined behavior. *Unsigned* integer overflow is well defined. Joerg
Re: CVS commit: src/sys/ufs/ufs
On Sun, Feb 24, 2019 at 07:41:59PM +, m...@netbsd.org wrote: > something like the overflow is undefined behaviour, so it cannot > happen, so the branch checking that it happened is eliminated. Integer overflow is not undefined, but implemenation defined behaviour. Martin
Re: CVS commit: src/sys/ufs/ufs
On Sun, Feb 24, 2019 at 07:06:40PM +, Michael van Elst wrote: > While here, also check for arithmetic overflow. > + /* how much to actually read */ > + rawbufmax = callerbytes + skipstart; > + if (rawbufmax < callerbytes) > + return EINVAL; hmm, I"m under the impression that checking for overflow without upsetting the compiler is a delicate matter. something like the overflow is undefined behaviour, so it cannot happen, so the branch checking that it happened is eliminated.
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: mlelstv Date: Sun Feb 24 19:06:40 UTC 2019 Modified Files: src/sys/ufs/ufs: ufs_vnops.c Log Message: Reading a directory may trigger a panic when the buffer is too small. Adjust necessary checks. While here, also check for arithmetic overflow. Reported-by: syzbot+88ecace8bff241690...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.242 -r1.243 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: mlelstv Date: Sun Feb 24 19:06:40 UTC 2019 Modified Files: src/sys/ufs/ufs: ufs_vnops.c Log Message: Reading a directory may trigger a panic when the buffer is too small. Adjust necessary checks. While here, also check for arithmetic overflow. Reported-by: syzbot+88ecace8bff241690...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.242 -r1.243 src/sys/ufs/ufs/ufs_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/ufs/ufs_vnops.c diff -u src/sys/ufs/ufs/ufs_vnops.c:1.242 src/sys/ufs/ufs/ufs_vnops.c:1.243 --- src/sys/ufs/ufs/ufs_vnops.c:1.242 Tue Jan 1 10:06:55 2019 +++ src/sys/ufs/ufs/ufs_vnops.c Sun Feb 24 19:06:40 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vnops.c,v 1.242 2019/01/01 10:06:55 hannken Exp $ */ +/* $NetBSD: ufs_vnops.c,v 1.243 2019/02/24 19:06:40 mlelstv Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.242 2019/01/01 10:06:55 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.243 2019/02/24 19:06:40 mlelstv Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -1268,19 +1268,28 @@ ufs_readdir(void *v) } /* round start and end down to block boundaries */ - physstart = startoffset & ~(off_t)(ump->um_dirblksiz - 1); - physend = endoffset & ~(off_t)(ump->um_dirblksiz - 1); + physstart = rounddown2(startoffset, ump->um_dirblksiz); + physend = rounddown2(endoffset, ump->um_dirblksiz); + + if (physstart >= physend) { + /* Need at least one block */ + return EINVAL; + } + skipstart = startoffset - physstart; dropend = endoffset - physend; - if (callerbytes - dropend < _DIRENT_MINSIZE(rawdp)) { + /* how much to actually read */ + rawbufmax = callerbytes + skipstart; + if (rawbufmax < callerbytes) + return EINVAL; + rawbuf -= dropend; + + if (rawbufmax < _DIRENT_MINSIZE(rawdp)) { /* no room for even one struct direct */ return EINVAL; } - /* how much to actually read */ - rawbufmax = callerbytes + skipstart - dropend; - /* read it */ rawbuf = kmem_alloc(rawbufmax, KM_SLEEP); rawiov.iov_base = rawbuf;
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: hannken Date: Sun Jan 28 10:01:18 UTC 2018 Modified Files: src/sys/ufs/ufs: ufs_inode.c Log Message: Make sure inode blocks and size are zero when VOP_INACTIVE() finalises a now unlinked inode. Counterpart of the check in ffs_newvnode(). To generate a diff of this commit: cvs rdiff -u -r1.102 -r1.103 src/sys/ufs/ufs/ufs_inode.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/ufs
Module Name:src Committed By: hannken Date: Sun Jan 28 10:01:18 UTC 2018 Modified Files: src/sys/ufs/ufs: ufs_inode.c Log Message: Make sure inode blocks and size are zero when VOP_INACTIVE() finalises a now unlinked inode. Counterpart of the check in ffs_newvnode(). To generate a diff of this commit: cvs rdiff -u -r1.102 -r1.103 src/sys/ufs/ufs/ufs_inode.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/ufs/ufs_inode.c diff -u src/sys/ufs/ufs/ufs_inode.c:1.102 src/sys/ufs/ufs/ufs_inode.c:1.103 --- src/sys/ufs/ufs/ufs_inode.c:1.102 Sat Oct 28 00:37:13 2017 +++ src/sys/ufs/ufs/ufs_inode.c Sun Jan 28 10:01:18 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_inode.c,v 1.102 2017/10/28 00:37:13 pgoyette Exp $ */ +/* $NetBSD: ufs_inode.c,v 1.103 2018/01/28 10:01:18 hannken Exp $ */ /* * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.102 2017/10/28 00:37:13 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.103 2018/01/28 10:01:18 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -149,6 +149,15 @@ out: */ *ap->a_recycle = (ip->i_mode == 0); + if (ip->i_mode == 0 && (DIP(ip, size) != 0 || DIP(ip, blocks) != 0)) { + printf("%s: unlinked ino %" PRId64 " on \"%s\" has" + " non zero size %" PRIx64 " or blocks %" PRIx64 + " with allerror %d\n", + __func__, ip->i_number, mp->mnt_stat.f_mntonname, + DIP(ip, size), DIP(ip, blocks), allerror); + panic("%s: dirty filesystem?", __func__); + } + return (allerror); }
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: jdolecek Date: Wed Oct 25 18:06:01 UTC 2017 Modified Files: src/sys/ufs/ufs: quota2.h Log Message: fix tyop, PR kern/52653 by Edgar Fuss To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/ufs/quota2.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/ufs
Module Name:src Committed By: jdolecek Date: Wed Oct 25 18:06:01 UTC 2017 Modified Files: src/sys/ufs/ufs: quota2.h Log Message: fix tyop, PR kern/52653 by Edgar Fuss To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/ufs/quota2.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/ufs/quota2.h diff -u src/sys/ufs/ufs/quota2.h:1.9 src/sys/ufs/ufs/quota2.h:1.10 --- src/sys/ufs/ufs/quota2.h:1.9 Sun Feb 5 14:19:04 2012 +++ src/sys/ufs/ufs/quota2.h Wed Oct 25 18:06:01 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: quota2.h,v 1.9 2012/02/05 14:19:04 dholland Exp $ */ +/* $NetBSD: quota2.h,v 1.10 2017/10/25 18:06:01 jdolecek Exp $ */ /*- * Copyright (c) 2010 Manuel Bouyer * All rights reserved. @@ -56,7 +56,7 @@ struct quota2_val { /* * On-disk description of a user or group quota - * These entries are keept as linked list, either in one of the hash HEAD, + * These entries are kept as linked list, either in one of the hash HEAD, * or in the free list. */
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: maya Date: Sun Aug 20 12:09:06 UTC 2017 Modified Files: src/sys/ufs/ufs: inode.h Log Message: update the comment to the current IFMT/permissions location To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/sys/ufs/ufs/inode.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/ufs/inode.h diff -u src/sys/ufs/ufs/inode.h:1.75 src/sys/ufs/ufs/inode.h:1.76 --- src/sys/ufs/ufs/inode.h:1.75 Sun Aug 14 11:31:41 2016 +++ src/sys/ufs/ufs/inode.h Sun Aug 20 12:09:06 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: inode.h,v 1.75 2016/08/14 11:31:41 jdolecek Exp $ */ +/* $NetBSD: inode.h,v 1.76 2017/08/20 12:09:06 maya Exp $ */ /* * Copyright (c) 1982, 1989, 1993 @@ -144,7 +144,7 @@ struct inode { * These fields are currently only used by FFS and LFS, * do NOT use them with ext2fs. */ - u_int16_t i_mode; /* IFMT, permissions; see below. */ + u_int16_t i_mode; /* IFMT, permissions; see dinode.h. */ int16_t i_nlink; /* File link count. */ u_int64_t i_size; /* File byte count. */ u_int32_t i_flags; /* Status flags (chflags). */
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: maya Date: Sun Aug 20 12:09:06 UTC 2017 Modified Files: src/sys/ufs/ufs: inode.h Log Message: update the comment to the current IFMT/permissions location To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/sys/ufs/ufs/inode.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/ufs
Module Name:src Committed By: hannken Date: Thu Mar 30 09:11:45 UTC 2017 Modified Files: src/sys/ufs/ufs: ufs_lookup.c Log Message: Remove now redundant calls to fstrans_start()/fstrans_done(). To generate a diff of this commit: cvs rdiff -u -r1.145 -r1.146 src/sys/ufs/ufs/ufs_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/ufs/ufs_lookup.c diff -u src/sys/ufs/ufs/ufs_lookup.c:1.145 src/sys/ufs/ufs/ufs_lookup.c:1.146 --- src/sys/ufs/ufs/ufs_lookup.c:1.145 Fri Apr 29 02:38:19 2016 +++ src/sys/ufs/ufs/ufs_lookup.c Thu Mar 30 09:11:45 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_lookup.c,v 1.145 2016/04/29 02:38:19 christos Exp $ */ +/* $NetBSD: ufs_lookup.c,v 1.146 2017/03/30 09:11:45 hannken Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.145 2016/04/29 02:38:19 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.146 2017/03/30 09:11:45 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_ffs.h" @@ -54,7 +54,6 @@ __KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c #include #include #include -#include #include #include @@ -376,8 +375,6 @@ ufs_lookup(void *v) cnp->cn_flags |= ISWHITEOUT; } - fstrans_start(vdp->v_mount, FSTRANS_SHARED); - /* * Suppress search for slots unless creating * file and at end of pathname, in which case @@ -695,7 +692,6 @@ found: error = 0; out: - fstrans_done(vdp->v_mount); return error; }
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: riastradh Date: Sat Mar 18 05:39:06 UTC 2017 Modified Files: src/sys/ufs/ufs: ufs_vnops.c Log Message: #if DIAGNOSTIC panic ---> KASSERT To generate a diff of this commit: cvs rdiff -u -r1.235 -r1.236 src/sys/ufs/ufs/ufs_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/ufs/ufs_vnops.c diff -u src/sys/ufs/ufs/ufs_vnops.c:1.235 src/sys/ufs/ufs/ufs_vnops.c:1.236 --- src/sys/ufs/ufs/ufs_vnops.c:1.235 Wed Mar 1 10:42:45 2017 +++ src/sys/ufs/ufs/ufs_vnops.c Sat Mar 18 05:39:06 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vnops.c,v 1.235 2017/03/01 10:42:45 hannken Exp $ */ +/* $NetBSD: ufs_vnops.c,v 1.236 2017/03/18 05:39:06 riastradh Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.235 2017/03/01 10:42:45 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.236 2017/03/18 05:39:06 riastradh Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -865,10 +865,9 @@ ufs_whiteout(void *v) error = UFS_WAPBL_BEGIN(dvp->v_mount); if (error) break; -#ifdef DIAGNOSTIC - if (ump->um_maxsymlinklen <= 0) - panic("ufs_whiteout: old format filesystem"); -#endif + + KASSERTMSG((ump->um_maxsymlinklen > 0), + "ufs_whiteout: old format filesystem"); newdir = pool_cache_get(ufs_direct_cache, PR_WAITOK); newdir->d_ino = UFS_WINO; @@ -886,10 +885,9 @@ ufs_whiteout(void *v) error = UFS_WAPBL_BEGIN(dvp->v_mount); if (error) break; -#ifdef DIAGNOSTIC - if (ump->um_maxsymlinklen <= 0) - panic("ufs_whiteout: old format filesystem"); -#endif + + KASSERTMSG((ump->um_maxsymlinklen > 0), + "ufs_whiteout: old format filesystem"); cnp->cn_flags &= ~DOWHITEOUT; error = ufs_dirremove(dvp, ulr, NULL, cnp->cn_flags, 0);
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: riastradh Date: Sat Mar 18 05:39:06 UTC 2017 Modified Files: src/sys/ufs/ufs: ufs_vnops.c Log Message: #if DIAGNOSTIC panic ---> KASSERT To generate a diff of this commit: cvs rdiff -u -r1.235 -r1.236 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: riastradh Date: Sat Mar 18 05:33:07 UTC 2017 Modified Files: src/sys/ufs/ufs: ufs_bmap.c Log Message: #if DIAGNOSTIC panic ---> KASSERT To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/ufs/ufs/ufs_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/ufs/ufs_bmap.c diff -u src/sys/ufs/ufs/ufs_bmap.c:1.51 src/sys/ufs/ufs/ufs_bmap.c:1.52 --- src/sys/ufs/ufs/ufs_bmap.c:1.51 Wed Mar 1 10:42:45 2017 +++ src/sys/ufs/ufs/ufs_bmap.c Sat Mar 18 05:33:06 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_bmap.c,v 1.51 2017/03/01 10:42:45 hannken Exp $ */ +/* $NetBSD: ufs_bmap.c,v 1.52 2017/03/18 05:33:06 riastradh Exp $ */ /* * Copyright (c) 1989, 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_bmap.c,v 1.51 2017/03/01 10:42:45 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_bmap.c,v 1.52 2017/03/18 05:33:06 riastradh Exp $"); #include #include @@ -127,10 +127,8 @@ ufs_bmaparray(struct vnode *vp, daddr_t ip = VTOI(vp); mp = vp->v_mount; ump = ip->i_ump; -#ifdef DIAGNOSTIC - if ((ap != NULL && nump == NULL) || (ap == NULL && nump != NULL)) - panic("ufs_bmaparray: invalid arguments"); -#endif + KASSERTMSG(((ap == NULL) == (nump == NULL)), + "ufs_bmaparray: invalid arguments: ap = %p, nump = %p", ap, nump); if (runp) { /* @@ -249,12 +247,9 @@ ufs_bmaparray(struct vnode *vp, daddr_t } if (bp->b_oflags & (BO_DONE | BO_DELWRI)) { trace(TR_BREADHIT, pack(vp, size), metalbn); - } -#ifdef DIAGNOSTIC - else if (!daddr) - panic("ufs_bmaparray: indirect block not in cache"); -#endif - else { + } else { + KASSERTMSG((daddr != 0), + "ufs_bmaparray: indirect block not in cache"); trace(TR_BREADMISS, pack(vp, size), metalbn); bp->b_blkno = blkptrtodb(ump, daddr); bp->b_flags |= B_READ;
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: riastradh Date: Sat Mar 18 05:33:07 UTC 2017 Modified Files: src/sys/ufs/ufs: ufs_bmap.c Log Message: #if DIAGNOSTIC panic ---> KASSERT To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: hannken Date: Wed Jan 4 10:04:17 UTC 2017 Modified Files: src/sys/ufs/ufs: ufs_inode.c Log Message: Change ufs_truncate_retry() to call UFS_TRUNCATE() at least once. Even with "newsize == ip->i_size" it must set mtime etc. Adresses PR kern/51762 "mtime not updated by open(O_TRUNC)" To generate a diff of this commit: cvs rdiff -u -r1.97 -r1.98 src/sys/ufs/ufs/ufs_inode.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/ufs
Module Name:src Committed By: hannken Date: Wed Jan 4 10:04:17 UTC 2017 Modified Files: src/sys/ufs/ufs: ufs_inode.c Log Message: Change ufs_truncate_retry() to call UFS_TRUNCATE() at least once. Even with "newsize == ip->i_size" it must set mtime etc. Adresses PR kern/51762 "mtime not updated by open(O_TRUNC)" To generate a diff of this commit: cvs rdiff -u -r1.97 -r1.98 src/sys/ufs/ufs/ufs_inode.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/ufs/ufs_inode.c diff -u src/sys/ufs/ufs/ufs_inode.c:1.97 src/sys/ufs/ufs/ufs_inode.c:1.98 --- src/sys/ufs/ufs/ufs_inode.c:1.97 Fri Oct 28 20:38:12 2016 +++ src/sys/ufs/ufs/ufs_inode.c Wed Jan 4 10:04:17 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_inode.c,v 1.97 2016/10/28 20:38:12 jdolecek Exp $ */ +/* $NetBSD: ufs_inode.c,v 1.98 2017/01/04 10:04:17 hannken Exp $ */ /* * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.97 2016/10/28 20:38:12 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.98 2017/01/04 10:04:17 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -303,7 +303,7 @@ ufs_truncate_retry(struct vnode *vp, uin /* * Truncate might temporarily fail, loop until done. */ - while (ip->i_size != newsize) { + do { error = UFS_WAPBL_BEGIN(mp); if (error) goto out; @@ -313,7 +313,7 @@ ufs_truncate_retry(struct vnode *vp, uin if (error != 0 && error != EAGAIN) goto out; - } + } while (ip->i_size != newsize); out: return error;
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: riastradh Date: Sun Nov 20 21:21:26 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_quota2.c Log Message: KASSERT(mutex_owner(...)) ---> KASSERT(mutex_owned(...)) Fixes part of PR kern/47114. Tested by code inspection. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/ufs/ufs/ufs_quota2.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/ufs
Module Name:src Committed By: riastradh Date: Sun Nov 20 21:21:26 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_quota2.c Log Message: KASSERT(mutex_owner(...)) ---> KASSERT(mutex_owned(...)) Fixes part of PR kern/47114. Tested by code inspection. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/ufs/ufs/ufs_quota2.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/ufs/ufs_quota2.c diff -u src/sys/ufs/ufs/ufs_quota2.c:1.40 src/sys/ufs/ufs/ufs_quota2.c:1.41 --- src/sys/ufs/ufs/ufs_quota2.c:1.40 Sat Mar 28 19:24:05 2015 +++ src/sys/ufs/ufs/ufs_quota2.c Sun Nov 20 21:21:26 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_quota2.c,v 1.40 2015/03/28 19:24:05 maxv Exp $ */ +/* $NetBSD: ufs_quota2.c,v 1.41 2016/11/20 21:21:26 riastradh Exp $ */ /*- * Copyright (c) 2010 Manuel Bouyer * All rights reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.40 2015/03/28 19:24:05 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.41 2016/11/20 21:21:26 riastradh Exp $"); #include #include @@ -200,7 +200,7 @@ quota2_walk_list(struct ufsmount *ump, s struct quota2_entry *q2e; daddr_t lblkno, blkoff, olblkno = 0; - KASSERT(mutex_owner()); + KASSERT(mutex_owned()); while (off != 0) { lblkno = (off >> ump->um_mountp->mnt_fs_bshift);
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: jdolecek Date: Fri Nov 11 22:59:26 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_wapbl.h Log Message: fix !WAPBL variant of UFS_WAPBL_REGISTER_DEALLOCATION() To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/ufs/ufs/ufs_wapbl.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/ufs
Module Name:src Committed By: jdolecek Date: Fri Nov 11 22:59:26 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_wapbl.h Log Message: fix !WAPBL variant of UFS_WAPBL_REGISTER_DEALLOCATION() To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/ufs/ufs/ufs_wapbl.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/ufs/ufs_wapbl.h diff -u src/sys/ufs/ufs/ufs_wapbl.h:1.13 src/sys/ufs/ufs/ufs_wapbl.h:1.14 --- src/sys/ufs/ufs/ufs_wapbl.h:1.13 Thu Nov 10 20:56:32 2016 +++ src/sys/ufs/ufs/ufs_wapbl.h Fri Nov 11 22:59:26 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_wapbl.h,v 1.13 2016/11/10 20:56:32 jdolecek Exp $ */ +/* $NetBSD: ufs_wapbl.h,v 1.14 2016/11/11 22:59:26 jdolecek Exp $ */ /*- * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc. @@ -171,8 +171,8 @@ ufs_wapbl_end(struct mount *mp) #define UFS_WAPBL_JUNLOCK_ASSERT(mp) #define UFS_WAPBL_REGISTER_INODE(mp, ino, mode) do { } while (0) #define UFS_WAPBL_UNREGISTER_INODE(mp, ino, mode) do { } while (0) -#define UFS_WAPBL_REGISTER_DEALLOCATION(mp, blk, len) 0 -#define UFS_WAPBL_REGISTER_DEALLOCATION_FORCE(mp, blk, len) 0 +#define UFS_WAPBL_REGISTER_DEALLOCATION(mp, blk, len, cookiep) 0 +#define UFS_WAPBL_REGISTER_DEALLOCATION_FORCE(mp, blk, len) 0 #define UFS_WAPBL_UNREGISTER_DEALLOCATION(mp, cookie) do { } while (0) #endif
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: dholland Date: Wed Nov 9 05:08:35 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_extattr.c Log Message: Explain why the lock in here needs to be recursive. Related to PR 46997. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/ufs/ufs/ufs_extattr.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/ufs
Module Name:src Committed By: dholland Date: Wed Nov 9 05:08:35 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_extattr.c Log Message: Explain why the lock in here needs to be recursive. Related to PR 46997. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/ufs/ufs/ufs_extattr.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/ufs/ufs_extattr.c diff -u src/sys/ufs/ufs/ufs_extattr.c:1.47 src/sys/ufs/ufs/ufs_extattr.c:1.48 --- src/sys/ufs/ufs/ufs_extattr.c:1.47 Thu Jul 7 06:55:44 2016 +++ src/sys/ufs/ufs/ufs_extattr.c Wed Nov 9 05:08:35 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_extattr.c,v 1.47 2016/07/07 06:55:44 msaitoh Exp $ */ +/* $NetBSD: ufs_extattr.c,v 1.48 2016/11/09 05:08:35 dholland Exp $ */ /*- * Copyright (c) 1999-2002 Robert N. M. Watson @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.47 2016/07/07 06:55:44 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.48 2016/11/09 05:08:35 dholland Exp $"); #ifdef _KERNEL_OPT #include "opt_ffs.h" @@ -168,7 +168,13 @@ static void ufs_extattr_uepm_lock(struct ufsmount *ump) { - /* XXX Why does this need to be recursive? */ + /* + * XXX This needs to be recursive for the following reasons: + * - it is taken in ufs_extattr_vnode_inactive + * - which is called from VOP_INACTIVE + * - which can be triggered by any vrele, vput, or vn_close + * - several of these can happen while it's held + */ if (mutex_owned(>um_extattr.uepm_lock)) { ump->um_extattr.uepm_lockcnt++; return;
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: dholland Date: Wed Nov 9 04:12:55 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_vnops.c Log Message: ufs_makeinode is declared file-static at the top of the file; mark it at its definition too, for consistency and to avoid misleading casual passersby. To generate a diff of this commit: cvs rdiff -u -r1.233 -r1.234 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: dholland Date: Wed Nov 9 04:12:55 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_vnops.c Log Message: ufs_makeinode is declared file-static at the top of the file; mark it at its definition too, for consistency and to avoid misleading casual passersby. To generate a diff of this commit: cvs rdiff -u -r1.233 -r1.234 src/sys/ufs/ufs/ufs_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/ufs/ufs_vnops.c diff -u src/sys/ufs/ufs/ufs_vnops.c:1.233 src/sys/ufs/ufs/ufs_vnops.c:1.234 --- src/sys/ufs/ufs/ufs_vnops.c:1.233 Fri Oct 28 20:38:12 2016 +++ src/sys/ufs/ufs/ufs_vnops.c Wed Nov 9 04:12:55 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vnops.c,v 1.233 2016/10/28 20:38:12 jdolecek Exp $ */ +/* $NetBSD: ufs_vnops.c,v 1.234 2016/11/09 04:12:55 dholland Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.233 2016/10/28 20:38:12 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.234 2016/11/09 04:12:55 dholland Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -1764,7 +1764,7 @@ ufs_vinit(struct mount *mntp, int (**spe /* * Allocate a new inode. */ -int +static int ufs_makeinode(struct vattr *vap, struct vnode *dvp, const struct ufs_lookup_results *ulr, struct vnode **vpp, struct componentname *cnp)
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: jdolecek Date: Sun Aug 14 11:31:41 UTC 2016 Modified Files: src/sys/ufs/ufs: inode.h Log Message: again remove IN_E4EXTENTS; it's not used anywhere any more, and it's better to keep fs-specific flags out of generic headers anyway To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/sys/ufs/ufs/inode.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/ufs
Module Name:src Committed By: jdolecek Date: Sun Aug 14 11:31:41 UTC 2016 Modified Files: src/sys/ufs/ufs: inode.h Log Message: again remove IN_E4EXTENTS; it's not used anywhere any more, and it's better to keep fs-specific flags out of generic headers anyway To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/sys/ufs/ufs/inode.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/ufs/inode.h diff -u src/sys/ufs/ufs/inode.h:1.74 src/sys/ufs/ufs/inode.h:1.75 --- src/sys/ufs/ufs/inode.h:1.74 Thu Aug 4 17:47:47 2016 +++ src/sys/ufs/ufs/inode.h Sun Aug 14 11:31:41 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: inode.h,v 1.74 2016/08/04 17:47:47 jdolecek Exp $ */ +/* $NetBSD: inode.h,v 1.75 2016/08/14 11:31:41 jdolecek Exp $ */ /* * Copyright (c) 1982, 1989, 1993 @@ -226,7 +226,6 @@ struct inode { /* unused 0x1000 */ /* was LFS-only IN_PAGING */ #define IN_MODIFY 0x2000 /* Modification time update request. */ /* unused 0x4000 */ /* was LFS-only IN_CDIROP */ -#define IN_E4EXTENTS0x8000 /* ext4 extents */ #if defined(_KERNEL)
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: dholland Date: Mon Jun 20 00:52:04 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_quota1.c Log Message: Widen before multiplying. Like -r1.21, but in the other similar case. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/ufs/ufs/ufs_quota1.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/ufs/ufs_quota1.c diff -u src/sys/ufs/ufs/ufs_quota1.c:1.21 src/sys/ufs/ufs/ufs_quota1.c:1.22 --- src/sys/ufs/ufs/ufs_quota1.c:1.21 Tue Nov 25 19:48:24 2014 +++ src/sys/ufs/ufs/ufs_quota1.c Mon Jun 20 00:52:04 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_quota1.c,v 1.21 2014/11/25 19:48:24 christos Exp $ */ +/* $NetBSD: ufs_quota1.c,v 1.22 2016/06/20 00:52:04 dholland Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993, 1995 @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.21 2014/11/25 19:48:24 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.22 2016/06/20 00:52:04 dholland Exp $"); #include #include @@ -806,7 +806,7 @@ dq1get(struct vnode *dqvp, u_long id, st aiov.iov_base = (void *)>dq_un.dq1_dqb; aiov.iov_len = sizeof (struct dqblk); auio.uio_resid = sizeof (struct dqblk); - auio.uio_offset = (off_t)(id * sizeof (struct dqblk)); + auio.uio_offset = (off_t)id * sizeof (struct dqblk); auio.uio_rw = UIO_READ; UIO_SETUP_SYSSPACE(); error = VOP_READ(dqvp, , 0, ump->um_cred[type]);
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: dholland Date: Mon Jun 20 00:52:04 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_quota1.c Log Message: Widen before multiplying. Like -r1.21, but in the other similar case. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/ufs/ufs/ufs_quota1.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/ufs
Module Name:src Committed By: christos Date: Fri Jun 3 15:36:03 UTC 2016 Modified Files: src/sys/ufs/ufs: inode.h Log Message: ext4 extents glue To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/sys/ufs/ufs/inode.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/ufs/inode.h diff -u src/sys/ufs/ufs/inode.h:1.71 src/sys/ufs/ufs/inode.h:1.72 --- src/sys/ufs/ufs/inode.h:1.71 Mon May 26 15:16:39 2014 +++ src/sys/ufs/ufs/inode.h Fri Jun 3 11:36:03 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: inode.h,v 1.71 2014/05/26 19:16:39 dholland Exp $ */ +/* $NetBSD: inode.h,v 1.72 2016/06/03 15:36:03 christos Exp $ */ /* * Copyright (c) 1982, 1989, 1993 @@ -44,6 +44,7 @@ #include #include #include +#include #include /* @@ -78,6 +79,7 @@ struct ffs_inode_ext { struct ext2fs_inode_ext { daddr_t ext2fs_last_lblk; /* last logical block allocated */ daddr_t ext2fs_last_blk; /* last block allocated on disk */ + struct ext4_extent_cache i_ext_cache; /* cache for ext4 extent */ }; struct lfs_inode_ext; @@ -234,8 +236,7 @@ struct inode { /* These flags are kept in i_flag. */ #define IN_ACCESS 0x0001 /* Access time update request. */ #define IN_CHANGE 0x0002 /* Inode change time update request. */ -#define IN_UPDATE 0x0004 /* Inode was written to; update mtime. */ -#define IN_MODIFY 0x2000 /* Modification time update request. */ +#define IN_UPDATE 0x0004 /* Inode written to; update mtime. */ #define IN_MODIFIED 0x0008 /* Inode has been modified. */ #define IN_ACCESSED 0x0010 /* Inode has been accessed. */ /* unused 0x0020 */ /* was IN_RENAME */ @@ -244,8 +245,12 @@ struct inode { /* unused 0x0100 */ /* was LFS-only IN_CLEANING */ /* unused 0x0200 */ /* was LFS-only IN_ADIROP */ #define IN_SPACECOUNTED 0x0400 /* Blocks to be freed in free count. */ +/* unused 0x0800 */ /* what was that? */ /* unused 0x1000 */ /* was LFS-only IN_PAGING */ +#define IN_MODIFY 0x2000 /* Modification time update request. */ /* unused 0x4000 */ /* was LFS-only IN_CDIROP */ +#define IN_E4EXTENTS0x8000 /* ext4 extents */ + #if defined(_KERNEL) /*
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: christos Date: Fri Jun 3 15:36:03 UTC 2016 Modified Files: src/sys/ufs/ufs: inode.h Log Message: ext4 extents glue To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/sys/ufs/ufs/inode.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/ufs
Module Name:src Committed By: riastradh Date: Thu May 19 18:32:03 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_vnops.c ufs_wapbl.h Log Message: Get rid of UFS_WAPBL_BEGIN1/END1 ufs makeinode no longer releases dvp, so incrementing the usecount for wapbl is unnecessary. >From coypu. To generate a diff of this commit: cvs rdiff -u -r1.231 -r1.232 src/sys/ufs/ufs/ufs_vnops.c cvs rdiff -u -r1.8 -r1.9 src/sys/ufs/ufs/ufs_wapbl.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/ufs/ufs_vnops.c diff -u src/sys/ufs/ufs/ufs_vnops.c:1.231 src/sys/ufs/ufs/ufs_vnops.c:1.232 --- src/sys/ufs/ufs/ufs_vnops.c:1.231 Tue Sep 1 06:09:23 2015 +++ src/sys/ufs/ufs/ufs_vnops.c Thu May 19 18:32:03 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vnops.c,v 1.231 2015/09/01 06:09:23 dholland Exp $ */ +/* $NetBSD: ufs_vnops.c,v 1.232 2016/05/19 18:32:03 riastradh Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.231 2015/09/01 06:09:23 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.232 2016/05/19 18:32:03 riastradh Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -151,7 +151,7 @@ ufs_create(void *v) UFS_CHECK_CRAPCOUNTER(VTOI(dvp)); /* - * UFS_WAPBL_BEGIN1(dvp->v_mount, dvp) performed by successful + * UFS_WAPBL_BEGIN(dvp->v_mount) performed by successful * ufs_makeinode */ fstrans_start(dvp->v_mount, FSTRANS_SHARED); @@ -160,7 +160,7 @@ ufs_create(void *v) fstrans_done(dvp->v_mount); return (error); } - UFS_WAPBL_END1(dvp->v_mount, dvp); + UFS_WAPBL_END(dvp->v_mount); fstrans_done(dvp->v_mount); VN_KNOTE(dvp, NOTE_WRITE); VOP_UNLOCK(*ap->a_vpp); @@ -194,7 +194,7 @@ ufs_mknod(void *v) UFS_CHECK_CRAPCOUNTER(VTOI(ap->a_dvp)); /* - * UFS_WAPBL_BEGIN1(dvp->v_mount, dvp) performed by successful + * UFS_WAPBL_BEGIN(dvp->v_mount) performed by successful * ufs_makeinode */ fstrans_start(ap->a_dvp->v_mount, FSTRANS_SHARED); @@ -204,7 +204,7 @@ ufs_mknod(void *v) ip = VTOI(*vpp); ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE; UFS_WAPBL_UPDATE(*vpp, NULL, NULL, 0); - UFS_WAPBL_END1(ap->a_dvp->v_mount, ap->a_dvp); + UFS_WAPBL_END(ap->a_dvp->v_mount); VOP_UNLOCK(*vpp); out: fstrans_done(ap->a_dvp->v_mount); @@ -1200,7 +1200,7 @@ ufs_symlink(void *v) UFS_CHECK_CRAPCOUNTER(VTOI(ap->a_dvp)); /* - * UFS_WAPBL_BEGIN1(dvp->v_mount, dvp) performed by successful + * UFS_WAPBL_BEGIN(dvp->v_mount) performed by successful * ufs_makeinode */ fstrans_start(ap->a_dvp->v_mount, FSTRANS_SHARED); @@ -1232,7 +1232,7 @@ ufs_symlink(void *v) error = ufs_bufio(UIO_WRITE, vp, ap->a_target, len, (off_t)0, IO_NODELOCKED | IO_JOURNALLOCKED, ap->a_cnp->cn_cred, NULL, NULL); - UFS_WAPBL_END1(ap->a_dvp->v_mount, ap->a_dvp); + UFS_WAPBL_END(ap->a_dvp->v_mount); VOP_UNLOCK(vp); if (error) vrele(vp); @@ -1784,7 +1784,7 @@ ufs_makeinode(struct vattr *vap, struct } *vpp = tvp; ip = VTOI(tvp); - error = UFS_WAPBL_BEGIN1(dvp->v_mount, dvp); + error = UFS_WAPBL_BEGIN(dvp->v_mount); if (error) { vput(tvp); return (error); @@ -1832,7 +1832,7 @@ ufs_makeinode(struct vattr *vap, struct DIP_ASSIGN(ip, nlink, 0); ip->i_flag |= IN_CHANGE; UFS_WAPBL_UPDATE(tvp, NULL, NULL, 0); - UFS_WAPBL_END1(dvp->v_mount, dvp); + UFS_WAPBL_END(dvp->v_mount); vput(tvp); return (error); } Index: src/sys/ufs/ufs/ufs_wapbl.h diff -u src/sys/ufs/ufs/ufs_wapbl.h:1.8 src/sys/ufs/ufs/ufs_wapbl.h:1.9 --- src/sys/ufs/ufs/ufs_wapbl.h:1.8 Sun Nov 10 18:28:08 2013 +++ src/sys/ufs/ufs/ufs_wapbl.h Thu May 19 18:32:03 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_wapbl.h,v 1.8 2013/11/10 18:28:08 christos Exp $ */ +/* $NetBSD: ufs_wapbl.h,v 1.9 2016/05/19 18:32:03 riastradh Exp $ */ /*- * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc. @@ -134,10 +134,7 @@ ufs_wapbl_end2(struct mount *mp, struct #define UFS_WAPBL_BEGIN(mp) \ ufs_wapbl_begin2(mp, NULL, NULL, __FUNCTION__, __LINE__) -#define UFS_WAPBL_BEGIN1(mp, v1) \ - ufs_wapbl_begin2(mp, v1, NULL, __FUNCTION__, __LINE__) #define UFS_WAPBL_END(mp) ufs_wapbl_end2(mp, NULL, NULL) -#define UFS_WAPBL_END1(mp, v1) ufs_wapbl_end2(mp, v1, NULL) #define UFS_WAPBL_UPDATE(vp, access, modify, flags) \ if ((vp)->v_mount->mnt_wapbl) { \ @@ -164,9 +161,7 @@ ufs_wapbl_end2(struct mount *mp, struct #else /* ! WAPBL */ #define UFS_WAPBL_BEGIN(mp) (__USE(mp), 0) -#define UFS_WAPBL_BEGIN1(mp, v1) 0 #define UFS_WAPBL_END(mp) do { } while (0) -#define UFS_WAPBL_END1(mp, v1) #define UFS_WAPBL_UPDATE(vp, access, modify, flags) do { } while (0) #define UFS_WAPBL_JLOCK_ASSERT(mp) #define UFS_WAPBL_JUNLOCK_ASSERT(mp)
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: riastradh Date: Thu May 19 18:32:20 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_wapbl.h Log Message: While here, replace GCC __FUNCTION__ by C99 __func__ >From coypu. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/ufs/ufs_wapbl.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/ufs/ufs_wapbl.h diff -u src/sys/ufs/ufs/ufs_wapbl.h:1.10 src/sys/ufs/ufs/ufs_wapbl.h:1.11 --- src/sys/ufs/ufs/ufs_wapbl.h:1.10 Thu May 19 18:32:11 2016 +++ src/sys/ufs/ufs/ufs_wapbl.h Thu May 19 18:32:20 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_wapbl.h,v 1.10 2016/05/19 18:32:11 riastradh Exp $ */ +/* $NetBSD: ufs_wapbl.h,v 1.11 2016/05/19 18:32:20 riastradh Exp $ */ /*- * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc. @@ -123,7 +123,7 @@ ufs_wapbl_end(struct mount *mp) } #define UFS_WAPBL_BEGIN(mp) \ - ufs_wapbl_begin(mp, __FUNCTION__, __LINE__) + ufs_wapbl_begin(mp, __func__, __LINE__) #define UFS_WAPBL_END(mp) ufs_wapbl_end(mp) #define UFS_WAPBL_UPDATE(vp, access, modify, flags) \
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: riastradh Date: Thu May 19 18:32:11 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_wapbl.h Log Message: Simplify ufs_wapbl_begin2/end2, drop 2 suffix We are no longer calling UFS_WAPBL_BEGIN/END with vnodes (we are giving NULL as a parameter in all cases), so we can get rid of this input parameter and the relevant check. >From coypu. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/ufs/ufs_wapbl.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/ufs
Module Name:src Committed By: riastradh Date: Thu May 19 18:32:11 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_wapbl.h Log Message: Simplify ufs_wapbl_begin2/end2, drop 2 suffix We are no longer calling UFS_WAPBL_BEGIN/END with vnodes (we are giving NULL as a parameter in all cases), so we can get rid of this input parameter and the relevant check. >From coypu. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/ufs/ufs_wapbl.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/ufs/ufs_wapbl.h diff -u src/sys/ufs/ufs/ufs_wapbl.h:1.9 src/sys/ufs/ufs/ufs_wapbl.h:1.10 --- src/sys/ufs/ufs/ufs_wapbl.h:1.9 Thu May 19 18:32:03 2016 +++ src/sys/ufs/ufs/ufs_wapbl.h Thu May 19 18:32:11 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_wapbl.h,v 1.9 2016/05/19 18:32:03 riastradh Exp $ */ +/* $NetBSD: ufs_wapbl.h,v 1.10 2016/05/19 18:32:11 riastradh Exp $ */ /*- * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc. @@ -95,16 +95,10 @@ void ufs_wapbl_verify_inodes(struct moun #endif static __inline int -ufs_wapbl_begin2(struct mount *mp, struct vnode *vp1, struct vnode *vp2, - const char *file, int line) +ufs_wapbl_begin(struct mount *mp, const char *file, int line) { if (mp->mnt_wapbl) { int error; - - if (vp1) - vref(vp1); - if (vp2) - vref(vp2); error = wapbl_begin(mp->mnt_wapbl, file, line); if (error) return error; @@ -117,7 +111,7 @@ ufs_wapbl_begin2(struct mount *mp, struc } static __inline void -ufs_wapbl_end2(struct mount *mp, struct vnode *vp1, struct vnode *vp2) +ufs_wapbl_end(struct mount *mp) { if (mp->mnt_wapbl) { #ifdef WAPBL_DEBUG_INODES @@ -125,16 +119,12 @@ ufs_wapbl_end2(struct mount *mp, struct ufs_wapbl_verify_inodes(mp, "wapbl_end"); #endif wapbl_end(mp->mnt_wapbl); - if (vp2) - vrele(vp2); - if (vp1) - vrele(vp1); } } #define UFS_WAPBL_BEGIN(mp) \ - ufs_wapbl_begin2(mp, NULL, NULL, __FUNCTION__, __LINE__) -#define UFS_WAPBL_END(mp) ufs_wapbl_end2(mp, NULL, NULL) + ufs_wapbl_begin(mp, __FUNCTION__, __LINE__) +#define UFS_WAPBL_END(mp) ufs_wapbl_end(mp) #define UFS_WAPBL_UPDATE(vp, access, modify, flags) \ if ((vp)->v_mount->mnt_wapbl) { \
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: riastradh Date: Thu May 19 18:32:03 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_vnops.c ufs_wapbl.h Log Message: Get rid of UFS_WAPBL_BEGIN1/END1 ufs makeinode no longer releases dvp, so incrementing the usecount for wapbl is unnecessary. >From coypu. To generate a diff of this commit: cvs rdiff -u -r1.231 -r1.232 src/sys/ufs/ufs/ufs_vnops.c cvs rdiff -u -r1.8 -r1.9 src/sys/ufs/ufs/ufs_wapbl.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/ufs
Module Name:src Committed By: riastradh Date: Thu May 19 18:32:20 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_wapbl.h Log Message: While here, replace GCC __FUNCTION__ by C99 __func__ >From coypu. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/ufs/ufs_wapbl.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/ufs
Module Name:src Committed By: christos Date: Fri Apr 29 03:05:05 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_bswap.h Log Message: use variables that could be unused. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/ufs/ufs/ufs_bswap.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/ufs/ufs_bswap.h diff -u src/sys/ufs/ufs/ufs_bswap.h:1.20 src/sys/ufs/ufs/ufs_bswap.h:1.21 --- src/sys/ufs/ufs/ufs_bswap.h:1.20 Sat Oct 19 16:12:18 2013 +++ src/sys/ufs/ufs/ufs_bswap.h Thu Apr 28 23:05:04 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_bswap.h,v 1.20 2013/10/19 20:12:18 mrg Exp $ */ +/* $NetBSD: ufs_bswap.h,v 1.21 2016/04/29 03:05:04 christos Exp $ */ /* * Copyright (c) 1998 Manuel Bouyer. @@ -40,9 +40,9 @@ #define UFS_FSNEEDSWAP(fs) ((fs)->fs_flags & FS_SWAPPED) #define UFS_IPNEEDSWAP(ip) UFS_MPNEEDSWAP((ip)->i_ump) #else -#define UFS_MPNEEDSWAP(ump) (0) -#define UFS_FSNEEDSWAP(fs) (0) -#define UFS_IPNEEDSWAP(ip) (0) +#define UFS_MPNEEDSWAP(ump) ((void)(ump), 0) +#define UFS_FSNEEDSWAP(fs) ((void)(fs), 0) +#define UFS_IPNEEDSWAP(ip) ((void)(ip), 0) #endif #if !defined(_KERNEL) || defined(FFS_EI)
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: christos Date: Fri Apr 29 03:05:05 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_bswap.h Log Message: use variables that could be unused. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/ufs/ufs/ufs_bswap.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/ufs
Module Name:src Committed By: christos Date: Fri Apr 29 02:38:19 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_lookup.c Log Message: mention the PR To generate a diff of this commit: cvs rdiff -u -r1.144 -r1.145 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: christos Date: Fri Apr 29 02:38:19 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_lookup.c Log Message: mention the PR To generate a diff of this commit: cvs rdiff -u -r1.144 -r1.145 src/sys/ufs/ufs/ufs_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/ufs/ufs_lookup.c diff -u src/sys/ufs/ufs/ufs_lookup.c:1.144 src/sys/ufs/ufs/ufs_lookup.c:1.145 --- src/sys/ufs/ufs/ufs_lookup.c:1.144 Thu Apr 28 22:16:53 2016 +++ src/sys/ufs/ufs/ufs_lookup.c Thu Apr 28 22:38:19 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_lookup.c,v 1.144 2016/04/29 02:16:53 christos Exp $ */ +/* $NetBSD: ufs_lookup.c,v 1.145 2016/04/29 02:38:19 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.144 2016/04/29 02:16:53 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.145 2016/04/29 02:38:19 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_ffs.h" @@ -865,7 +865,7 @@ ufs_dirgrow(struct vnode *dvp, const str static int #if __GNUC_PREREQ__(5, 3) -/* This gets miscompiled by gcc 5.3 */ +/* This gets miscompiled by gcc 5.3 PR/51094 */ __attribute__((__optimize__("no-tree-vrp"))) #endif ufs_dircompact(struct vnode *dvp, const struct ufs_lookup_results *ulr,
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: christos Date: Fri Apr 29 02:16:53 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_lookup.c Log Message: Split ufs_direnter futher and turn off tree-vrp for the broken function. To generate a diff of this commit: cvs rdiff -u -r1.143 -r1.144 src/sys/ufs/ufs/ufs_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/ufs/ufs_lookup.c diff -u src/sys/ufs/ufs/ufs_lookup.c:1.143 src/sys/ufs/ufs/ufs_lookup.c:1.144 --- src/sys/ufs/ufs/ufs_lookup.c:1.143 Wed Apr 13 23:25:28 2016 +++ src/sys/ufs/ufs/ufs_lookup.c Thu Apr 28 22:16:53 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_lookup.c,v 1.143 2016/04/14 03:25:28 christos Exp $ */ +/* $NetBSD: ufs_lookup.c,v 1.144 2016/04/29 02:16:53 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.143 2016/04/14 03:25:28 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.144 2016/04/29 02:16:53 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_ffs.h" @@ -807,102 +807,85 @@ ufs_makedirentry(struct inode *ip, struc newdirp->d_type = IFTODT(ip->i_mode); } -/* - * Write a directory entry after a call to namei, using the parameters - * that ufs_lookup left in nameidata and in the ufs_lookup_results. - * - * DVP is the directory to be updated. It must be locked. - * ULR is the ufs_lookup_results structure from the final lookup step. - * TVP is not used. (XXX: why is it here? remove it) - * DIRP is the new directory entry contents. - * CNP is the componentname from the final lookup step. - * NEWDIRBP is not used and (XXX) should be removed. The previous - * comment here said it was used by the now-removed softupdates code. - * - * The link count of the target inode is *not* incremented; the - * caller does that. - * - * If ulr->ulr_count is 0, ufs_lookup did not find space to insert the - * directory entry. ulr_offset, which is the place to put the entry, - * should be on a block boundary (and should be at the end of the - * directory AFAIK) and a fresh block is allocated to put the new - * directory entry in. - * - * If ulr->ulr_count is not zero, ufs_lookup found a slot to insert - * the entry into. This slot ranges from ulr_offset to ulr_offset + - * ulr_count. However, this slot may already be partially populated - * requiring compaction. See notes below. - * - * Furthermore, if ulr_count is not zero and ulr_endoff is not the - * same as i_size, the directory is truncated to size ulr_endoff. - */ -int -ufs_direnter(struct vnode *dvp, const struct ufs_lookup_results *ulr, + +static int +ufs_dirgrow(struct vnode *dvp, const struct ufs_lookup_results *ulr, struct vnode *tvp, struct direct *dirp, struct componentname *cnp, struct buf *newdirbp) { - kauth_cred_t cr; - int newentrysize; - struct inode *dp; + const kauth_cred_t cr = cnp->cn_cred; + const struct ufsmount *ump = VFSTOUFS(dvp->v_mount); + const int needswap = UFS_MPNEEDSWAP(ump); + const int dirblksiz = ump->um_dirblksiz; + const int fsfmt = FSFMT(dvp); + const u_int newentrysize = UFS_DIRSIZ(0, dirp, 0); + struct inode *dp = VTOI(dvp); + int error, ret, blkoff; + struct timespec ts; + struct buf *bp; + + /* + * If ulr_count is 0, then namei could find no + * space in the directory. Here, ulr_offset will + * be on a directory block boundary and we will write the + * new entry into a fresh block. + */ + if (ulr->ulr_offset & (dirblksiz - 1)) + panic("%s: newblk", __func__); + if ((error = UFS_BALLOC(dvp, (off_t)ulr->ulr_offset, dirblksiz, + cr, B_CLRBUF | B_SYNC, )) != 0) { + return error; + } + + dp->i_size = ulr->ulr_offset + dirblksiz; + DIP_ASSIGN(dp, size, dp->i_size); + dp->i_flag |= IN_CHANGE | IN_UPDATE; + uvm_vnp_setsize(dvp, dp->i_size); + dirp->d_reclen = ufs_rw16(dirblksiz, needswap); + dirp->d_ino = ufs_rw32(dirp->d_ino, needswap); + if (fsfmt && ENDIANSWAP(needswap)) + ufs_dirswap(dirp); + blkoff = ulr->ulr_offset & (ump->um_mountp->mnt_stat.f_iosize - 1); + memcpy((char *)bp->b_data + blkoff, dirp, newentrysize); +#ifdef UFS_DIRHASH + if (dp->i_dirhash != NULL) { + ufsdirhash_newblk(dp, ulr->ulr_offset); + ufsdirhash_add(dp, dirp, ulr->ulr_offset); + ufsdirhash_checkblock(dp, (char *)bp->b_data + blkoff, + ulr->ulr_offset); + } +#endif + error = VOP_BWRITE(bp->b_vp, bp); + vfs_timestamp(); + ret = UFS_UPDATE(dvp, , , UPDATE_DIROP); + if (error == 0) + return ret; + return error; +} + +static int +#if __GNUC_PREREQ__(5, 3) +/* This gets miscompiled by gcc 5.3 */ +__attribute__((__optimize__("no-tree-vrp"))) +#endif +ufs_dircompact(struct vnode *dvp, const struct ufs_lookup_results *ulr, +struct vnode *tvp, struct direct *dirp, +struct componentname *cnp, struct buf *newdirbp) +{ + const struct ufsmount *ump = VFSTOUFS(dvp->v_mount); + const int needswap = UFS_MPNEEDSWAP(ump); + const int fsfmt = FSFMT(dvp); + const
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: christos Date: Fri Apr 29 02:16:53 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_lookup.c Log Message: Split ufs_direnter futher and turn off tree-vrp for the broken function. To generate a diff of this commit: cvs rdiff -u -r1.143 -r1.144 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: christos Date: Thu Apr 14 03:25:28 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_lookup.c Log Message: missing , To generate a diff of this commit: cvs rdiff -u -r1.142 -r1.143 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: christos Date: Thu Apr 14 03:25:28 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_lookup.c Log Message: missing , To generate a diff of this commit: cvs rdiff -u -r1.142 -r1.143 src/sys/ufs/ufs/ufs_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/ufs/ufs_lookup.c diff -u src/sys/ufs/ufs/ufs_lookup.c:1.142 src/sys/ufs/ufs/ufs_lookup.c:1.143 --- src/sys/ufs/ufs/ufs_lookup.c:1.142 Wed Apr 13 23:23:22 2016 +++ src/sys/ufs/ufs/ufs_lookup.c Wed Apr 13 23:25:28 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_lookup.c,v 1.142 2016/04/14 03:23:22 christos Exp $ */ +/* $NetBSD: ufs_lookup.c,v 1.143 2016/04/14 03:25:28 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.142 2016/04/14 03:23:22 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.143 2016/04/14 03:25:28 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_ffs.h" @@ -769,7 +769,7 @@ ufs_dirbadentry(const struct vnode *dp, if (name[i] == '\0') { str = "NUL in name"; #ifdef DIAGNOSTIC - snprintf(buf, sizeof(buf), "%s [%s] i=%d, namlen=%d" + snprintf(buf, sizeof(buf), "%s [%s] i=%d, namlen=%d", str, name, i, namlen); str = buf; #endif
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: christos Date: Thu Apr 14 03:23:22 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_lookup.c Log Message: - match endianness logic more to the original code - fix namlen type - use bool more - eat \n's from panic strings To generate a diff of this commit: cvs rdiff -u -r1.141 -r1.142 src/sys/ufs/ufs/ufs_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/ufs/ufs_lookup.c diff -u src/sys/ufs/ufs/ufs_lookup.c:1.141 src/sys/ufs/ufs/ufs_lookup.c:1.142 --- src/sys/ufs/ufs/ufs_lookup.c:1.141 Tue Apr 12 20:09:26 2016 +++ src/sys/ufs/ufs/ufs_lookup.c Wed Apr 13 23:23:22 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_lookup.c,v 1.141 2016/04/13 00:09:26 christos Exp $ */ +/* $NetBSD: ufs_lookup.c,v 1.142 2016/04/14 03:23:22 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.141 2016/04/13 00:09:26 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.142 2016/04/14 03:23:22 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_ffs.h" @@ -77,18 +77,18 @@ int dirchk = 0; #endif #if BYTE_ORDER == LITTLE_ENDIAN -#define ENDIANSWAP 0 +# define ENDIANSWAP(needswap) ((needswap) == 0) #else -#define ENDIANSWAP UFS_NEEDSWAP +# define ENDIANSWAP(needswap) ((needswap) != 0) #endif #define NAMLEN(fsfmt, needswap, dp) \ -((fsfmt) && (needswap) == ENDIANSWAP ? (dp)->d_type : dp->d_namlen) +((fsfmt) && ENDIANSWAP(needswap) ? (dp)->d_type : (dp)->d_namlen) static void ufs_dirswap(struct direct *dirp) { - u_char tmp = dirp->d_namlen; + uint8_t tmp = dirp->d_namlen; dirp->d_namlen = dirp->d_type; dirp->d_type = tmp; } @@ -242,7 +242,7 @@ out: static int ufs_getino(struct vnode *vdp, struct inode *ip, ino_t foundino, -struct vnode **tdp, int same) +struct vnode **tdp, bool same) { if (ip->i_number == foundino) { if (same) @@ -655,7 +655,7 @@ found: */ calc_count(results, dirblksiz, prevoff); - if ((error = ufs_getino(vdp, dp, foundino, , FALSE)) != 0) + if ((error = ufs_getino(vdp, dp, foundino, , false)) != 0) goto out; if ((error = ufs_can_delete(tdp, vdp, dp, cred)) != 0) @@ -678,13 +678,13 @@ found: * Careful about locking second inode. * This can only occur if the target is ".". */ - if ((error = ufs_getino(vdp, dp, foundino, , TRUE)) != 0) + if ((error = ufs_getino(vdp, dp, foundino, , true)) != 0) goto out; *vpp = tdp; goto out; } - if ((error = ufs_getino(vdp, dp, foundino, , FALSE)) != 0) + if ((error = ufs_getino(vdp, dp, foundino, , false)) != 0) goto out; *vpp = tdp; @@ -728,7 +728,7 @@ ufs_dirbadentry(const struct vnode *dp, const int dirblksiz = ump->um_dirblksiz; const int maxsize = dirblksiz - (entryoffsetinblock & (dirblksiz - 1)); const int fsfmt = FSFMT(dp); - const uint16_t namlen = NAMLEN(fsfmt, needswap, ep); + const uint8_t namlen = NAMLEN(fsfmt, needswap, ep); const uint16_t reclen = ufs_rw16(ep->d_reclen, needswap); const int dirsiz = (int)UFS_DIRSIZ(fsfmt, ep, needswap); const char *name = ep->d_name; @@ -743,8 +743,10 @@ ufs_dirbadentry(const struct vnode *dp, str = "too big"; else if (reclen < dirsiz) str = "too small"; +#if FFS_MAXNAMLEN < 255 else if (namlen > FFS_MAXNAMLEN) str = "long name"; +#endif else str = NULL; @@ -752,7 +754,7 @@ ufs_dirbadentry(const struct vnode *dp, #ifdef DIAGNOSTIC snprintf(buf, sizeof(buf), "Bad dir (%s), reclen=%#x, " "namlen=%d, dirsiz=%d <= reclen=%d <= maxsize=%d, " - "flags=%#x, entryoffsetinblock=%d, dirblksiz=%d\n", + "flags=%#x, entryoffsetinblock=%d, dirblksiz=%d", str, reclen, namlen, dirsiz, reclen, maxsize, dp->v_mount->mnt_flag, entryoffsetinblock, dirblksiz); str = buf; @@ -763,11 +765,11 @@ ufs_dirbadentry(const struct vnode *dp, if (ep->d_ino == 0) return NULL; - for (int i = 0; i < namlen; i++) + for (uint8_t i = 0; i < namlen; i++) if (name[i] == '\0') { str = "NUL in name"; #ifdef DIAGNOSTIC - snprintf(buf, sizeof(buf), "%s [%s] i=%d, namlen=%d\n", + snprintf(buf, sizeof(buf), "%s [%s] i=%d, namlen=%d" str, name, i, namlen); str = buf; #endif @@ -777,7 +779,7 @@ ufs_dirbadentry(const struct vnode *dp, if (name[namlen]) { str = "missing NUL in name"; #ifdef DIAGNOSTIC - snprintf(buf, sizeof(buf), "%s [%*.*s] namlen=%d\n", str, + snprintf(buf, sizeof(buf), "%s [%*.*s] namlen=%d", str, namlen, namlen, name, namlen); str = buf; #endif @@ -881,7 +883,7 @@ ufs_direnter(struct vnode *dvp, const st uvm_vnp_setsize(dvp, dp->i_size); dirp->d_reclen = ufs_rw16(dirblksiz, needswap); dirp->d_ino = ufs_rw32(dirp->d_ino, needswap); - if (fsfmt && needswap == ENDIANSWAP) + if (fsfmt && ENDIANSWAP(needswap)) ufs_dirswap(dirp); blkoff = ulr->ulr_offset & (ump->um_mountp->mnt_stat.f_iosize
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: christos Date: Thu Apr 14 03:23:22 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_lookup.c Log Message: - match endianness logic more to the original code - fix namlen type - use bool more - eat \n's from panic strings To generate a diff of this commit: cvs rdiff -u -r1.141 -r1.142 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: christos Date: Wed Apr 13 00:09:26 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_lookup.c Log Message: more deduplication. To generate a diff of this commit: cvs rdiff -u -r1.140 -r1.141 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: christos Date: Wed Apr 13 00:09:26 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_lookup.c Log Message: more deduplication. To generate a diff of this commit: cvs rdiff -u -r1.140 -r1.141 src/sys/ufs/ufs/ufs_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/ufs/ufs_lookup.c diff -u src/sys/ufs/ufs/ufs_lookup.c:1.140 src/sys/ufs/ufs/ufs_lookup.c:1.141 --- src/sys/ufs/ufs/ufs_lookup.c:1.140 Tue Apr 12 12:12:22 2016 +++ src/sys/ufs/ufs/ufs_lookup.c Tue Apr 12 20:09:26 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_lookup.c,v 1.140 2016/04/12 16:12:22 christos Exp $ */ +/* $NetBSD: ufs_lookup.c,v 1.141 2016/04/13 00:09:26 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.140 2016/04/12 16:12:22 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.141 2016/04/13 00:09:26 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_ffs.h" @@ -109,6 +109,15 @@ struct slotinfo { }; static void +calc_count(struct ufs_lookup_results *results, int dirblksiz, doff_t prevoff) +{ + if ((results->ulr_offset & (dirblksiz - 1)) == 0) + results->ulr_count = 0; + else + results->ulr_count = results->ulr_offset - prevoff; +} + +static void slot_init(struct slotinfo *slot) { slot->status = FOUND; @@ -181,10 +190,7 @@ slot_estimate(const struct slotinfo *slo enduseful = results->ulr_offset; } else if (nameiop == DELETE) { results->ulr_offset = slot->offset; - if ((results->ulr_offset & (dirblksiz - 1)) == 0) - results->ulr_count = 0; - else - results->ulr_count = results->ulr_offset - prevoff; + calc_count(results, dirblksiz, prevoff); } else { results->ulr_offset = slot->offset; results->ulr_count = slot->size; @@ -199,6 +205,57 @@ slot_estimate(const struct slotinfo *slo } /* + * Check if we can delete inode tdp in directory vdp with inode ip and creds. + */ +static int +ufs_can_delete(struct vnode *tdp, struct vnode *vdp, struct inode *ip, +kauth_cred_t cred) +{ + int error; + /* + * Write access to directory required to delete files. + */ + error = VOP_ACCESS(vdp, VWRITE, cred); + if (error) + goto out; + + if (!(ip->i_mode & ISVTX)) + return 0; + + /* + * If directory is "sticky", then user must own + * the directory, or the file in it, else she + * may not delete it (unless she's root). This + * implements append-only directories. + */ + error = kauth_authorize_vnode(cred, KAUTH_VNODE_DELETE, tdp, vdp, + genfs_can_sticky(cred, ip->i_uid, VTOI(tdp)->i_uid)); + if (error) { + error = EPERM; // Why override? + goto out; + } + return 0; +out: + vrele(tdp); + return error; +} + +static int +ufs_getino(struct vnode *vdp, struct inode *ip, ino_t foundino, +struct vnode **tdp, int same) +{ + if (ip->i_number == foundino) { + if (same) + return EISDIR; + vref(vdp); + *tdp = vdp; + return 0; + } + return vcache_get(vdp->v_mount, , sizeof(foundino), tdp); +} + + +/* * Convert a component of a pathname into a pointer to a locked inode. * This is a very central and rather complicated routine. * If the file system is not maintained in a strict tree hierarchy, @@ -299,7 +356,7 @@ ufs_lookup(void *v) * we are looking for is known already. */ if (cache_lookup(vdp, cnp->cn_nameptr, cnp->cn_namelen, - cnp->cn_nameiop, cnp->cn_flags, , vpp)) { + cnp->cn_nameiop, cnp->cn_flags, , vpp)) { if (iswhiteout) { cnp->cn_flags |= ISWHITEOUT; } @@ -464,8 +521,7 @@ searchloop: */ const uint16_t namlen = NAMLEN(fsfmt, needswap, ep); if (namlen != cnp->cn_namelen || - memcmp(cnp->cn_nameptr, ep->d_name, - (unsigned)namlen)) + memcmp(cnp->cn_nameptr, ep->d_name, (size_t)namlen)) goto next; #ifdef UFS_DIRHASH @@ -597,45 +653,15 @@ found: * is a previous entry in this block) in results->ulr_count. * Save directory inode pointer in ndp->ni_dvp for dirremove(). */ - if ((results->ulr_offset & (dirblksiz - 1)) == 0) - results->ulr_count = 0; - else - results->ulr_count = results->ulr_offset - prevoff; - if (dp->i_number == foundino) { - vref(vdp); - tdp = vdp; - } else { - error = vcache_get(vdp->v_mount, - , sizeof(foundino), ); - if (error) -goto out; - } - /* - * Write access to directory required to delete files. - */ - error = VOP_ACCESS(vdp, VWRITE, cred); - if (error) { - vrele(tdp); + calc_count(results, dirblksiz, prevoff); + + if ((error = ufs_getino(vdp, dp, foundino, , FALSE)) != 0) goto out; - } - /* - * If directory is "sticky", then user must own - * the directory, or the file in it, else she - * may not delete it (unless she's root). This - * implements append-only directories. - */ - if (dp->i_mode & ISVTX) { - error = kauth_authorize_vnode(cred, KAUTH_VNODE_DELETE, - tdp, vdp, genfs_can_sticky(cred,
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: christos Date: Tue Apr 12 16:12:22 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_extern.h ufs_lookup.c Log Message: Remove gcc hack, it does not help. Add more const. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/sys/ufs/ufs/ufs_extern.h cvs rdiff -u -r1.139 -r1.140 src/sys/ufs/ufs/ufs_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/ufs/ufs_extern.h diff -u src/sys/ufs/ufs/ufs_extern.h:1.81 src/sys/ufs/ufs/ufs_extern.h:1.82 --- src/sys/ufs/ufs/ufs_extern.h:1.81 Mon Apr 11 20:36:29 2016 +++ src/sys/ufs/ufs/ufs_extern.h Tue Apr 12 12:12:22 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_extern.h,v 1.81 2016/04/12 00:36:29 christos Exp $ */ +/* $NetBSD: ufs_extern.h,v 1.82 2016/04/12 16:12:22 christos Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -115,7 +115,7 @@ int ufs_truncate(struct vnode *, uint64_ /* ufs_lookup.c */ void ufs_dirbad(struct inode *, doff_t, const char *); -const char *ufs_dirbadentry(struct vnode *, struct direct *, int); +const char *ufs_dirbadentry(const struct vnode *, const struct direct *, int); void ufs_makedirentry(struct inode *, struct componentname *, struct direct *); int ufs_direnter(struct vnode *, const struct ufs_lookup_results *, Index: src/sys/ufs/ufs/ufs_lookup.c diff -u src/sys/ufs/ufs/ufs_lookup.c:1.139 src/sys/ufs/ufs/ufs_lookup.c:1.140 --- src/sys/ufs/ufs/ufs_lookup.c:1.139 Tue Apr 12 11:56:05 2016 +++ src/sys/ufs/ufs/ufs_lookup.c Tue Apr 12 12:12:22 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_lookup.c,v 1.139 2016/04/12 15:56:05 christos Exp $ */ +/* $NetBSD: ufs_lookup.c,v 1.140 2016/04/12 16:12:22 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.139 2016/04/12 15:56:05 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.140 2016/04/12 16:12:22 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_ffs.h" @@ -384,14 +384,12 @@ ufs_lookup(void *v) results->ulr_offset = 0; numdirpasses = 1; } else { - struct buf *vbp = bp; // XXX: gcc results->ulr_offset = results->ulr_diroff; entryoffsetinblock = results->ulr_offset & bmask; if (entryoffsetinblock != 0 && (error = ufs_blkatoff(vdp, (off_t)results->ulr_offset, - NULL, , false))) + NULL, , false))) goto out; - bp = vbp; numdirpasses = 2; namecache_count_2passes(); }
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: christos Date: Tue Apr 12 16:12:22 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_extern.h ufs_lookup.c Log Message: Remove gcc hack, it does not help. Add more const. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/sys/ufs/ufs/ufs_extern.h cvs rdiff -u -r1.139 -r1.140 src/sys/ufs/ufs/ufs_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/ufs
Module Name:src Committed By: christos Date: Tue Apr 12 15:56:05 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_lookup.c Log Message: - fix build with UFS_DIRHASH - hide extra diagnostic info - try to elide gcc bug To generate a diff of this commit: cvs rdiff -u -r1.138 -r1.139 src/sys/ufs/ufs/ufs_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/ufs/ufs_lookup.c diff -u src/sys/ufs/ufs/ufs_lookup.c:1.138 src/sys/ufs/ufs/ufs_lookup.c:1.139 --- src/sys/ufs/ufs/ufs_lookup.c:1.138 Tue Apr 12 10:40:16 2016 +++ src/sys/ufs/ufs/ufs_lookup.c Tue Apr 12 11:56:05 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_lookup.c,v 1.138 2016/04/12 14:40:16 christos Exp $ */ +/* $NetBSD: ufs_lookup.c,v 1.139 2016/04/12 15:56:05 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.138 2016/04/12 14:40:16 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.139 2016/04/12 15:56:05 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_ffs.h" @@ -356,7 +356,7 @@ ufs_lookup(void *v) */ if (ufsdirhash_build(dp) == 0) { /* Look for a free slot if needed. */ - enduseful = slot_findfree(, dp->i_size); + enduseful = slot_findfree(, dp); /* Look up the component. */ numdirpasses = 1; entryoffsetinblock = 0; /* silence compiler warning */ @@ -366,6 +366,7 @@ ufs_lookup(void *v) case 0: ep = (void *)((char *)bp->b_data + (results->ulr_offset & bmask)); + reclen = ufs_rw16(ep->d_reclen, needswap); goto foundentry; case ENOENT: results->ulr_offset = roundup(dp->i_size, dirblksiz); @@ -383,11 +384,14 @@ ufs_lookup(void *v) results->ulr_offset = 0; numdirpasses = 1; } else { + struct buf *vbp = bp; // XXX: gcc results->ulr_offset = results->ulr_diroff; - if ((entryoffsetinblock = results->ulr_offset & bmask) && + entryoffsetinblock = results->ulr_offset & bmask; + if (entryoffsetinblock != 0 && (error = ufs_blkatoff(vdp, (off_t)results->ulr_offset, - NULL, , false))) + NULL, , false))) goto out; + bp = vbp; numdirpasses = 2; namecache_count_2passes(); } @@ -707,7 +711,8 @@ ufs_dirbad(struct inode *ip, doff_t offs * name must be as long as advertised, and null terminated */ const char * -ufs_dirbadentry(struct vnode *dp, struct direct *ep, int entryoffsetinblock) +ufs_dirbadentry(const struct vnode *dp, const struct direct *ep, +int entryoffsetinblock) { const struct ufsmount *ump = VFSTOUFS(dp->v_mount); const int needswap = UFS_MPNEEDSWAP(ump); @@ -717,8 +722,12 @@ ufs_dirbadentry(struct vnode *dp, struct const uint16_t namlen = NAMLEN(fsfmt, needswap, ep); const uint16_t reclen = ufs_rw16(ep->d_reclen, needswap); const int dirsiz = (int)UFS_DIRSIZ(fsfmt, ep, needswap); - + const char *name = ep->d_name; const char *str; +#ifdef DIAGNOSTIC + static char buf[512]; +#endif + if ((reclen & 0x3) != 0) str = "not rounded"; else if (reclen > maxsize) @@ -731,11 +740,14 @@ ufs_dirbadentry(struct vnode *dp, struct str = NULL; if (str) { - printf("%s: Bad dir (%s), reclen=%#x, namlen=%d, " - "dirsiz=%d <= reclen=%d <= maxsize=%d, " +#ifdef DIAGNOSTIC + snprintf(buf, sizeof(buf), "Bad dir (%s), reclen=%#x, " + "namlen=%d, dirsiz=%d <= reclen=%d <= maxsize=%d, " "flags=%#x, entryoffsetinblock=%d, dirblksiz=%d\n", - __func__, str, reclen, namlen, dirsiz, reclen, maxsize, + str, reclen, namlen, dirsiz, reclen, maxsize, dp->v_mount->mnt_flag, entryoffsetinblock, dirblksiz); + str = buf; +#endif return str; } @@ -743,16 +755,23 @@ ufs_dirbadentry(struct vnode *dp, struct return NULL; for (int i = 0; i < namlen; i++) - if (ep->d_name[i] == '\0') { + if (name[i] == '\0') { str = "NUL in name"; - printf("%s: %s i=%d, namlen=%d\n", __func__, str, i, - namlen); +#ifdef DIAGNOSTIC + snprintf(buf, sizeof(buf), "%s [%s] i=%d, namlen=%d\n", + str, name, i, namlen); + str = buf; +#endif return str; } - if (ep->d_name[namlen]) { + if (name[namlen]) { str = "missing NUL in name"; - printf("%s: %s namlen=%d\n", __func__, str, namlen); +#ifdef DIAGNOSTIC + snprintf(buf, sizeof(buf), "%s [%*.*s] namlen=%d\n", str, + namlen, namlen, name, namlen); + str = buf; +#endif return str; } return NULL; @@ -915,7 +934,7 @@ ufs_direnter(struct vnode *dvp, const st ep = (void *)dirbuf; dsize = (ep->d_ino != 0) ? UFS_DIRSIZ(fsfmt, ep, needswap) : 0; reclen = ufs_rw16(ep->d_reclen, needswap); - spacefree = reclen - dsize; + spacefree = reclen - dsize; for (loc = reclen; loc < ulr->ulr_count; ) { nep = (void *)(dirbuf + loc);