More progress on parsing elf files. Fixes to memfs file read/write

Increased inode block pointers to 40. The current maximum allowed (and checked).
Updates to file size after every file write ensures subsequent writes can
correctly operate using updated file size information (i.e. not try to add
more pages that are already present). We cannot do this inside write() because
directory writes rely on byte-granularity updates on file buffers, whereas
file updates are by page-granularity (currently).
This commit is contained in:
Bahadir Balban
2008-11-21 19:26:10 +02:00
parent 27d331895b
commit 2d5a08ff32
15 changed files with 187 additions and 30 deletions

View File

@@ -6,9 +6,45 @@
#include <unistd.h>
#include <sys/types.h>
#include <tests.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
void exectest(void)
extern char _start_test1[];
extern char _end_test1[];
int exectest(void)
{
execve("/usr/home/bahadir/executable", 0, 0);
int fd;
void *exec_start = (void *)_start_test1;
unsigned long size = _end_test1 - _start_test1;
int left, cnt;
/* First create a new file and write the executable data to that file */
printf("%s: Creating new executable file.\n", __FUNCTION__);
if ((fd = open("/home/bahadir/test1.axf", O_RDWR | O_CREAT | O_TRUNC, S_IRWXU)) < 0) {
perror("OPEN");
return -1;
}
printf("%s: Writing to the executable file.\n", __FUNCTION__);
left = size;
while (left != 0) {
cnt = write(fd, exec_start, left);
if (cnt < 0) {
printf("Error writing to file.\n");
return -1;
}
left -= cnt;
}
close(fd);
printf("%s: Executing the file.\n", __FUNCTION__);
/* Execute the file */
execve("/home/bahadir/test1.axf", 0, 0);
return 0;
}