Reading and writing to files in DROPS

Adam Lackorzynski adam at os.inf.tu-dresden.de
Thu May 19 13:31:51 CEST 2005


On Wed May 18, 2005 at 18:00:49 +0200, Rene Wittmann wrote:
> I'm still trying to write to a file in DROPS. What is the best way to do
> so?
> 
> When trying to use the OSKIT support (at least I think that I use it...)
> it doesn't work, maybe I'm thinking too straightforward, but my code
> looks simply this way:
> 
> ---------------------------------------------------------------------
> #include <stdio.h>
> 
> char LOG_tag[9]="tso_test";
> 
> int main(int argc, const char**argv){
> 	FILE *handle;
> 	int i;
> 	handle = fopen("/tmp/check","w+");
> 	printf("before fileprinting\n");
> 	fprintf(handle,"Just a writing to file test.");
> 	printf("after fileprinting\n");
> 	fclose(handle);
> 	printf("after closing\n");
> 	return 0;
> }
> --------------------------------------------------------------------
> 
> My Makefile (compiling without error or warning):
> --------------------------------------------------------------------
> PKGDIR  ?= ../..
> L4DIR   ?= $(PKGDIR)/../..
> TARGET  = tso_test
> 
> DEFAULT_RELOC   = 0x02000000
> MODE    = l4env
> SRC_C   = tso_test.c
> LOGTAG  = $(addprefix ",$(addsuffix ",$(TARGET)))
> 
> include $(L4DIR)/mk/prog.mk   
> --------------------------------------------------------------------
> 
> Finally my config:
> --------------------------------------------------------------------
> title vmware tso_test
> root (hd0,1)
> kernel /drops/drops/bin/x86_586/l4v2/rmgr -sigma0
> module /drops/l4/kernel/fiasco/build/main -nokdb -nowait -serial -serial_esc
> module /drops/drops/bin/x86_586/l4v2/sigma0
> modaddr 0x02000000
> module /drops/drops/bin/x86_586/l4v2/names
> module /drops/drops/bin/x86_586/l4v2/log
> module /drops/drops/bin/x86_586/l4v2/dm_phys
> module /drops/drops/bin/x86_586/l4v2/simple_ts
> module /drops/drops/bin/x86_586/l4v2/tso_test
> --------------------------------------------------------------------
> 
> But the error message:
> --------------------------------------------------------------------
> names   | Fiasco detected, registering thread names at kernel
> tso_test| OSKit support: using 4096KB at 0x00180000 as heap
> tso_test| fs_init: WARNING: No Filesystem
> tso_test| before fileprinting
> tso_test| Just a writing to file test.after fileprinting
> tso_test| L4RM: [PF] read at 0x000000c, eip 0200e54b, src 9.02
> tso_test| [9.0] l4rm/lib/src/pagefault.c:78:__unknown_pf():
> tso_test|  unhandled page fault
>   
>   --PANIC--------------------------------------------------EIP:02004403
> (9.00) jdb:
> --------------------------------------------------------------------
> 
> Of course, I can see that fs_init says about "No Filesystem". Is it
> because I'm using reiserfs? Would it work with ext2?
> 
> Or is there a better way writing to a file in DROPS? Maybe some
> L4-specific functions?

You're missing quite a bit of functionality to make writing to a file
actually work. To write some data to a file you'll need at least a block
driver for your storage device (e.g. IDE driver) and a filesystem that
brings some order into the many blocks of your block device. Those
components are somehow missing from your module list. ;)

I suggest looking into the l4vfs package, it has some of the needed
infrastructure for filesystems etc.




Adam
-- 
Adam                 adam at os.inf.tu-dresden.de
  Lackorzynski         http://os.inf.tu-dresden.de/~adam/




More information about the l4-hackers mailing list