pub unsafe trait FSVolumeKernelOffloadedIOOperations: NSObjectProtocol {
// Provided methods
unsafe fn blockmapFile_offset_length_flags_operationID_packer_replyHandler(
&self,
file: &FSItem,
offset: off_t,
length: usize,
flags: FSBlockmapFlags,
operation_id: FSOperationID,
packer: &FSExtentPacker,
reply: &DynBlock<dyn Fn(*mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn completeIOForFile_offset_length_status_flags_operationID_replyHandler(
&self,
file: &FSItem,
offset: off_t,
length: usize,
status: &NSError,
flags: FSCompleteIOFlags,
operation_id: FSOperationID,
reply: &DynBlock<dyn Fn(*mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn createFileNamed_inDirectory_attributes_packer_replyHandler(
&self,
name: &FSFileName,
directory: &FSItem,
attributes: &FSItemSetAttributesRequest,
packer: &FSExtentPacker,
reply: &DynBlock<dyn Fn(*mut FSItem, *mut FSFileName, *mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn lookupItemNamed_inDirectory_packer_replyHandler(
&self,
name: &FSFileName,
directory: &FSItem,
packer: &FSExtentPacker,
reply: &DynBlock<dyn Fn(*mut FSItem, *mut FSFileName, *mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn preallocateSpaceForFile_atOffset_length_flags_packer_replyHandler(
&self,
file: &FSItem,
offset: off_t,
length: usize,
flags: FSPreallocateFlags,
packer: &FSExtentPacker,
reply: &DynBlock<dyn Fn(usize, *mut NSError)>,
)
where Self: Sized + Message { ... }
}FSVolumeExtent only.Expand description
Methods and properties implemented by volumes that use kernel-offloaded I/O to achieve higher file transfer performance.
A volume that conforms to this protocol supplies file extent mappings to FSKit, which allows file transfers to take place in the kernel. This approach provides higher-performance file transfer than transferring data between the module and kernel, while still allowing the file system to run in user space.
This protocol uses extents to provide the kernel the logical-to-physical mapping of a given file.
An extent describes a physical offset on disk, and a length and a logical offset within the file.
You don’t manage extents directly.
Instead, FSKit provides you with an FSExtentPacker to define and pack the extents in your implementations of this protocol’s methods.
Most volumes conform to either this protocol or FSVolumeReadWriteOperations.
You can conform to both if you need to provide kernel-offloaded I/O only for certain files.
In that case, files with the FSItem/Attribute/inhibitKernelOffloadedIO attribute set use FSVolumeReadWriteOperations, and those without it use this protocol.
A volume that doesn’t conform to either protocol can’t support any I/O operation.
See also Apple’s documentation
Provided Methods§
Sourceunsafe fn blockmapFile_offset_length_flags_operationID_packer_replyHandler(
&self,
file: &FSItem,
offset: off_t,
length: usize,
flags: FSBlockmapFlags,
operation_id: FSOperationID,
packer: &FSExtentPacker,
reply: &DynBlock<dyn Fn(*mut NSError)>,
)
Available on crate features FSItem and block2 and libc only.
unsafe fn blockmapFile_offset_length_flags_operationID_packer_replyHandler( &self, file: &FSItem, offset: off_t, length: usize, flags: FSBlockmapFlags, operation_id: FSOperationID, packer: &FSExtentPacker, reply: &DynBlock<dyn Fn(*mut NSError)>, )
FSItem and block2 and libc only.Maps a file’s disk space into extents, allowing the kernel to perform I/O with that space.
FSKit calls this method when the kernel needs to get a mapping of logical-to-physical offsets of the file’s data.
This call may occur as part of an I/O operation on the file, or just to get the mapping as part of a fcntl(F_LOG2PHYS) system call.
In the case of an I/O operation on the file, operationID has a nonzero value; a future call to completeIO(for:offset:length:status:flags:operationID:replyHandler:) uses the same operationID to indicate which operation it completes.
In the case of a fcntl(F_LOG2PHYS) system call, the operationID parameter is 0 (Objective-C) or FSOperationID/unspecified (Swift).
In both cases the kernel retains the mapping, and it may perform I/O to this range (or a part of it) at any time.
If satisfying a blockmap request requires more extents than packer can handle, FSKit makes additional calls to this method with the same operation ID to collect the remainder.
- Parameters:
- file: The file for which to map disk space.
- offset: The starting logical offset of the range to be mapped (in bytes).
- length: The length of the range to be mapped (in bytes).
- flags: Flags that affect the behavior of the blockmap operation.
- operationID: A unique identifier of the blockmap call. Any value other than
0(Objective-C) orFSOperationID/unspecified(Swift) indicates the beginning of an I/O operation. A value of0orFSOperationID/unspecifiedindicates the kernel maps the file without performing I/O. In this case, FSKit doesn’t perform a corresponding call tocompleteIO(for:offset:length:status:flags:operationID:replyHandler:). - packer: An extent packer you use to pack the requested range of the file’s allocated disk space. FSKit sends all of the packed extents to the kernel when it invokes
reply. - reply: A block or closure to indicate success or failure. If mapping fails, pass an error as the one parameter to the reply handler. If mapping succeeds, pass
nil. For anasyncSwift implementation, there’s no reply handler; simply throw an error or return normally.
Sourceunsafe fn completeIOForFile_offset_length_status_flags_operationID_replyHandler(
&self,
file: &FSItem,
offset: off_t,
length: usize,
status: &NSError,
flags: FSCompleteIOFlags,
operation_id: FSOperationID,
reply: &DynBlock<dyn Fn(*mut NSError)>,
)
Available on crate features FSItem and block2 and libc only.
unsafe fn completeIOForFile_offset_length_status_flags_operationID_replyHandler( &self, file: &FSItem, offset: off_t, length: usize, status: &NSError, flags: FSCompleteIOFlags, operation_id: FSOperationID, reply: &DynBlock<dyn Fn(*mut NSError)>, )
FSItem and block2 and libc only.Completes an I/O operation for a given file.
Implement this method by updating a file’s metadata, such as its size and modification time.
FSKit may call this method without an earlier call to blockmapFile(_:offset:length:flags:operationID:packer:replyHandler:).
In this case, the operationID is 0 (Objective-C) or FSOperationID/unspecified (Swift).
- Parameters:
- file: The file for which the I/O operation completed.
- offset: The starting logical offset at which I/O started.
- length: The length of the I/O range (in bytes).
- status: Any error that occurred during the operation. If no error occurred, this parameter is
nil. - flags: Flags that affect the behavior of the complete I/O operation.
- operationID: A unique identifier of the blockmap call. Any value other than
0(Objective-C) orFSOperationID/unspecified(Swift) corresponds to a previous call toblockmapFile(_:offset:length:flags:operationID:packer:replyHandler:)with the sameoperationID. - reply: A block or closure to indicate success or failure. If completing I/O fails, pass an error as the one parameter to the reply handler. If completing I/O succeeds, pass
nil. For anasyncSwift implementation, there’s no reply handler; simply throw an error or return normally.
Sourceunsafe fn createFileNamed_inDirectory_attributes_packer_replyHandler(
&self,
name: &FSFileName,
directory: &FSItem,
attributes: &FSItemSetAttributesRequest,
packer: &FSExtentPacker,
reply: &DynBlock<dyn Fn(*mut FSItem, *mut FSFileName, *mut NSError)>,
)
Available on crate features FSFileName and FSItem and block2 only.
unsafe fn createFileNamed_inDirectory_attributes_packer_replyHandler( &self, name: &FSFileName, directory: &FSItem, attributes: &FSItemSetAttributesRequest, packer: &FSExtentPacker, reply: &DynBlock<dyn Fn(*mut FSItem, *mut FSFileName, *mut NSError)>, )
FSFileName and FSItem and block2 only.Creates a new file item and map its disk space.
This method allows the module to opportunistically supply extents, avoiding future calls to blockmapFile(_:offset:length:flags:operationID:packer:replyHandler:).
Only perform this technique opportunistically.
In particular, don’t perform additional I/O to fetch extent data.
Packing extents in this method requires that attributes defines a size greater than 0.
An implementation that doesn’t supply the extents can ignore the packer and call the corresponding method in the FSVolume/Operations protocol, FSVolume/Operations/createItem(named:type:inDirectory:attributes:replyHandler:).
- Parameters:
- name: The new file’s name.
- directory: The directory in which to create the file.
- attributes: Attributes to apply to the new file.
- packer: An extent packer you use to pack the file’s allocated disk space.
- reply: A block or closure to indicate success or failure. If creation succeeds, pass the newly created
FSItemand itsFSFileName, along with anilerror. If creation fails, pass the relevant error as the third parameter; FSKit ignores anyFSItemorFSFileNamein this case. For anasyncSwift implementation, there’s no reply handler; instead, return a tuple of theFSItemand itsFSFileNameor throw an error.
Sourceunsafe fn lookupItemNamed_inDirectory_packer_replyHandler(
&self,
name: &FSFileName,
directory: &FSItem,
packer: &FSExtentPacker,
reply: &DynBlock<dyn Fn(*mut FSItem, *mut FSFileName, *mut NSError)>,
)
Available on crate features FSFileName and FSItem and block2 only.
unsafe fn lookupItemNamed_inDirectory_packer_replyHandler( &self, name: &FSFileName, directory: &FSItem, packer: &FSExtentPacker, reply: &DynBlock<dyn Fn(*mut FSItem, *mut FSFileName, *mut NSError)>, )
FSFileName and FSItem and block2 only.Looks up an item within a directory and maps its disk space.
This method allows the module to opportunistically supply extents, avoiding future calls to blockmapFile(_:offset:length:flags:operationID:packer:replyHandler:).
Only perform this technique opportunistically.
In particular, don’t perform additional I/O to fetch extent data.
- Parameters:
- name: The name of the file to look up.
- directory: The directory in which to look up the file.
- packer: An extent packer you use to pack the file’s allocated disk space.
- reply: A block or closure to indicate success or failure. If lookup succeeds, pass the found
FSItemand itsFSFileName, along with anilerror. If lookup fails, pass the relevant error as the third parameter; FSKit ignores anyFSItemorFSFileNamein this case. For anasyncSwift implementation, there’s no reply handler; instead, return a tuple of theFSItemand itsFSFileNameor throw an error.
Sourceunsafe fn preallocateSpaceForFile_atOffset_length_flags_packer_replyHandler(
&self,
file: &FSItem,
offset: off_t,
length: usize,
flags: FSPreallocateFlags,
packer: &FSExtentPacker,
reply: &DynBlock<dyn Fn(usize, *mut NSError)>,
)
Available on crate features FSItem and FSVolume and block2 and libc only.
unsafe fn preallocateSpaceForFile_atOffset_length_flags_packer_replyHandler( &self, file: &FSItem, offset: off_t, length: usize, flags: FSPreallocateFlags, packer: &FSExtentPacker, reply: &DynBlock<dyn Fn(usize, *mut NSError)>, )
FSItem and FSVolume and block2 and libc only.Preallocates and maps disk space for the given file.
This method allows the module to opportunistically supply extents, avoiding future calls to blockmapFile(_:offset:length:flags:operationID:packer:replyHandler:).
Important: Only implement this method if your file system conforms to
FSVolume/PreallocateOperations.
- Parameters:
- file: The item for which to preallocate space.
- offset: The offset from which to allocate.
- length: The length of the space in bytes.
- flags: Flags that affect the preallocation behavior.
- packer: An extent packer you use to pack the file’s preallocated disk space.
- reply: A block or closure to indicate success or failure. If preallocation succeeds, pass the amount of bytes allocated and a nil error. If preallocation fails, pass the relevant error as the second parameter; FSKit ignores any byte count in this case. For an
asyncSwift implementation, there’s no reply handler; simply return the allocated byte count or throw an error.