mirror of
https://github.com/drasko/codezero.git
synced 2026-02-10 17:03:26 +01:00
In FS0 filesystem image buffer was smaller than the memfs-defined maximum.
- Now fs size is in sync with memfs max size.
This commit is contained in:
@@ -20,55 +20,6 @@
|
||||
#include <exit.h>
|
||||
#include <lib/elf/elf.h>
|
||||
|
||||
/*
|
||||
* Different from vfs_open(), which validates an already opened
|
||||
* file descriptor, this call opens a new vfs file by the pager
|
||||
* using the given path. The vnum handle and file length is returned
|
||||
* since the pager uses this information to access file pages.
|
||||
*/
|
||||
int vfs_open_bypath(const char *pathname, unsigned long *vnum, unsigned long *length)
|
||||
{
|
||||
int err = 0;
|
||||
struct tcb *vfs;
|
||||
|
||||
// printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
|
||||
|
||||
if (!(vfs = find_task(VFS_TID)))
|
||||
return -ESRCH;
|
||||
|
||||
/*
|
||||
* Copy string to vfs shared page.
|
||||
*
|
||||
* FIXME: There's a chance we're overwriting other tasks'
|
||||
* ipc information that is on the vfs shared page.
|
||||
*/
|
||||
strcpy(vfs->shared_page, pathname);
|
||||
|
||||
l4_save_ipcregs();
|
||||
|
||||
write_mr(L4SYS_ARG0, (unsigned long)vfs->shared_page);
|
||||
|
||||
if ((err = l4_sendrecv(VFS_TID, VFS_TID,
|
||||
L4_IPC_TAG_PAGER_OPEN_BYPATH)) < 0) {
|
||||
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Check if syscall was successful */
|
||||
if ((err = l4_get_retval()) < 0) {
|
||||
printf("%s: VFS open error: %d.\n",
|
||||
__FUNCTION__, err);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Read file information */
|
||||
*vnum = read_mr(L4SYS_ARG0);
|
||||
*length = read_mr(L4SYS_ARG1);
|
||||
|
||||
out:
|
||||
l4_restore_ipcregs();
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Probes and parses the low-level executable file format and creates a
|
||||
|
||||
@@ -84,6 +84,55 @@ out:
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Different from vfs_open(), which validates an already opened
|
||||
* file descriptor, this call opens a new vfs file by the pager
|
||||
* using the given path. The vnum handle and file length is returned
|
||||
* since the pager uses this information to access file pages.
|
||||
*/
|
||||
int vfs_open_bypath(const char *pathname, unsigned long *vnum, unsigned long *length)
|
||||
{
|
||||
int err = 0;
|
||||
struct tcb *vfs;
|
||||
|
||||
// printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
|
||||
|
||||
if (!(vfs = find_task(VFS_TID)))
|
||||
return -ESRCH;
|
||||
|
||||
/*
|
||||
* Copy string to vfs shared page.
|
||||
*
|
||||
* FIXME: There's a chance we're overwriting other tasks'
|
||||
* ipc information that is on the vfs shared page.
|
||||
*/
|
||||
strcpy(vfs->shared_page + 0x200, pathname);
|
||||
|
||||
l4_save_ipcregs();
|
||||
|
||||
write_mr(L4SYS_ARG0, (unsigned long)vfs->shared_page + 0x200);
|
||||
|
||||
if ((err = l4_sendrecv(VFS_TID, VFS_TID,
|
||||
L4_IPC_TAG_PAGER_OPEN_BYPATH)) < 0) {
|
||||
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Check if syscall was successful */
|
||||
if ((err = l4_get_retval()) < 0) {
|
||||
printf("%s: VFS open error: %d.\n",
|
||||
__FUNCTION__, err);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Read file information */
|
||||
*vnum = read_mr(L4SYS_ARG0);
|
||||
*length = read_mr(L4SYS_ARG1);
|
||||
|
||||
out:
|
||||
l4_restore_ipcregs();
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* When a task does a read/write/mmap request on a file, if
|
||||
@@ -95,8 +144,6 @@ int vfs_open(l4id_t opener, int fd, unsigned long *vnum, unsigned long *length)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
// printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
|
||||
|
||||
l4_save_ipcregs();
|
||||
|
||||
write_mr(L4SYS_ARG0, opener);
|
||||
|
||||
@@ -97,11 +97,12 @@ int elf_mark_segments(struct elf_section_header *sect_header, int nsections,
|
||||
"bss segment in ELF file.\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/* Data and text are less than page apart */
|
||||
if ((task->data_start - task->text_start) < PAGE_SIZE) {
|
||||
/* Data and text are less than page apart and unaligned */
|
||||
if ((task->data_start - task->text_end) < PAGE_SIZE &&
|
||||
!is_page_aligned(task->text_end)) {
|
||||
printf("%s: Error: Distance between data and text"
|
||||
" sections are less than page size (4K)\n",
|
||||
__FUNCTION__);
|
||||
" sections are less than page size (%d bytes)\n",
|
||||
__FUNCTION__, PAGE_SIZE);
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user