NetFSMountURLSync won't mount my FTP volume

I would like to replace the deprecated method FSMountServerVolumeSync with the newer one NetFSMountURLSync.

I can properly mount my FTP volume using "Connect to Server" in the Finder and with FSMountServerVolumeSync (the volume comes as read only, but it's ok).

When I try to mount the FTP volume with NetFSMountURLSync I get this error message:

"The share does not exist on the server. Please check the share name and then try again".

But as I know I can't define the share on a FTP server. How can I fix this issue?

Still looking for a way to mount a remote FTP volume from within my macOS app.

I have just tried the Terminal command

open ftp://user:password @ server.domain.com/

(without those 2 spaces) to mount my FTP volume. It works but it's async so it doesn't return a value (mounted or not). And I don't know how to invoke a callback when the task is done. Also I must define the username and password within the address and it's not a good practice.

Recap

  1. FSMountServerVolumeSync is deprecated…
  2. NetFSMountURLSync asks for a share and I cannot use it.
  3. The Terminal command "open" is async so it does't return a value nor it invokes a callback.
  4. mount_ftp needs for an existing directory as a mount point as e.g. /Volumes/MyFTPDisk but I can't create a directory within the /Volumes folder with createDirectoryAtPath:

For now I stay stuck on the deprecated point 1. Too bad.

So, let me start back here and correct a misunderstanding:

When I try to mount the FTP volume with NetFSMountURLSync I get this error message: "The share does not exist on the server. Please check the share name and then try again".

But as I know I can't define the share on a FTP server. How can I fix this issue?

The NetFS framework basically uses the term "share" as the generic term for "remote source I was asked to mount". The framework supports lots of different protocols and "share" was the term they ended up using for all of those different sources.

That leads me to here:

I would like to replace the deprecated method FSMountServerVolumeSync with the newer one NetFSMountURLSync.

I don't see why FSMountServerVolumeSync could do anything NetFSMountURLSync couldn't do. FSMountServerVolumeSync isn't calling directly into "NetFSMountURLSync", but that's only because it's calling into a slightly different private function inside the NetFS framework. Nothing about the SPI is particularly "special". All does is convert bitfield flags of FSMountServerVolumeSync into the dictionary structure NetFS uses, then call the same underlying mount call that NetFSMountURLSync.

Can you share the your code for "FSMountServerVolumeSync" and "NetFSMountURLSync"? While I believe both functions are equally capable, the argument structure FSMountServerVolumeSync is different than NetFSMountURLSync, so I suspect NetFSMountURLSync is failing because you're (unintentionally) asking it to do something slightly different than your FSMountServerVolumeSync call.

Similarly, coming at this from the other direction, this is the most "basic" mount call option:

let url = URL(string: "ftp://server.domain.com")!
let err = NetFSMountURLSync(
    url as NSURL,           // url
    nil,                    // mountpath
    user as NSString,  // user
    password as NSString, // passwd
    nil,                    // open_options
    nil,                    // mount_options,
    nil                     // mountpoints
)
print(err)

Finally one quick comment on this:

mount_ftp needs for an existing directory as a mount point as e.g. /Volumes/MyFTPDisk but I can't create a directory within the /Volumes folder with createDirectoryAtPath:

I don't think you'll need to, but if you choose to use "mount_ftp" (or any of the direct mount tools), then you should NOT attempt to create a directory in /Volumes/. You should create your own mount directory "somewhere else" and use that as the mount target. "/Volumes/" is the system's mount directory for auto mounted volumes and/or volumes mounted through our "high level" API (DiskArb, NetFS, etc.).

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

NetFSMountURLSync won't mount my FTP volume
 
 
Q