HAMMER VFS - Handle RLIMIT_FSIZE
authorMatthew Dillon <dillon@apollo.backplane.com>
Wed, 15 Jun 2011 15:49:07 +0000 (08:49 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Wed, 15 Jun 2011 15:49:07 +0000 (08:49 -0700)
* Handle the RLIMIT_FSIZE resource.

sys/vfs/hammer/hammer_vnops.c

index 183ff53..3050727 100644 (file)
@@ -476,6 +476,7 @@ hammer_vop_write(struct vop_write_args *ap)
        struct hammer_transaction trans;
        struct hammer_inode *ip;
        hammer_mount_t hmp;
+       thread_t td;
        struct uio *uio;
        int offset;
        off_t base_offset;
@@ -529,6 +530,14 @@ hammer_vop_write(struct vop_write_args *ap)
                return (EFBIG);
        }
 
+       if (uio->uio_resid > 0 && (td = uio->uio_td) != NULL && td->td_proc &&
+           base_offset > td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur) {
+               hammer_done_transaction(&trans);
+               lwkt_reltoken(&hmp->fs_token);
+               lwpsignal(td->td_proc, td->td_lwp, SIGXFSZ);
+               return (EFBIG);
+       }
+
        /*
         * If reading or writing a huge amount of data we have to break
         * atomicy and allow the operation to be interrupted by a signal