git: 9ec3a87c969d - stable/13 - Add vn_rlimit_trunc()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 08 Oct 2022 00:39:05 UTC
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9ec3a87c969da7de438ef5aa67cdc7f43d0dc894 commit 9ec3a87c969da7de438ef5aa67cdc7f43d0dc894 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2022-09-18 19:52:13 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-10-08 00:29:35 +0000 Add vn_rlimit_trunc() (cherry picked from commit 2ac083f60f8c9ce361c3daf691c60486459d87ae) --- sys/kern/vfs_vnops.c | 24 +++++++++++++++++++----- sys/sys/vnode.h | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 3089aca3468f..a7043ae818f5 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -2361,6 +2361,23 @@ vn_vget_ino_gen(struct vnode *vp, vn_get_ino_t alloc, void *alloc_arg, return (error); } +static void +vn_send_sigxfsz(struct proc *p) +{ + PROC_LOCK(p); + kern_psignal(p, SIGXFSZ); + PROC_UNLOCK(p); +} + +int +vn_rlimit_trunc(u_quad_t size, struct thread *td) +{ + if (size <= lim_cur(td, RLIMIT_FSIZE)) + return (0); + vn_send_sigxfsz(td->td_proc); + return (EFBIG); +} + int vn_rlimit_fsize(const struct vnode *vp, const struct uio *uio, struct thread *td) @@ -2389,11 +2406,8 @@ vn_rlimit_fsize(const struct vnode *vp, const struct uio *uio, (td->td_pflags2 & TDP2_ACCT) != 0) return (0); - if (!ktr_write || ktr_filesize_limit_signal) { - PROC_LOCK(td->td_proc); - kern_psignal(td->td_proc, SIGXFSZ); - PROC_UNLOCK(td->td_proc); - } + if (!ktr_write || ktr_filesize_limit_signal) + vn_send_sigxfsz(td->td_proc); return (EFBIG); } diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 6d3e7eac8b23..599b42b98239 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -779,6 +779,7 @@ int vn_rdwr_inchunks(enum uio_rw rw, struct vnode *vp, void *base, int vn_read_from_obj(struct vnode *vp, struct uio *uio); int vn_rlimit_fsize(const struct vnode *vp, const struct uio *uio, struct thread *td); +int vn_rlimit_trunc(u_quad_t size, struct thread *td); int vn_start_write(struct vnode *vp, struct mount **mpp, int flags); int vn_start_secondary_write(struct vnode *vp, struct mount **mpp, int flags);