File system, adds file system interruption in int0x21()
More...
#include <types.h>
#include <errno.h>
#include <io.h>
#include <string.h>
#include "interrupts.h"
Go to the source code of this file.
File system, adds file system interruption in int0x21()
Adds file management
- Attention
- Only for kernel use, users should use file.h
- Todo:
- better handle disk errors see info.c, check if CF is set after reading/writing
Definition in file fs.h.
◆ SECTORS_PER_TRACK
| #define SECTORS_PER_TRACK 37 |
Number of sectors per track.
Depends on floppy mode, 18 for 1.44 or 36 for 2.88, I use 2.88
- Todo:
- to avoid breaking file into tracks see sys_create()
Definition at line 30 of file fs.h.
◆ TRACKS_MAX
Maximal number of tracks in OS.
- Todo:
- do it dynamically
Definition at line 36 of file fs.h.
◆ int0x21()
interruption for file system
sets all sys_* functions as interruption see interrupts-asm.c and interrupts.h
| AH | Description | BX | CX | DX | Returned AX |
| 0 | sys_setup() | | | | Number of loaded files |
| 1 | sys_open() | file name | | | (file ID)<<8 | (file size (in sectors)) |
| 2 | sys_read() | file id | memory beginning | size in B | Actually readed Bytes |
| 3 | sys_write() | file id | memory beginning | size in B | Actually saved Bytes (completed to 512B) |
| 4 | sys_create() | file name | new file size in Sec | | file's ID |
| 4 | sys_remove() | file name | | | 0 if success |
- Parameters
-
| registers | AX, BX, CX, DX, SI, DI |
- Returns
- register AX
- Todo:
- change order of ah
Definition at line 310 of file fs.h.
◆ sys_create()
| int sys_create |
( |
const int |
filename, |
|
|
size_t |
size |
|
) |
| |
Create file.
- Parameters
-
| filename | |
| size | in sectors(512B) |
- Returns
- int new file's id or -error
- Todo:
file must be all in one track, change it
add it to sys_open when file wasn't found
Definition at line 120 of file fs.h.
◆ sys_open()
| int sys_open |
( |
const int |
filename | ) |
|
Open file.
- Parameters
-
- Returns
- int {size in Sectors(512B),id} or -error
Definition at line 101 of file fs.h.
◆ sys_read()
| int sys_read |
( |
const Byte |
id, |
|
|
int |
ptr, |
|
|
size_t |
size |
|
) |
| |
Read from file.
- Parameters
-
| id | file's id |
| ptr | pointer to target memory |
| size | to read in bytes |
- Returns
- int actually readed Bytes or -error
Definition at line 203 of file fs.h.
◆ sys_remove()
| int sys_remove |
( |
const int |
filename | ) |
|
Remove file.
- Parameters
-
- Returns
- int 0 if success or -error
Definition at line 171 of file fs.h.
◆ sys_setup()
load file system
- Returns
- int number of loaded files
Definition at line 81 of file fs.h.
◆ sys_write()
| int sys_write |
( |
Byte |
id, |
|
|
int |
ptr, |
|
|
size_t |
size |
|
) |
| |
Write to file.
- Parameters
-
| id | file's id |
| ptr | pointer to source memory |
| size | to write in Bytes, file will be rounded to whole sectors |
- Returns
- int actually written Bytes or -error
- Todo:
- add modes, when append when override
Definition at line 249 of file fs.h.