Commit graph

12 commits

Author SHA1 Message Date
Franciszek Pindel 8cc2d90123 fs: ext2: Fix removing indirect blocks
This commit fixes removing indirect blocks (marking them as 0)
in the inode structure. Previous version of the code was removing
the top-level blocks only when the first removed block was
one of the first 12 direct blocks. However, when the first removed
block is the first block in the referenced block list, its parent
(indirect block) should also be removed.

Signed-off-by: Franciszek Pindel <fpindel@antmicro.com>
2024-04-19 10:13:09 +02:00
Daniel Leung f02d40017f fs: rename shadow variables
Rename shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-22 11:39:58 +02:00
Andrei Emeltchenko 4170eb2433 fs: ext2: Remove comparing unsigned < 0
Remove never true comparisons for ext2.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-08-16 15:04:48 +02:00
Franciszek Zdobylak 1eb104795e fs: ext2: Use disk structs to access data on disk
This commits changes how data on the disk is accessed. There are disk
structures which are packed and their fields are stored in little endian
byte order. To use data in the program structures it has to be translated
from little endian to cpu endianness.

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak 984bdab456 fs: ext2: update how memory is allocated in ext2
- `ext2_file` and `ext2_dir` merged into one struct and allocated from
  dedicated slab
- `ext2_inode` allocated from dedicated slab
- `ext2_disk_dentry` allocated from heap (because their size is not
  constant)
- `ext2_bgroup` and `ext2_disk_superblock` statically allocated

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak 1f62d99e7e fs: ext2: Update memory writes
Fix the behavior when data should be written to storage device. Now all
writes are done directly to disk_access layer (where it might possibly
be cached).

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak b3eec79f5b fs: ext2: Interpret s_errors field in superblocks
Added funtion that takes specified action when file system corruption is
detected. Possible actions are: do nothing, make mount point read-only,
panic.

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak dfd845b131 fs: ext2: fix blocks and inodes handling
Changes:
  - Added few assertions to check if some assumptions are correct
  - Fix removing blocks during trucate and inode removal
  - Clear entry in inode table after inode has been removed

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak b814246764 fs: ext2: create correct file system in mkfs
Changes:
  - Add fs::sync function
  - Make correct file system in mkfs
  - Add few assertions to ensure that all assumptions are correct

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak f793e0b3c3 fs: ext2: implement unlink
Introduce fs_unlink function.

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak 685682ff49 fs: ext2: implement fs_truncate
Introduce fs_truncate function.

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak 64da407ea5 fs: ext2: create dir and file operations
Introduced functions:
  - open
  - close
  - mkdir

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00