MentOS
0.8.0
The Mentoring Operating System
|
EXT2 driver. More...
Classes | |
struct | ext2_superblock_t |
The superblock contains all the information about the configuration of the filesystem. More... | |
struct | ext2_group_descriptor_t |
Entry of the Block Group Descriptor Table (BGDT). More... | |
struct | ext2_inode_t |
The ext2 inode. More... | |
struct | ext2_dirent_t |
The header of an ext2 directory entry. More... | |
struct | ext2_filesystem_t |
The details regarding the filesystem. More... | |
struct | ext2_direntry_search_t |
Structure used when searching for a directory entry. More... | |
struct | ext2_direntry_iterator_t |
Iterator for visiting the directory entries. More... | |
Macros | |
#define | __DEBUG_HEADER__ "[EXT2 ]" |
Change header. | |
#define | __DEBUG_LEVEL__ LOGLEVEL_NOTICE |
Set log level. | |
#define | EXT2_SUPERBLOCK_MAGIC 0xEF53 |
Magic value used to identify an ext2 filesystem. | |
#define | EXT2_DIRECT_BLOCKS 12 |
Amount of indirect blocks in an inode. | |
#define | EXT2_PATH_MAX 4096 |
Maximum length of a pathname. | |
#define | EXT2_MAX_SYMLINK_COUNT 8 |
Maximum nesting of symlinks, used to prevent a loop. | |
#define | EXT2_NAME_LEN 255 |
The lenght of names inside directory entries. | |
#define | EXT2_S_ISUID 0x0800 |
SUID. | |
#define | EXT2_S_ISGID 0x0400 |
SGID. | |
#define | EXT2_S_ISVTX 0x0200 |
Sticky Bit. | |
#define | EXT2_S_IRWXU 0x01C0 |
rwx----— : User can read/write/execute | |
#define | EXT2_S_IRUSR 0x0100 |
-r-----— : User can read | |
#define | EXT2_S_IWUSR 0x0080 |
–w----— : User can write | |
#define | EXT2_S_IXUSR 0x0040 |
—x---— : User can execute | |
#define | EXT2_S_IRWXG 0x0038 |
-—rwx— : Group can read/write/execute | |
#define | EXT2_S_IRGRP 0x0020 |
-—r--— : Group can read | |
#define | EXT2_S_IWGRP 0x0010 |
--—w-— : Group can write | |
#define | EXT2_S_IXGRP 0x0008 |
---—x— : Group can execute | |
#define | EXT2_S_IRWXO 0x0007 |
----—rwx : Others can read/write/execute | |
#define | EXT2_S_IROTH 0x0004 |
----—r– : Others can read | |
#define | EXT2_S_IWOTH 0x0002 |
-----—w- : Others can write | |
#define | EXT2_S_IXOTH 0x0001 |
------—x : Others can execute | |
Typedefs | |
typedef enum ext2_file_type_t | ext2_file_type_t |
Types of file in an EXT2 filesystem. | |
typedef struct ext2_superblock_t | ext2_superblock_t |
The superblock contains all the information about the configuration of the filesystem. More... | |
typedef struct ext2_group_descriptor_t | ext2_group_descriptor_t |
Entry of the Block Group Descriptor Table (BGDT). | |
typedef struct ext2_inode_t | ext2_inode_t |
The ext2 inode. | |
typedef struct ext2_dirent_t | ext2_dirent_t |
The header of an ext2 directory entry. | |
typedef struct ext2_filesystem_t | ext2_filesystem_t |
The details regarding the filesystem. | |
typedef struct ext2_direntry_search_t | ext2_direntry_search_t |
Structure used when searching for a directory entry. | |
typedef struct ext2_direntry_iterator_t | ext2_direntry_iterator_t |
Iterator for visiting the directory entries. | |
Enumerations | |
enum | ext2_file_type_t { ext2_file_type_unknown , ext2_file_type_regular_file , ext2_file_type_directory , ext2_file_type_character_device , ext2_file_type_block_device , ext2_file_type_named_pipe , ext2_file_type_socket , ext2_file_type_symbolic_link } |
Types of file in an EXT2 filesystem. More... | |
Functions | |
static int | ext2_bitmap_check (uint8_t *buffer, uint32_t offset) |
Cheks if the bit at the given linear index is free. More... | |
static void | ext2_bitmap_set (uint8_t *buffer, uint32_t offset) |
Sets the bit at the given index. More... | |
static void | ext2_bitmap_clear (uint8_t *buffer, uint32_t offset) |
Clears the bit at the given index. More... | |
static int | ext2_read_superblock (ext2_filesystem_t *fs) |
Reads the superblock from the block device associated with this filesystem. More... | |
static int | ext2_write_superblock (ext2_filesystem_t *fs) |
Writes the superblock on the block device associated with this filesystem. More... | |
static int | ext2_read_block (ext2_filesystem_t *fs, uint32_t block_index, uint8_t *buffer) |
Read a block from the block device associated with this filesystem. More... | |
static int | ext2_write_block (ext2_filesystem_t *fs, uint32_t block_index, uint8_t *buffer) |
Writes a block on the block device associated with this filesystem. More... | |
static int | ext2_read_bgdt (ext2_filesystem_t *fs) |
Reads the Block Group Descriptor Table (BGDT) from the block device associated with this filesystem. More... | |
static int | ext2_write_bgdt (ext2_filesystem_t *fs) |
Writes the Block Group Descriptor Table (BGDT) to the block device associated with this filesystem. More... | |
static int | ext2_read_inode (ext2_filesystem_t *fs, ext2_inode_t *inode, uint32_t inode_index) |
Reads an inode. More... | |
static int | ext2_write_inode (ext2_filesystem_t *fs, ext2_inode_t *inode, uint32_t inode_index) |
Writes the inode. More... | |
static vfs_file_t * | ext2_open (const char *path, int flags, mode_t mode) |
Open the file at the given path and returns its file descriptor. More... | |
static int | ext2_unlink (const char *path) |
Delete a name and possibly the file it refers to. More... | |
static int | ext2_close (vfs_file_t *file) |
Closes the given file. More... | |
static ssize_t | ext2_read (vfs_file_t *file, char *buffer, off_t offset, size_t nbyte) |
Reads from the file identified by the file descriptor. More... | |
static ssize_t | ext2_write (vfs_file_t *file, const void *buffer, off_t offset, size_t nbyte) |
Writes the given content inside the file. More... | |
static off_t | ext2_lseek (vfs_file_t *file, off_t offset, int whence) |
Repositions the file offset inside a file. More... | |
static int | ext2_fstat (vfs_file_t *file, stat_t *stat) |
Retrieves information concerning the file at the given position. More... | |
static int | ext2_ioctl (vfs_file_t *file, int request, void *data) |
Perform the I/O control operation specified by REQUEST on FD. One argument may follow; its presence and type depend on REQUEST. More... | |
static ssize_t | ext2_getdents (vfs_file_t *file, dirent_t *dirp, off_t doff, size_t count) |
Reads contents of the directories to a dirent buffer, updating the offset and returning the number of written bytes in the buffer, it assumes that all paths are well-formed. More... | |
static ssize_t | ext2_readlink (const char *path, char *buffer, size_t bufsize) |
Read the symbolic link, if present. More... | |
static int | ext2_fsetattr (vfs_file_t *file, struct iattr *attr) |
Set attributes of the file at the given position. More... | |
static int | ext2_mkdir (const char *path, mode_t permission) |
Creates a new directory at the given path. More... | |
static int | ext2_rmdir (const char *path) |
Removes the given directory. More... | |
static int | ext2_stat (const char *path, stat_t *stat) |
Retrieves information concerning the file at the given position. More... | |
static int | ext2_setattr (const char *path, struct iattr *attr) |
Set attributes of a file. More... | |
static vfs_file_t * | ext2_creat (const char *path, mode_t mode) |
Creates a new file or rewrite an existing one. More... | |
static vfs_file_t * | ext2_mount (vfs_file_t *block_device, const char *path) |
Mounts the block device as an EXT2 filesystem. More... | |
static uint32_t | ext2_get_real_block_index (ext2_filesystem_t *fs, ext2_inode_t *inode, uint32_t block_index) |
Returns the real block index starting from a block index inside an inode. More... | |
static const char * | uuid_to_string (uint8_t uuid[16]) |
Turns an UUID to string. More... | |
static const char * | ext2_file_type_to_string (ext2_file_type_t ext2_type) |
Turns an ext2_file_type to string. More... | |
static int | ext2_file_type_to_vfs_file_type (int ext2_type) |
Turns the EXT2 file type to OS standard file types. More... | |
static const char * | time_to_string (uint32_t time) |
Turns the time to string. More... | |
static void | ext2_dump_superblock (ext2_superblock_t *sb) |
Dumps on debugging output the superblock. More... | |
static void | ext2_dump_group_descriptor (ext2_group_descriptor_t *gd) |
Dumps on debugging output the group descriptor. More... | |
static void | ext2_dump_inode (ext2_filesystem_t *fs, ext2_inode_t *inode) |
Dumps on debugging output the inode. More... | |
static void | ext2_dump_dirent (ext2_dirent_t *dirent) |
Dumps on debugging output the dirent. More... | |
static void | ext2_dump_bgdt (ext2_filesystem_t *fs) |
Dumps on debugging output the BGDT. More... | |
static void | ext2_dump_filesystem (ext2_filesystem_t *fs) |
Dumps on debugging output the filesystem. More... | |
static uint8_t * | ext2_alloc_cache (ext2_filesystem_t *fs) |
Allocate cache for EXT2 operations. More... | |
static void | ext2_dealloc_cache (uint8_t *cache) |
Free the cache. More... | |
static uint32_t | ext2_get_rec_len_from_name (const char *name) |
Returns the rec_len from the given name. More... | |
static uint32_t | ext2_get_rec_len_from_direntry (const ext2_dirent_t *direntry) |
Returns the rec_len from the given direntry. More... | |
static uint32_t | ext2_is_last_directory_entry (const ext2_dirent_t *direntry) |
If the real rec_len is different from the on in attribute rec_len, this is the last directory entry. More... | |
static uint32_t | ext2_inode_index_to_group_index (ext2_filesystem_t *fs, uint32_t inode_index) |
Determining which block group contains an inode. More... | |
static uint32_t | ext2_inode_index_to_group_offset (ext2_filesystem_t *fs, uint32_t inode_index) |
Determining the offest of the inode inside the inode group. More... | |
static uint32_t | ext2_inode_index_to_block_index (ext2_filesystem_t *fs, uint32_t inode_index) |
Determining the block index from the inode index. More... | |
static uint32_t | ext2_block_index_to_group_index (ext2_filesystem_t *fs, uint32_t block_index) |
Determining which block group contains a given block. More... | |
static uint32_t | ext2_block_index_to_group_offset (ext2_filesystem_t *fs, uint32_t block_index) |
Determining the offest of the block inside the block group. More... | |
static int | __valid_x_permission (task_struct *task, ext2_inode_t *inode) |
Checks if the task has x-permission for a given inode. More... | |
static int | ext2_find_free_inode_in_group (ext2_filesystem_t *fs, uint8_t *cache, uint32_t *group_offset, int skip_reserved) |
Searches for a free inode inside the group data loaded inside the cache. More... | |
static int | ext2_find_free_inode (ext2_filesystem_t *fs, uint8_t *cache, uint32_t *group_index, uint32_t *group_offset, uint32_t preferred_group) |
Searches for a free inode inside the Block Group Descriptor Table (BGDT). More... | |
static int | ext2_find_free_block_in_group (ext2_filesystem_t *fs, uint8_t *cache, uint32_t *block_offset) |
Searches for a free block inside the group data loaded inside the cache. More... | |
static int | ext2_find_free_block (ext2_filesystem_t *fs, uint8_t *cache, uint32_t *group_index, uint32_t *block_offset) |
Searches for a free block. More... | |
static int | ext2_allocate_inode (ext2_filesystem_t *fs, unsigned preferred_group) |
Allocate a new inode. More... | |
static uint32_t | ext2_allocate_block (ext2_filesystem_t *fs) |
Allocates a new block. More... | |
static void | ext2_free_block (ext2_filesystem_t *fs, uint32_t block_index) |
Frees a block. More... | |
static int | ext2_free_inode (ext2_filesystem_t *fs, ext2_inode_t *inode, uint32_t inode_index) |
Frees the given inode. More... | |
static int | __ext2_allocate_indexing_block_for_inode (ext2_filesystem_t *fs, uint32_t *current_index) |
Allocates a new block for storing block indices, for an inode. More... | |
static int | __ext2_read_and_allocate_indexing_block (ext2_filesystem_t *fs, uint32_t indexing_block, uint8_t *cache, uint32_t index) |
Allocates a new block for storing block indices, for a block containing block indices. More... | |
static int | ext2_set_real_block_index (ext2_filesystem_t *fs, ext2_inode_t *inode, uint32_t inode_index, uint32_t block_index, uint32_t real_index) |
Sets the real block index based on the block index inside an inode. More... | |
static int | ext2_allocate_inode_block (ext2_filesystem_t *fs, ext2_inode_t *inode, uint32_t inode_index, uint32_t block_index) |
Allocate a new block for an inode. More... | |
static ssize_t | ext2_read_inode_block (ext2_filesystem_t *fs, ext2_inode_t *inode, uint32_t block_index, uint8_t *buffer) |
Reads the real block starting from an inode and the block index inside the inode. More... | |
static ssize_t | ext2_write_inode_block (ext2_filesystem_t *fs, ext2_inode_t *inode, uint32_t inode_index, uint32_t block_index, uint8_t *buffer) |
Writes the real block starting from an inode and the block index inside the inode. More... | |
static ssize_t | ext2_read_inode_data (ext2_filesystem_t *fs, ext2_inode_t *inode, uint32_t inode_index, off_t offset, size_t nbyte, char *buffer) |
Reads the data from the given inode. More... | |
static ssize_t | ext2_write_inode_data (ext2_filesystem_t *fs, ext2_inode_t *inode, uint32_t inode_index, off_t offset, size_t nbyte, char *buffer) |
Writes the data on the given inode. More... | |
ext2_dirent_t * | ext2_direntry_iterator_get (ext2_direntry_iterator_t *it) |
Returns the ext2_dirent_t pointed by the iterator. More... | |
int | ext2_direntry_iterator_valid (ext2_direntry_iterator_t *it) |
Check if the iterator is valid. More... | |
ext2_direntry_iterator_t | ext2_direntry_iterator_begin (ext2_filesystem_t *fs, uint8_t *cache, ext2_inode_t *inode) |
Initializes the iterator and reads the first block. More... | |
void | ext2_direntry_iterator_next (ext2_direntry_iterator_t *it) |
Moves to the next direntry, and moves to the next block if necessary. More... | |
static int | ext2_directory_is_empty (ext2_filesystem_t *fs, uint8_t *cache, ext2_inode_t *inode) |
Checks if the directory is empty. More... | |
static int | ext2_clean_inode_content (ext2_filesystem_t *fs, ext2_inode_t *inode, uint32_t inode_index) |
Cleans the inode content. More... | |
static void | ext2_initialize_direntry (ext2_dirent_t *direntry, const char *name, ino_t inode_index, uint32_t rec_len, uint8_t file_type) |
Initializes a directory entry. More... | |
static int | ext2_initialize_new_direntry_block (ext2_filesystem_t *fs, uint32_t inode_index, uint32_t block_index) |
Initializes a new directory entry block for the specified inode. More... | |
static void | ext2_dump_direntries (ext2_filesystem_t *fs, uint8_t *cache, ext2_inode_t *parent_inode) |
Dumps the directory entries inside the parent directory. More... | |
static int | ext2_get_free_direntry (ext2_filesystem_t *fs, uint8_t *cache, ino_t parent_inode_index, const char *name, ino_t inode_index, uint8_t file_type) |
Searches for a free unused directory entry (inode == 0). More... | |
static int | ext2_append_new_direntry (ext2_filesystem_t *fs, uint8_t *cache, ino_t parent_inode_index, const char *name, ino_t inode_index, uint8_t file_type) |
Appends the new directory entry at the end of the last used block, if there is enough space. More... | |
static int | ext2_create_new_direntry (ext2_filesystem_t *fs, uint8_t *cache, ino_t parent_inode_index, const char *name, ino_t inode_index, uint8_t file_type) |
Allocates a new block, and creates a new directory entry inside that new block. More... | |
static int | ext2_allocate_direntry (ext2_filesystem_t *fs, uint32_t parent_inode_index, uint32_t direntry_inode_index, const char *name, uint8_t file_type) |
Allocates a directory entry. More... | |
static int | ext2_destroy_direntry (ext2_filesystem_t *fs, ext2_inode_t parent, ext2_inode_t inode, uint32_t parent_index, uint32_t inode_index, uint32_t block_index, uint32_t block_offset) |
Destroys a directory entry in the parent directory. More... | |
static int | ext2_find_direntry (ext2_filesystem_t *fs, ino_t ino, const char *name, ext2_direntry_search_t *search) |
Finds the entry with the given name inside the directory . More... | |
static int | ext2_resolve_path (vfs_file_t *directory, const char *path, ext2_direntry_search_t *search) |
Searches the entry specified in path starting from directory . More... | |
static ext2_filesystem_t * | get_ext2_filesystem (const char *absolute_path) |
Get the ext2 filesystem object starting from a path. More... | |
static int | ext2_init_vfs_file (ext2_filesystem_t *fs, vfs_file_t *file, ext2_inode_t *inode, uint32_t inode_index, const char *name, size_t name_len) |
Initializes the VFS file. More... | |
static vfs_file_t * | ext2_find_vfs_file_with_inode (ext2_filesystem_t *fs, ino_t inode) |
Finds the VFS file that is associated with the given inode index. More... | |
static int | ext2_create_inode (ext2_filesystem_t *fs, ext2_inode_t *inode, mode_t mode, uint32_t preferred_group) |
Creates and initializes a new inode. More... | |
static int | __ext2_stat (ext2_inode_t *inode, stat_t *stat) |
Saves the information concerning the file. More... | |
static int | __ext2_setattr (ext2_inode_t *inode, struct iattr *attr) |
Sets the attributes of an inode and saves it. More... | |
static int | __ext2_check_setattr_permission (uid_t file_owner) |
Checks the attributes permission. More... | |
static vfs_file_t * | ext2_mount_callback (const char *path, const char *device) |
The mount call-back, which prepares everything and calls the actual EXT2 mount function. More... | |
int | ext2_initialize (void) |
Initializes the EXT2 drivers. More... | |
int | ext2_finalize (void) |
De-initializes the EXT2 drivers. More... | |
Variables | |
static vfs_sys_operations_t | ext2_sys_operations |
Filesystem general operations. More... | |
static vfs_file_operations_t | ext2_fs_operations |
Filesystem file operations. More... | |
static file_system_type | ext2_file_system_type |
Filesystem information. More... | |
EXT2 driver.
typedef struct ext2_superblock_t ext2_superblock_t |
The superblock contains all the information about the configuration of the filesystem.
The primary copy of the superblock is stored at an offset of 1024 bytes from the start of the device, and it is essential to mounting the filesystem. Since it is so important, backup copies of the superblock are stored in block groups throughout the filesystem.
enum ext2_file_type_t |
Types of file in an EXT2 filesystem.
|
static |
Allocates a new block for storing block indices, for an inode.
fs | the filesystem. |
current_index | the current index, or if 0, where we store the new one. |
|
static |
Checks the attributes permission.
file_owner | the file owner we are checking against. |
|
static |
Allocates a new block for storing block indices, for a block containing block indices.
fs | the filesystem. |
indexing_block | the index of block that contains the indices. |
cache | the cache were we load the block content. |
index | the index inside the list of indices. |
|
static |
Sets the attributes of an inode and saves it.
inode | The inode to set the attributes |
attr | The structure where the attributes are stored. |
|
static |
Saves the information concerning the file.
inode | The inode containing the data. |
stat | The structure where the information are stored. |
|
static |
Checks if the task has x-permission for a given inode.
task | the task to check permission for. |
inode | the inode to check permission. |
|
inlinestatic |
Allocate cache for EXT2 operations.
fs | file system we are working with. |
|
static |
Allocates a new block.
fs | the filesystem. |
|
static |
Allocates a directory entry.
fs | a pointer to the filesystem. |
parent_inode_index | the inode index of the parent. |
direntry_inode_index | the inode index of the new entry. |
name | the name of the new entry. |
file_type | the type of file. |
|
static |
Allocate a new inode.
fs | the filesystem. |
preferred_group | the preferred group. |
Here are the rules used to allocate new inodes:
|
static |
Allocate a new block for an inode.
fs | the filesystem. |
inode | the inode which we are working with. |
inode_index | The index of the inode. |
block_index | The index of the block within the inode. |
|
inlinestatic |
Appends the new directory entry at the end of the last used block, if there is enough space.
fs | a pointer to the filesystem. |
cache | cache for memory EXT2 operations. |
parent_inode_index | the parent inode index. |
name | the name of the new entry. |
inode_index | its inode index. |
file_type | its file type. |
Cheks if the bit at the given linear index is free.
buffer | the buffer containing the bitmap |
offset | the linear index we want to check. |
How we access the specific bits inside the bitmap takes inspiration from the mailman's algorithm.
Clears the bit at the given index.
buffer | the buffer containing the bitmap |
offset | the bit index we want to clear. |
Sets the bit at the given index.
buffer | the buffer containing the bitmap |
offset | the bit index we want to set. |
|
static |
Determining which block group contains a given block.
fs | the ext2 filesystem structure. |
block_index | the block index. |
|
static |
Determining the offest of the block inside the block group.
fs | the ext2 filesystem structure. |
block_index | the block index. |
|
static |
Cleans the inode content.
fs | a pointer to the filesystem. |
inode | the inode. |
inode_index | the inode index. |
|
static |
Closes the given file.
file | The file structure. |
|
static |
Creates a new file or rewrite an existing one.
path | path to the file. |
mode | mode for file creation. |
It is equivalent to: open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)
|
static |
Creates and initializes a new inode.
fs | the filesystem. |
inode | the inode we use to initialize the root of the filesystem. |
mode | the creat mode. |
preferred_group | the preferred group where the inode should be allocated. |
|
inlinestatic |
Allocates a new block, and creates a new directory entry inside that new block.
fs | a pointer to the filesystem. |
cache | cache for memory EXT2 operations. |
parent_inode_index | the parent inode index. |
name | the name of the new entry. |
inode_index | its inode index. |
file_type | its file type. |
|
inlinestatic |
Free the cache.
cache | pointer to the cache. |
|
static |
Destroys a directory entry in the parent directory.
fs | A pointer to the filesystem structure. |
parent | The inode of the parent directory. |
inode | The inode of the directory entry to be destroyed. |
parent_index | The index of the parent inode. |
inode_index | The index of the directory entry's inode. |
block_index | The block index where the directory entry resides. |
block_offset | The offset within the block where the directory entry is located. |
|
inlinestatic |
Checks if the directory is empty.
fs | a pointer to the filesystem. |
cache | used for reading. |
inode | the inode of the directory. |
ext2_direntry_iterator_t ext2_direntry_iterator_begin | ( | ext2_filesystem_t * | fs, |
uint8_t * | cache, | ||
ext2_inode_t * | inode | ||
) |
Initializes the iterator and reads the first block.
fs | pointer to the filesystem. |
cache | used for reading. |
inode | pointer to the directory inode. |
ext2_dirent_t* ext2_direntry_iterator_get | ( | ext2_direntry_iterator_t * | it | ) |
Returns the ext2_dirent_t pointed by the iterator.
it | the iterator. |
void ext2_direntry_iterator_next | ( | ext2_direntry_iterator_t * | it | ) |
Moves to the next direntry, and moves to the next block if necessary.
it | the iterator. |
int ext2_direntry_iterator_valid | ( | ext2_direntry_iterator_t * | it | ) |
Check if the iterator is valid.
it | the iterator to check. |
|
static |
Dumps on debugging output the BGDT.
fs | the filesystem of which we print the BGDT. |
|
static |
Dumps on debugging output the dirent.
dirent | the object to dump. |
|
inlinestatic |
Dumps the directory entries inside the parent directory.
fs | A pointer to the filesystem structure. |
cache | A pointer to a memory cache used for EXT2 operations. |
parent_inode | A pointer to the parent inode whose directory entries are to be dumped. |
Initialize the directory entry iterator for the parent directory
Iterate through all directory entries in the parent directory
Dump debug information for the directory entry's block index and offset
Dump detailed information about the current directory entry
|
static |
Dumps on debugging output the filesystem.
fs | the object to dump. |
|
static |
Dumps on debugging output the group descriptor.
gd | the object to dump. |
|
static |
Dumps on debugging output the inode.
fs | a pointer to the filesystem. |
inode | the object to dump. |
|
static |
Dumps on debugging output the superblock.
sb | the object to dump. |
|
static |
Turns an ext2_file_type to string.
ext2_type | the ext2_file_type to turn to string. |
|
static |
Turns the EXT2 file type to OS standard file types.
ext2_type | the EXT2 file type. |
int ext2_finalize | ( | void | ) |
De-initializes the EXT2 drivers.
|
static |
Finds the entry with the given name
inside the directory
.
fs | a pointer to the filesystem. |
ino | the inodex of the directory entry. |
name | the name of the entry we are looking for. |
search | the output variable where we save the info about the entry. |
|
inlinestatic |
Searches for a free block.
fs | the ext2 filesystem structure. |
cache | the cache from which we read the bgdt data. |
group_index | the output variable where we store the group index. |
block_offset | the output variable where we store the linear indes to the free block. |
|
inlinestatic |
Searches for a free block inside the group data loaded inside the cache.
fs | the ext2 filesystem structure. |
cache | the cache from which we read the bgdt data. |
block_offset | the output variable where we store the linear indes to the free block. |
|
inlinestatic |
Searches for a free inode inside the Block Group Descriptor Table (BGDT).
fs | the ext2 filesystem structure. |
cache | the cache from which we read the bgdt data. |
group_index | the output variable where we store the group index. |
group_offset | the output variable where we store the linear indes to the free inode. |
preferred_group | we accept a preferred group, but only if available. |
|
inlinestatic |
Searches for a free inode inside the group data loaded inside the cache.
fs | the ext2 filesystem structure. |
cache | the cache from which we read the bgdt data. |
group_offset | the output variable where we store the linear indes to the free inode. |
skip_reserved | should we skip reserved inodes. |
|
static |
Finds the VFS file that is associated with the given inode index.
fs | a pointer to the fileystem. |
inode | the inode index. |
|
static |
Frees a block.
fs | the filesystem. |
block_index | the index of the block we are freeing. |
|
static |
Frees the given inode.
fs | a pointer to the filesystem. |
inode | the inode we free. |
inode_index | its index. |
|
static |
Set attributes of the file at the given position.
file | The file struct. |
attr | The structure where the attributes are stored. |
|
static |
Retrieves information concerning the file at the given position.
file | The file struct. |
stat | The structure where the information are stored. |
ID of device containing file.
|
inlinestatic |
Searches for a free unused directory entry (inode == 0).
fs | a pointer to the filesystem. |
cache | cache for memory EXT2 operations. |
parent_inode_index | the parent inode index. |
name | the name of the new entry. |
inode_index | its inode index. |
file_type | its file type. |
|
static |
Returns the real block index starting from a block index inside an inode.
fs | the filesystem. |
inode | the inode which we are working with. |
block_index | the block index inside the inode. |
|
inlinestatic |
Returns the rec_len from the given direntry.
direntry | the direntry we use to compute the rec_len. |
|
inlinestatic |
Returns the rec_len from the given name.
name | the name we use to compute the rec_len. |
|
static |
Reads contents of the directories to a dirent buffer, updating the offset and returning the number of written bytes in the buffer, it assumes that all paths are well-formed.
file | The directory handler. |
dirp | The buffer where the data should be written. |
doff | The offset inside the buffer where the data should be written. |
count | The maximum length of the buffer. |
|
static |
Initializes the VFS file.
fs | a pointer to the filesystem. |
file | the file we want to initialize. |
inode | the inode we use to initialize the VFS file. |
inode_index | the inode index. |
name | the name of the file. |
name_len | the length of the name. |
int ext2_initialize | ( | void | ) |
Initializes the EXT2 drivers.
|
inlinestatic |
Initializes a directory entry.
direntry | a pointer to the directory entry we want to initialize. |
name | the name of the new entry. |
inode_index | its inode index. |
rec_len | the length of the new entry. |
file_type | its file type. |
|
inlinestatic |
Initializes a new directory entry block for the specified inode.
fs | Pointer to the ext2 filesystem structure. |
inode_index | The index of the inode for which the directory entry block is to be initialized. |
block_index | The index of the block to be allocated. |
|
static |
Determining the block index from the inode index.
fs | the ext2 filesystem structure. |
inode_index | the inode index. |
|
static |
Determining which block group contains an inode.
fs | the ext2 filesystem structure. |
inode_index | the inode index. |
Remember that inode addressing starts from 1.
|
static |
Determining the offest of the inode inside the inode group.
fs | the ext2 filesystem structure. |
inode_index | the inode index. |
Remember that inode addressing starts from 1.
|
static |
Perform the I/O control operation specified by REQUEST on FD. One argument may follow; its presence and type depend on REQUEST.
file | the file on which we perform the operations. |
request | the device-dependent request code |
data | an untyped pointer to memory. |
|
inlinestatic |
If the real rec_len is different from the on in attribute rec_len, this is the last directory entry.
direntry | the directory entry to check. |
|
static |
Repositions the file offset inside a file.
file | the file we are working with. |
offset | the offest to use for the operation. |
whence | the type of operation. |
|
static |
Creates a new directory at the given path.
path | The path of the new directory. |
permission | The permission of the new directory. |
|
static |
Mounts the block device as an EXT2 filesystem.
block_device | the block device formatted as EXT2. |
path | location where we mount the filesystem. |
|
static |
The mount call-back, which prepares everything and calls the actual EXT2 mount function.
path | the path where the filesystem should be mounted. |
device | the device we mount. |
|
static |
Open the file at the given path and returns its file descriptor.
path | The path to the file. |
flags | The flags used to determine the behavior of the function. |
mode | The mode with which we open the file. |
|
static |
Reads from the file identified by the file descriptor.
file | The file. |
buffer | Buffer where the read content must be placed. |
offset | Offset from which we start reading from the file. |
nbyte | The number of bytes to read. |
|
static |
Reads the Block Group Descriptor Table (BGDT) from the block device associated with this filesystem.
fs | the ext2 filesystem structure. |
|
static |
Read a block from the block device associated with this filesystem.
fs | the ext2 filesystem structure. |
block_index | the index of the block we want to read. |
buffer | the buffer where the content will be placed. |
|
static |
Reads an inode.
fs | the filesystem. |
inode | the inode which we are working with. |
inode_index | The index of the inode. |
|
static |
Reads the real block starting from an inode and the block index inside the inode.
fs | the filesystem. |
inode | the inode which we are working with. |
block_index | the index of the block within the inode. |
buffer | the buffer where to put the data. |
|
static |
Reads the data from the given inode.
fs | the filesystem. |
inode | the inode which we are working with. |
inode_index | the index of the inode. |
offset | the offset from which we start reading the data. |
nbyte | the number of bytes to read. |
buffer | the buffer containing the data. |
|
static |
Reads the superblock from the block device associated with this filesystem.
fs | the ext2 filesystem structure. |
Read the symbolic link, if present.
path | The path to the file for which we want to read the symbolic link information. |
buffer | The buffer where we will store the symbolic link path. |
bufsize | The size of the buffer. |
|
static |
Searches the entry specified in path
starting from directory
.
directory | the directory from which we start performing the search. |
path | the path of the entry we are looking for, it can be a relative path. |
search | the output variable where we save the entry information. |
|
static |
Removes the given directory.
path | The path to the directory to remove. |
|
static |
Sets the real block index based on the block index inside an inode.
fs | the filesystem. |
inode | the inode which we are working with. |
inode_index | thwe inode index. |
block_index | the block index inside the inode. |
real_index | the real block number. |
|
static |
Set attributes of a file.
path | The path where the file resides. |
attr | The structure where the information are stored. |
|
static |
Retrieves information concerning the file at the given position.
path | The path where the file resides. |
stat | The structure where the information are stored. |
ID of device containing file.
|
static |
Delete a name and possibly the file it refers to.
path | The path to the file. |
|
static |
Writes the given content inside the file.
file | The file descriptor of the file. |
buffer | The content to write. |
offset | Offset from which we start writing in the file. |
nbyte | The number of bytes to write. |
|
static |
Writes the Block Group Descriptor Table (BGDT) to the block device associated with this filesystem.
fs | the ext2 filesystem structure. |
|
static |
Writes a block on the block device associated with this filesystem.
fs | the ext2 filesystem structure. |
block_index | the index of the block we want to read. |
buffer | the buffer where the content will be placed. |
|
static |
Writes the inode.
fs | the filesystem. |
inode | the inode which we are working with. |
inode_index | The index of the inode. |
|
static |
Writes the real block starting from an inode and the block index inside the inode.
fs | the filesystem. |
inode | the inode which we are working with. |
inode_index | The index of the inode. |
block_index | the index of the block within the inode. |
buffer | the buffer where to put the data. |
|
static |
Writes the data on the given inode.
fs | the filesystem. |
inode | the inode which we are working with. |
inode_index | the index of the inode. |
offset | the offset from which we start writing the data. |
nbyte | the number of bytes to write. |
buffer | the buffer containing the data. |
|
static |
Writes the superblock on the block device associated with this filesystem.
fs | the ext2 filesystem structure. |
|
static |
Get the ext2 filesystem object starting from a path.
absolute_path | the absolute path for which we want to find the associated EXT2 filesystem. |
|
static |
Turns the time to string.
time | the UNIX time to turn to string. |
|
static |
Turns an UUID to string.
uuid | the UUID to turn to string. |
|
static |
Filesystem information.
|
static |
Filesystem file operations.
|
static |
Filesystem general operations.