mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-07 00:59:00 +08:00
fixed the coding style in components/dfs
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2530 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : dfs.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
|
||||
+192
-192
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : dfs_elm.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2008-2011, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2008-2012, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : dfs_file.c
|
||||
* File : dfs_file.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
@@ -12,8 +12,8 @@
|
||||
* 2005-01-26 Bernard The first version.
|
||||
*/
|
||||
|
||||
#ifndef __DFS_RAW_H__
|
||||
#define __DFS_RAW_H__
|
||||
#ifndef __DFS_FILE_H__
|
||||
#define __DFS_FILE_H__
|
||||
|
||||
#include <dfs_def.h>
|
||||
#include <dfs.h>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : dfs_fs.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
#include <dfs_def.h>
|
||||
|
||||
#define DFS_FS_FLAG_DEFAULT 0x00 /* default flag */
|
||||
#define DFS_FS_FLAG_FULLPATH 0x01 /* set full path to underlaying file system */
|
||||
#define DFS_FS_FLAG_DEFAULT 0x00 /* default flag */
|
||||
#define DFS_FS_FLAG_FULLPATH 0x01 /* set full path to underlaying file system */
|
||||
|
||||
/* Pre-declaration */
|
||||
struct dfs_filesystem;
|
||||
@@ -27,58 +27,62 @@ struct dfs_fd;
|
||||
/* File system operations struct */
|
||||
struct dfs_filesystem_operation
|
||||
{
|
||||
char *name;
|
||||
rt_uint32_t flags; /* flags for file system operations */
|
||||
char *name;
|
||||
rt_uint32_t flags; /* flags for file system operations */
|
||||
|
||||
/* mount and unmount file system */
|
||||
int (*mount) (struct dfs_filesystem *fs, unsigned long rwflag, const void *data);
|
||||
int (*unmount) (struct dfs_filesystem *fs);
|
||||
/* 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);
|
||||
/* 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 (*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);
|
||||
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 */
|
||||
rt_device_t dev_id; /* Attached device */
|
||||
|
||||
char *path; /* File system mount point */
|
||||
const struct dfs_filesystem_operation *ops; /* Operations for file system type */
|
||||
char *path; /* File system mount point */
|
||||
const struct dfs_filesystem_operation *ops; /* Operations for file system type */
|
||||
|
||||
void *data; /* Specific file system data */
|
||||
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;
|
||||
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);
|
||||
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_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 */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : dfs_init.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : dfs_def.h
|
||||
* File : dfs_posix.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
@@ -21,68 +21,68 @@
|
||||
#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_BINARY DFS_O_BINARY
|
||||
#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_BINARY DFS_O_BINARY
|
||||
#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_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_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_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_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
|
||||
#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>
|
||||
#elif defined(_MSC_VER)
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#define SEEK_SET DFS_SEEK_SET
|
||||
#define SEEK_CUR DFS_SEEK_CUR
|
||||
#define SEEK_END DFS_SEEK_END
|
||||
#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;
|
||||
int fd; /* directory file */
|
||||
char buf[512];
|
||||
int num;
|
||||
int cur;
|
||||
} DIR;
|
||||
|
||||
/* directory api*/
|
||||
|
||||
+192
-191
File diff suppressed because it is too large
Load Diff
+374
-362
File diff suppressed because it is too large
Load Diff
+317
-291
File diff suppressed because it is too large
Load Diff
+372
-360
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user