RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
|
#include "errno.h"
#include "fcntl.h"
#include <dfs.h>
#include "dfs_file.h"
#include "dfs_dentry.h"
#include "dfs_fs.h"
#include "dfs_mnt.h"
#include "dfs_private.h"
#include <rtdbg.h>
宏定义 | |
#define | DBG_TAG "DFS.file" |
#define | DBG_LVL DBG_WARNING |
#define | MAX_RW_COUNT 0xfffc0000 |
#define | _COLOR_RED "\033[31m" |
#define | _COLOR_GREEN "\033[32m" |
#define | _COLOR_YELLOW "\033[33m" |
#define | _COLOR_BLUE "\033[34m" |
#define | _COLOR_CYAN "\033[36m" |
#define | _COLOR_WHITE "\033[37m" |
#define | _COLOR_NORMAL "\033[0m" |
#define | BUF_SZ 4096 |
#define | FLAG_SRC_TYPE 0x03 |
#define | FLAG_SRC_IS_DIR 0x01 |
#define | FLAG_SRC_IS_FILE 0x02 |
#define | FLAG_SRC_NON_EXSIT 0x00 |
#define | FLAG_DST_TYPE 0x0C |
#define | FLAG_DST_IS_DIR 0x04 |
#define | FLAG_DST_IS_FILE 0x08 |
#define | FLAG_DST_NON_EXSIT 0x00 |
函数 | |
rt_inline int | _first_path_len (const char *path) |
ssize_t | rw_verify_area (struct dfs_file *file, off_t *ppos, size_t count) |
off_t | dfs_file_get_fpos (struct dfs_file *file) |
void | dfs_file_set_fpos (struct dfs_file *file, off_t fpos) |
void | dfs_file_init (struct dfs_file *file) |
void | dfs_file_deinit (struct dfs_file *file) |
char * | dfs_file_realpath (struct dfs_mnt **mnt, const char *fullpath, int mode) |
int | dfs_file_open (struct dfs_file *file, const char *path, int oflags, mode_t mode) |
int | dfs_file_close (struct dfs_file *file) |
ssize_t | dfs_file_pread (struct dfs_file *file, void *buf, size_t len, off_t offset) |
ssize_t | dfs_file_read (struct dfs_file *file, void *buf, size_t len) |
ssize_t | dfs_file_pwrite (struct dfs_file *file, const void *buf, size_t len, off_t offset) |
ssize_t | dfs_file_write (struct dfs_file *file, const void *buf, size_t len) |
off_t | generic_dfs_lseek (struct dfs_file *file, off_t offset, int whence) |
off_t | dfs_file_lseek (struct dfs_file *file, off_t offset, int wherece) |
int | dfs_file_stat (const char *path, struct stat *buf) |
int | dfs_file_lstat (const char *path, struct stat *buf) |
int | dfs_file_fstat (struct dfs_file *file, struct stat *buf) |
int | dfs_file_setattr (const char *path, struct dfs_attr *attr) |
int | dfs_file_ioctl (struct dfs_file *file, int cmd, void *args) |
int | dfs_file_fcntl (int fd, int cmd, unsigned long arg) |
int | dfs_file_fsync (struct dfs_file *file) |
int | dfs_file_unlink (const char *path) |
int | dfs_file_link (const char *oldname, const char *newname) |
int | dfs_file_symlink (const char *target, const char *linkpath) |
int | dfs_file_readlink (const char *path, char *buf, int bufsize) |
int | dfs_file_rename (const char *old_file, const char *new_file) |
int | dfs_file_ftruncate (struct dfs_file *file, off_t length) |
int | dfs_file_flush (struct dfs_file *file) |
int | dfs_file_getdents (struct dfs_file *file, struct dirent *dirp, size_t nbytes) |
int | dfs_file_isdir (const char *path) |
int | dfs_file_access (const char *path, mode_t mode) |
void | ls (const char *pathname) |
void | cat (const char *filename) |
int | mkdir (const char *path, mode_t mode) |
void | copy (const char *src, const char *dst) |
#define DBG_TAG "DFS.file" |
在文件 dfs_file.c 第 26 行定义.
#define DBG_LVL DBG_WARNING |
在文件 dfs_file.c 第 27 行定义.
#define MAX_RW_COUNT 0xfffc0000 |
在文件 dfs_file.c 第 30 行定义.
#define _COLOR_RED "\033[31m" |
在文件 dfs_file.c 第 1965 行定义.
#define _COLOR_GREEN "\033[32m" |
在文件 dfs_file.c 第 1966 行定义.
#define _COLOR_YELLOW "\033[33m" |
在文件 dfs_file.c 第 1967 行定义.
#define _COLOR_BLUE "\033[34m" |
在文件 dfs_file.c 第 1968 行定义.
#define _COLOR_CYAN "\033[36m" |
在文件 dfs_file.c 第 1969 行定义.
#define _COLOR_WHITE "\033[37m" |
在文件 dfs_file.c 第 1970 行定义.
#define _COLOR_NORMAL "\033[0m" |
在文件 dfs_file.c 第 1971 行定义.
#define BUF_SZ 4096 |
在文件 dfs_file.c 第 2179 行定义.
#define FLAG_SRC_TYPE 0x03 |
#define FLAG_SRC_IS_DIR 0x01 |
#define FLAG_SRC_IS_FILE 0x02 |
#define FLAG_SRC_NON_EXSIT 0x00 |
#define FLAG_DST_TYPE 0x0C |
#define FLAG_DST_IS_DIR 0x04 |
#define FLAG_DST_IS_FILE 0x08 |
#define FLAG_DST_NON_EXSIT 0x00 |
rt_inline int _first_path_len | ( | const char * | path | ) |
在文件 dfs_file.c 第 32 行定义.
ssize_t rw_verify_area | ( | struct dfs_file * | file, |
off_t * | ppos, | ||
size_t | count ) |
在文件 dfs_file.c 第 145 行定义.
引用了 MAX_RW_COUNT.
off_t dfs_file_get_fpos | ( | struct dfs_file * | file | ) |
在文件 dfs_file.c 第 162 行定义.
引用了 dfs_file::fpos, dfs_file::pos_lock, rt_mutex_take(), RT_WAITING_FOREVER, dfs_vnode::type , 以及 dfs_file::vnode.
void dfs_file_set_fpos | ( | struct dfs_file * | file, |
off_t | fpos ) |
在文件 dfs_file.c 第 176 行定义.
引用了 dfs_file::fpos, dfs_file::pos_lock, rt_mutex_release(), rt_mutex_take(), RT_WAITING_FOREVER, dfs_vnode::type , 以及 dfs_file::vnode.
void dfs_file_init | ( | struct dfs_file * | file | ) |
在文件 dfs_file.c 第 189 行定义.
引用了 DFS_FD_MAGIC, dfs_file::magic, dfs_file::pos_lock, dfs_file::ref_count, rt_atomic_store, RT_IPC_FLAG_PRIO , 以及 rt_mutex_init().
void dfs_file_deinit | ( | struct dfs_file * | file | ) |
在文件 dfs_file.c 第 200 行定义.
引用了 dfs_file::pos_lock , 以及 rt_mutex_detach().
char * dfs_file_realpath | ( | struct dfs_mnt ** | mnt, |
const char * | fullpath, | ||
int | mode ) |
在文件 dfs_file.c 第 253 行定义.
引用了 _first_path_len(), dfs_mnt_lookup(), DFS_PATH_MAX, DFS_REALPATH_EXCEPT_LAST, DFS_REALPATH_ONLY_LAST, dfs_mnt::fullpath, rt_free(), rt_malloc() , 以及 RT_NULL.
int dfs_file_open | ( | struct dfs_file * | file, |
const char * | path, | ||
int | oflags, | ||
mode_t | mode ) |
this function will open a file which specified by path with specified oflags.
fd | the file descriptor pointer to return the corresponding result. |
path | the specified file path. |
oflags | the oflags for open operator. |
在文件 dfs_file.c 第 409 行定义.
引用了 dfs_vnode::aspace, dfs_filesystem_ops::create_vnode, dfs_filesystem_ops::default_fops, dfs_file::dentry, dfs_dentry_create(), dfs_dentry_insert(), dfs_dentry_lookup(), dfs_dentry_unref(), DFS_F_FREAD, DFS_F_FWRITE, dfs_fflags(), dfs_file_lock(), dfs_file_realpath(), dfs_file_unlock(), dfs_is_mounted(), dfs_mnt_lookup(), dfs_normalize_path(), DFS_REALPATH_EXCEPT_LAST, DFS_REALPATH_ONLY_LAST, DLOG, dfs_file::flags, dfs_file::fops, dfs_vnode::fops, dfs_mnt::fs_ops, dfs_mnt::fullpath, LOG_I, dfs_dentry::mnt, dfs_vnode::mnt, dfs_vnode::mode, dfs_filesystem_ops::name, dfs_file_ops::open, RT_FALSE, rt_free(), RT_NULL, RT_TRUE, dfs_file_ops::truncate, dfs_vnode::type, dfs_dentry::vnode , 以及 dfs_file::vnode.
int dfs_file_close | ( | struct dfs_file * | file | ) |
在文件 dfs_file.c 第 670 行定义.
引用了 dfs_vnode::aspace, dfs_file_ops::close, dfs_file::dentry, dfs_file_lock(), dfs_file_unlock(), DLOG, dfs_file::fops, dfs_mnt::fs_ops, LOG_W, dfs_dentry::mnt, dfs_filesystem_ops::name, dfs_dentry::pathname, dfs_file::ref_count, dfs_vnode::ref_count, rt_atomic_load , 以及 dfs_file::vnode.
ssize_t dfs_file_pread | ( | struct dfs_file * | file, |
void * | buf, | ||
size_t | len, | ||
off_t | offset ) |
在文件 dfs_file.c 第 714 行定义.
引用了 dfs_vnode::aspace, DFS_F_FREAD, dfs_fflags(), dfs_is_mounted(), dfs_file::flags, dfs_file::fops, dfs_vnode::mnt, dfs_file_ops::read, rw_verify_area(), dfs_vnode::type , 以及 dfs_file::vnode.
ssize_t dfs_file_read | ( | struct dfs_file * | file, |
void * | buf, | ||
size_t | len ) |
在文件 dfs_file.c 第 762 行定义.
引用了 dfs_vnode::aspace, DFS_F_FREAD, dfs_fflags(), dfs_file_get_fpos(), dfs_file_set_fpos(), dfs_is_mounted(), dfs_file::flags, dfs_file::fops, dfs_vnode::mnt, dfs_file_ops::read, rw_verify_area(), dfs_vnode::type , 以及 dfs_file::vnode.
ssize_t dfs_file_pwrite | ( | struct dfs_file * | file, |
const void * | buf, | ||
size_t | len, | ||
off_t | offset ) |
在文件 dfs_file.c 第 813 行定义.
引用了 dfs_vnode::aspace, dfs_file::dentry, DFS_F_FWRITE, dfs_fflags(), dfs_is_mounted(), DLOG, dfs_file::flags, dfs_file_ops::flush, dfs_file::fops, dfs_mnt::fs_ops, LOG_W, dfs_dentry::mnt, dfs_vnode::mnt, dfs_filesystem_ops::name, rw_verify_area(), dfs_vnode::type, dfs_file::vnode , 以及 dfs_file_ops::write.
ssize_t dfs_file_write | ( | struct dfs_file * | file, |
const void * | buf, | ||
size_t | len ) |
在文件 dfs_file.c 第 869 行定义.
引用了 dfs_vnode::aspace, dfs_file::dentry, DFS_F_FWRITE, dfs_fflags(), dfs_file_get_fpos(), dfs_file_set_fpos(), dfs_is_mounted(), DLOG, dfs_file::flags, dfs_file_ops::flush, dfs_file::fops, dfs_mnt::fs_ops, LOG_W, dfs_dentry::mnt, dfs_vnode::mnt, dfs_filesystem_ops::name, rw_verify_area(), dfs_vnode::size, dfs_vnode::type, dfs_file::vnode , 以及 dfs_file_ops::write.
off_t generic_dfs_lseek | ( | struct dfs_file * | file, |
off_t | offset, | ||
int | whence ) |
在文件 dfs_file.c 第 940 行定义.
引用了 dfs_file::fpos, dfs_vnode::size , 以及 dfs_file::vnode.
off_t dfs_file_lseek | ( | struct dfs_file * | file, |
off_t | offset, | ||
int | wherece ) |
在文件 dfs_file.c 第 956 行定义.
引用了 dfs_file_get_fpos(), dfs_file_set_fpos(), dfs_is_mounted(), dfs_file::fops, dfs_file_ops::lseek, dfs_vnode::mnt , 以及 dfs_file::vnode.
int dfs_file_stat | ( | const char * | path, |
struct stat * | buf ) |
在文件 dfs_file.c 第 979 行定义.
引用了 dfs_dentry_lookup(), dfs_dentry_unref(), dfs_file_realpath(), dfs_is_mounted(), dfs_mnt_lookup(), dfs_normalize_path(), DFS_REALPATH_EXCEPT_NONE, DLOG, dfs_mnt::fs_ops, dfs_dentry::mnt, dfs_filesystem_ops::name, rt_free(), RT_NULL, dfs_filesystem_ops::stat , 以及 stat().
int dfs_file_lstat | ( | const char * | path, |
struct stat * | buf ) |
在文件 dfs_file.c 第 1033 行定义.
引用了 dfs_dentry_lookup(), dfs_dentry_unref(), dfs_file_realpath(), dfs_is_mounted(), dfs_mnt_lookup(), dfs_normalize_path(), DFS_REALPATH_EXCEPT_LAST, DLOG, dfs_mnt::fs_ops, dfs_dentry::mnt, dfs_filesystem_ops::name, rt_free(), RT_NULL, dfs_filesystem_ops::stat , 以及 stat().
在文件 dfs_file.c 第 1089 行定义.
引用了 dfs_file::fops, dfs_file_ops::ioctl , 以及 stat().
int dfs_file_setattr | ( | const char * | path, |
struct dfs_attr * | attr ) |
在文件 dfs_file.c 第 1112 行定义.
引用了 dfs_dentry_lookup(), dfs_dentry_unref(), dfs_file_realpath(), dfs_is_mounted(), dfs_mnt_lookup(), dfs_normalize_path(), DFS_REALPATH_EXCEPT_LAST, DLOG, dfs_mnt::fs_ops, dfs_dentry::mnt, dfs_filesystem_ops::name, rt_free(), RT_NULL , 以及 dfs_filesystem_ops::setattr.
int dfs_file_ioctl | ( | struct dfs_file * | file, |
int | cmd, | ||
void * | args ) |
在文件 dfs_file.c 第 1162 行定义.
引用了 dfs_is_mounted(), dfs_file::fops, dfs_file_ops::ioctl, dfs_vnode::mnt , 以及 dfs_file::vnode.
int dfs_file_fcntl | ( | int | fd, |
int | cmd, | ||
unsigned long | arg ) |
在文件 dfs_file.c 第 1192 行定义.
引用了 dfs_dup(), fd_get(), dfs_file::flags , 以及 dfs_file::mode.
int dfs_file_fsync | ( | struct dfs_file * | file | ) |
在文件 dfs_file.c 第 1257 行定义.
引用了 dfs_vnode::aspace, dfs_is_mounted(), dfs_file_ops::flush, dfs_file::fops, dfs_vnode::mnt , 以及 dfs_file::vnode.
int dfs_file_unlink | ( | const char * | path | ) |
在文件 dfs_file.c 第 1285 行定义.
引用了 dfs_vnode::aspace, dfs_dentry_lookup(), dfs_dentry_unref(), dfs_file_lock(), dfs_file_realpath(), dfs_file_unlock(), dfs_is_mounted(), dfs_mnt_has_child_mnt(), dfs_mnt_lookup(), dfs_normalize_path(), DFS_REALPATH_EXCEPT_LAST, DLOG, dfs_mnt::fs_ops, dfs_mnt::fullpath, dfs_dentry::mnt, RT_FALSE, rt_free(), RT_NULL, dfs_filesystem_ops::unlink , 以及 dfs_dentry::vnode.
int dfs_file_link | ( | const char * | oldname, |
const char * | newname ) |
在文件 dfs_file.c 第 1373 行定义.
引用了 dfs_dentry_create(), dfs_dentry_lookup(), dfs_dentry_unref(), dfs_file_isdir(), dfs_file_lstat(), dfs_file_realpath(), dfs_is_mounted(), dfs_mnt_lookup(), dfs_normalize_path(), DFS_REALPATH_EXCEPT_LAST, DLOG, dfs_mnt::fs_ops, dfs_filesystem_ops::link, dfs_dentry::mnt, rt_free(), RT_NULL , 以及 stat().
int dfs_file_symlink | ( | const char * | target, |
const char * | linkpath ) |
在文件 dfs_file.c 第 1459 行定义.
引用了 dfs_dentry_lookup(), dfs_dentry_unref(), dfs_file_access(), dfs_file_realpath(), dfs_is_mounted(), dfs_mnt_lookup(), dfs_normalize_path(), DFS_REALPATH_EXCEPT_LAST, DLOG, dfs_mnt::fs_ops, dfs_dentry::mnt, rt_free(), rt_malloc(), RT_NULL , 以及 dfs_filesystem_ops::symlink.
int dfs_file_readlink | ( | const char * | path, |
char * | buf, | ||
int | bufsize ) |
在文件 dfs_file.c 第 1587 行定义.
引用了 dfs_dentry_lookup(), dfs_dentry_unref(), dfs_file_realpath(), dfs_is_mounted(), dfs_mnt_lookup(), dfs_normalize_path(), DFS_REALPATH_EXCEPT_LAST, DLOG, dfs_mnt::fs_ops, dfs_dentry::mnt, dfs_filesystem_ops::readlink, rt_free() , 以及 RT_NULL.
int dfs_file_rename | ( | const char * | old_file, |
const char * | new_file ) |
在文件 dfs_file.c 第 1649 行定义.
引用了 dfs_vnode::aspace, dfs_dentry_create(), dfs_dentry_lookup(), dfs_dentry_unref(), dfs_file_realpath(), dfs_is_mounted(), dfs_mnt_lookup(), dfs_normalize_path(), DFS_REALPATH_EXCEPT_LAST, DLOG, dfs_mnt::fs_ops, dfs_dentry::mnt, dfs_filesystem_ops::rename, rt_free(), RT_NULL , 以及 dfs_dentry::vnode.
int dfs_file_ftruncate | ( | struct dfs_file * | file, |
off_t | length ) |
在文件 dfs_file.c 第 1728 行定义.
引用了 dfs_vnode::aspace, dfs_is_mounted(), dfs_file::fops, dfs_vnode::mnt, dfs_file_ops::truncate , 以及 dfs_file::vnode.
int dfs_file_flush | ( | struct dfs_file * | file | ) |
在文件 dfs_file.c 第 1764 行定义.
引用了 dfs_vnode::aspace, dfs_is_mounted(), dfs_file_ops::flush, dfs_file::fops, dfs_vnode::mnt , 以及 dfs_file::vnode.
int dfs_file_getdents | ( | struct dfs_file * | file, |
struct dirent * | dirp, | ||
size_t | nbytes ) |
在文件 dfs_file.c 第 1800 行定义.
引用了 dfs_file::dentry, dfs_is_mounted(), DLOG, dfs_file::fops, dfs_mnt::fs_ops, dfs_file_ops::getdents, dfs_dentry::mnt, dfs_vnode::mnt, dfs_vnode::mode, dfs_filesystem_ops::name , 以及 dfs_file::vnode.
int dfs_file_isdir | ( | const char * | path | ) |
this function will check the path is it a directory.
path | the file path. |
在文件 dfs_file.c 第 1838 行定义.
引用了 dfs_dentry_lookup(), dfs_dentry_unref(), dfs_file_realpath(), dfs_is_mounted(), dfs_mnt_lookup(), dfs_normalize_path(), DFS_REALPATH_EXCEPT_NONE, DLOG, dfs_mnt::fs_ops, dfs_dentry::mnt, dfs_filesystem_ops::name, rt_free(), RT_NULL, dfs_filesystem_ops::stat , 以及 stat().
int dfs_file_access | ( | const char * | path, |
mode_t | mode ) |
在文件 dfs_file.c 第 1898 行定义.
引用了 dfs_file_close(), dfs_file_deinit(), dfs_file_init(), dfs_file_open() , 以及 dfs_file::mode.
void ls | ( | const char * | pathname | ) |
在文件 dfs_file.c 第 1973 行定义.
引用了 _COLOR_BLUE, _COLOR_CYAN, _COLOR_GREEN, _COLOR_NORMAL, _COLOR_RED, _COLOR_YELLOW, dfs_file_close(), dfs_file_deinit(), dfs_file_getdents(), dfs_file_init(), dfs_file_lstat(), dfs_file_open(), dfs_file_readlink(), dfs_file_realpath(), dfs_mnt_lookup(), dfs_normalize_path(), DFS_PATH_MAX, DFS_REALPATH_EXCEPT_LAST, DLOG, dfs_mnt::fullpath, dfs_mnt::parent, rt_free(), rt_kprintf, rt_malloc(), RT_NULL, stat() , 以及 working_directory.
void cat | ( | const char * | filename | ) |
在文件 dfs_file.c 第 2139 行定义.
引用了 dfs_file_close(), dfs_file_deinit(), dfs_file_init(), dfs_file_isdir(), dfs_file_open(), dfs_file_read(), DLOG , 以及 rt_kprintf.
void copy | ( | const char * | src, |
const char * | dst ) |
在文件 dfs_file.c 第 2321 行定义.
引用了 dfs_file_lstat(), dfs_file_stat(), dfs_normalize_path(), FLAG_DST_IS_DIR, FLAG_DST_IS_FILE, FLAG_DST_NON_EXSIT, FLAG_DST_TYPE, FLAG_SRC_IS_DIR, FLAG_SRC_IS_FILE, mkdir(), rt_free(), rt_kprintf , 以及 stat().