JustBash.FS.Special (JustBash v0.4.0)

View Source

Device nodes the filesystem layer services itself, rather than storing them in a backend.

/dev/null is the one device the shell already handled on the write side of redirection (> /dev/null discards). It did not exist in the VFS, so cat /dev/null and test -e /dev/null failed even while cat < /dev/null succeeded. Resolution consults this table so the read side, the write side, and the operand side agree.

/dev is the directory that holds it. Without that node, tee /dev/null would fail looking up the parent, and ls /dev would report the path missing. Other /dev nodes (zero, stdin, stdout, stderr) are not in the table; add them here if the same invariant ever needs them.

Summary

Types

kind()

@type kind() :: :null | :directory

Functions

append_file(fs, atom, path, content)

@spec append_file(term(), kind(), String.t(), binary()) ::
  {:ok, term()} | {:error, VFS.Error.t()}

children(arg1)

@spec children(String.t()) :: [String.t()]

Virtual children a special path (or /) contributes to readdir.

/ lists dev so the directory that holds /dev/null is visible; /dev lists null.

chmod(fs, kind)

@spec chmod(term(), kind()) :: {:ok, term()}

exists?(fs, kind)

@spec exists?(term(), kind()) :: {true, term()}

lookup(arg1)

@spec lookup(String.t()) :: {:ok, kind()} | :none

Look up a normalized path in the special-file table.

Callers must pass a path that JustBash.FS.normalize_path/1 has already rooted and collapsed, so /dev/./null and /dev/null name the same node.

merge_children(path, entries)

@spec merge_children(String.t(), [String.t()]) :: [String.t()]

Merge special children into a backend listing.

Only paths that contribute children (/ and /dev) are uniq-sorted. Every other directory returns entries in the backend's order, so ls of an unrelated path is not a drive-by sort.

mkdir(fs, atom, path, opts)

@spec mkdir(term(), kind(), String.t(), keyword()) ::
  {:ok, term()} | {:error, VFS.Error.t()}

null?(path)

@spec null?(String.t()) :: boolean()

True when a normalized path is the null device.

read_file(fs, atom, path)

@spec read_file(term(), kind(), String.t()) ::
  {:ok, binary(), term()} | {:error, VFS.Error.t()}

readdir(fs, atom, path, backend_entries)

@spec readdir(term(), kind(), String.t(), [String.t()]) ::
  {:ok, [String.t()], term()} | {:error, VFS.Error.t()}

readlink(kind, path)

@spec readlink(kind(), String.t()) :: {:error, VFS.Error.t()}

refuse_create(path)

@spec refuse_create(String.t()) :: {:error, VFS.Error.t()}

refuse_link(kind, path)

@spec refuse_link(kind(), String.t()) :: {:error, VFS.Error.t()}

rm(kind, path)

@spec rm(kind(), String.t()) :: {:error, VFS.Error.t()}

stat(fs, atom, path)

@spec stat(term(), kind(), String.t()) :: {:ok, VFS.Stat.t(), term()}

stream_read(fs, atom, path, opts)

@spec stream_read(term(), kind(), String.t(), keyword()) ::
  {:ok, Enumerable.t(), term()} | {:error, VFS.Error.t()}

write_file(fs, atom, path, content)

@spec write_file(term(), kind(), String.t(), binary()) ::
  {:ok, term()} | {:error, VFS.Error.t()}