Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Developing "File Systems" for linux, mac, windows

Tags:

filesystems

What technologies do applications such as dropbox (http://www.dropbox.com/) and expandrive (http://www.expandrive.com/mac) use to build functionality right into the local filesystems on each platform? Can anyone suggest anything that would allow for maximum code reuse on all of the major platforms?

I've only looked into FUSE on linux so far and I like what I see.

like image 714
mcot Avatar asked Jan 29 '11 16:01

mcot


2 Answers

Implementing a virtual file system is very OS-specific. The reason is that architecture of drivers is different in Unix-like OS and in Windows.

To avoid writing your own driver, you can use user-mode file system toolkit. On Linux, BSD and MacOS there exist FUSE and OSXFUSE (fork of now-inactive MacFUSE) respectively. On Windows our Callback File System is used.

Dropbox at the moment doesn't have a virtual file system but only shell extension (afaik they planned to create a virtual disk but I don't know what they have decided).

Regarding how file changes are tracked: there exist several methods. The simplest is to scan the directory on timer and compare timestamps and file sizes. Next, one can use FindFirstChangeNotification WinAPI function. And the most sophisticated and most reliable method is to use a filesystem filter driver. On Windows our CallbackFilter can be used. On MacOS X and on Linux you can get post-notifications similar to what FileSystemWatcher offers in .NET/Windows. In particular, on Linux, one can use inotify.

like image 67
Eugene Mayevski 'Callback Avatar answered Oct 23 '22 11:10

Eugene Mayevski 'Callback


What you are after are usrspace filesystems. I don't know if there is a unified solution for implementing userspace filesystems on all (or most of all) platforms (probably not), but here's a starting point:

  • for linux and (I think only some) unices: fusefs
  • for windows: dokan
  • for mac os: macfuse

I am not familiar with all of them so I don't know how easy is to code proxies/interfaces so you can seamlessly implement filesystems in a platform-independent manner. Anyway, the operations that a filesystem is supposed to support are (to some extent) the same for everyone (open,read,write,etc) so at first sight this seems to be an easy start (even if coded with C preprocessing techniques, altho you may want to take a look at C++ boost libraries which are supposed to be highly platform independent and offer some good platform independent development tools as well).

Good luck!

like image 27
user237419 Avatar answered Oct 23 '22 10:10

user237419