]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/hfs/hfs_readwrite.c
xnu-792.13.8.tar.gz
[apple/xnu.git] / bsd / hfs / hfs_readwrite.c
index a4ca02b26e0c0fa53a1c4b12c136896e2fa586b2..39c3b37730b688da85975825af27273e9b6db74f 100644 (file)
@@ -1,24 +1,31 @@
 /*
  * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
  * 
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
+ * This file contains Original Code and/or Modifications of Original Code 
+ * as defined in and that are subject to the Apple Public Source License 
+ * Version 2.0 (the 'License'). You may not use this file except in 
+ * compliance with the License.  The rights granted to you under the 
+ * License may not be used to create, or enable the creation or 
+ * redistribution of, unlawful or unlicensed copies of an Apple operating 
+ * system, or to circumvent, violate, or enable the circumvention or 
+ * violation of, any terms of an Apple operating system software license 
+ * agreement.
+ *
+ * Please obtain a copy of the License at 
+ * http://www.opensource.apple.com/apsl/ and read it before using this 
  * file.
- * 
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
+ *
+ * The Original Code and all software distributed under the License are 
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
+ * Please see the License for the specific language governing rights and 
  * limitations under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
+ *
+ * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
  */
 /*     @(#)hfs_readwrite.c     1.0
  *
@@ -853,6 +860,18 @@ hfs_vnop_ioctl( struct vnop_ioctl_args /* {
 
        switch (ap->a_command) {
 
+       case HFS_RESIZE_PROGRESS: {
+
+               vfsp = vfs_statfs(HFSTOVFS(hfsmp));
+               if (suser(cred, NULL) &&
+                       kauth_cred_getuid(cred) != vfsp->f_owner) {
+                       return (EACCES); /* must be owner of file system */
+               }
+               if (!vnode_isvroot(vp)) {
+                       return (EINVAL);
+               }
+               return hfs_resize_progress(hfsmp, (u_int32_t *)ap->a_data);
+       }
        case HFS_RESIZE_VOLUME: {
                u_int64_t newsize;
                u_int64_t cursize;
@@ -1159,6 +1178,7 @@ hfs_vnop_ioctl( struct vnop_ioctl_args /* {
                        goto err_exit_bulk_access;
                }
                myucred.cr_rgid = myucred.cr_svgid = myucred.cr_groups[0];
+               myucred.cr_gmuid = myucred.cr_uid;
                
                my_context.vc_proc = p;
                my_context.vc_ucred = &myucred;
@@ -2549,7 +2569,8 @@ hfs_vnop_bwrite(struct vnop_bwrite_args *ap)
        /* Trap B-Tree writes */
        if ((VTOC(vp)->c_fileid == kHFSExtentsFileID) ||
            (VTOC(vp)->c_fileid == kHFSCatalogFileID) ||
-           (VTOC(vp)->c_fileid == kHFSAttributesFileID)) {
+           (VTOC(vp)->c_fileid == kHFSAttributesFileID) ||
+           (vp == VTOHFS(vp)->hfc_filevp)) {
 
                /* 
                 * Swap and validate the node if it is in native byte order.
@@ -2818,10 +2839,10 @@ out:
                lockflags = 0;
        }
 
-       // See comment up above about calls to hfs_fsync()
-       //
-       //if (retval == 0)
-       //      retval = hfs_fsync(vp, MNT_WAIT, 0, p);
+       /* Push cnode's new extent data to disk. */
+       if (retval == 0) {
+               (void) hfs_update(vp, MNT_WAIT);
+       }
 
        if (hfsmp->jnl) {
                if (cp->c_cnid < kHFSFirstUserCatalogNodeID)
@@ -2915,7 +2936,7 @@ hfs_clonefile(struct vnode *vp, int blkstart, int blkcnt, int blksize)
        filesize = VTOF(vp)->ff_blocks * blksize;  /* virtual file size */
        writebase = blkstart * blksize;
        copysize = blkcnt * blksize;
-       iosize = bufsize = MIN(copysize, 4096 * 16);
+       iosize = bufsize = MIN(copysize, 128 * 1024);
        offset = 0;
 
        if (kmem_alloc(kernel_map, (vm_offset_t *)&bufp, bufsize)) {