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

# FSVolume.OpenCloseHandler

Methods and properties implemented by volumes that want to receive open and close calls for each item.

```
protocol OpenCloseHandler : NSObjectProtocol
```

## Overview

When a file system volume conforms to this protocol, the kernel layer issues an open call to indicate desired access, and a close call to indicate what access to retain.
A file is fully closed when the kernel layer issues a close call with no retained open nodes.
When a file system receives the close call, it removes all access to the item.
When all memory mappings to the item release, the kernel layer issues a final close.

If a file system volume doesn’t conform to this protocol, the kernel layer can skip making such calls to the volume.

> Important: This protocol replaces the ``doc://FSKit/documentation/FSKit/FSVolume/OpenCloseOperations`` protocol. It exposes the same functionality, while adding the ``doc://FSKit/documentation/FSKit/FSContext`` parameters.

## Topics

### Opening and closing

[`func openItem(FSItem, modes: FSVolume.OpenModes, context: FSContext, replyHandler: ((any Error)?) -> Void)`](/documentation/FSKit/FSVolume/OpenCloseHandler/openItem(_:modes:context:replyHandler:))

Opens a file for access.

[`func closeItem(FSItem, modes: FSVolume.OpenModes, context: FSContext, replyHandler: ((any Error)?) -> Void)`](/documentation/FSKit/FSVolume/OpenCloseHandler/closeItem(_:modes:context:replyHandler:))

Closes a file from further access.

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

Defined modes for opening a file.

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

A context object that provides information about the initiator of a file system operation.

### Inspecting volume properties

[`var isOpenCloseInhibited: Bool`](/documentation/FSKit/FSVolume/OpenCloseHandler/isOpenCloseInhibited)

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)