If you're a programmer, one of the great things about Linux and Unix is that everything is a file -- or at least acts like one. From devices to sockets, the "everything is a file" paradigm has served Unix well for a long, long time.
If you’re a programmer, one of the great things about Linux and Unix is that everything is a file — or at least acts like one. From devices to sockets, the “everything is a file” paradigm has served Unix well for a long, long time.
However, as high speed networks have become ubiquitous, it’s more and more likely that the “files” you want to access are on a remote machine. And unfortunately, there’s no single protocol for getting at them. Sure, NFS is an option, but it’s really only useful within a single organization.
What’s really needed is an abstract interface that makes opening remote files seamless and easy. Sure, you could use cURL or libcurl (http://curl.haxx.se) in your code, but wouldn’t it be nice if you could do it at a higher level? Maybe get the Linux kernel to do the work for you? Wouldn’t it be convenient if Internet resources (like FTP directories and SSH servers) appear as though they’re part of your local filesystem? That’s where the Linux Userland Filesystem (LUFS) enters the picture.
Here’s a brief description of the package from the LUFS Web site:
LUFS is a hybrid user-space filesystem framework [that supports] an indefinite number of filesystems (localfs, sshfs, ftpfs, cardfs, and cefs are implemented so far) transparently for any application.
LUFS comes in two pieces. The first piece is a module — a filesystem driver — that plugs into the Linux kernel. The driver acts as a bridge between the kernel and the second part of LUFS, a separate user-space daemon. The daemon handles the complexity of talking to remote network services. The separation between the kernel and the daemon keeps as little of the code as necessary in the kernel. Instead, all of the really hard work is done in user-space (where changes are easily made and debugged).
Getting LUFS installed and running isn’t difficult, and the process is well-documented. First, you need the kernel source (or at least the header files) for the kernel you’re running. Then, after you download and unpack the LUFS distribution, go through the typical, common steps of building the kernel:
# make install
Next, run lusetup to configure various LUFS options.
Once installed, you can easily mount a remote filesystem. For example, to mount an SSH “filesystem” from foo.example.com as /mnt/foo (using sftp behind the scenes), you can either use the normal mount command or lufsmount:
mount -t lufs none /mnt/foo -o \
nosuid,fs=sshfs,host=foo.example.com, \ username=jzawodn,fmode=444,dmode=555
Similarly, you can mount a remote FTP server as a local filesystem, too:
mount -t lufs none /mnt/ftp -n -o \
nosuid,fs=ftpfs,host=ftp.example.com, \ username=jzawodn,password=mypassword,ftpactive
Once the remote filesystem is mounted, you can cd to /mnt/foo or /mnt/ssh and begin accessing files.
More to come…
Currently, LUFS only supports a few network services, the most notable being SSH via SSHFS. Over time, developers will be adding support for others, including HTTP, WebDAV, and FreeNet.
LUFS is still relatively new, but it has the potential to make life a lot easier. Give it a try. Combined with NFS and Samba, there’s very little information that can’t be at your fingertips.
Have an idea for a project we should feature? Drop a note to email@example.com and let us know.