cmdfs

Command File System
Download

cmdfs Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • Mike Swain
  • Publisher web site:

cmdfs Tags


cmdfs Description

Command File System cmdfs is a FUSE-based virtual filesystem which applies an arbitary filter command to selected files in a source directory tree to create the destination files. Includes configurable caching and monitoring of the source tree to limit CPU use and prefetch data.Build 1. Unpack archive tar zxvf cmdfs-0.1 2. Configure build cd cmdfs-0.1 ./configure 3. Build make 4. Install sudo make installSynposiscmdfs < source-dir > < mount-dir > options -o extension=ext1] Specify matching file extension(s) to apply command to -o path-re=< regular expression > Specify regexp of pathnames to apply command to -o mime-re=< regular expression > Specify regexp of mime types to apply command to (as returned by file -b --mime-type) -o link-thru Pass unmatched files through to filesystem as symbolic links -o monitor Watch source directory tree for new files and cache them as they appear. New directories will be monitored -o cache-dir=< dir > Directory to save cache files -o cache-size=< size in Mb > Size to attempt to limit cache directory to. Files removed on least-recent access basis. -o cache-entries=< count > Number of entries to attempt to limit cache directory to. Files removed on least-recent access basis.How It Works - An ExampleGiven a source tree, which includes, say, jpg images, we can generate a view filesystem which contains the same files resized to email size.The filter command is set up as a fileystem option at mount time. In this case our filter option might be something like (using ImageMagick's convert command):command=convert - -resize 20% -Note we follow the UNIX convention of taking the standard input and filtering to standard output. Being a FUSE filesystem, the child process will be run under the group/user of the owner. The command is run within a shell (/bin/sh) process, as if started by /bin/sh -c ''Obviously there'll be files in the source tree which we dont want to apply the filter to. In this case we identify files of interest by extension:extension=jpg;gif;pngTo mount the filesystem as above for a particular user: cmdfs /home/bob/images /mnt/myphotos "-ocommand=convert - -resize 20% -,extension=jpg;gif;png"Selection FiltersAs well as just matching on extension, files of interest can be selected by mime type, matching a regexp (cmdfs uses the file command to determine the mimetype):mime-re=image/*Or just a plain path regexp (this allows us to exclude whole directory subtrees etcpath-re=.*/my-images/These options can be combined to get the required filter selection.Unmatched FilesBy default, files which don't match a filter won't appear in the filesystem view. We may want to see the original files though, so thelink-thruoption may be specified. This will generate symbolic links to the original files.MonitoringThe image resize example is a good example of an application where we might want the files in the source filesystem to be filtered as they are added, rather than just on-demand. Cmdfs uses inotify to monitor all the directories in the tree, and automatically monitors new subdirectories as they are added:monitorWhen you copy the latest batch of files from your camera the resized versions will automatically be generated.Cachingcmdfs only recreates view files if the modification date changes on the source. All files created using the filter are held in a cache directory, with a name created as a hash from the full path. By default this directory is located in /tmp/cmdfs-cache.< user name >, but can be changed:cache-dir=< dir >Note that some systems will clear the /tmp directory tree between reboots, which may or may not be desired.The size of the cache directory can be limited using:cache-size=< size in mb >and/orcache-entries=< number of files >The least recently accessed cached files will be removed in the background to maintain these limits.Mounting With fstabTo aid in mounting directories for multiple users, cmdfs accepts the source base directory as the first argument so it can be mounted using the conventional mount.fuse script from fstab. This allows supplying cmdfs# as the fs_spec (see man 5 fstab). The user_allow_other option needs to be enabled in /etc/fuse.conf to allow normal users to mount (see fuse.conf). An example fstab entry:cmdfs#/media/myphotos /home/bob/images fuse user,allow_other,command=convert\040-\040-resize\04020%\040-,monitor,cache-size=500,extension=jpg;gif;png 0 0Note that the spaces in the command need to be escaped using \040 for /etc/fstab to parse correctly. Requirements: · Filesystem in Userspace · libmhash What's New in This Release: · Remove base-dir option - specify with first argument for fstab · Code tidy · Bug, inotify event name not null terminated · Update help and README


cmdfs Related Software