rt-thread-official/components/dfs/include/dfs.h

118 lines
2.6 KiB
C
Raw Normal View History

/*
2021-03-08 18:19:04 +08:00
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2005-02-22 Bernard The first version.
*/
#ifndef __DFS_H__
#define __DFS_H__
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
2021-09-01 21:28:16 +08:00
#include <dirent.h>
2021-09-11 11:07:51 +08:00
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/statfs.h>
2021-08-31 10:27:09 +08:00
#include <sys/time.h>
#include <rtdevice.h>
2021-08-31 10:27:09 +08:00
#ifdef __cplusplus
extern "C" {
#endif
#ifndef DFS_FILESYSTEMS_MAX
2021-09-01 21:28:16 +08:00
#define DFS_FILESYSTEMS_MAX 4
#endif
#ifndef DFS_FD_MAX
2021-09-01 21:28:16 +08:00
#define DFS_FD_MAX 16
#endif
/*
* skip stdin/stdout/stderr normally
*/
#ifndef DFS_STDIO_OFFSET
#define DFS_STDIO_OFFSET 3
#endif
#ifndef DFS_PATH_MAX
2021-09-01 21:28:16 +08:00
#define DFS_PATH_MAX DIRENT_NAME_MAX
#endif
#ifndef SECTOR_SIZE
#define SECTOR_SIZE 512
#endif
#ifndef DFS_FILESYSTEM_TYPES_MAX
#define DFS_FILESYSTEM_TYPES_MAX 2
#endif
#define DFS_FS_FLAG_DEFAULT 0x00 /* default flag */
#define DFS_FS_FLAG_FULLPATH 0x01 /* set full path to underlaying file system */
/* File types */
#define FT_REGULAR 0 /* regular file */
#define FT_SOCKET 1 /* socket file */
#define FT_DIRECTORY 2 /* directory */
#define FT_USER 3 /* user defined */
#define FT_DEVICE 4 /* device */
/* File flags */
#define DFS_F_OPEN 0x01000000
#define DFS_F_DIRECTORY 0x02000000
#define DFS_F_EOF 0x04000000
#define DFS_F_ERR 0x08000000
struct dfs_fdtable
{
uint32_t maxfd;
struct dfs_fd **fds;
};
/* Initialization of dfs */
int dfs_init(void);
2013-06-23 07:53:19 +08:00
char *dfs_normalize_path(const char *directory, const char *filename);
const char *dfs_subdir(const char *directory, const char *filename);
2021-11-16 00:22:49 +08:00
int fd_is_open(const char *pathname);
struct dfs_fdtable *dfs_fdtable_get(void);
void dfs_lock(void);
void dfs_unlock(void);
void dfs_fd_lock(void);
void dfs_fd_unlock(void);
void dfs_fm_lock(void);
void dfs_fm_unlock(void);
2021-11-16 00:22:49 +08:00
#ifdef DFS_USING_POSIX
/* FD APIs */
int fdt_fd_new(struct dfs_fdtable *fdt);
struct dfs_fd *fdt_fd_get(struct dfs_fdtable* fdt, int fd);
void fdt_fd_release(struct dfs_fdtable* fdt, int fd);
int fd_new(void);
int fd_associate(struct dfs_fdtable *fdt, int fd, struct dfs_fd *file);
struct dfs_fd *fd_get(int fd);
int fd_get_fd_index(struct dfs_fd *file);
void fd_release(int fd);
void fd_init(struct dfs_fd *fd);
struct dfs_fdtable *dfs_fdtable_get(void);
struct dfs_fdtable *dfs_fdtable_get_global(void);
2021-11-16 00:22:49 +08:00
#endif /* DFS_USING_POSIX */
#ifdef __cplusplus
}
#endif
#endif