Implemented tty_read () - tty_t obtain backlog (512bytes) created ondemand; telnetd...
[ZeXOS.git] / docs / zexos_devbook-en.html
blob3dc21d76df8d4d610402cac9642d78ee5bee23dc
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html lang="cs">
3 <head>
12 <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
21 <title>Devbook</title>
22 </head>
25 <body>
30 <div style="text-align: center;">
31 <h1><span style="font-weight: bold; color: rgb(195, 21, 26);">ZeX/OS</span></h1>
36 <span style="font-weight: bold;">Developer's book for v0.4.1<br>
41 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;writed by ZeXx86<br>
46 <br>
51 </span>
52 <div style="text-align: left;"><span style="font-weight: bold;"></span><br>
57 <span style="font-weight: bold;"></span></div>
62 <span style="font-weight: bold;"><br>
67 <br>
72 1. System calls<br>
77 2. Assembler tutorial<br>
81 3. C tutorial<br>
84 4. Glibc<br>
85 5. Filesystem driver tutorial<br>
90 <br>
95 </span>
96 <hr style="width: 100%; height: 2px;"><br>
101 <br>
106 <div style="text-align: left;">
107 <span style="font-weight: bold;">1. &nbsp;&nbsp;&nbsp; &nbsp; System calls<br>
111 <br>
115 </span>
116 In <a href="http://en.wikipedia.org/wiki/Computing" title="Computing">computing</a>, a <b>system call</b> is the mechanism used by an application program to request service from the <a href="http://en.wikipedia.org/wiki/Operating_system" title="Operating system">operating system</a>.<br>
121 ZeX/OS uses this implementation on <a href="http://en.wikipedia.org/wiki/X86" title="X86">x86</a> where the system call number is placed in the EAX <a href="http://en.wikipedia.org/wiki/Processor_register" title="Processor register">register</a> before interrupt 0x80 is executed.<br>
125 &nbsp;
126 <table style="text-align: left; width: 883px; height: 247px;" border="1" cellpadding="2" cellspacing="2">
131 <tbody>
136 <tr>
141 <td style="text-align: center; background-color: rgb(51, 204, 255); font-weight: bold; font-style: italic;" valign="undefined">Name</td>
146 <td style="background-color: rgb(51, 204, 255); text-align: center; font-weight: bold; font-style: italic;" valign="undefined">Description</td>
151 <td style="text-align: center; font-weight: bold; font-style: italic; background-color: rgb(51, 255, 255);" valign="undefined">%eax</td>
156 <td style="text-align: center; font-weight: bold; font-style: italic; background-color: rgb(51, 255, 255);" valign="undefined">%ebx</td>
161 <td style="text-align: center; font-weight: bold; font-style: italic; background-color: rgb(51, 255, 255);" valign="undefined">%ecx</td>
166 <td style="text-align: center; font-weight: bold; font-style: italic; background-color: rgb(51, 255, 255);" valign="undefined">%edx</td>
171 <td style="font-weight: bold; font-style: italic; text-align: center; background-color: rgb(51, 255, 255);" valign="undefined">$0x9000</td>
176 </tr>
181 <tr>
186 <td style="text-align: center;" valign="undefined">sys_exit</td>
191 <td style="text-align: center;" valign="undefined">Exit app at call point</td>
196 <td style="text-align: center;" valign="undefined">1</td>
201 <td style="text-align: center;" valign="undefined">int</td>
206 <td style="text-align: center;" valign="undefined">-</td>
211 <td style="text-align: center;" valign="undefined">-</td>
216 <td style="text-align: center;" valign="undefined">-</td>
221 </tr>
226 <tr>
231 <td style="text-align: center;" valign="undefined">sys_getch</td>
236 <td style="text-align: center;" valign="undefined">Get a pressed character</td>
241 <td style="text-align: center;" valign="undefined">2</td>
246 <td style="text-align: center;" valign="undefined">-</td>
251 <td style="text-align: center;" valign="undefined">-</td>
256 <td style="text-align: center;" valign="undefined">-</td>
261 <td style="text-align: center;" valign="undefined">unsigned char</td>
266 </tr>
271 <tr>
276 <td style="text-align: center;" valign="undefined">sys_sleep</td>
281 <td style="text-align: center;" valign="undefined">Wait until time (in sec) pass</td>
286 <td style="text-align: center;" valign="undefined">3</td>
291 <td style="text-align: center;" valign="undefined">unsigned int</td>
296 <td style="text-align: center;" valign="undefined">-</td>
301 <td style="text-align: center;" valign="undefined">-</td>
306 <td style="text-align: center;" valign="undefined">-</td>
311 </tr>
316 <tr>
321 <td style="text-align: center;" valign="undefined">sys_putch</td>
326 <td style="text-align: center;" valign="undefined">Print a character on the screen</td>
331 <td style="text-align: center;" valign="undefined">4</td>
336 <td style="text-align: center;" valign="undefined">char</td>
341 <td style="text-align: center;" valign="undefined">-</td>
346 <td style="text-align: center;" valign="undefined">-</td>
351 <td style="text-align: center;" valign="undefined">-</td>
356 </tr>
361 <tr>
366 <td style="text-align: center;" valign="undefined">sys_color</td>
371 <td style="text-align: center;" valign="undefined">Set color to next text</td>
376 <td style="text-align: center;" valign="undefined">5</td>
381 <td style="text-align: center;" valign="undefined">unsigned int</td>
386 <td style="text-align: center;" valign="undefined">unsigned int</td>
391 <td style="text-align: center;" valign="undefined">-</td>
396 <td style="text-align: center;" valign="undefined">-</td>
401 </tr>
406 <tr>
411 <td style="text-align: center;" valign="undefined">sys_cls</td>
416 <td style="text-align: center;" valign="undefined">Clear a screen</td>
421 <td style="text-align: center;" valign="undefined">6</td>
426 <td style="text-align: center;" valign="undefined">-</td>
431 <td style="text-align: center;" valign="undefined">-</td>
436 <td style="text-align: center;" valign="undefined">-</td>
441 <td style="text-align: center;" valign="undefined">-</td>
446 </tr>
451 <tr>
456 <td style="text-align: center;" valign="undefined">sys_getkey</td>
461 <td style="text-align: center;" valign="undefined">Get a keycode</td>
466 <td style="text-align: center;" valign="undefined">7</td>
471 <td style="text-align: center;" valign="undefined">-</td>
476 <td style="text-align: center;" valign="undefined">-</td>
481 <td style="text-align: center;" valign="undefined">-</td>
486 <td style="text-align: center;" valign="undefined">unsigned char</td>
491 </tr>
496 <tr>
501 <td style="text-align: center;" valign="undefined">sys_gotoxy</td>
506 <td style="text-align: center;" valign="undefined">Move a cursor to another place</td>
511 <td style="text-align: center;" valign="undefined">8</td>
516 <td style="text-align: center;" valign="undefined">unsigned int</td>
521 <td style="text-align: center;" valign="undefined">unsigned int</td>
526 <td style="text-align: center;" valign="undefined">-</td>
531 <td style="text-align: center;" valign="undefined">-</td>
536 </tr>
545 </tbody>
546 </table>
551 </div>
556 <div style="text-align: left;"><br>
560 <span style="font-weight: bold;">2.&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Assembler tutorial &nbsp;<br>
564 </span><br>
568 <span style="font-weight: normal;">For people interested in assembler programming for ZeX/OS is small example of source code for <span style="font-style: italic;">nasm</span> </span><span style="font-weight: normal;">compiler.</span><span style="font-weight: bold;"></span><br>
572 <span style="font-weight: bold;"><br>
576 <span style="font-weight: bold;"></span></span><span style="font-style: italic;">&gt;File start.asm&lt;<br>
580 </span>
581 <table style="text-align: left; background-color: rgb(234, 234, 234); width: 521px; height: 544px;" border="0" cellpadding="2" cellspacing="2">
585 <tbody>
589 <tr>
593 <td>[BITS 32]&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
594 &nbsp;&nbsp;&nbsp; &nbsp; ; first, we need tell to compiler, that we
595 want work in 32bit mode<br>
599 global _start&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ; entry point<br>
603 _start: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; define of _start function<br>
607 &nbsp;&nbsp;&nbsp; jmp main&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;; jump to main function<br>
611 <br>
615 <br>
619 cls:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
620 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;;
621 clear screen function<br>
625 &nbsp;&nbsp;&nbsp; mov eax, 6&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;; system call number 6<br>
629 &nbsp;&nbsp;&nbsp; int 0x80&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
630 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;; call interrupt for system call
631 - 0x80<br>
635 &nbsp;&nbsp;&nbsp; ret&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
636 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
637 &nbsp;&nbsp;&nbsp; ; end of cls function<br>
641 <br>
645 putch:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
646 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ; print
647 chatacter on the screen<br>
651 &nbsp;&nbsp;&nbsp; mov ebx, '.' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; we want print character '.'<br>
655 &nbsp;&nbsp;&nbsp; mov eax, 4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; this is system call number 6<br>
659 &nbsp;&nbsp;&nbsp; int 0x80&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
660 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;; system call interrupt<br>
664 &nbsp;&nbsp;&nbsp; ret&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
665 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
666 &nbsp;&nbsp;&nbsp; &nbsp;; end of putch function<br>
670 <br>
674 <br>
678 main:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; ; main function<br>
682 &nbsp;&nbsp;&nbsp; call cls&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
683 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;; this clear a screen<br>
687 <br>
691 &nbsp;&nbsp;&nbsp; mov cl, 10&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; ; set number 10 to register cl<br>
695 nav:<br>
699 &nbsp;&nbsp;&nbsp; dec cl&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
700 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; ; decrease one number from
701 register cl<br>
705 &nbsp;&nbsp;&nbsp; call putch&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;; print charecter '.' on the screen<br>
709 &nbsp;&nbsp;&nbsp; jnz nav&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
710 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;; will be jump to nav until
711 cl is'nt zero<br>
715 <br>
719 &nbsp;&nbsp;&nbsp; ret&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
720 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
721 &nbsp;; here ends our program<br>
725 </td>
729 </tr>
736 </tbody>
737 </table>
741 <br>
745 For compile, you need <span style="font-style: italic;">nasm</span> compiler and <span style="font-style: italic;">ld</span> for link object.<br>
749 nasm -f elf -ostart.o start.asm<br>
753 ld -m elf_i386 -s -omyapp start.o<br>
757 <span style="font-style: italic;"></span><span style="font-weight: bold;"><span style="font-weight: bold;"></span></span><br>
761 <br>
765 <span style="font-weight: bold;">3. &nbsp;&nbsp;&nbsp; &nbsp;C tutorial<br>
769 <br>
773 <span style="font-weight: bold;"><span style="font-weight: bold;"></span></span></span><span style="font-weight: normal;">For people interested in C programming language for ZeX/OS is small example of source code for </span><span style="font-style: italic; font-weight: normal;">gcc</span><span style="font-weight: normal;"> compiler.<br>
777 </span><span style="font-weight: bold;"><span style="font-weight: bold;"></span><br>
781 </span><span style="font-style: italic;">&gt;File main.c&lt;</span><span style="font-style: italic;"><br>
785 </span>
786 <table style="text-align: left; background-color: rgb(234, 234, 234); height: 237px; width: 381px;" border="0" cellpadding="2" cellspacing="2">
790 <tbody>
794 <tr>
798 <td>#include &lt;stdio.h&gt;<br>
802 <br>
806 int main ()<br>
810 {<br>
814 &nbsp; &nbsp; &nbsp; &nbsp; puts ("Hello world !");<br>
818 &nbsp; &nbsp; &nbsp; &nbsp; putch ('\n');<br>
822 <br>
826 &nbsp; &nbsp; &nbsp; &nbsp; int a = 8;<br>
830 &nbsp; &nbsp; &nbsp; &nbsp; int b = 5;<br>
834 &nbsp; &nbsp; &nbsp; &nbsp; int result = a + b;<br>
838 <br>
842 &nbsp; &nbsp; &nbsp; &nbsp; printf ("a + b = result\n%d + %d = %d", a, b, result);<br>
846 <br>
850 &nbsp; &nbsp; &nbsp; &nbsp; return 1;<br>
854 }<br>
858 </td>
862 </tr>
869 </tbody>
870 </table>
873 <br>
876 <br>
879 <br>
882 <span style="font-weight: bold;">4.&nbsp;&nbsp;&nbsp; &nbsp; Glibc<br>
885 <br>
888 <span style="font-weight: bold;"></span></span>The GNU C Library,
889 commonly known as glibc, is the C standard library released by the GNU
890 Project. Originally written by the Free Software Foundation (FSF) for
891 the GNU operating system, the library's development has been overseen
892 by a committee since 2001, with Ulrich Drepper as the lead contributor
893 and maintainer.<br>
896 <br>
899 This version of glibc is completly written by&nbsp;<span style="font-style: italic;">ZeXx86</span> for light compatibility with GNU programs written in C programming languague on ZeX/OS.<br>
902 <br>
905 <span style="text-decoration: underline;">Include layout<br>
908 <br>
911 </span>#include &lt;stdio.h&gt;<span style="font-style: italic;"></span><br>
914 <table style="text-align: left; background-color: rgb(234, 234, 234); width: 608px; height: 164px;" border="0" cellpadding="2" cellspacing="2">
917 <tbody>
920 <tr>
923 <td>
926 <div style="text-align: left;">void putch (char c); //&nbsp;Print a character on the screen </div>
929 void puts (unsigned char *text); // Print a string<br>
932 void printf (const char *fmt, ...); // Same as puts but with arguments<br>
935 void cls (); // Clear a screen<br>
938 unsigned char getch (); // Get a pressed character<br>
941 unsigned char getkey (); // Get a keycode<br>
944 void gotoxy (int x, int y); // Move a cursor to another place<br>
947 void setcolor (int t, int f); // Set color to next text<br>
949 int sprintf(char *buffer, const char *fmt, ...); // Copy string fmt with args to buffer
950 </td>
954 </tr>
961 </tbody>
962 </table>
965 <br>
968 #include &lt;stdlib.h&gt;<span style="font-style: italic;"></span><br>
971 <table style="text-align: left; background-color: rgb(234, 234, 234); width: 608px; height: 88px;" border="0" cellpadding="2" cellspacing="2">
974 <tbody>
977 <tr>
980 <td>void *malloc (size_t size); // Allocate block of memory<br>
983 void *realloc (void *blk, size_t size); // Allocate next block of memory<br>
986 void free (void *blk); // Free a block of allocated memory<br>
989 void exit (); //&nbsp;Exit app at call point
990 </td>
994 </tr>
1001 </tbody>
1002 </table>
1005 <br>
1008 #include &lt;unistd.h&gt;<span style="font-style: italic;"></span><br>
1011 <table style="text-align: left; background-color: rgb(234, 234, 234); width: 607px; height: 31px;" border="0" cellpadding="2" cellspacing="2">
1014 <tbody>
1017 <tr>
1020 <td>unsigned int sleep (unsigned int) // Wait until time (in sec) pass
1021 </td>
1025 </tr>
1032 </tbody>
1033 </table>
1036 <br>
1039 #include &lt;string.h&gt;<br>
1042 <table style="text-align: left; background-color: rgb(234, 234, 234); width: 756px; height: 164px;" border="0" cellpadding="2" cellspacing="2">
1045 <tbody>
1048 <tr>
1051 <td>void *memcpy (void *dst_ptr, const void *src_ptr, size_t count); // Copy block of memory<br>
1054 void *memsetw (void *dst, int val, size_t count); // Put to memory block of&nbsp;some character<br>
1057 void *memset (void *dst, int val, size_t count); // Put to memory block of&nbsp;some character<br>
1060 size_t strlen (const char *str); // Get length of string<br>
1063 char *strcpy (char *to, const char *from); // Copy string<br>
1065 char *strncpy (char *s1, const char *s2, size_t n); // Copy string with declared length<br>
1068 char *strcat (char *s, const char *add); // Add string to another string<br>
1071 int strcmp (const char *cs, const char *ct); // Compare two strings<br>
1074 int strncmp (const char *cs, const char *ct, size_t count); // Compare two strings with defined length<br>
1076 char *strdup (const char *s); // Alloc new block of memory for string s<br>
1080 </td>
1084 </tr>
1091 </tbody>
1092 </table>
1095 <br>
1098 #include &lt;x86.h&gt;<span style="font-style: italic;"></span><br>
1101 <table style="text-align: left; background-color: rgb(234, 234, 234); width: 403px; height: 126px;" border="0" cellpadding="2" cellspacing="2">
1104 <tbody>
1107 <tr>
1110 <td>unsigned inportb (unsigned short port); // Get byte from port<br>
1113 void outportb (unsigned port, unsigned val); // Set byte on port<br>
1116 unsigned disable (void); // Disable interrupts<br>
1119 void enable (void); // Enable interrupts<br>
1122 void enable_irq (unsigned short irq_num); // Enable irq<br>
1125 void disable_irq (unsigned short irq_num); // Disable irq
1126 </td>
1130 </tr>
1137 </tbody>
1138 </table>
1139 <br>
1140 <br>
1141 <span style="font-weight: bold;">5.&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;</span><span style="font-weight: bold;">Filesystem driver tutorial<br>
1142 <br>
1143 </span>ZeX/OS is developed for no one filesystem, so it supports fs handlers, disk handlers, etc..<br>
1144 As you should see, in this short tutorial, you will learn how it works<br>
1145 <br>
1146 <br>
1147 Base function to read/write data over disk<span style="font-style: italic;"></span><br>
1150 <table style="text-align: left; background-color: rgb(234, 234, 234); width: 593px; height: 126px;" border="0" cellpadding="2" cellspacing="2">
1153 <tbody>
1156 <tr>
1159 <td>/* partition_t is defined in partition.h, addr is 28bit
1160 (32) address of block, easy addr = 1 is block 1, etc .. buffer is
1161 classical char * for getting data after calling */<br>
1162 int lba28_drive_read (partition_t *p, unsigned int addr, unsigned char *buffer);<br>
1163 <br>
1164 /* same, but for writing data from buffer */<br>
1165 int lba28_drive_write (partition_t *p, unsigned char addr, unsigned char *buffer);<br>
1166 <br>
1167 /* when you want device metod, use this */<br>
1168 dev_t *dev = dev_findbypartition (p);<br>
1169 <br>
1170 if (!dev) // check for existing device<br>
1171 &nbsp;&nbsp;&nbsp; return 0;<br>
1172 <br>
1173 if (!dev-&gt;handler (DEV_ACT_READ, p, block, more, n))<br>
1174 &nbsp;&nbsp;&nbsp; return 0; // error ?<br>
1175 <br>
1176 /* handler is defined in drive.c and function shows like this */<br>
1177 bool ide_acthandler (unsigned act, partition_t *p, char *block, char *more, int n)<br>
1179 </td>
1183 </tr>
1190 </tbody>
1191 </table>
1192 <br>
1193 <br>
1194 myfs.c<span style="font-style: italic;"></span><br>
1197 <table style="text-align: left; background-color: rgb(234, 234, 234); width: 687px; height: 1057px;" border="0" cellpadding="2" cellspacing="2">
1200 <tbody>
1203 <tr>
1206 <td>#include &lt;partition.h&gt;<br>
1207 #include &lt;system.h&gt;<br>
1208 #include &lt;string.h&gt;<br>
1209 #include &lt;dev.h&gt;<br>
1210 #include &lt;fs.h&gt;<br>
1211 <br>
1212 <br>
1213 bool myfs_read_dir (partition_t *p, char *block, int n)<br>
1214 {<br>
1215 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* its your space for create
1216 function, which read directory and put it to dir[] structure, <br>
1217 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dir is defined in system.h include */<br>
1218 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return 1;<br>
1219 }<br>
1220 <br>
1221 /*<br>
1222 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;...<br>
1223 */<br>
1224 <br>
1225 /** MyFS handler for handling disk operations<br>
1226 &nbsp;*&nbsp; act - action; arg - argument; block - chunk of data for
1227 input/output; n - number of block; l - lenght of &nbsp;output<br>
1228 &nbsp;*/<br>
1229 bool myfs_handler (unsigned act, unsigned arg, char *block, unsigned n, unsigned long l)<br>
1230 {<br>
1231 &nbsp;&nbsp;&nbsp; switch (act) {<br>
1232 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; case FS_ACT_INIT:<br>
1233 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
1234 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* something, what&nbsp;you need to initialize, e.g. memory stacks */<br>
1235 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return 1;<br>
1236 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
1237 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>
1238 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; case FS_ACT_READ:<br>
1239 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
1240 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; switch (arg) {<br>
1241 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; case FS_ARG_FILE:<br>
1242 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
1243 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
1244 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;myfs_read_file (curr_part, n); //
1245 this have to read file at n block on partition_t *curr_part<br>
1246 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* ... some stuff for get new data on char *block */<br>
1247 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return 1;<br>
1248 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
1249 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>
1250 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; case FS_ARG_DIR:<br>
1251 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
1252 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
1253 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; myfs_read_dir (curr_part, n); //
1254 this is your new fs function too<br>
1255 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* same as in file operation */<br>
1256 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return 1;<br>
1257 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
1258 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>
1259 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
1260 <br>
1261 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return 0;<br>
1262 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
1263 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>
1264 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; case FS_ACT_WRITE:<br>
1265 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
1266 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* Yeah, you
1267 want to probably create FS with write support, you can do it here */<br>
1268 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return 1;<br>
1269 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
1270 &nbsp;&nbsp;&nbsp; }<br>
1271 <br>
1272 &nbsp;&nbsp;&nbsp; return 0;<br>
1273 }<br>
1275 </td>
1279 </tr>
1286 </tbody>
1287 </table>
1289 <br>
1290 <span style="font-weight: bold;">&nbsp;&nbsp;&nbsp;</span><span style="font-weight: bold;"></span></div>
1296 </div>
1301 </body>
1302 </html>