FSKit removeItem Not Being Called

Environment

  • macOS Version: 26.1
  • Xcode Version: 16.2

Description

I'm developing a custom file system using FSKit and have encountered an issue where the removeItem(_:named:fromDirectory:) method in my FSVolume.Operations implementation is not being invoked when attempting to delete files or directories through Finder or the command line.

Implementation

My volume implements the required FSVolume.Operations protocol with the following removeItem implementation:

func removeItem(
    _ item: FSItem,
    named name: FSFileName,
    fromDirectory directory: FSItem
) async throws {
    logger.info("remove: \(name)")
    if let item = item as? MyFSItem, let directory = directory as? MyFSItem {
        directory.removeItem(item)
    } else {
        throw fs_errorForPOSIXError(POSIXError.EIO.rawValue)
    }
}


Steps to Reproduce

  1. Mount the custom FSKit-based file system using: mount -F -t MyFS /dev/diskX /tmp/mountpoint

  2. Create files using Finder or terminal (works correctly - createItem is called)

  3. Attempt to delete a file using any of the following methods:

    • Terminal command: rm -rf /path/to/mounted/file
    • option + cmd + delete to remove the file in Finder

Expected Behavior

The removeItem(_:named:fromDirectory:) method should be called, logging "remove: [filename]" and removing the item from the directory's children collection.

Actual Behavior

The removeItem method is never invoked. No logs appear from this method in Console.app. The deletion operation either fails silently or returns an error, but the callback never occurs.

Additional Context

  • Working operations: Other operations work correctly including:
    • createItem - files and directories can be created
    • lookupItem - items can be looked up successfully
    • enumerateDirectory - directory listing works
    • read and write - file I/O operations work correctly
  • Volume state:
    • The volume is properly mounted and accessible
    • Files can be created, read, and written successfully
  • Volume capabilities configured:
  var supportedVolumeCapabilities: FSVolume.SupportedCapabilities {
      let capabilities = FSVolume.SupportedCapabilities()
      capabilities.supportsHardLinks = true
      capabilities.supportsSymbolicLinks = true
      capabilities.supportsPersistentObjectIDs = true
      capabilities.doesNotSupportVolumeSizes = true
      capabilities.supportsHiddenFiles = true
      capabilities.supports64BitObjectIDs = true
      capabilities.caseFormat = .insensitiveCasePreserving
      return capabilities
  }

Questions

  1. Are there specific volume capabilities or entitlements required for removeItem to be invoked?
  2. Is there a specific way deletion operations need to be enabled in FSKit?
  3. Could this be related to how file permissions or attributes are set during createItem?
  4. Are there any known issues with deletion operations in the current FSKit implementation?
  5. Do I need to implement additional protocols or set specific flags to support item deletion?

Any guidance would be greatly appreciated. Has anyone successfully implemented deletion operations in FSKit?

Thank you!

Could this be related to how file permissions or attributes are set during createItem?

Yes, absolutely. FSKit and the VFS layer may be using this data, but even if they weren’t, many tools/apps preflight operations before they perform them. Related to that point, this kind of "real world" testing:

Terminal command: rm -rf /path/to/mounted/file option + cmd + delete to remove the file in Finder

...isn't all that useful when you're trying to get a file system working. A "simple" tool like rm is 600+ lines of code, but that's ignoring the fact that it's built on fts which pulls in even more code. For diagnostic purposes, you want to know exactly which syscalls occurred and what/how they failed, but either of those tests is FAR too high a level to determine that. The better approach here is to write your own very basic test tool, so you can see exactly what's going on.

Looking at specific details:

entitlements required for removeItem to be invoked?

No, nothing like that is required.

Similarly:

Is there a specific way deletion operations need to be enabled in FSKit?

...

Do I need to implement additional protocols or set specific flags to support item deletion?

...there isn't really a specific "allow deletion" flag or protocol

Having said that:

Are there specific volume capabilities or ... Are there any known issues with deletion operations in the current FSKit implementation?

What can go wrong here is that the configuration you’re presenting to the system means that remove can't happen. For example, remove won't occur if:

  • FSKit thinks the volume/directory is read-only or otherwise can't be modified.

  • FSKit thinks the directory isn't empty (since only empty directories can be removed).

...or "something else" about your configuration means that the system thinks the directory can't be removed. The place to start here is with the simplest possible test (I'd start by removing a single file at the root of the volume) and then slowly building up complexity.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

FSKit removeItem Not Being Called
 
 
Q