Documentation ¶
Overview ¶
Package proto describes ps3netsrv protocol used by WebMAN MOD to interact with remote filesystem using network. Protocol is request-response. Any request starts from OpCode, and it's size always 16 bytes including it. For some messages Command can be followed by arbitrary data which length encoded in Command.Data.
Index ¶
- Constants
- type Command
- type CreateFileCommand
- type CreateFileResult
- type DeleteFileCommand
- type DeleteFileResult
- type DirEntry
- type GetDirSizeCommand
- type GetDirSizeResult
- type LenReader
- type MkdirCommand
- type MkdirResult
- type OpCode
- type OpenDirCommand
- type OpenDirResult
- type OpenFileCommand
- type OpenFileResult
- type ReadDirEntryCommand
- type ReadDirEntryResult
- type ReadDirResult
- type ReadFileCommand
- type ReadFileCriticalCommand
- type ReadFileResult
- type Reader
- func (r *Reader) ReadCommand() (OpCode, error)
- func (r *Reader) ReadCreateFile() (string, error)
- func (r *Reader) ReadDeleteFile() (string, error)
- func (r *Reader) ReadGetDirSize() (string, error)
- func (r *Reader) ReadMkdir() (string, error)
- func (r *Reader) ReadOpenDir() (string, error)
- func (r *Reader) ReadOpenFile() (string, error)
- func (r *Reader) ReadReadFile() (bytesToRead uint32, offset uint64, err error)
- func (r *Reader) ReadReadFileCritical() (bytesToRead uint32, offset uint64, err error)
- func (r *Reader) ReadRmdir() (string, error)
- func (r *Reader) ReadStatFile() (string, error)
- func (r *Reader) ReadWriteFile() (io.Reader, error)
- type RmdirCommand
- type RmdirResult
- type StatFileCommand
- type StatFileResult
- type WriteFileCommand
- type WriteFileResult
- type Writer
- func (w *Writer) SendCreateFileError() error
- func (w *Writer) SendCreateFileResult() error
- func (w *Writer) SendDeleteFileError() error
- func (w *Writer) SendDeleteFileResult() error
- func (w *Writer) SendGetDirectorySizeError() error
- func (w *Writer) SendGetDirectorySizeResult(size int64) error
- func (w *Writer) SendMkdirError() error
- func (w *Writer) SendMkdirResult() error
- func (w *Writer) SendOpenDirResult(success bool) error
- func (w *Writer) SendOpenFileError() error
- func (w *Writer) SendOpenFileForCLOSEFILE() error
- func (w *Writer) SendOpenFileResult(f afero.File) error
- func (w *Writer) SendReadDirEntryResult(entry os.FileInfo) error
- func (w *Writer) SendReadDirResult(entries []os.FileInfo) error
- func (w *Writer) SendReadFileCriticalResult(data io.Reader) error
- func (w *Writer) SendReadFileResult(data LenReader) error
- func (w *Writer) SendRmdirError() error
- func (w *Writer) SendRmdirResult() error
- func (w *Writer) SendStatFileError() error
- func (w *Writer) SendStatFileResult(entry os.FileInfo) error
- func (w *Writer) SendWriteFileError() error
- func (w *Writer) SendWriteFileResult(written int32) error
Constants ¶
const MaxDirEntryName = 512
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateFileCommand ¶ added in v0.0.4
type CreateFileCommand struct { // FpLen is a length of path to read further. FpLen uint16 }
CreateFileCommand contains data for CmdCreateFile.
type CreateFileResult ¶ added in v0.0.4
type CreateFileResult struct { // Result shows if creating file was successful (0) or not (-1). Result int32 }
CreateFileResult is a response for CmdCreateFile.
type DeleteFileCommand ¶ added in v0.0.4
type DeleteFileCommand struct { // FpLen is a length of path to read further. Path is absolute here. FpLen uint16 }
DeleteFileCommand contains data for CmdDeleteFile.
type DeleteFileResult ¶ added in v0.0.4
type DeleteFileResult struct { // Result shows if creating file was successful (0) or not (-1). Result int32 }
DeleteFileResult is a response for CmdCreateFile.
type DirEntry ¶
type DirEntry struct { FileSize int64 ModTime uint64 IsDirectory bool Name [MaxDirEntryName]byte }
DirEntry represents a single directory entry.
type GetDirSizeCommand ¶ added in v0.0.4
type GetDirSizeCommand struct { // DpLen is a length of path to read further. Path is absolute here. DpLen uint16 }
GetDirSizeCommand contains data for CmdGetDirSize.
type GetDirSizeResult ¶ added in v0.0.4
type GetDirSizeResult struct { // Size contains total directory size or -1 on error. Size int64 }
GetDirSizeResult is a result of CmdGetDirSize with file info.
type MkdirCommand ¶ added in v0.0.4
type MkdirCommand struct { // DpLen is a length of path to read further. Path is absolute here. DpLen uint16 }
MkdirCommand contains data for CmdMkdir.
type MkdirResult ¶ added in v0.0.4
type MkdirResult struct { // Result shows if creating directory was successful (0) or not (-1). Result int32 }
MkdirResult is a result of CmdMkdir with file info.
type OpCode ¶
type OpCode uint16
OpCode is an operation code which read firstly.
const ( // CmdOpenFile requests to close the active ro file (if any) and open/stat a new one. CmdOpenFile OpCode = 0x1224 + iota // CmdReadFileCritical the active ro file. // Offsets and sizes in bytes. If file read fails, client is exited. Only read data is returned. CmdReadFileCritical // CmdReadCD2048Critical reads 2048 sectors in 2352 sectors iso. // Offsets and sizes in sectors. If file read fails, client is exited. CmdReadCD2048Critical // CmdReadFile closes the active wo file (if any) and opens+truncates or creates a new one. CmdReadFile // CmdCreateFile Closes the active wo file (if any) and opens+truncates or creates a new one. CmdCreateFile // CmdWriteFile writes to the active wo file. // After command, data is sent it returns number of bytes written to client, -1 on error. CmdWriteFile // CmdOpenDir Closes the active directory (if any) and opens a new one. CmdOpenDir // CmdReadDirEntry reads a directory entry and returns result. // If no more entries or an error happens, the directory is automatically closed. // '.' and '..' are automatically ignored. CmdReadDirEntry // CmdDeleteFile deletes a file. CmdDeleteFile // CmdMkdir creates a directory. CmdMkdir // CmdRmdir removes a directory. CmdRmdir // CmdReadDirEntryV2 Reads a directory entry (v2) and returns result. // If no more entries or an error happens, the directory is automatically closed. CmdReadDirEntryV2 // CmdStatFile stats a file or directory. CmdStatFile // CmdGetDirSize gets a directory size. CmdGetDirSize // CmdReadDir get complete directory contents - 2013 by deank. CmdReadDir // CmdCustom0 reserved for custom commands. CmdCustom0 OpCode = 0x2412 )
type OpenDirCommand ¶
type OpenDirCommand struct { // DpLen is a length of path to read further. DpLen uint16 }
OpenDirCommand contains data for CmdOpenDir.
type OpenDirResult ¶
type OpenDirResult struct { // Result shows if reading dir was successful (0) or not (-1). Result int32 }
OpenDirResult is a response for CmdOpenDir.
type OpenFileCommand ¶
type OpenFileCommand struct { // FpLen is a length of path to read further. Path is absolute here. FpLen uint16 }
OpenFileCommand contains data for CmdOpenFile.
type OpenFileResult ¶
type OpenFileResult struct { // FileSize contains file size or -1 for error. FileSize int64 ModTime uint64 }
OpenFileResult is a result of CmdOpenFile with file info.
type ReadDirEntryCommand ¶
type ReadDirEntryCommand struct { }
ReadDirEntryCommand contains data for CmdReadDir, CmdReadDirEntry.
type ReadDirEntryResult ¶ added in v0.0.2
ReadDirEntryResult used by CmdReadDirEntry. Instead of using a fixed-size buffer for Name as in DirEntry, this struct contains FilenameLen so the receiver knows how many bytes to read for the name.
type ReadDirResult ¶
type ReadDirResult struct { // Size is a count of following DirEntry items. Size int64 }
ReadDirResult is a response for CmdReadDir.
type ReadFileCommand ¶
type ReadFileCommand struct { // BytesToRead is a limit to read. BytesToRead uint32 // Offset is offset from origin of the file (io.SeekStart). Offset uint64 // contains filtered or unexported fields }
ReadFileCommand contains data for CmdReadFile.
type ReadFileCriticalCommand ¶
type ReadFileCriticalCommand ReadFileCommand
ReadFileCriticalCommand contains data for CmdReadFileCritical.
type ReadFileResult ¶
type ReadFileResult struct { // BytesRead is a number of bytes we read from file. Followed by read bytes if greater than zero. BytesRead int32 }
ReadFileResult is a result of CmdReadFile.
type Reader ¶
func (*Reader) ReadCommand ¶
ReadCommand reads a request command.
func (*Reader) ReadCreateFile ¶ added in v0.0.4
func (*Reader) ReadDeleteFile ¶ added in v0.0.4
func (*Reader) ReadGetDirSize ¶ added in v0.0.4
func (*Reader) ReadOpenDir ¶
ReadOpenDir used for CmdOpenDir.
func (*Reader) ReadOpenFile ¶
func (*Reader) ReadReadFile ¶
func (*Reader) ReadReadFileCritical ¶
func (*Reader) ReadStatFile ¶
type RmdirCommand ¶ added in v0.0.4
type RmdirCommand struct { // DpLen is a length of path to read further. Path is absolute here. DpLen uint16 }
RmdirCommand contains data for CmdRmdir.
type RmdirResult ¶ added in v0.0.4
type RmdirResult struct { // Result shows if removing directory was successful (0) or not (-1). Result int32 }
RmdirResult is a result of CmdRmdir with file info.
type StatFileCommand ¶
type StatFileCommand struct { // FpLen is a length of path to read further. Path is absolute here. FpLen uint16 }
StatFileCommand contains data for CmdStatFile.
type StatFileResult ¶
type StatFileResult struct { // FileSize contains file size for files, 0 for directories and -1 for error. FileSize int64 ModTime uint64 AccessTime uint64 ChangeTime uint64 IsDirectory bool }
StatFileResult is a result of CmdStatFile with file info.
type WriteFileCommand ¶ added in v0.0.4
type WriteFileCommand struct { // BytesToWrite is a number of bytes to write. BytesToWrite uint32 // contains filtered or unexported fields }
WriteFileCommand contains data for CmdWriteFile.
type WriteFileResult ¶ added in v0.0.4
type WriteFileResult struct { // BytesWritten contains number of written bytes or -1 on error. BytesWritten int32 }
WriteFileResult is a response for CmdWriteFile.