Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1085 | pj | 1 | /* |
2 | * |
||
3 | * |
||
4 | * |
||
5 | */ |
||
6 | |||
7 | #include <kernel/func.h> |
||
8 | |||
9 | #include <fs/bdevinit.h> |
||
10 | #include <fs/fsinit.h> |
||
11 | #include <fs/bdev.h> |
||
12 | |||
13 | #include <drivers/keyb.h> |
||
14 | |||
15 | #include <sys/mount.h> |
||
16 | |||
17 | #include <fcntl.h> |
||
18 | #include <unistd.h> |
||
19 | #include <errno.h> |
||
20 | #include <string.h> |
||
21 | |||
22 | #include "common.h" |
||
23 | |||
24 | //#define FILENAME "/temp/ALFA1.TXT" |
||
25 | |||
26 | #define FILENAME "/pippo.c" |
||
27 | |||
28 | int leggi(int h) |
||
29 | { |
||
30 | char buffer[124]; |
||
31 | int len; |
||
32 | |||
33 | memset(buffer,'\0',sizeof(buffer)); |
||
34 | cprintf("READING...\n"); |
||
35 | len=read(h,buffer,sizeof(buffer)-1); |
||
36 | cprintf("READ %i bytes\n",len); |
||
37 | cprintf("buffer='%s'\n",buffer); |
||
38 | |||
39 | return len; |
||
40 | } |
||
41 | |||
42 | int main(int argc,char *argv[]) |
||
43 | { |
||
44 | int h; |
||
45 | |||
46 | showmessage("Try lseek() using a file for reading."); |
||
47 | |||
48 | cprintf("OPENING %s\n",FILENAME); |
||
49 | h=open(FILENAME,O_RDONLY); |
||
50 | |||
51 | if (h>=0) { |
||
52 | cprintf("OPENED!\n"); |
||
53 | |||
54 | leggi(h); |
||
55 | leggi(h); |
||
56 | leggi(h); |
||
57 | |||
58 | cprintf("SEEK to 16\n"); |
||
59 | lseek(h,16,SEEK_SET); |
||
60 | |||
61 | leggi(h); |
||
62 | |||
63 | cprintf("SEEK to %i\n",123*3+1); |
||
64 | lseek(h,123*3+1,SEEK_SET); |
||
65 | |||
66 | leggi(h); |
||
67 | |||
68 | } else |
||
69 | cprintf("FAILED!\n"); |
||
70 | |||
71 | waitend(); |
||
72 | |||
73 | return 0; |
||
74 | } |