Ext
 All Files Functions
Functions
methods.h File Reference

Contains useful methods to work with FS. More...

#include <string.h>
#include <stdio.h>
#include "superblock.h"
#include "block.h"
#include "inode.h"

Go to the source code of this file.

Functions

uint16_t create_dir_helper (int fd, const struct superblock *superblock, uint16_t parent_node_id, bool is_root)
 Helper for create new directory Creates dir with parent = parent_node_id (or itself if is_root). Push to new dir records about "." and "..". More...
 
uint16_t create_file_helper (int fd, const struct superblock *superblock, uint16_t parent_node_id)
 Helper for create new file Creates file with parent = parent_node_id. More...
 
uint16_t get_inode_id_of_dir (int fd, const char *path, const struct superblock *superblock)
 Parse path and find inode of this dir. More...
 
bool is_dir_exist (int fd, struct inode *inode, const char *dirname, const struct superblock *superblock)
 Check if dir exists in inode. More...
 
uint16_t get_file_inode_id (int fd, struct inode *inode, const char *dirname, const struct superblock *superblock)
 Return inode_id of file. More...
 

Detailed Description

Contains useful methods to work with FS.

Author
yaishenka
Date
13.03.2021

Definition in file methods.h.

Function Documentation

uint16_t create_dir_helper ( const int  fd,
const struct superblock *  superblock,
uint16_t  parent_node_id,
bool  is_root 
)

Helper for create new directory Creates dir with parent = parent_node_id (or itself if is_root). Push to new dir records about "." and "..".

Parameters
fdopened fd
superblock
parent_node_idparent of new dir
is_root
Returns
id of new inode if all ok; superblock->fs_info->inodes_count otherwise
Author
yaishenka
Date
12.03.2021

Definition at line 8 of file methods.c.

uint16_t create_file_helper ( int  fd,
const struct superblock *  superblock,
uint16_t  parent_node_id 
)

Helper for create new file Creates file with parent = parent_node_id.

Parameters
fd
superblock
parent_node_id
Returns
id of new inode if all ok; superblock->fs_info->inodes_count otherwise

Definition at line 76 of file methods.c.

uint16_t get_file_inode_id ( int  fd,
struct inode *  inode,
const char *  dirname,
const struct superblock *  superblock 
)

Return inode_id of file.

Parameters
fd
inode
dirname
superblock
Returns
inode_id of file if it exists in this node; superblock->fs_info.inodes_count otherwise

Definition at line 232 of file methods.c.

uint16_t get_inode_id_of_dir ( int  fd,
const char *  path,
const struct superblock *  superblock 
)

Parse path and find inode of this dir.

Parameters
fd
path
superblock
Returns
id of inode of this dir if all ok; superblock->fs_info.inodes_count otherwise

Definition at line 197 of file methods.c.

bool is_dir_exist ( int  fd,
struct inode *  inode,
const char *  dirname,
const struct superblock *  superblock 
)

Check if dir exists in inode.

Parameters
fd
inode
dirname
superblock
Returns

Definition at line 210 of file methods.c.