]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/vm/vm_compressor_backing_file.c
xnu-3789.51.2.tar.gz
[apple/xnu.git] / bsd / vm / vm_compressor_backing_file.c
index 5ac063e604416add0e1bc9435bd813a344597a18..c0014b606d06c86a21ca21ba67c19376a7638142 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2013 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2016 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -61,6 +61,18 @@ vm_swapfile_open(const char *path, vnode_t *vp)
                return;
        }       
 
+       /*
+        * If MNT_IOFLAGS_NOSWAP is set, opening the swap file should fail.
+        * To avoid a race on the mount we only make this check after creating the
+        * vnode.
+        */
+       if ((*vp)->v_mount->mnt_kern_flag & MNTK_NOSWAP) {
+               vnode_put(*vp);
+               vm_swapfile_close((uint64_t)path, *vp);
+               *vp = NULL;
+               return;
+       }
+
        vnode_put(*vp);
 }