]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE12-ignore-max-file-size-ulimit-internally-20020809
authorNickolai Zeldovich <kolya@mit.edu>
Wed, 21 Aug 2002 20:29:00 +0000 (20:29 +0000)
committerDerrick Brashear <shadow@dementia.org>
Wed, 21 Aug 2002 20:29:00 +0000 (20:29 +0000)
Set the maxfilesize rlimit to infinity while writing to cache files
to avoid potential truncation if the user's rlimit is too low.  This
bug likely also exists in AIX, DARWIN, DUX, FBSD, HPUX and NBSD, but
surprisingly IRIX got this right.

(cherry picked from commit 3e6640e96dfee36cc302428d71f5de210f67be5f)

src/afs/LINUX/osi_misc.c
src/afs/SOLARIS/osi_file.c

index e92f8852c58e3251a07d8453ab3d16c1e28d69ca..c123b7d0cf80dccad9e2c8e0915ed933c23cfe70 100644 (file)
@@ -114,6 +114,7 @@ int osi_rdwr(int rw, struct osi_file *file, caddr_t addrp, size_t asize,
     KERNEL_SPACE_DECL;
     struct file *filp = &file->file;
     off_t offset = file->offset;
+    unsigned long savelim;
 
     /* Seek to the desired position. Return -1 on error. */
     if (filp->f_op->llseek) {
@@ -123,6 +124,9 @@ int osi_rdwr(int rw, struct osi_file *file, caddr_t addrp, size_t asize,
     else
        filp->f_pos = offset;
 
+    savelim = current->rlim[RLIMIT_FSIZE].rlim_cur;
+    current->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
+
     /* Read/Write the data. */
     TO_USER_SPACE();
     if (rw == UIO_READ)
@@ -133,6 +137,8 @@ int osi_rdwr(int rw, struct osi_file *file, caddr_t addrp, size_t asize,
        code = asize;
     TO_KERNEL_SPACE();
 
+    current->rlim[RLIMIT_FSIZE].rlim_cur = savelim;
+
     if (code >=0) {
        *resid = asize - code;
        return 0;
@@ -152,6 +158,10 @@ int osi_file_uio_rdwr(struct osi_file *osifile, uio_t *uiop, int rw)
     int code = 0;
     struct iovec *iov;
     int count;
+    unsigned long savelim;
+
+    savelim = current->rlim[RLIMIT_FSIZE].rlim_cur;
+    current->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
 
     if (uiop->uio_seg == AFS_UIOSYS)
        TO_USER_SPACE();
@@ -165,7 +175,7 @@ int osi_file_uio_rdwr(struct osi_file *osifile, uio_t *uiop, int rw)
            uiop->uio_iovcnt--;
            continue;
        }
-       
+
        if (rw == UIO_READ)
            code = FOP_READ(filp, iov->iov_base, count);
        else
@@ -186,6 +196,8 @@ int osi_file_uio_rdwr(struct osi_file *osifile, uio_t *uiop, int rw)
     if (uiop->uio_seg == AFS_UIOSYS)
        TO_KERNEL_SPACE();
 
+    current->rlim[RLIMIT_FSIZE].rlim_cur = savelim;
+
     return code;
 }
 
index c7709cd9600b205639d00d18392167443ae13885..acbb091378229273d75ef8e061ade56cd1c22234 100644 (file)
@@ -339,13 +339,9 @@ afs_osi_Write(afile, offset, aptr, asize)
         osi_Panic("afs_osi_Write called with null param");
     if (offset != -1) afile->offset = offset;
     AFS_GUNLOCK();
-#ifdef AFS_SUN59_ENV
-    code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, afile->offset,
-                 AFS_UIOSYS, 0, curproc->p_fsz_ctl.rlim_cur, &afs_osi_cred, &resid);
-#else
-    code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, afile->offset,
-                 AFS_UIOSYS, 0,  (u.u_rlimit[RLIMIT_FSIZE].rlim_cur), &afs_osi_cred, &resid);
-#endif
+    code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize,
+                   afile->offset, AFS_UIOSYS, 0, RLIM64_INFINITY,
+                   &afs_osi_cred, &resid);
     AFS_GLOCK();
     if (code == 0) {
        code = asize - resid;