mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-25 14:28:20 +08:00
change to UNIX end of line.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1746 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
@@ -1,37 +1,37 @@
|
||||
/*
|
||||
* File : dfs.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2010, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2005-02-22 Bernard The first version.
|
||||
*/
|
||||
|
||||
#ifndef __DFS_H__
|
||||
#define __DFS_H__
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
char* dfs_normalize_path(const char* directory, const char* filename);
|
||||
const char* dfs_subdir(const char* directory, const char* filename);
|
||||
|
||||
/* FD APIs */
|
||||
int fd_new(void);
|
||||
struct dfs_fd* fd_get(int fd);
|
||||
void fd_put(struct dfs_fd* fd);
|
||||
int fd_is_open(const char* pathname);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/*
|
||||
* File : dfs.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2010, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2005-02-22 Bernard The first version.
|
||||
*/
|
||||
|
||||
#ifndef __DFS_H__
|
||||
#define __DFS_H__
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
char* dfs_normalize_path(const char* directory, const char* filename);
|
||||
const char* dfs_subdir(const char* directory, const char* filename);
|
||||
|
||||
/* FD APIs */
|
||||
int fd_new(void);
|
||||
struct dfs_fd* fd_get(int fd);
|
||||
void fd_put(struct dfs_fd* fd);
|
||||
int fd_is_open(const char* pathname);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
/*
|
||||
+------------------------------------------------------------------------------
|
||||
| Project : Device Filesystem
|
||||
+------------------------------------------------------------------------------
|
||||
| Copyright 2004, 2005 www.fayfayspace.org.
|
||||
| All rights reserved.
|
||||
|------------------------------------------------------------------------------
|
||||
| File : dfs_efs.h
|
||||
|------------------------------------------------------------------------------
|
||||
| Chang Logs:
|
||||
| Date Author Notes
|
||||
| 2010-02-06 Bernard Add elm_init function declaration
|
||||
+------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef __DFS_ELM_H__
|
||||
#define __DFS_ELM_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int elm_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/*
|
||||
+------------------------------------------------------------------------------
|
||||
| Project : Device Filesystem
|
||||
+------------------------------------------------------------------------------
|
||||
| Copyright 2004, 2005 www.fayfayspace.org.
|
||||
| All rights reserved.
|
||||
|------------------------------------------------------------------------------
|
||||
| File : dfs_efs.h
|
||||
|------------------------------------------------------------------------------
|
||||
| Chang Logs:
|
||||
| Date Author Notes
|
||||
| 2010-02-06 Bernard Add elm_init function declaration
|
||||
+------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef __DFS_ELM_H__
|
||||
#define __DFS_ELM_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int elm_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
/*
|
||||
+------------------------------------------------------------------------------
|
||||
| Project : Device Filesystem
|
||||
+------------------------------------------------------------------------------
|
||||
| Copyright 2004, 2005 www.fayfayspace.org.
|
||||
| All rights reserved.
|
||||
|------------------------------------------------------------------------------
|
||||
| File : dfs_raw.h, the raw APIs of Device FileSystem
|
||||
|------------------------------------------------------------------------------
|
||||
| Chang Logs:
|
||||
| Date Author Notes
|
||||
| 2005-01-26 ffxz The first version
|
||||
+------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef __DFS_RAW_H__
|
||||
#define __DFS_RAW_H__
|
||||
|
||||
#include <dfs_def.h>
|
||||
#include <dfs.h>
|
||||
#include <dfs_fs.h>
|
||||
|
||||
int dfs_file_open(struct dfs_fd* fd, const char *path, int flags);
|
||||
int dfs_file_close(struct dfs_fd* fd);
|
||||
int dfs_file_ioctl(struct dfs_fd* fd, int cmd, void *args);
|
||||
int dfs_file_read(struct dfs_fd* fd, void *buf, rt_size_t len);
|
||||
int dfs_file_getdents(struct dfs_fd* fd, struct dirent* dirp, rt_size_t nbytes);
|
||||
int dfs_file_unlink(const char *path);
|
||||
int dfs_file_write(struct dfs_fd* fd, const void *buf, rt_size_t len);
|
||||
int dfs_file_lseek(struct dfs_fd* fd, rt_off_t offset);
|
||||
int dfs_file_stat(const char *path, struct stat *buf);
|
||||
int dfs_file_rename(const char* oldpath, const char* newpath);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
+------------------------------------------------------------------------------
|
||||
| Project : Device Filesystem
|
||||
+------------------------------------------------------------------------------
|
||||
| Copyright 2004, 2005 www.fayfayspace.org.
|
||||
| All rights reserved.
|
||||
|------------------------------------------------------------------------------
|
||||
| File : dfs_raw.h, the raw APIs of Device FileSystem
|
||||
|------------------------------------------------------------------------------
|
||||
| Chang Logs:
|
||||
| Date Author Notes
|
||||
| 2005-01-26 ffxz The first version
|
||||
+------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef __DFS_RAW_H__
|
||||
#define __DFS_RAW_H__
|
||||
|
||||
#include <dfs_def.h>
|
||||
#include <dfs.h>
|
||||
#include <dfs_fs.h>
|
||||
|
||||
int dfs_file_open(struct dfs_fd* fd, const char *path, int flags);
|
||||
int dfs_file_close(struct dfs_fd* fd);
|
||||
int dfs_file_ioctl(struct dfs_fd* fd, int cmd, void *args);
|
||||
int dfs_file_read(struct dfs_fd* fd, void *buf, rt_size_t len);
|
||||
int dfs_file_getdents(struct dfs_fd* fd, struct dirent* dirp, rt_size_t nbytes);
|
||||
int dfs_file_unlink(const char *path);
|
||||
int dfs_file_write(struct dfs_fd* fd, const void *buf, rt_size_t len);
|
||||
int dfs_file_lseek(struct dfs_fd* fd, rt_off_t offset);
|
||||
int dfs_file_stat(const char *path, struct stat *buf);
|
||||
int dfs_file_rename(const char* oldpath, const char* newpath);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,89 +1,89 @@
|
||||
/*
|
||||
* File : dfs_fs.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2010, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2005-02-22 Bernard The first version.
|
||||
*/
|
||||
#ifndef __DFS_FS_H__
|
||||
#define __DFS_FS_H__
|
||||
|
||||
#include <dfs_def.h>
|
||||
|
||||
/* Pre-declaration */
|
||||
struct dfs_filesystem;
|
||||
struct dfs_fd;
|
||||
|
||||
/* File system operations struct */
|
||||
struct dfs_filesystem_operation
|
||||
{
|
||||
char *name;
|
||||
|
||||
/* mount and unmount file system */
|
||||
int (*mount) (struct dfs_filesystem* fs, unsigned long rwflag, const void* data);
|
||||
int (*unmount) (struct dfs_filesystem* fs);
|
||||
|
||||
/* make a file system */
|
||||
int (*mkfs) (const char* device_name);
|
||||
int (*statfs) (struct dfs_filesystem* fs, struct statfs *buf);
|
||||
|
||||
int (*open) (struct dfs_fd* fd);
|
||||
int (*close) (struct dfs_fd* fd);
|
||||
int (*ioctl) (struct dfs_fd* fd, int cmd, void *args);
|
||||
int (*read) (struct dfs_fd* fd, void* buf, rt_size_t count);
|
||||
int (*write) (struct dfs_fd* fd, const void* buf, rt_size_t count);
|
||||
int (*flush) (struct dfs_fd* fd);
|
||||
int (*lseek) (struct dfs_fd* fd, rt_off_t offset);
|
||||
int (*getdents) (struct dfs_fd* fd, struct dirent* dirp, rt_uint32_t count);
|
||||
|
||||
int (*unlink) (struct dfs_filesystem* fs, const char* pathname);
|
||||
int (*stat) (struct dfs_filesystem* fs, const char* filename, struct stat* buf);
|
||||
int (*rename) (struct dfs_filesystem* fs, const char* oldpath, const char* newpath);
|
||||
};
|
||||
|
||||
/* Mounted file system */
|
||||
struct dfs_filesystem
|
||||
{
|
||||
rt_device_t dev_id; /* Attached device */
|
||||
|
||||
char* path; /* File system mount point */
|
||||
const struct dfs_filesystem_operation* ops; /* Operations for file system type */
|
||||
|
||||
void *data; /* Specific file system data */
|
||||
};
|
||||
|
||||
/* file system partition table */
|
||||
struct dfs_partition
|
||||
{
|
||||
rt_uint8_t type; /* file system type */
|
||||
rt_off_t offset; /* partition start offset */
|
||||
rt_size_t size; /* partition size */
|
||||
rt_sem_t lock;
|
||||
};
|
||||
|
||||
int dfs_register(const struct dfs_filesystem_operation* ops);
|
||||
struct dfs_filesystem* dfs_filesystem_lookup(const char *path);
|
||||
rt_err_t dfs_filesystem_get_partition(struct dfs_partition* part, rt_uint8_t* buf, rt_uint32_t pindex);
|
||||
|
||||
int dfs_mount(const char* device_name, const char* path,
|
||||
const char* filesystemtype, rt_uint32_t rwflag, const
|
||||
void* data);
|
||||
int dfs_unmount(const char *specialfile);
|
||||
|
||||
/* extern variable */
|
||||
extern const struct dfs_filesystem_operation* filesystem_operation_table[];
|
||||
extern struct dfs_filesystem filesystem_table[];
|
||||
|
||||
extern char working_directory[];
|
||||
|
||||
void dfs_lock(void);
|
||||
void dfs_unlock(void);
|
||||
int dfs_statfs(const char* path, struct statfs* buffer);
|
||||
|
||||
#endif
|
||||
/*
|
||||
* File : dfs_fs.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2010, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2005-02-22 Bernard The first version.
|
||||
*/
|
||||
#ifndef __DFS_FS_H__
|
||||
#define __DFS_FS_H__
|
||||
|
||||
#include <dfs_def.h>
|
||||
|
||||
/* Pre-declaration */
|
||||
struct dfs_filesystem;
|
||||
struct dfs_fd;
|
||||
|
||||
/* File system operations struct */
|
||||
struct dfs_filesystem_operation
|
||||
{
|
||||
char *name;
|
||||
|
||||
/* mount and unmount file system */
|
||||
int (*mount) (struct dfs_filesystem* fs, unsigned long rwflag, const void* data);
|
||||
int (*unmount) (struct dfs_filesystem* fs);
|
||||
|
||||
/* make a file system */
|
||||
int (*mkfs) (const char* device_name);
|
||||
int (*statfs) (struct dfs_filesystem* fs, struct statfs *buf);
|
||||
|
||||
int (*open) (struct dfs_fd* fd);
|
||||
int (*close) (struct dfs_fd* fd);
|
||||
int (*ioctl) (struct dfs_fd* fd, int cmd, void *args);
|
||||
int (*read) (struct dfs_fd* fd, void* buf, rt_size_t count);
|
||||
int (*write) (struct dfs_fd* fd, const void* buf, rt_size_t count);
|
||||
int (*flush) (struct dfs_fd* fd);
|
||||
int (*lseek) (struct dfs_fd* fd, rt_off_t offset);
|
||||
int (*getdents) (struct dfs_fd* fd, struct dirent* dirp, rt_uint32_t count);
|
||||
|
||||
int (*unlink) (struct dfs_filesystem* fs, const char* pathname);
|
||||
int (*stat) (struct dfs_filesystem* fs, const char* filename, struct stat* buf);
|
||||
int (*rename) (struct dfs_filesystem* fs, const char* oldpath, const char* newpath);
|
||||
};
|
||||
|
||||
/* Mounted file system */
|
||||
struct dfs_filesystem
|
||||
{
|
||||
rt_device_t dev_id; /* Attached device */
|
||||
|
||||
char* path; /* File system mount point */
|
||||
const struct dfs_filesystem_operation* ops; /* Operations for file system type */
|
||||
|
||||
void *data; /* Specific file system data */
|
||||
};
|
||||
|
||||
/* file system partition table */
|
||||
struct dfs_partition
|
||||
{
|
||||
rt_uint8_t type; /* file system type */
|
||||
rt_off_t offset; /* partition start offset */
|
||||
rt_size_t size; /* partition size */
|
||||
rt_sem_t lock;
|
||||
};
|
||||
|
||||
int dfs_register(const struct dfs_filesystem_operation* ops);
|
||||
struct dfs_filesystem* dfs_filesystem_lookup(const char *path);
|
||||
rt_err_t dfs_filesystem_get_partition(struct dfs_partition* part, rt_uint8_t* buf, rt_uint32_t pindex);
|
||||
|
||||
int dfs_mount(const char* device_name, const char* path,
|
||||
const char* filesystemtype, rt_uint32_t rwflag, const
|
||||
void* data);
|
||||
int dfs_unmount(const char *specialfile);
|
||||
|
||||
/* extern variable */
|
||||
extern const struct dfs_filesystem_operation* filesystem_operation_table[];
|
||||
extern struct dfs_filesystem filesystem_table[];
|
||||
|
||||
extern char working_directory[];
|
||||
|
||||
void dfs_lock(void);
|
||||
void dfs_unlock(void);
|
||||
int dfs_statfs(const char* path, struct statfs* buffer);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
/*
|
||||
|
||||
+------------------------------------------------------------------------------
|
||||
|
||||
| Project : Device Filesystem
|
||||
|
||||
+------------------------------------------------------------------------------
|
||||
|
||||
| Copyright 2004, 2005 www.fayfayspace.org.
|
||||
|
||||
| All rights reserved.
|
||||
|
||||
|------------------------------------------------------------------------------
|
||||
|
||||
| File : dfs_init.h, the initilization definitions of Device FileSystem
|
||||
|------------------------------------------------------------------------------
|
||||
| Chang Logs:
|
||||
|
||||
| Date Author Notes
|
||||
|
||||
| 2005-02-21 ffxz The first version.
|
||||
+------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef __DFS_INIT_H__
|
||||
#define __DFS_INIT_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* initilization of dfs */
|
||||
void dfs_init(void);
|
||||
|
||||
/* initilization of dfs with filesystem server */
|
||||
void dfs_server_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/*
|
||||
|
||||
+------------------------------------------------------------------------------
|
||||
|
||||
| Project : Device Filesystem
|
||||
|
||||
+------------------------------------------------------------------------------
|
||||
|
||||
| Copyright 2004, 2005 www.fayfayspace.org.
|
||||
|
||||
| All rights reserved.
|
||||
|
||||
|------------------------------------------------------------------------------
|
||||
|
||||
| File : dfs_init.h, the initilization definitions of Device FileSystem
|
||||
|------------------------------------------------------------------------------
|
||||
| Chang Logs:
|
||||
|
||||
| Date Author Notes
|
||||
|
||||
| 2005-02-21 ffxz The first version.
|
||||
+------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef __DFS_INIT_H__
|
||||
#define __DFS_INIT_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* initilization of dfs */
|
||||
void dfs_init(void);
|
||||
|
||||
/* initilization of dfs with filesystem server */
|
||||
void dfs_server_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+116
-116
@@ -1,116 +1,116 @@
|
||||
/*
|
||||
* File : dfs_def.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2010, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2009-05-27 Yi.qiu The first version.
|
||||
* 2010-07-18 Bernard add stat and statfs structure definitions.
|
||||
* 2011-05-16 Yi.qiu Change parameter name of rename, "new" is C++ key word.
|
||||
*/
|
||||
#ifndef __DFS_POSIX_H__
|
||||
#define __DFS_POSIX_H__
|
||||
|
||||
#include <dfs_file.h>
|
||||
#include <dfs_def.h>
|
||||
|
||||
#ifndef RT_USING_NEWLIB
|
||||
#define O_RDONLY DFS_O_RDONLY
|
||||
#define O_WRONLY DFS_O_WRONLY
|
||||
#define O_RDWR DFS_O_RDWR
|
||||
#define O_ACCMODE DFS_O_ACCMODE
|
||||
#define O_CREAT DFS_O_CREAT
|
||||
#define O_EXCL DFS_O_EXCL
|
||||
#define O_TRUNC DFS_O_TRUNC
|
||||
#define O_APPEND DFS_O_APPEND
|
||||
#define O_DIRECTORY DFS_O_DIRECTORY
|
||||
|
||||
#define S_IFMT DFS_S_IFMT
|
||||
#define S_IFSOCK DFS_S_IFSOCK
|
||||
#define S_IFLNK DFS_S_IFLNK
|
||||
#define S_IFREG DFS_S_IFREG
|
||||
#define S_IFBLK DFS_S_IFBLK
|
||||
#define S_IFDIR DFS_S_IFDIR
|
||||
#define S_IFCHR DFS_S_IFCHR
|
||||
#define S_IFIFO DFS_S_IFIFO
|
||||
#define S_ISUID DFS_S_ISUID
|
||||
#define S_ISGID DFS_S_ISGID
|
||||
#define S_ISVTX DFS_S_ISVTX
|
||||
|
||||
#define S_ISLNK(m) (((m) & DFS_S_IFMT) == DFS_S_IFLNK)
|
||||
#define S_ISREG(m) (((m) & DFS_S_IFMT) == DFS_S_IFREG)
|
||||
#define S_ISDIR(m) (((m) & DFS_S_IFMT) == DFS_S_IFDIR)
|
||||
#define S_ISCHR(m) (((m) & DFS_S_IFMT) == DFS_S_IFCHR)
|
||||
#define S_ISBLK(m) (((m) & DFS_S_IFMT) == DFS_S_IFBLK)
|
||||
#define S_ISFIFO(m) (((m) & DFS_S_IFMT) == DFS_S_IFIFO)
|
||||
#define S_ISSOCK(m) (((m) & DFS_S_IFMT) == DFS_S_IFSOCK)
|
||||
|
||||
#define S_IRWXU DFS_S_IRWXU
|
||||
#define S_IRUSR DFS_S_IRUSR
|
||||
#define S_IWUSR DFS_S_IWUSR
|
||||
#define S_IXUSR DFS_S_IXUSR
|
||||
|
||||
#define S_IRWXG DFS_S_IRWXG
|
||||
#define S_IRGRP DFS_S_IRGRP
|
||||
#define S_IWGRP DFS_S_IWGRP
|
||||
#define S_IXGRP DFS_S_IXGRP
|
||||
|
||||
#define S_IRWXO DFS_S_IRWXO
|
||||
#define S_IROTH DFS_S_IROTH
|
||||
#define S_IWOTH DFS_S_IWOTH
|
||||
#define S_IXOTH DFS_S_IXOTH
|
||||
|
||||
#if defined(__CC_ARM)
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#define SEEK_SET DFS_SEEK_SET
|
||||
#define SEEK_CUR DFS_SEEK_CUR
|
||||
#define SEEK_END DFS_SEEK_END
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int fd; /* directory file */
|
||||
char buf[512];
|
||||
int num;
|
||||
int cur;
|
||||
} DIR;
|
||||
|
||||
/* directory api*/
|
||||
int mkdir (const char *path, mode_t mode);
|
||||
DIR* opendir(const char* name);
|
||||
struct dirent* readdir(DIR *d);
|
||||
long telldir(DIR *d);
|
||||
void seekdir(DIR *d, off_t offset);
|
||||
void rewinddir(DIR *d);
|
||||
int closedir(DIR* d);
|
||||
|
||||
#else
|
||||
/* use newlib header file */
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
/* file api*/
|
||||
int open(const char *file, int flags, int mode);
|
||||
int close(int d);
|
||||
int read(int fd, void *buf, size_t len);
|
||||
int write(int fd, const void *buf, size_t len);
|
||||
off_t lseek(int fd, off_t offset, int whence);
|
||||
int rename(const char *from, const char *to);
|
||||
int unlink(const char *pathname);
|
||||
int stat(const char *file, struct stat *buf);
|
||||
int fstat(int fildes, struct stat *buf);
|
||||
int statfs(const char *path, struct statfs *buf);
|
||||
|
||||
/* directory api*/
|
||||
int rmdir(const char *path);
|
||||
int chdir(const char *path);
|
||||
char *getcwd(char *buf, size_t size);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* File : dfs_def.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2010, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2009-05-27 Yi.qiu The first version.
|
||||
* 2010-07-18 Bernard add stat and statfs structure definitions.
|
||||
* 2011-05-16 Yi.qiu Change parameter name of rename, "new" is C++ key word.
|
||||
*/
|
||||
#ifndef __DFS_POSIX_H__
|
||||
#define __DFS_POSIX_H__
|
||||
|
||||
#include <dfs_file.h>
|
||||
#include <dfs_def.h>
|
||||
|
||||
#ifndef RT_USING_NEWLIB
|
||||
#define O_RDONLY DFS_O_RDONLY
|
||||
#define O_WRONLY DFS_O_WRONLY
|
||||
#define O_RDWR DFS_O_RDWR
|
||||
#define O_ACCMODE DFS_O_ACCMODE
|
||||
#define O_CREAT DFS_O_CREAT
|
||||
#define O_EXCL DFS_O_EXCL
|
||||
#define O_TRUNC DFS_O_TRUNC
|
||||
#define O_APPEND DFS_O_APPEND
|
||||
#define O_DIRECTORY DFS_O_DIRECTORY
|
||||
|
||||
#define S_IFMT DFS_S_IFMT
|
||||
#define S_IFSOCK DFS_S_IFSOCK
|
||||
#define S_IFLNK DFS_S_IFLNK
|
||||
#define S_IFREG DFS_S_IFREG
|
||||
#define S_IFBLK DFS_S_IFBLK
|
||||
#define S_IFDIR DFS_S_IFDIR
|
||||
#define S_IFCHR DFS_S_IFCHR
|
||||
#define S_IFIFO DFS_S_IFIFO
|
||||
#define S_ISUID DFS_S_ISUID
|
||||
#define S_ISGID DFS_S_ISGID
|
||||
#define S_ISVTX DFS_S_ISVTX
|
||||
|
||||
#define S_ISLNK(m) (((m) & DFS_S_IFMT) == DFS_S_IFLNK)
|
||||
#define S_ISREG(m) (((m) & DFS_S_IFMT) == DFS_S_IFREG)
|
||||
#define S_ISDIR(m) (((m) & DFS_S_IFMT) == DFS_S_IFDIR)
|
||||
#define S_ISCHR(m) (((m) & DFS_S_IFMT) == DFS_S_IFCHR)
|
||||
#define S_ISBLK(m) (((m) & DFS_S_IFMT) == DFS_S_IFBLK)
|
||||
#define S_ISFIFO(m) (((m) & DFS_S_IFMT) == DFS_S_IFIFO)
|
||||
#define S_ISSOCK(m) (((m) & DFS_S_IFMT) == DFS_S_IFSOCK)
|
||||
|
||||
#define S_IRWXU DFS_S_IRWXU
|
||||
#define S_IRUSR DFS_S_IRUSR
|
||||
#define S_IWUSR DFS_S_IWUSR
|
||||
#define S_IXUSR DFS_S_IXUSR
|
||||
|
||||
#define S_IRWXG DFS_S_IRWXG
|
||||
#define S_IRGRP DFS_S_IRGRP
|
||||
#define S_IWGRP DFS_S_IWGRP
|
||||
#define S_IXGRP DFS_S_IXGRP
|
||||
|
||||
#define S_IRWXO DFS_S_IRWXO
|
||||
#define S_IROTH DFS_S_IROTH
|
||||
#define S_IWOTH DFS_S_IWOTH
|
||||
#define S_IXOTH DFS_S_IXOTH
|
||||
|
||||
#if defined(__CC_ARM)
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#define SEEK_SET DFS_SEEK_SET
|
||||
#define SEEK_CUR DFS_SEEK_CUR
|
||||
#define SEEK_END DFS_SEEK_END
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int fd; /* directory file */
|
||||
char buf[512];
|
||||
int num;
|
||||
int cur;
|
||||
} DIR;
|
||||
|
||||
/* directory api*/
|
||||
int mkdir (const char *path, mode_t mode);
|
||||
DIR* opendir(const char* name);
|
||||
struct dirent* readdir(DIR *d);
|
||||
long telldir(DIR *d);
|
||||
void seekdir(DIR *d, off_t offset);
|
||||
void rewinddir(DIR *d);
|
||||
int closedir(DIR* d);
|
||||
|
||||
#else
|
||||
/* use newlib header file */
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
/* file api*/
|
||||
int open(const char *file, int flags, int mode);
|
||||
int close(int d);
|
||||
int read(int fd, void *buf, size_t len);
|
||||
int write(int fd, const void *buf, size_t len);
|
||||
off_t lseek(int fd, off_t offset, int whence);
|
||||
int rename(const char *from, const char *to);
|
||||
int unlink(const char *pathname);
|
||||
int stat(const char *file, struct stat *buf);
|
||||
int fstat(int fildes, struct stat *buf);
|
||||
int statfs(const char *path, struct statfs *buf);
|
||||
|
||||
/* directory api*/
|
||||
int rmdir(const char *path);
|
||||
int chdir(const char *path);
|
||||
char *getcwd(char *buf, size_t size);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user