3

I created a case-insensitive file system in OSX (using OSXFuse). But when I tried to check the case insensitiveness of my volume, using NSURLVolumeSupportsCaseSensitiveNamesKey, it reported it as case sensitive. My question is, what do I need to do on OSX so that when I check the case sensitivity using NSURLVolumeSupportsCaseSensitiveNamesKey, it will correctly report my file system as case insensitive?

Bellow are more details on what I did:

This is how I used NSURLVolumeSupportsCaseSensitiveNamesKey to check for case insensitivity:

NSString *path = @"/Volumes/MyVolume";
NSURL *file_system = [NSURL fileURLWithPath:path isDirectory:YES];
NSNumber *case_sensitive_fs;
BOOL has_case_sensitive_resource = [file_system getResourceValue:&case_sensitive_fs
                                                          forKey:NSURLVolumeSupportsCaseSensitiveNamesKey
                                                           error:NULL];
if (!has_case_sensitive_resource) {
  LOG("Has no case sensitive resource");
} else {
  if ([case_sensitive_fs intValue] ==1) {
    LOG("This is case sensitive file system");
  } else {
    LOG("This is case insensitive file system");
  }
}

Note that when I used getattrlist, it correctly reported that my file system was case insensitive:

    typedef struct volume_capabilities_result {
      u_int32_t length;
      vol_capabilities_attr_t volume_capability;
    } VolumeCapabilitiesResult;
//...
    struct attrlist list = { 0 };
    list.bitmapcount = ATTR_BIT_MAP_COUNT;
    list.reserved = 0;
    list.volattr = ATTR_VOL_INFO | ATTR_VOL_CAPABILITIES;

    VolumeCapabilitiesResult volumeCapResult;
    int result = getattrlist("/Volumes/MyVolume", &list, &volumeCapResult, sizeof(volumeCapResult), 0);
    if (result != -1 &&
        (volumeCapResult.volume_capability.valid[VOL_CAPABILITIES_FORMAT] & VOL_CAP_FMT_CASE_SENSITIVE) != 0) {
      bool case_senstive = (volumeCapResult.volume_capability.capabilities[VOL_CAPABILITIES_FORMAT] &
                                    VOL_CAP_FMT_CASE_SENSITIVE) != 0;
      if (case_senstive) {
        LOG("getattrlist said we are case sensitive");
      } else {
        LOG("getattrlist said we are case insensitive");
      }
    }

I believe getattrlist reported it correctly because I used osxfuse to implement the fuse_operations.init as follow:

void fuse_init(void* user_data, struct fuse_conn_info* conn) {
  conn->want |= FUSE_CAP_CASE_INSENSITIVE;
}
trungdinhtrong
  • 2,604
  • 2
  • 17
  • 26
  • I'm in basically the same situation; I have an osxfuse filesystem set to case insensitive mode and both getattrlist and pathconf indicate that it is case insensitive, but the NSURL check does not. Did you ever figure out how to get it to return the correct result? – Wez Furlong Sep 23 '20 at 00:41

1 Answers1

0

Are you sure your path is correct in the first code snippet, i.e. the missing slash at the beginning?

NSString *path = @"Volumes/MyVolume";

Otherwise than that, this code seems to work for me.

mschmidt
  • 2,740
  • 4
  • 17
  • 31
  • 1
    Ah, sorry for the typo. I just edited the code. After copy-pasting I did some re-formatting of the code and accidentally deleted the slash. The first and second snippet "works" in the sense that it did run and reported that my volume was case sensitive. I just dont know how to make it so that my volume register with OSX as case insensitive. – trungdinhtrong Nov 28 '17 at 14:46