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:
Bahadir Balban
2009-05-13 16:09:20 +03:00
parent 680d20ff94
commit 2c01463482
11 changed files with 68 additions and 64 deletions

View File

@@ -39,7 +39,7 @@
* These fixed filesystem limits make it much easier to implement
* filesystem space allocation.
*/
#define MEMFS_TOTAL_SIZE SZ_8MB
#define MEMFS_TOTAL_SIZE SZ_4MB
#define MEMFS_TOTAL_INODES 128
#define MEMFS_TOTAL_BLOCKS 2000
#define MEMFS_FMAX_BLOCKS 40

View File

@@ -2,11 +2,12 @@
* This is just to allocate some memory as a block device.
*/
#include <l4/macros.h>
#include <memfs/memfs.h>
extern char _start_bdev[];
extern char _end_bdev[];
__attribute__((section(".data.memfs"))) char blockdevice[SZ_1MB*2];
__attribute__((section(".data.memfs"))) char blockdevice[MEMFS_TOTAL_SIZE];
void *vfs_rootdev_open(void)
{

View File

@@ -411,7 +411,6 @@ int memfs_vnode_filldir(void *userbuf, struct vnode *v, int count)
return 0;
}
struct vnode_ops memfs_vnode_operations = {
.readdir = memfs_vnode_readdir,
.filldir = memfs_vnode_filldir,

View File

@@ -36,8 +36,7 @@ int pager_sys_open(struct tcb *pager, l4id_t opener, int fd)
struct tcb *task;
struct vnode *v;
// printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
//
//printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
if (pager->tid != PAGER_TID)
return -EINVAL;
@@ -76,8 +75,6 @@ int pager_open_bypath(struct tcb *pager, char *pathname)
if (pager->tid != PAGER_TID)
return -EINVAL;
// printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
/* Parse path data */
if (IS_ERR(pdata = pathdata_parse(pathname,
alloca(strlen(pathname) + 1),

View File

@@ -17,6 +17,8 @@ int sys_close(struct tcb *sender, int fd);
int sys_fsync(struct tcb *sender, int fd);
int file_open(struct tcb *opener, int fd);
int vfs_open_bypath(const char *pathname, unsigned long *vnum, unsigned long *length);
struct vm_file *do_open2(struct tcb *task, int fd, unsigned long vnum, unsigned long length);
int flush_file_pages(struct vm_file *f);
int read_file_pages(struct vm_file *vmfile, unsigned long pfn_start,

View File

@@ -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

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -47,7 +47,7 @@ void main(void)
clonetest();
// exectest();
exectest();
while (1)
wait_pager(0);

View File

@@ -21,14 +21,19 @@ int exectest(void)
unsigned long size = _end_test1 - _start_test1;
int left, cnt;
char *argv[5];
char filename[128];
memset(filename, 0, 128);
sprintf(filename, "/home/bahadir/execfile%d.txt", getpid());
/* First create a new file and write the executable data to that file */
if ((fd = open("/home/bahadir/test1.axf", O_RDWR | O_CREAT | O_TRUNC, S_IRWXU)) < 0) {
if ((fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, S_IRWXU)) < 0) {
test_printf("OPEN: %d\n", errno);
goto out_err;
}
left = size;
printf("Writing %d bytes to %s\n", left, filename);
while (left != 0) {
if ((cnt = write(fd, exec_start, left)) < 0)
goto out_err;