git: 8bdb2695d697 - main - tmpfs: truncate write if it would exceed the fs max file size or RLIMIT_FSIZE
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 24 Sep 2022 16:42:40 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8bdb2695d69710b7f2e7cc20820aab8b3f4668a6 commit 8bdb2695d69710b7f2e7cc20820aab8b3f4668a6 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2022-09-18 13:27:28 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-09-24 16:42:05 +0000 tmpfs: truncate write if it would exceed the fs max file size or RLIMIT_FSIZE PR: 164793 Reviewed by: asomers, jah, markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D36625 --- sys/fs/tmpfs/tmpfs_vnops.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 079936946270..7a9ffed9696c 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -639,6 +639,7 @@ tmpfs_write(struct vop_write_args *v) struct uio *uio; struct tmpfs_node *node; off_t oldsize; + ssize_t r; int error, ioflag; mode_t newmode; @@ -655,12 +656,12 @@ tmpfs_write(struct vop_write_args *v) return (0); if (ioflag & IO_APPEND) uio->uio_offset = node->tn_size; - if (uio->uio_offset + uio->uio_resid > - VFS_TO_TMPFS(vp->v_mount)->tm_maxfilesize) - return (EFBIG); - error = vn_rlimit_fsize(vp, uio, uio->uio_td); - if (error != 0) + error = vn_rlimit_fsizex(vp, uio, VFS_TO_TMPFS(vp->v_mount)-> + tm_maxfilesize, &r, uio->uio_td); + if (error != 0) { + vn_rlimit_fsizex_res(uio, r); return (error); + } if (uio->uio_offset + uio->uio_resid > node->tn_size) { error = tmpfs_reg_resize(vp, uio->uio_offset + uio->uio_resid, @@ -687,6 +688,7 @@ out: MPASS(IMPLIES(error == 0, uio->uio_resid == 0)); MPASS(IMPLIES(error != 0, oldsize == node->tn_size)); + vn_rlimit_fsizex_res(uio, r); return (error); }