diskdb — tool for creating and querying file system content database
diskdb cmd [-1CcDFMqrStvx] -d
db [-d db] [-I
filename...] [-i
pattern...] [-E
filename...] [-e
pattern...] [-L
filename...] [-P
filename...] [-R dir] [path...]
Program diskdb manages a database of information about the contents of a file system. The database contains a list of files and directories in the file system. For each file (or directory), the remembered attributes are its name, metadata, size, and optionally checksum (only for regular files, using cryptographic hash SHA256). The metadata include the file type, permissions, owner, group, times (access, modify, change, create), file flags, and ACLs. For symbolic links, the link target is also recorded. The database is in a textual format.
It is possible to select a subset of the whole file system directory in several ways:
One or more paths can be specified on
the command line or read from a file when creating a database.
The operation of the program is then
limited to subtrees of the file system hierarchy rooted at these
paths. If a path is a directory, its whole subtree is processed by
default. If the path arguments are omitted, an empty database is
created. If at least one path argument or path file is specified for
commands other than create, the operation of the
program is limited to these paths (either from arguments or from the
file), without recursion for paths denoting directories.
Option -1 stops at a file system boundary, that
is, mount points are not crossed when creating a database.
A list of inclusion and exclusion patterns can be defined. Each
path encountered when traversing a file system subtree is compared to
the list. The first matching pattern controls whether the path will be
processed, or ignored. If no pattern matches, the path is processed,
unless -x is used. The pattern can contain shell
pattern matching characters, but they behave more like
-path of find(1), that is, slash and dot characters (at a file name
beginning) do not have to be matched explicitly.
The list of patterns is composed of patterns defined by
options -i and -e and patterns read
from files selected by options -I and
-E. The ordering of options defines the ordering of patterns
in the list.
Inclusion and exclusion patterns work recursively, that is, including/excluding a directory includes/excludes also its contents.
When a database content is displayed in textual form (by commands
list, diff, and
all other database comparison commands), the output is sorted
by paths component-wise. As this is not the same as the lexicographic order,
two such outputs cannot compared by command comm(1) without being sorted by sort(1)
first.
createCreates a new database by examining the current
contents of the file system. This command requires one
-d option.
diffCompares a database with the current contents of the
file system or two databases, and writes the differences to
the standard output. Each line of the output contains a single
character followed by a space and the file path. The first
character is '+' for added files
(those existing only in the current file system or in the second
database), '-' for deleted files
(those existing only in the (first) database),
'!' for modified files (different in
the first database and the file system or the second
database), 'd' for files changed from
non-directory to directory (directory in the second
database and some other file type in the first database),
'f' for files changed from directory
to non-directory (directory in the first
database and some other file type in the second database).
This command requires two
-d options.
diffequalLike diff, but reports (with prefix
'=') also files that are equal in
both databases.
addedLike diff, but reports only added
files, one path per line.
deletedLike diff, but reports only deleted
files, one path per line.
changedLike diff, but reports only
modified files, one path per line.
equalLike diff, but reports only equal
files, one path per line.
dirLike diff, but reports only files
changed from non-directory to directory, one path per
line.
nondirLike diff, but reports only files
changed from directory to non-directory, one path per
line.
setmetaCreates directories that are in the database, but do
not exist in the filesystem. Directories are created as
empty. Sets file and directory metadata according to the
database. This command requires one -d
option.
showOutputs all information for selected files from the
database in a textual format. This command requires one
-d option.
listOutputs paths (and no other information) for
selected files from the database in a textual format. This
command requires one -d option.
-1When recursively descending a directory tree, it does not go into directories mounted from different devices. It means that file system boundaries at mount points are not crossed.
-CWhen comparing two databases, it checks only file
contents: size, checksum (modification time is used
instead of the checksum if -c is
set), or target file (for symbolic links). File system
objects that are not regular objects or symbolic links are
always treated as having equal contents. By
default, both contents and metadata are compared. File
types are always compared and files of different types are
treated as different. This option is allowed only for
commands that compare two databases.
-cFile checksums are not computed when used
together with the create command and are not
checked when used with the diff or
changed command. If a database does not
contain checksums, an attempt to use it for comparison
without -M or -c
set leads to an error.
-DOperate only on directories. This option cannot
be used for command create and is
mutually exclusive with option -F.
-d
dbThe name of the created or processed database file. This option is required once or twice, depending on the command.
-E
filenameAdds patterns from file
filename (or the standard input
if filename is
'-') to the pattern list as exclusion
patterns. The file contains one pattern per line.
Blank lines and leading/trailing whitespace are ignored.
Lines whose first non-space character is a pound-sign (#)
are comments, and are ignored.
-e
patternAdds pattern to the
pattern list as an exclusion pattern.
-FOperate only on file types other than directories.
This option cannot be used for
command create and is mutually exclusive
with option -D.
-I
filenameAdds patterns from file
filename (or the standard input
if filename is
'-') to the pattern list as
inclusion patterns. The file contains one pattern per
line.
-i
patternAdds pattern to the
pattern list as an inclusion pattern.
-L
filenameAdds patterns from file
filename (or the standard input
if filename is
'-') to the pattern list.
The file contains one pattern per line. Inclusion patterns
are preceded by characters "+ "
(plus sign and space). Exclusion patterns are preceded by
"- " (minus sign and space).
Blank lines and leading/trailing whitespace are ignored.
Lines whose first non-space character is a pound-sign (#)
are comments, and are ignored.
-MWhen comparing files, it checks only metadata. By default, both file contents and metadata are checked. Files types are always compared and files of different types are treated as different. This option is allowed only for commands that compare two databases.
-P
filenameAdds paths from file
filename (or the standard input
if filename is
'-') to the path
list. There is one path per line.
-qFile names containing newlines are silently ignored when creating a database. If this option not set and there are some file names that contain the newline character, a warning message is reported at the end, and the program finishes with an error status.
Files that do not exist are silently ignored by
command setmeta. If this option is not
set, missing files are reported. Missing directories are
always created, regardless of -q.
-R dirRelative paths are
relative to directory dir
instead of the current directory. Used by commands
create and setmeta.
-rTurns off recursive descent into directories when
creating a database. Only files specified explicitly in
the path list are
processed.
-SInclude sockets in the created database or output. Sockets are skipped by default, because programs such as tar(1) cannot process them.
-TCheck no file times. Normally, modification times
(or all times with -c) are compared
when comparing file metadata. This option skips
the time test, and only the remaining metadata types are tested.
-tCheck all file times. If not set, only the modification time is checked when comparing databases.
-vVerbose operation, prints each processed path to
stderr.
-xPaths that do not match any include and exclude
pattern will be ignored. Without -x, they
would be processed.
The diskdb program terminates with 0 status if successul, and with a nonzero if an error occurs.
If the requested information cannot be obtained for a file when
creating the database, an error message containing the failed path is
written to stderr, the file is ignored, and the
processing continues with the next file. The final exit status will be
nonzero.