Documentation
¶
Index ¶
- Constants
- Variables
- func ArchivePath(in io.Reader, out io.Writer, args []string) error
- func ExportedToError(ee *ExportedError) error
- func ExtractArchive(in io.Reader, out io.Writer, args []string) error
- func Lchmod(in io.Reader, out io.Writer, args []string) error
- func Lchown(in io.Reader, out io.Writer, args []string) error
- func Link(in io.Reader, out io.Writer, args []string) error
- func Lstat(in io.Reader, out io.Writer, args []string) error
- func Mkdir(in io.Reader, out io.Writer, args []string) error
- func MkdirAll(in io.Reader, out io.Writer, args []string) error
- func Mkfifo(in io.Reader, out io.Writer, args []string) error
- func Mknod(in io.Reader, out io.Writer, args []string) error
- func OpenFile(in io.Reader, out io.Writer, args []string) (err error)
- func ReadDir(in io.Reader, out io.Writer, args []string) error
- func ReadFile(in io.Reader, out io.Writer, args []string) error
- func ReadTarOptions(r io.Reader) (*archive.TarOptions, error)
- func Readlink(in io.Reader, out io.Writer, args []string) error
- func Remove(in io.Reader, out io.Writer, args []string) error
- func RemoveAll(in io.Reader, out io.Writer, args []string) error
- func ResolvePath(in io.Reader, out io.Writer, args []string) error
- func Stat(in io.Reader, out io.Writer, args []string) error
- func Symlink(in io.Reader, out io.Writer, args []string) error
- func WriteError(err error, out io.Writer) error
- func WriteFile(in io.Reader, out io.Writer, args []string) error
- func WriteFileHeader(w io.Writer, hdr *FileHeader, extraData []byte) error
- func WriteTarOptions(w io.Writer, opts *archive.TarOptions) error
- type ExportedError
- type FileHeader
- type FileInfo
- type Func
- type SeekHeader
Constants ¶
const ( StatCmd = "stat" LstatCmd = "lstat" ReadlinkCmd = "readlink" MkdirCmd = "mkdir" MkdirAllCmd = "mkdirall" RemoveCmd = "remove" RemoveAllCmd = "removeall" LinkCmd = "link" SymlinkCmd = "symlink" LchmodCmd = "lchmod" LchownCmd = "lchown" MknodCmd = "mknod" MkfifoCmd = "mkfifo" OpenFileCmd = "openfile" ReadFileCmd = "readfile" WriteFileCmd = "writefile" ReadDirCmd = "readdir" ResolvePathCmd = "resolvepath" ExtractArchiveCmd = "extractarchive" ArchivePathCmd = "archivepath" )
Name of the commands when called from the cli context (remotefs <CMD> ...)
const ( // Read request command. Read uint32 = iota // Write request command. Write // Seek request command. Seek // Close request command. Close // CmdOK is a response meaning request succeeded. CmdOK // CmdFailed is a response meaning request failed. CmdFailed )
const RemotefsCmd = "remotefs"
RemotefsCmd is the name of the remotefs meta command
Variables ¶
var Commands = map[string]Func{ StatCmd: Stat, LstatCmd: Lstat, ReadlinkCmd: Readlink, MkdirCmd: Mkdir, MkdirAllCmd: MkdirAll, RemoveCmd: Remove, RemoveAllCmd: RemoveAll, LinkCmd: Link, SymlinkCmd: Symlink, LchmodCmd: Lchmod, LchownCmd: Lchown, MknodCmd: Mknod, MkfifoCmd: Mkfifo, OpenFileCmd: OpenFile, ReadFileCmd: ReadFile, WriteFileCmd: WriteFile, ReadDirCmd: ReadDir, ResolvePathCmd: ResolvePath, ExtractArchiveCmd: ExtractArchive, ArchivePathCmd: ArchivePath, }
Commands provide a string -> remotefs function mapping. This is useful for commandline programs that will receive a string as the function to execute.
var ErrInvalid = errors.New("invalid arguments")
ErrInvalid is returned if the parameters are invalid
var ErrUnknown = errors.New("unkown command")
ErrUnknown is returned for an unknown remotefs command
Functions ¶
func ArchivePath ¶
ArchivePath archives the given directory and writes it to out. Args: - in = size of json | json of archive.TarOptions - args[0] = source directory name Out: - out = tar file of the archive
func ExportedToError ¶
func ExportedToError(ee *ExportedError) error
ExportedToError will convert a ExportedError to an error. It will try to match the error to any existing known error like os.ErrNotExist. Otherwise, it will just return an implementation of the error interface.
func ExtractArchive ¶
ExtractArchive extracts the archive read from in. Args: - in = size of json | json of archive.TarOptions | input tar stream - args[0] = extract directory name
func Lchmod ¶
Lchmod changes permission of the given file without following symlinks Args:
- args[0] = path
- args[1] = permission mode in octal (like 0755)
func Lchown ¶
Lchown works like os.Lchown Args:
- args[0] = path
- args[1] = uid in base 10
- args[2] = gid in base 10
func Link ¶
Link works like os.Link Args:
- args[0] = old path name (link source)
- args[1] = new path name (link dest)
func Lstat ¶
Lstat functions like os.Lstat. Args: - args[0] is the path Out: - out = FileInfo object
func Mkdir ¶
Mkdir works like os.Mkdir Args: - args[0] is the path - args[1] is the permissions in octal (like 0755)
func MkdirAll ¶
MkdirAll works like os.MkdirAll. Args: - args[0] is the path - args[1] is the permissions in octal (like 0755)
func Mkfifo ¶
Mkfifo creates a FIFO special file with the given path name and permissions Args:
- args[0] = path
- args[1] = permission mode in octal (like 0755)
func Mknod ¶
Mknod works like syscall.Mknod Args:
- args[0] = path
- args[1] = permission mode in octal (like 0755)
- args[2] = major device number in base 10
- args[3] = minor device number in base 10
func OpenFile ¶ added in v0.3.3
OpenFile works like os.OpenFile. To manage the file pointer state, this function acts as a single file "file server" with Read/Write/Close being serialized control codes from in. Args:
- args[0] = path
- args[1] = flag in base 10
- args[2] = permission mode in octal (like 0755)
func ReadDir ¶
ReadDir works like *os.File.Readdir but instead writes the result to a writer Args:
- args[0] = path
- args[1] = number of directory entries to return. If <= 0, return all entries in directory
func ReadFile ¶
ReadFile works like ioutil.ReadFile but instead writes the file to a writer Args:
- args[0] = path
Out:
- Write file contents to out
func ReadTarOptions ¶
func ReadTarOptions(r io.Reader) (*archive.TarOptions, error)
ReadTarOptions reads from the specified reader and deserializes an archive.TarOptions struct.
func ResolvePath ¶
ResolvePath works like docker's symlink.FollowSymlinkInScope. It takens in a `path` and a `root` and evaluates symlinks in `path` as if they were scoped in `root`. `path` must be a child path of `root`. In other words, `path` must have `root` as a prefix. Example: path=/foo/bar -> /baz root=/foo, Expected result = /foo/baz
Args: - args[0] is `path` - args[1] is `root` Out: - Write resolved path to stdout
func Symlink ¶
Symlink works like os.Symlink Args:
- args[0] = old path name (link source)
- args[1] = new path name (link dest)
func WriteError ¶
WriteError is an utility function that serializes the error and writes it to the output writer.
func WriteFile ¶
WriteFile works like ioutil.WriteFile but instead reads the file from a reader Args:
- args[0] = path
- args[1] = permission mode in octal (like 0755)
- input data stream from in
func WriteFileHeader ¶ added in v0.3.3
func WriteFileHeader(w io.Writer, hdr *FileHeader, extraData []byte) error
WriteFileHeader serializes a FileHeader and writes it to w, along with any extra data
func WriteTarOptions ¶
func WriteTarOptions(w io.Writer, opts *archive.TarOptions) error
WriteTarOptions serializes a archive.TarOptions struct and writes it to the writer.
Types ¶
type ExportedError ¶
ExportedError is the serialized version of the a Go error. It also provides a trivial implementation of the error interface.
type FileHeader ¶ added in v0.3.3
FileHeader is a header for remote *os.File operations for remotefs.OpenFile
func ReadFileHeader ¶ added in v0.3.3
func ReadFileHeader(r io.Reader) (*FileHeader, error)
ReadFileHeader reads from r and returns a deserialized FileHeader
type FileInfo ¶
type FileInfo struct { NameVar string SizeVar int64 ModeVar os.FileMode ModTimeVar int64 // Serialization of time.Time breaks in travis, so use an int IsDirVar bool }
FileInfo is the stat struct returned by the remotefs system. It fulfills the os.FileInfo interface.
type Func ¶
Func is the function definition for a generic remote fs function The input to the function is any serialized structs / data from in and the string slice from args. The output of the function will be serialized and written to out.
type SeekHeader ¶ added in v0.3.3
SeekHeader is header for the Seek operation for remotefs.OpenFile