131 lines
2.9 KiB
C
131 lines
2.9 KiB
C
/*----------------------------------------------------------------------------
|
|
* Copyright (c) Fenda Technologies Co., Ltd. 2021. All rights reserved.
|
|
*
|
|
* Description: fs_api_base.c
|
|
*
|
|
* Author: saimen
|
|
*
|
|
* Create: 2024-06-28
|
|
*--------------------------------------------------------------------------*/
|
|
#include "sys_typedef.h"
|
|
#include "sys_config.h"
|
|
#include "fs_api_base.h"
|
|
#include <fcntl.h>
|
|
#include <sys/stat.h>
|
|
#include <unistd.h>
|
|
#include "dirent.h"
|
|
|
|
/**********************************************************************************************************************
|
|
* DEFINE
|
|
*/
|
|
#define ENABLE_STATIC_PRINT false
|
|
#define static_print_error(...) sys_fs_log_e(__VA_ARGS__) //错误信息打印一般常开
|
|
#define static_print_warn(...) sys_fs_log_w(__VA_ARGS__) //警告信息打印一般常开
|
|
#if ENABLE_STATIC_PRINT
|
|
#define static_print_debug(...) sys_fs_log_d(__VA_ARGS__)
|
|
#else
|
|
#define static_print_debug(...)
|
|
#endif
|
|
|
|
/**********************************************************************************************************************
|
|
* PUBLIC FUNCTIONS
|
|
*/
|
|
int tjd_fs_api_used(char *dev)
|
|
{
|
|
int ret = RET_SUCCESS;
|
|
return ret;
|
|
}
|
|
|
|
int tjd_fs_api_unused(char *dev)
|
|
{
|
|
int ret = RET_SUCCESS;
|
|
return ret;
|
|
}
|
|
|
|
int tjd_fs_api_total(char *dev)
|
|
{
|
|
int ret = RET_SUCCESS;
|
|
return ret;
|
|
}
|
|
|
|
int tjd_fs_api_file_open(const char *path, int flags, int *file_index)
|
|
{
|
|
int ret = RET_SUCCESS;
|
|
*file_index = open(path, flags);
|
|
if(*file_index < 0){
|
|
ret = RET_ERROR;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int tjd_fs_api_file_close(int file_index)
|
|
{
|
|
return close(file_index);
|
|
}
|
|
|
|
int tjd_fs_api_file_write(int file_index, void *buffer, uint32_t size)
|
|
{
|
|
return write(file_index, buffer, size);
|
|
}
|
|
|
|
int tjd_fs_api_file_read(int file_index, void *buffer, uint32_t size)
|
|
{
|
|
return read(file_index, buffer, size);
|
|
}
|
|
|
|
/*
|
|
flags 的值选择如下
|
|
#define SEEK_SET 0
|
|
#define SEEK_CUR 1
|
|
#define SEEK_END 2
|
|
#define SEEK_DATA 3
|
|
#define SEEK_HOLE 4
|
|
*/
|
|
int tjd_fs_api_file_seek(int file_index, uint32_t oft, int flags)
|
|
{
|
|
return lseek(file_index,oft,flags);
|
|
}
|
|
|
|
int tjd_fs_api_file_truncate(int file_index, uint32_t oft)
|
|
{
|
|
int ret = RET_SUCCESS;
|
|
return ret;
|
|
}
|
|
|
|
int tjd_fs_api_dir_open(const char *path, void* dir)
|
|
{
|
|
int ret = RET_SUCCESS;
|
|
return ret;
|
|
}
|
|
|
|
int tjd_fs_api_dir_close(void* dir)
|
|
{
|
|
int ret = RET_SUCCESS;
|
|
return ret;
|
|
}
|
|
|
|
int tjd_fs_api_dir_read(void* dir, void *info)
|
|
{
|
|
int ret = RET_SUCCESS;
|
|
return ret;
|
|
}
|
|
|
|
int tjd_fs_api_dir_create(const char *path)
|
|
{
|
|
int ret = RET_SUCCESS;
|
|
return ret;
|
|
}
|
|
|
|
int tjd_fs_api_unlink(const char *path)
|
|
{
|
|
int ret = RET_SUCCESS;
|
|
ret = unlink(path);
|
|
return ret;
|
|
}
|
|
|
|
int tjd_fs_api_rename(const char *oldpath, const char *newpath)
|
|
{
|
|
int ret = RET_SUCCESS;
|
|
return ret;
|
|
}
|