whio  Update of "whio_epfs_cp"

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

Artifact ID: 21f7d03d176a3e062e684ed3b4088e83720ff19c
Page Name:whio_epfs_cp
Date: 2011-05-23 18:50:54
Original User: stephan
Parent: 37384d1368d736fb9454c75256f3222988303444
Content

ACHTUNG: AS OF 20110523, THIS PAGE IS NOW MAINTAINED IN THE NEW WIKI: http://whiki.wanderinghorse.net/wikis/whio/?page=whio_epfs_cp

See also: whio_epfs_tools

whio-epfs-cp

whio-epfs-cp is a tool for listing the contents of whio_epfs container files. Aside from the common tools arguments, it accepts these optional parameters:

  • -i means to import files into the EFS. This is the default, and need not be specifiied.
  • -x means to export files from the EFS. This disables -i.
  • -all or -A in conjunction with -x
    Equivalent to passing a filename of '*', this exports all inodes from the EFS into files named the same as their inode ID (that is, numeric filenames). This can be used in contexts where escaping the * character may be difficult to properly do due to multiple levels of command escaping (e.g. in Makefiles).
  • --show-id means to print out the inode ID for each imported file.

EPFS does not directly support storage of filenames, so filenames passed to this tool have a syntax which allows the user to specify inode/filename combinations. Filenames may be in any of these formats, depending on whether it is run in import or export mode (### indicates an inode ID):

  • ###=filename imports filename to inode ### or exports inode ### to filename.
  • ### imports file ### to the next free inode or exports inode ### to file ###.
  • filename imports filename to the next free inode.
  • '*' exports all inodes to files of the same name. Be sure to quote the '*' character so it is not expanded by your shell! You can use the --all/-A parameter in place of the asterisk, to avoid quoting/escaping problems.

The filename "-" can be used to send exported files to stdout (it has no special meaning in import mode). Some platforms also support the name /dev/stdout for that purpose. Importing from stdin is not yet supported because the importer tries to pre-allocate all space and an input stream cannot report its size.

inode IDs start at 1 and go up to the number specified when the EFS container is created (see whio_epfs_mkfs). Using an out-of-bounds inode ID will cause an error.

When importing, if no inode ID is specified then the next available inode will be used. The --show-id option can be used to print the assigned ID to stdout.

Some reasons why importing a file might fail:

  • The EFS has no free inodes.
  • The user specified an out-of-range inode (too big of a number for the EFS).
  • The EFS does not have enough free blocks to store the file.
  • The EFS file is read-only.

If import of a given file fails, the file will be removed from the EFS to avoid leaving partially-populated data lying around.

Importing Filenames

As of 20101218, this tool supports storing of imported file names, but cannot yet export them to those names. For this to work, the EFS must have a namer installed, e.g. by using the --namer=... option to whio_epfs_mkfs or calling whio_epfs_namer_format() when programmatically creating the EFS. If no namer is installed, the imported names will simply not be stored in the EFS.

An example:

stephan@ludo:~/whio/pfs$ ./whio-epfs-mkfs --force -i200 --namer=whio_epfs_namer_ht x.epfs
./whio-epfs-mkfs [x.epfs]: EFS container created (22640 bytes).
stephan@ludo:~/whio/pfs$ ./whio-epfs-cp x.epfs *.[ch]
stephan@ludo:~/whio/pfs$ ./whio-epfs-ls x.epfs 
whio_efps container file [x.epfs]:
Label:	[<empty>]
Inode #	   Size	  Mod. Time (Local)	Name
     1     5002   2010-12-18 16:55:57	whio_epfs_namer_ht.whio_ht
     2    32429   2010-12-07 00:12:41	EPFSApp.c
...
    25     6428   2010-12-18 17:51:14	whio_epfs_namer_array.c
    26    21751   2010-12-18 17:53:28	whio_epfs_namer_ht.c

Totals: 26 of 200 inodes take up 353045 bytes.

Note that inode #1 has a name which does not match the wildcard we imported (*.[ch])! That's because the whio_ht-based whio_epfs_namer implementation requires an inode to store the inodes-to-names mappings, and they are stored in inode #1 in this case. (When adding the namer programmatically, that namer implemenation will use the next available inode.)

Examples

# Import some files into my.epfs into the next free inodes:
~> whio-epfs-cp my.epfs foo.c bar.c baz.h

# Import file foo.c into inode #7:
~> whio-epfs-cp my.epfs 7=foo.c

# Export inode #3 to file "xxx.yyy":
~> whio-epfs-cp -x my.epfs 3=xxx.yyy

# Export inode #2 to file "2" and inode #3 to file "3.out":
~> whio-epfs-cp -x my.epfs 2 3=3.out

# Export inode #1 to stdout:
~> whio-epfs-cp -x my.epfs 1=-

# Import several files and print out their inode IDs:
~> whio-epfs-cp --show-id my.epfs foo.c bar.c 7=baz.c
1
2
7

TODOs:

  • Add --format=STRING, like --format="inode-%i.out", which would define the name pattern for otherwise "unnamed" exports.
  • For export mode, the ability to specify ranges of inodes, e.g. "1-5" or "5-" to mean (5-end_of_list).