+BlockAllocate (ExtendedVCB * vcb,
+ u_int32_t startingBlock,
+ u_int32_t minBlocks,
+ u_int32_t maxBlocks,
+ hfs_block_alloc_flags_t flags,
+ u_int32_t * startBlock,
+ u_int32_t * actualBlocks);
+
+typedef struct hfs_alloc_extra_args {
+ // Used with HFS_ALLOC_TRY_HARD and HFS_ALLOC_FORCECONTIG
+ uint32_t max_blocks;
+
+ // Used with with HFS_ALLOC_USE_TENTATIVE & HFS_ALLOC_COMMIT
+ struct rl_entry **reservation_in;
+
+ // Used with HFS_ALLOC_TENTATIVE & HFS_ALLOC_LOCKED
+ struct rl_entry **reservation_out;
+
+ /*
+ * If the maximum cannot be returned, the allocation will be
+ * trimmed to the specified alignment after taking
+ * @alignment_offset into account. @alignment and
+ * @alignment_offset are both in terms of blocks, *not* bytes.
+ * The result will be such that:
+ *
+ * (block_count + @alignment_offset) % @alignment == 0
+ *
+ * Alignment is *not* guaranteed.
+ *
+ * One example where alignment might be useful is in the case
+ * where the page size is greater than the allocation block size
+ * and I/O is being performed in multiples of the page size.
+ */
+ int alignment;
+ int alignment_offset;
+} hfs_alloc_extra_args_t;
+
+/*
+ * Same as BlockAllocate but slightly different API.
+ * @extent.startBlock is a hint for where to start searching and
+ * @extent.blockCount is the minimum number of blocks acceptable.
+ * Additional arguments can be passed in @extra_args and use will
+ * depend on @flags. See comment at top of hfs_block_alloc_int for
+ * more information.
+ */
+errno_t hfs_block_alloc(hfsmount_t *hfsmp,
+ HFSPlusExtentDescriptor *extent,
+ hfs_block_alloc_flags_t flags,
+ hfs_alloc_extra_args_t *extra_args);