mirror of https://gitlab.com/nakst/essence
update posix subsystem to use systemData; introduce build-port command
This commit is contained in:
parent
a9401068d7
commit
128022faa4
|
@ -114,13 +114,6 @@ struct EsBundle {
|
|||
ptrdiff_t bytes;
|
||||
};
|
||||
|
||||
struct SystemStartupDataHeader {
|
||||
// TODO Make mount points and devices equal, somehow?
|
||||
size_t initialMountPointCount;
|
||||
size_t initialDeviceCount;
|
||||
EsHandle themeCursorData;
|
||||
};
|
||||
|
||||
const EsBundle bundleDefault = {
|
||||
.base = (const BundleHeader *) BUNDLE_FILE_MAP_ADDRESS,
|
||||
.bytes = -1,
|
||||
|
|
|
@ -337,6 +337,13 @@ struct GlobalData {
|
|||
volatile uint16_t keyboardLayout;
|
||||
};
|
||||
|
||||
struct SystemStartupDataHeader {
|
||||
// TODO Make mount points and devices equal, somehow?
|
||||
size_t initialMountPointCount;
|
||||
size_t initialDeviceCount;
|
||||
uintptr_t themeCursorData;
|
||||
};
|
||||
|
||||
#ifdef KERNEL
|
||||
#define K_BOOT_DRIVE ""
|
||||
#else
|
||||
|
|
|
@ -506,15 +506,22 @@ namespace POSIX {
|
|||
EsMemoryCopy(path, (void *) syscall.arguments[0], syscall.arguments[1]);
|
||||
|
||||
Process *process = currentThread->posixData->forkProcess;
|
||||
process->data.environment = ConstantBufferCreate((void *) syscall.arguments[2], syscall.arguments[3], process);
|
||||
process->data.subsystemID = ES_SUBSYSTEM_ID_POSIX;
|
||||
process->data.subsystemData = ConstantBufferCreate((void *) syscall.arguments[2], syscall.arguments[3], process);
|
||||
process->posixForking = true;
|
||||
process->permissions = currentProcess->permissions;
|
||||
|
||||
EsMountPoint mountPoint = {};
|
||||
struct {
|
||||
SystemStartupDataHeader header;
|
||||
EsMountPoint mountPoint;
|
||||
} systemData;
|
||||
|
||||
EsMemoryZero(&systemData, sizeof(systemData));
|
||||
OpenHandleToObject((void *) syscall.arguments[4], KERNEL_OBJECT_NODE, _ES_NODE_DIRECTORY_WRITE);
|
||||
mountPoint.base = process->handleTable.OpenHandle((void *) syscall.arguments[4], _ES_NODE_DIRECTORY_WRITE, KERNEL_OBJECT_NODE);
|
||||
mountPoint.prefixBytes = EsStringFormat(mountPoint.prefix, sizeof(mountPoint.prefix), "|POSIX:");
|
||||
process->data.initialMountPoints = ConstantBufferCreate(&mountPoint, sizeof(EsMountPoint), process);
|
||||
systemData.mountPoint.base = process->handleTable.OpenHandle((void *) syscall.arguments[4], _ES_NODE_DIRECTORY_WRITE, KERNEL_OBJECT_NODE);
|
||||
systemData.mountPoint.prefixBytes = EsStringFormat(systemData.mountPoint.prefix, sizeof(systemData.mountPoint.prefix), "|POSIX:");
|
||||
systemData.header.initialMountPointCount = 1;
|
||||
process->data.systemData = ConstantBufferCreate(&systemData, sizeof(systemData), process);
|
||||
|
||||
// Start the process.
|
||||
|
||||
|
@ -547,8 +554,6 @@ namespace POSIX {
|
|||
currentThread->posixData->forkStack = nullptr;
|
||||
currentThread->posixData->forkUSP = 0;
|
||||
|
||||
if (!process) return -ENOMEM;
|
||||
|
||||
return currentProcess->handleTable.OpenHandle(process, 0, KERNEL_OBJECT_PROCESS);
|
||||
} break;
|
||||
|
||||
|
|
32
util/build.c
32
util/build.c
|
@ -1432,6 +1432,38 @@ void DoCommand(const char *l) {
|
|||
printf(ColorNormal);
|
||||
} else if (0 == memcmp(l, "a2l ", 4)) {
|
||||
AddressToLine(l + 3);
|
||||
} else if (0 == strcmp(l, "build-port")) {
|
||||
printf("\nAvailable ports:\n");
|
||||
DIR *directory = opendir("ports");
|
||||
struct dirent *entry;
|
||||
|
||||
while ((entry = readdir(directory))) {
|
||||
char buffer[4096];
|
||||
snprintf(buffer, sizeof(buffer), "ports/%s/port.sh", entry->d_name);
|
||||
FILE *f = fopen(buffer, "rb");
|
||||
|
||||
if (f) {
|
||||
printf("\t%s\n", entry->d_name);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
closedir(directory);
|
||||
|
||||
LoadOptions();
|
||||
|
||||
if (!IsOptionEnabled("Flag.ENABLE_POSIX_SUBSYSTEM")) {
|
||||
printf("\nMost ports require the POSIX subsystem to be enabled.\n");
|
||||
printf("Run " ColorHighlight "config" ColorNormal " and select " ColorHighlight "Flag.ENABLE_POSIX_SUBSYSTEM" ColorNormal " to enable it.\n");
|
||||
}
|
||||
|
||||
printf("\nEnter the port to be built: ");
|
||||
char *l2 = NULL;
|
||||
size_t pos;
|
||||
getline(&l2, &pos, stdin);
|
||||
l2[strlen(l2) - 1] = 0;
|
||||
CallSystemF("ports/%s/port.sh", l2);
|
||||
free(l2);
|
||||
} else if (0 == memcmp(l, "get-source ", 11)) {
|
||||
if (CallSystem("mkdir -p bin/cache && rm -rf bin/source")) {
|
||||
exit(1);
|
||||
|
|
Loading…
Reference in New Issue