2 * (c) 2008-2009 Technische Universität Dresden
3 * This file is part of TUD:OS and distributed under the terms of the
4 * GNU General Public License 2.
5 * Please see the COPYING-GPL-2 file for details.
9 #include <l4/ocaml/ext2.h>
11 int main(int argc, char** argv)
14 fprintf (stderr,"usage: ext2_example <disk_image_name> <path_to_file>\n");
18 if (!open_disk_image (argv[1])) {
19 fprintf (stderr,"open_disk_image '%s' failed\n",argv[1]);
23 int fd = open_file (argv[2]);
25 fprintf (stderr,"open_file '%s' failed\n",argv[2]);
29 char* buffer = (char*)malloc(2<<12);
31 fprintf (stderr,"malloc(4k) failed\n");
35 if (!read_block (fd, 0, buffer)) {
36 fprintf (stderr,"read_block failed\n");
40 printf ("dumping file '%s'\n",argv[2]);
43 for (int i=0; i<64; i++) {
45 printf ("0x%04x : ",i);
47 printf ("%02x ",buffer[i]);
55 printf ("opening dir /\n");
57 unsigned dir = opendir("/");
60 fprintf (stderr,"opendir / failed\n");
70 printf (" '%s'\n",filename(dir));
71 } while (dir = readdir (dir));