Go to the documentation of this file.
18 #include <FreeNOS/System.h>
48 ERROR(
"failed to retrieve ProcessInfo for PID " << msg->
pid <<
49 ": result = " << (
int)result);
60 ERROR(
"failed to stop PID " << msg->
pid <<
61 ": result = " << (
int) result);
74 ERROR(
"failed to read command string from PID " << msg->
pid <<
75 ": result = " << (
int) result);
79 cmd[
sizeof(cmd) - 1] = 0;
83 if (progpath.count() == 0)
85 ERROR(
"failed to find program path for PID " << msg->
pid);
93 ERROR(
"failed to reload PID " << msg->
pid <<
94 " from " << *progpath[0] <<
95 ": result = " << (
int) result);
104 ERROR(
"failed to resume PID " << msg->
pid <<
105 ": result = " << (
int) result);
115 const char *path)
const
121 DEBUG(
"pid = " << pid <<
" path = " << path);
127 ERROR(
"failed to statFile() for " << path <<
": result = " << (
int) statResult);
142 ERROR(
"failed to map compressed memory: result = " << (
int) mapResult);
150 ERROR(
"failed to openFile() for " << path <<
151 ": result = " << (
int) openResult);
161 ERROR(
"failed to readFile() for " << path <<
162 ": result = " << (
int) readResult <<
", num = " << num);
171 ERROR(
"failed to closeFile() for " << path <<
172 ": result = " << (
int) closeResult);
182 ERROR(
"failed to initialize LZ4 decompressor: result = " << (
int) lz4Result);
198 ERROR(
"failed to map uncompressed memory: result = " << (
int) mapResult);
207 ERROR(
"failed to decompress file: result = " << (
int) lz4Result);
216 ERROR(
"failed to cleanup program data for PID " << pid);
225 ERROR(
"failed to reset data for PID " << pid);
235 DEBUG(
"failed to release compressed memory: result = " << (
int) releaseResult);
243 DEBUG(
"failed to release uncompressed memory: result = " << (
int) releaseResult);
256 DEBUG(
"pid = " << pid);
262 ERROR(
"failed to release UserData region in PID " << pid <<
263 ": result = " << (
int) dataResult);
271 ERROR(
"failed to release UserHeap region in PID " << pid <<
272 ": result = " << (
int) heapResult);
280 ERROR(
"failed to release UserPrivate region in PID " << pid <<
281 ": result = " << (
int) privResult);
290 const Size size)
const
296 Size numRegions = 16;
299 DEBUG(
"pid = " << pid <<
" program = " << (
void *) program <<
" size = " << size);
307 ERROR(
"failed to parse executable: result = " << (
int) execResult);
315 ERROR(
"failed to retrieve entry point: result = " << (
int) entryResult);
324 ERROR(
"failed to retrieve regions: result = " << (
int) regionResult);
333 for (
Size i = 0; i < numRegions; i++)
345 ERROR(
"failed to map " << (
void *) regions[i].virt <<
346 " in PID " << pid <<
": result = " << (
int) mapResult);
355 ERROR(
"failed to map " << (
void *) regions[i].virt <<
356 ": result = " << (
int) selfResult);
365 if (regions[i].memorySize > regions[i].dataSize)
375 ERROR(
"failed to unmap " << (
void *) regions[i].virt <<
376 ": result = " << (
int) unmapResult);
385 ERROR(
"failed to reset PID " << pid <<
386 ": result = " << (
int) resetResult);
bool reloadProgram(const ProcessID pid, const char *path) const
Overwrite the given process by fetching a fresh program data copy.
static Size copy(void *dest, const void *src, Size count)
Copy memory from one place to another.
Process information structure, used for Info.
Result
Enumeration of generic kernel API result codes.
static void * set(void *dest, int ch, unsigned count)
Fill memory with a constant byte.
FileSystem::Result statFile(const char *path, FileSystem::FileStat *st) const
Retrieve status of a file.
void restartProcess(RecoveryMessage *msg)
Restart a process.
u64 getUncompressedSize() const
Get size of the uncompressed data.
FileSystemClient provides a simple interface to a FileSystemServer.
Result initialize()
Initialize the decompressor.
u32 ProcessID
Process Identification Number.
unsigned long Address
A memory address.
API::Result VMCtl(const ProcessID procID, const MemoryOperation op, Memory::Range *range=ZERO)
Prototype for user applications.
@ UserData
< User program data from libexec, e.g.
API::Result ProcessCtl(const ProcessID proc, const ProcessOperation op, const Address addr=0, const Address output=0)
Prototype for user applications.
List< String > split(const char delimiter) const
Split the String into parts separated by a delimiter.
Memory mapping for the kernel and user processes on the ARM architecture.
Size size
< File access permission bits.
#define DEBUG(msg)
Output a debug message to standard output.
Address phys
Physical address.
FileSystem::Result closeFile(const Size descriptor) const
Close a file.
FileSystem::Result openFile(const char *path, Size &descriptor) const
Open a file.
#define MAX_PROCS
Maximum number of processes.
Memory::Range range(Region region) const
Get memory range for the given region.
RecoveryServer()
Class constructor function.
unsigned int Size
Any sane size indicator cannot go negative.
@ UserPrivate
< User private dynamic memory mappings
ProcessID pid
Process identifier of target process.
FileSystem::Result readFile(const Size descriptor, void *buf, Size *size) const
Read a file.
Template class which serves incoming messages from Channels using MessageHandlers.
bool rewriteProgram(const ProcessID pid, const Address program, const Size size) const
Overwrite process with given program data.
Result read(void *buffer, const Size size) const
Reads compressed data.
Contains file information.
#define ERROR(msg)
Output an error message.
Recovery::Result result
Result of action.
Result
Result code for filesystem Actions.
unsigned char u8
Unsigned 8-bit number.
Decompress data using the LZ4 algorithm created by Yann Collet.
void addIPCHandler(const Size slot, IPCHandlerFunction h, const bool sendReply=true)
Register a new IPC message action handler.
bool cleanupProgram(const ProcessID pid) const
Release and unmap program data.
Address virt
Virtual address.
@ UserArgs
< Used for copying program arguments and file descriptors
API::Result VMCopy(const ProcessID proc, const API::Operation how, const Address ours, const Address theirs, const Size sz)
Prototype for user applications.
Size size
Size in number of bytes.
Access access
Page access flags.