Skip to content

lib_filesys

pf4 edited this page Sep 4, 2024 · 3 revisions

File System Library

Warning

This page is under construction and may not be accurate... Contact me on Discord @pf4 for details or questions :)

Definitions

#define NULL_SID ((sid_t) {0, 0})
#define ROOT_SID ((sid_t) {1, 0})
#define IS_NULL_SID(sid) (sid.device == 0 && sid.sector == 0)
#define IS_SAME_SID(sid1, sid2) (sid1.device == sid2.device && sid1.sector == sid2.sector)

Directories

fu_is_dir

int fu_is_dir (
    sid_t dir_sid
);

fu_get_dir_content

int fu_get_dir_content (
    sid_t   dir_sid,
    sid_t **ids,
    char ***names
);

fu_add_element_to_dir

int fu_add_element_to_dir (
    sid_t dir_sid,
    sid_t element_sid,
    char *name
);

fu_remove_element_from_dir

int fu_remove_element_from_dir (
    sid_t dir_sid,
    sid_t element_sid
);

fu_dir_create

sid_t fu_dir_create (
    int   device_id,
    char *path
);

Files

fu_is_file

int fu_is_file (
    sid_t dir_sid
);

fu_file_create

sid_t fu_file_create (
    int   device_id,
    char *path
);

fu_file_read

int fu_file_read (
    sid_t    file_sid,
    void    *buf,
    uint32_t offset,
    uint32_t size
);

fu_file_write

int fu_file_write (
    sid_t    file_sid,
    void    *buf,
    uint32_t offset,
    uint32_t size
);

fu_file_get_size

#define fu_get_file_size(sid) (c_fs_cnt_get_size(c_fs_get_main(), sid))

fu_file_set_size

#define fu_set_file_size(sid, size) (c_fs_cnt_set_size(c_fs_get_main(), sid, size))

Fctf

fu_is_fctf

int fu_is_fctf (
    sid_t file_sid
);

fu_fctf_create

sid_t fu_fctf_create (
    int   device_id,
    char *path,
    int (*fct) (
        void *,
        uint32_t,
        uint32_t,
        uint8_t
    )
);

fu_fctf_get_addr

uint32_t fu_fctf_get_addr (
    sid_t file_sid
);

fu_fctf_rw

int fu_fctf_rw (
    sid_t    file_sid,
    void    *buf,
    uint32_t offset,
    uint32_t size,
    uint8_t  is_read
);
#define fu_fctf_write(sid, buf, offset, size) (fu_fctf_rw(sid, buf, offset, size, 0))
#define fu_fctf_read(sid, buf, offset, size) (fu_fctf_rw(sid, buf, offset, size, 1))

Utilities

fu_sep_path

void fu_sep_path (
    char  *fullpath,
    char **parent,
    char **cnt
);

fu_path_to_sid

sid_t fu_path_to_sid (
    sid_t from,
    char *path
);

fu_simplify_path

void fu_simplify_path (
    char *path
);

fu_get_vdisk_info

uint32_t *fu_get_vdisk_info (void);