Add vn_rlimit_trunc()
Reviewed by: asomers, jah, markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D36625
This commit is contained in:
parent
cc65a412ae
commit
2ac083f60f
@ -2372,6 +2372,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)
|
||||
@ -2400,11 +2417,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);
|
||||
}
|
||||
|
||||
|
@ -786,6 +786,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);
|
||||
|
Loading…
Reference in New Issue
Block a user