1

I'd like my application to be able to show a directory listing from a remote FTP (or SFTP etc) location. When a file/directory changes in the remote directory tree, the application should update its view with the relevant changes.

Because traversing the entire tree is slow and wasteful, I'd like to use something along the lines of FSEvents (inotify/kqueues on Linux), but obviously these libraries are filesystem-based, and a connection to an FTP server is not the same as a mounted filesystem.

In order to make these libraries work, I'd need to actually mount a filesystem backed by FTP/SFTP on the local machine, then attach an FSEventStream (or kqueue etc) to this local mount. I know FUSE can do this, but is there any way I can use FUSE without the user having to first install it? I mean, can I bundle it with my (Mac) application and create mounts without having to put the user through the process of actually running an installer package to copy libfuse and the kernel modules into the system? Does it assume /dev/fuse exists, or can this live outside the /dev/ path, inside my application directory?

Nice Mac applications are installed with a simple drag & drop and I'd like to keep mine this way if possible. I'm unclear on if it's possible to use libfuse directly (provided the files are included with the app), without installing it in the system paths.

Alternatively, does anyone have any other suggestions for monitoring for changes over FTP, without polling?

1 Answer 1

2

Unfortunately FTP and SFTP do not support any form of client notification.

Much like HTTP they are based on a request/response scheme, where each data transfer is initiated by the client. What makes things worse is that, contrary to HTTP, there is no way to ask the server to inform the client of any changes since a specific date.

This means that not only you have to use polling, but also that said polling will by no means be lightweight.

As far as FUSE is related, most FTP and SFTP modules that are available only update their view of the filesystem when the userspace applications ask for a directory listing (e.g. hitting Refresh in a file browser window). They do not perform polling on their own. Your userspace application will have to initiate the refresh by polling the directory itself.

EDIT:

To clarify a couple of things, recent versions of FUSE do support notification events. They simply pass through the events from the modules to the kernel. The modules still have to generate them and in the case of an FTP/SFTP client module that is impossible without polling the server.

Also keep in mind that many current NFS implementations do not support change notifications either, despite the fact that NFSv4.1 has the necessary provisions. Many SMB/CIFS servers (esp. those in cheap Network-Attached-Storage embedded systems) also have limited to no support.

3
  • Thanks, you're right and I think I'm just going to have to fall back to a manual "Refresh" control in my app. I did stumble upon this interview with the MacFUSE author however who indicates that MacFUSE supports FSEvents, kqueues and KAuth. I'm not sure if this would only work if all events occur on the client however... I find it hard to see how events occuring on the host would be reflected on the client. Research will tell (I'll be using FSEvents for local storage monitoring anyway, so pointing it at a sshfs mount will be trivial to test).
    – d11wtq
    Dec 8, 2010 at 13:47
  • Err... "this interview" :) mactech.com/articles/mactech/Vol.23/23.03/…
    – d11wtq
    Dec 8, 2010 at 13:48
  • which NFS servers support notifications? and which clients can be used with those? Jul 19, 2015 at 23:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.