<!--
{
  "availability" : [
    "macOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "FSKit",
  "identifier" : "/documentation/FSKit/FSVolume/PreallocateHandler",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "FSKit"
    ],
    "preciseIdentifier" : "c:objc(pl)FSVolumePreallocateHandler"
  },
  "title" : "FSVolume.PreallocateHandler"
}
-->

# FSVolume.PreallocateHandler

Methods and properties implemented by volumes that want to offer preallocation functions.

```
protocol PreallocateHandler : NSObjectProtocol
```

## Overview

A preallocation operation allocates space for a file without writing to it yet.
A file system may use reallocation to avoid performing space allocation while in the midst of I/O; this strategy improves performance.
Also, if the expected I/O pattern is many small writes, preallocating contiguous chunks may prevent fragmenting the file system.
This process can improve performance later.

In a kernel-based file system, you typically preallocate space with the `VNOP_ALLOCATE` operation, called from `fcntl(F_PREALLOCATE)`.

> Important: This protocol replaces the ``doc://FSKit/documentation/FSKit/FSVolume/PreallocateOperations`` protocol. It exposes the same functionality, while using the ``doc://FSKit/documentation/FSKit/FSPreallocateResult`` object. This objects adds the ability to reply with ``doc://FSKit/documentation/FSKit/FSItem/Attributes`` and free space from ``doc://FSKit/documentation/FSKit/FSVolume/PreallocateHandler/preallocateSpace(for:at:length:flags:context:replyHandler:)``.

## Topics

### Preallocating space

[`func preallocateSpace(for: FSItem, at: off_t, length: Int, flags: FSVolume.PreallocateFlags, context: FSContext, replyHandler: (FSPreallocateResult?, (any Error)?) -> Void)`](/documentation/FSKit/FSVolume/PreallocateHandler/preallocateSpace(for:at:length:flags:context:replyHandler:))

Preallocates disk space for the given item.

[`struct PreallocateFlags`](/documentation/FSKit/FSVolume/PreallocateFlags)

Behavior flags for preallocation operations.

[`class FSPreallocateResult`](/documentation/FSKit/FSPreallocateResult)

The result of a preallocate call.

### Inspecting volume properties

[`var isPreallocateInhibited: Bool`](/documentation/FSKit/FSVolume/PreallocateHandler/isPreallocateInhibited)

A Boolean value that instructs FSKit not to call this protocol’s methods, even if the volume conforms to it.

## Relationships

### Inherits From

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)