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