Seemingly Simple Task Not So Simple? OSXFUSE, XCode, and Swift

105 views
Skip to first unread message

Clair Ross

unread,
Aug 11, 2016, 7:57:45 PM8/11/16
to OSXFUSE


Hi,

I am working on a Swift application in XCode that implements the OSXFUSE library in order to create a mount and then write and read some folder/files to it, that is all. I can create the mount fine but I don't seem to be able to interact with it beyond unmounting it, 'New Folder' doesn't seem to work without a delegate, and when I try to use a delegate creating a new folder gives the error:

"The operation can't be completed because you don't have the necessary permission"

I have tried creating my own delegate, using NSFileManager, and extending FileManager each ending up with permission errors. I can't seem to change the permissions of the mount after it has been created too. 

I am unsure how to solve let alone properly diagnose this problem, and would appreciate any help! I'll include more info and some photos below.

Cheers!
Clair Ross

Extra Info:

The app is running on XCode 7.3 on MacOS 10.11.4. The main app is being built in XCode and it is using NSTask to run the helper program that is creating the mount.




A few lines of the code that I am setting up the mount with:



        let filesystem = GMUserFileSystem(delegate: websiteDelegate, isThreadSafe: false)



        var options: [AnyObject] = [AnyObject]()


        let volName: String = volumeName


        let mountPath: String = self.basePath!.path! + "/" + volName

       



        options.append("volname=\(volName)")


        options.append("allow_other")


        options.append("local")


     

        filesystem.mountAtPath(mountPath, withOptions: options)





Sam Moffatt

unread,
Aug 14, 2016, 2:15:23 AM8/14/16
to osxfus...@googlegroups.com
My standard advice for debugging these problems is to run your file system in debug mode and single threaded. Finder can be picky about what it thinks is legit or not. In the past I’ve had plenty of issues with Finder giving me weird behaviour or error messages (like permission denied) when it got back something not entirely consistent.

What I’d personally do is run your file system in debug mode and see exactly what FS operations are being called and what is being returned. It’s possible that there is a call to your filesystem for some folder metadata that is being returned in such a way that Finder is translating to a permission denied value.

It could be as simple as a race condition where your underlying backing store isn’t updated quick enough to handle a subsequent read request. It might be that you’re not setting the appropriate mode automatically. Without having full access to your file systems source code it’s hard to tell. 

Running your filesystem in debug mode and single threaded are great ways to debug your file system and see what is going on. Single threaded mode isn’t always necessary but I’ve found it useful in the past to determine if the bug is the result of a race condition in my filesystem (if it works in single threaded mode but Finder pukes otherwise then my FS is behaving inconsistently).

Best of luck!

Cheers,

Sam


--
You received this message because you are subscribed to the Google Groups "OSXFUSE" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osxfuse-group+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Clair Ross

unread,
Aug 15, 2016, 1:33:22 PM8/15/16
to OSXFUSE
Hi Sam,

I looked at some of the debugging info to try and clarify the problems that are going on. Running it in single-threaded mode didn't seem to change either of the errors (below), so perhaps race conditions aren't to blame here. Looking at the errors I have a suspicion the problem exists before creating anything new, but the same problems seem to exist for both delegates. With the additional info, do you have any follow-up ideas?

Cheers!
Clair


Spit out on 'New Folder' with NSFileManager:

   unique: 20, opcode: LOOKUP (1), nodeid: 1, insize: 56
LOOKUP /untitled folder
   unique: 20, error: -2 (No such file or directory), outsize: 16
unique: 0, opcode: MKDIR (9), nodeid: 1, insize: 64
MKDIR /untitled folder
   unique: 0, error: -13 (Permission denied), outsize: 16
unique: 1, opcode: GETATTR (3), nodeid: 1, insize: 40
   unique: 1, error: 0 (Undefined error: 0), outsize: 128
unique: 2, opcode: GETXATTR (22), nodeid: 1, insize: 77
   unique: 2, error: 0 (Undefined error: 0), outsize: 48
unique: 3, opcode: GETXATTR (22), nodeid: 1, insize: 92
   unique: 3, error: -45 (Operation not supported), outsize: 16
unique: 4, opcode: LOOKUP (1), nodeid: 1, insize: 44
LOOKUP /._.
   unique: 4, error: -2 (No such file or directory), outsize: 16
unique: 5, opcode: GETXATTR (22), nodeid: 1, insize: 77
   unique: 5, error: 0 (Undefined error: 0), outsize: 48



 
Spit out on 'New Folder' with Custom Delegate:

unique: 2, opcode: MKDIR (9), nodeid: 1, insize: 64
MKDIR /untitled folder
createDirectoryAtPath: path - /untitled folder, attributes - [NSFilePosixPermissions: 493]
2016-08-15 10:26:48.915 Mountee 3 Fuse Helper[2082:35857] -[Mountee_3_Fuse_Helper.WebsiteFileSystemDelegate createDirectoryAtPath:attributes:error:]: unrecognized selector sent to instance 0x600000043480
   unique: 2, error: -13 (Permission denied), outsize: 16
unique: 3, opcode: GETATTR (3), nodeid: 1, insize: 40
attributesOfItemAtPath: path - /, userData - nil
   unique: 3, error: 0 (Undefined error: 0), outsize: 128
unique: 4, opcode: GETXATTR (22), nodeid: 1, insize: 77
valueOfExtendedAttribute: panameth - com.apple.FinderInfo, ofItemAtPath - /, position - 0
   unique: 4, error: 0 (Undefined error: 0), outsize: 48
unique: 6, opcode: GETXATTR (22), nodeid: 1, insize: 92
valueOfExtendedAttribute: panameth - com.apple.metadata:_kMDItemUserTags, ofItemAtPath - /, position - 0
   unique: 6, error: 0 (Undefined error: 0), outsize: 24
unique: 5, opcode: GETXATTR (22), nodeid: 1, insize: 77
valueOfExtendedAttribute: panameth - com.apple.FinderInfo, ofItemAtPath - /, position - 0
   unique: 5, error: 0 (Undefined error: 0), outsize: 48

To unsubscribe from this group and stop receiving emails from it, send an email to osxfuse-grou...@googlegroups.com.

Sam Moffatt

unread,
Aug 17, 2016, 2:34:19 AM8/17/16
to osxfus...@googlegroups.com
Your file system is returning a permission denied it seems for the mkdir, which would point to an implementation issue somewhere. At a stretch it could be the parent directory doesn’t have the right permissions set but I’d take a closer look at your code and understanding what you’re returning. I’d set a breakpoint while running in single threaded mode (reduce noise) to make sure that your delegate is being hit properly and see what path it’s tracing to trigger a permission denied response.

Cheers,

Sam
To unsubscribe from this group and stop receiving emails from it, send an email to osxfuse-group+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages