summaryrefslogtreecommitdiff
path: root/components/dfs/include
diff options
context:
space:
mode:
author[email protected] <[email protected]>2012-12-26 01:12:13 +0000
committer[email protected] <[email protected]>2012-12-26 01:12:13 +0000
commit69521e2c8fa17515a625f96fae138df2c1ca8ba3 (patch)
tree7228654ca2f917870d2f7a0c44cf0e1e33d7495f /components/dfs/include
parentef5c47e6840a2d2cd986f4ecfdde87c9148375b2 (diff)
fixed the coding style in components/dfs
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2530 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/dfs/include')
-rw-r--r--components/dfs/include/dfs.h2
-rw-r--r--components/dfs/include/dfs_def.h384
-rw-r--r--components/dfs/include/dfs_elm.h2
-rw-r--r--components/dfs/include/dfs_file.h8
-rw-r--r--components/dfs/include/dfs_fs.h72
-rw-r--r--components/dfs/include/dfs_init.h2
-rw-r--r--components/dfs/include/dfs_posix.h96
7 files changed, 285 insertions, 281 deletions
diff --git a/components/dfs/include/dfs.h b/components/dfs/include/dfs.h
index 193c8b1678..cc8248699c 100644
--- a/components/dfs/include/dfs.h
+++ b/components/dfs/include/dfs.h
@@ -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
diff --git a/components/dfs/include/dfs_def.h b/components/dfs/include/dfs_def.h
index d467792f2f..c90a9709aa 100644
--- a/components/dfs/include/dfs_def.h
+++ b/components/dfs/include/dfs_def.h
@@ -1,7 +1,7 @@
/*
* File : dfs_def.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
@@ -23,278 +23,278 @@
#define __D_FS__
#endif
-#define DEVICE_GETGEOME 0
-#define DEVICE_GETINFO 1
-#define DEVICE_FORMAT 2
-#define DEVICE_CLEAN_SECTOR 3
+#define DEVICE_GETGEOME 0
+#define DEVICE_GETINFO 1
+#define DEVICE_FORMAT 2
+#define DEVICE_CLEAN_SECTOR 3
/* File flags */
-#define DFS_F_OPEN 0x01000000
-#define DFS_F_DIRECTORY 0x02000000
-#define DFS_F_EOF 0x04000000
-#define DFS_F_ERR 0x08000000
+#define DFS_F_OPEN 0x01000000
+#define DFS_F_DIRECTORY 0x02000000
+#define DFS_F_EOF 0x04000000
+#define DFS_F_ERR 0x08000000
#ifndef DFS_PATH_MAX
-#define DFS_PATH_MAX 256
+#define DFS_PATH_MAX 256
#endif
#ifndef SECTOR_SIZE
-#define SECTOR_SIZE 512
+#define SECTOR_SIZE 512
#endif
#ifndef DFS_FILESYSTEM_TYPES_MAX
-#define DFS_FILESYSTEM_TYPES_MAX 4
+#define DFS_FILESYSTEM_TYPES_MAX 4
#endif
-#define DFS_DEBUG_INFO 0x01
-#define DFS_DEBUG_WARNING 0x02
-#define DFS_DEBUG_ERROR 0x04
-#define DFS_DEBUG_LEVEL (DFS_DEBUG_INFO | DFS_DEBUG_WARNING | DFS_DEBUG_ERROR)
+#define DFS_DEBUG_INFO 0x01
+#define DFS_DEBUG_WARNING 0x02
+#define DFS_DEBUG_ERROR 0x04
+#define DFS_DEBUG_LEVEL (DFS_DEBUG_INFO | DFS_DEBUG_WARNING | DFS_DEBUG_ERROR)
/* #define DFS_DEBUG */
#ifdef DFS_DEBUG
-#define dfs_log(level, x) do { if (level & DFS_DEBUG_LEVEL) \
- {rt_kprintf("DFS %s, %d:", __FUNCTION__, __LINE__); rt_kprintf x; \
- rt_kprintf ("\n");}}while (0)
+#define dfs_log(level, x) do { if (level & DFS_DEBUG_LEVEL) \
+ {rt_kprintf("DFS %s, %d:", __FUNCTION__, __LINE__); rt_kprintf x; \
+ rt_kprintf ("\n");}}while (0)
#else
#define dfs_log(level, x)
#endif
#if defined(RT_USING_NEWLIB)
#include <string.h>
-#include <sys/stat.h> /* used for struct stat */
-#include <sys/statfs.h> /* used for struct statfs */
-#include <sys/errno.h> /* used for error number */
-#include <sys/fcntl.h> /* used for operation flags */
-#include <sys/unistd.h> /* used for SEEK_SET/CUR/END */
-#include <dirent.h> /* used for struct dirent */
+#include <sys/stat.h> /* used for struct stat */
+#include <sys/statfs.h> /* used for struct statfs */
+#include <sys/errno.h> /* used for error number */
+#include <sys/fcntl.h> /* used for operation flags */
+#include <sys/unistd.h> /* used for SEEK_SET/CUR/END */
+#include <dirent.h> /* used for struct dirent */
/* Device error codes */
-#define DFS_STATUS_OK 0 /* no error */
-#define DFS_STATUS_ENOENT ENOENT /* No such file or directory */
-#define DFS_STATUS_EIO EIO /* I/O error */
-#define DFS_STATUS_ENXIO ENXIO /* No such device or address */
-#define DFS_STATUS_EBADF EBADF /* Bad file number */
-#define DFS_STATUS_EAGAIN EAGAIN /* Try again */
-#define DFS_STATUS_ENOMEM ENOMEM /* no memory */
-#define DFS_STATUS_EBUSY EBUSY /* Device or resource busy */
-#define DFS_STATUS_EEXIST EEXIST /* File exists */
-#define DFS_STATUS_EXDEV EXDEV /* Cross-device link */
-#define DFS_STATUS_ENODEV ENODEV /* No such device */
-#define DFS_STATUS_ENOTDIR ENOTDIR /* Not a directory */
-#define DFS_STATUS_EISDIR EISDIR /* Is a directory */
-#define DFS_STATUS_EINVAL EINVAL /* Invalid argument */
-#define DFS_STATUS_ENOSPC ENOSPC /* No space left on device */
-#define DFS_STATUS_EROFS EROFS /* Read-only file system */
-#define DFS_STATUS_ENOSYS ENOSYS /* Function not implemented */
-#define DFS_STATUS_ENOTEMPTY ENOTEMPTY /* Directory not empty */
+#define DFS_STATUS_OK 0 /* no error */
+#define DFS_STATUS_ENOENT ENOENT /* No such file or directory */
+#define DFS_STATUS_EIO EIO /* I/O error */
+#define DFS_STATUS_ENXIO ENXIO /* No such device or address */
+#define DFS_STATUS_EBADF EBADF /* Bad file number */
+#define DFS_STATUS_EAGAIN EAGAIN /* Try again */
+#define DFS_STATUS_ENOMEM ENOMEM /* no memory */
+#define DFS_STATUS_EBUSY EBUSY /* Device or resource busy */
+#define DFS_STATUS_EEXIST EEXIST /* File exists */
+#define DFS_STATUS_EXDEV EXDEV /* Cross-device link */
+#define DFS_STATUS_ENODEV ENODEV /* No such device */
+#define DFS_STATUS_ENOTDIR ENOTDIR /* Not a directory */
+#define DFS_STATUS_EISDIR EISDIR /* Is a directory */
+#define DFS_STATUS_EINVAL EINVAL /* Invalid argument */
+#define DFS_STATUS_ENOSPC ENOSPC /* No space left on device */
+#define DFS_STATUS_EROFS EROFS /* Read-only file system */
+#define DFS_STATUS_ENOSYS ENOSYS /* Function not implemented */
+#define DFS_STATUS_ENOTEMPTY ENOTEMPTY /* Directory not empty */
/* Operation flags */
-#define DFS_O_RDONLY O_RDONLY
-#define DFS_O_WRONLY O_WRONLY
-#define DFS_O_RDWR O_RDWR
-#define DFS_O_ACCMODE O_ACCMODE
-#define DFS_O_CREAT O_CREAT
-#define DFS_O_EXCL O_EXCL
-#define DFS_O_TRUNC O_TRUNC
-#define DFS_O_APPEND O_APPEND
-#define DFS_O_DIRECTORY O_DIRECTORY
+#define DFS_O_RDONLY O_RDONLY
+#define DFS_O_WRONLY O_WRONLY
+#define DFS_O_RDWR O_RDWR
+#define DFS_O_ACCMODE O_ACCMODE
+#define DFS_O_CREAT O_CREAT
+#define DFS_O_EXCL O_EXCL
+#define DFS_O_TRUNC O_TRUNC
+#define DFS_O_APPEND O_APPEND
+#define DFS_O_DIRECTORY O_DIRECTORY
/* Seek flags */
-#define DFS_SEEK_SET SEEK_SET
-#define DFS_SEEK_CUR SEEK_CUR
-#define DFS_SEEK_END SEEK_END
+#define DFS_SEEK_SET SEEK_SET
+#define DFS_SEEK_CUR SEEK_CUR
+#define DFS_SEEK_END SEEK_END
/* Stat codes */
-#define DFS_S_IFMT S_IFMT
-#define DFS_S_IFSOCK S_IFSOCK
-#define DFS_S_IFLNK S_IFLNK
-#define DFS_S_IFREG S_IFREG
-#define DFS_S_IFBLK S_IFBLK
-#define DFS_S_IFDIR S_IFDIR
-#define DFS_S_IFCHR S_IFCHR
-#define DFS_S_IFIFO S_IFIFO
-#define DFS_S_ISUID S_ISUID
-#define DFS_S_ISGID S_ISGID
-#define DFS_S_ISVTX S_ISVTX
+#define DFS_S_IFMT S_IFMT
+#define DFS_S_IFSOCK S_IFSOCK
+#define DFS_S_IFLNK S_IFLNK
+#define DFS_S_IFREG S_IFREG
+#define DFS_S_IFBLK S_IFBLK
+#define DFS_S_IFDIR S_IFDIR
+#define DFS_S_IFCHR S_IFCHR
+#define DFS_S_IFIFO S_IFIFO
+#define DFS_S_ISUID S_ISUID
+#define DFS_S_ISGID S_ISGID
+#define DFS_S_ISVTX S_ISVTX
-#define DFS_S_ISLNK(m) S_ISLNK(m)
-#define DFS_S_ISREG(m) S_ISREG(m)
-#define DFS_S_ISDIR(m) S_ISDIR(m)
-#define DFS_S_ISCHR(m) S_ISCHR(m)
-#define DFS_S_ISBLK(m) S_ISBLK(m)
-#define DFS_S_ISFIFO(m) S_ISFIFO(m)
-#define DFS_S_ISSOCK(m) S_ISSOCK(m)
+#define DFS_S_ISLNK(m) S_ISLNK(m)
+#define DFS_S_ISREG(m) S_ISREG(m)
+#define DFS_S_ISDIR(m) S_ISDIR(m)
+#define DFS_S_ISCHR(m) S_ISCHR(m)
+#define DFS_S_ISBLK(m) S_ISBLK(m)
+#define DFS_S_ISFIFO(m) S_ISFIFO(m)
+#define DFS_S_ISSOCK(m) S_ISSOCK(m)
-#define DFS_S_IRWXU S_IRWXU
-#define DFS_S_IRUSR S_IRUSR
-#define DFS_S_IWUSR S_IWUSR
-#define DFS_S_IXUSR S_IXUSR
+#define DFS_S_IRWXU S_IRWXU
+#define DFS_S_IRUSR S_IRUSR
+#define DFS_S_IWUSR S_IWUSR
+#define DFS_S_IXUSR S_IXUSR
-#define DFS_S_IRWXG S_IRWXG
-#define DFS_S_IRGRP S_IRGRP
-#define DFS_S_IWGRP S_IWGRP
-#define DFS_S_IXGRP S_IXGRP
+#define DFS_S_IRWXG S_IRWXG
+#define DFS_S_IRGRP S_IRGRP
+#define DFS_S_IWGRP S_IWGRP
+#define DFS_S_IXGRP S_IXGRP
-#define DFS_S_IRWXO S_IRWXO
-#define DFS_S_IROTH S_IROTH
-#define DFS_S_IWOTH S_IWOTH
-#define DFS_S_IXOTH S_IXOTH
+#define DFS_S_IRWXO S_IRWXO
+#define DFS_S_IROTH S_IROTH
+#define DFS_S_IWOTH S_IWOTH
+#define DFS_S_IXOTH S_IXOTH
/* Dirent types */
-#define DFS_DT_UNKNOWN DT_UNKNOWN
-#define DFS_DT_REG DT_REG
-#define DFS_DT_DIR DT_DIR
+#define DFS_DT_UNKNOWN DT_UNKNOWN
+#define DFS_DT_REG DT_REG
+#define DFS_DT_DIR DT_DIR
#else
- #ifdef RT_USING_MINILIBC
- #include <string.h>
- #else
- typedef long off_t;
- typedef int mode_t;
- #endif
+ #ifdef RT_USING_MINILIBC
+ #include <string.h>
+ #else
+ typedef long off_t;
+ typedef int mode_t;
+ #endif
/* Device error codes */
-#define DFS_STATUS_OK 0 /* no error */
-#define DFS_STATUS_ENOENT 2 /* No such file or directory */
-#define DFS_STATUS_EIO 5 /* I/O error */
-#define DFS_STATUS_ENXIO 6 /* No such device or address */
-#define DFS_STATUS_EBADF 9 /* Bad file number */
-#define DFS_STATUS_EAGAIN 11 /* Try again */
-#define DFS_STATUS_ENOMEM 12 /* no memory */
-#define DFS_STATUS_EBUSY 16 /* Device or resource busy */
-#define DFS_STATUS_EEXIST 17 /* File exists */
-#define DFS_STATUS_EXDEV 18 /* Cross-device link */
-#define DFS_STATUS_ENODEV 19 /* No such device */
-#define DFS_STATUS_ENOTDIR 20 /* Not a directory */
-#define DFS_STATUS_EISDIR 21 /* Is a directory */
-#define DFS_STATUS_EINVAL 22 /* Invalid argument */
-#define DFS_STATUS_ENOSPC 28 /* No space left on device */
-#define DFS_STATUS_EROFS 30 /* Read-only file system */
-#define DFS_STATUS_ENOSYS 38 /* Function not implemented */
-#define DFS_STATUS_ENOTEMPTY 39 /* Directory not empty */
+#define DFS_STATUS_OK 0 /* no error */
+#define DFS_STATUS_ENOENT 2 /* No such file or directory */
+#define DFS_STATUS_EIO 5 /* I/O error */
+#define DFS_STATUS_ENXIO 6 /* No such device or address */
+#define DFS_STATUS_EBADF 9 /* Bad file number */
+#define DFS_STATUS_EAGAIN 11 /* Try again */
+#define DFS_STATUS_ENOMEM 12 /* no memory */
+#define DFS_STATUS_EBUSY 16 /* Device or resource busy */
+#define DFS_STATUS_EEXIST 17 /* File exists */
+#define DFS_STATUS_EXDEV 18 /* Cross-device link */
+#define DFS_STATUS_ENODEV 19 /* No such device */
+#define DFS_STATUS_ENOTDIR 20 /* Not a directory */
+#define DFS_STATUS_EISDIR 21 /* Is a directory */
+#define DFS_STATUS_EINVAL 22 /* Invalid argument */
+#define DFS_STATUS_ENOSPC 28 /* No space left on device */
+#define DFS_STATUS_EROFS 30 /* Read-only file system */
+#define DFS_STATUS_ENOSYS 38 /* Function not implemented */
+#define DFS_STATUS_ENOTEMPTY 39 /* Directory not empty */
/* Operation flags */
-#define DFS_O_RDONLY 0x0000000
-#define DFS_O_WRONLY 0x0000001
-#define DFS_O_RDWR 0x0000002
-#define DFS_O_ACCMODE 0x0000003
-#define DFS_O_CREAT 0x0000100
-#define DFS_O_EXCL 0x0000200
-#define DFS_O_TRUNC 0x0001000
-#define DFS_O_APPEND 0x0002000
-#define DFS_O_BINARY 0x0008000
-#define DFS_O_DIRECTORY 0x0200000
+#define DFS_O_RDONLY 0x0000000
+#define DFS_O_WRONLY 0x0000001
+#define DFS_O_RDWR 0x0000002
+#define DFS_O_ACCMODE 0x0000003
+#define DFS_O_CREAT 0x0000100
+#define DFS_O_EXCL 0x0000200
+#define DFS_O_TRUNC 0x0001000
+#define DFS_O_APPEND 0x0002000
+#define DFS_O_BINARY 0x0008000
+#define DFS_O_DIRECTORY 0x0200000
/* File flags */
-#define DFS_F_OPEN 0x01000000
-#define DFS_F_DIRECTORY 0x02000000
-#define DFS_F_EOF 0x04000000
-#define DFS_F_ERR 0x08000000
+#define DFS_F_OPEN 0x01000000
+#define DFS_F_DIRECTORY 0x02000000
+#define DFS_F_EOF 0x04000000
+#define DFS_F_ERR 0x08000000
/* Seek flags */
#ifdef __CC_ARM
#include <stdio.h>
-#define DFS_SEEK_SET SEEK_SET
-#define DFS_SEEK_CUR SEEK_CUR
-#define DFS_SEEK_END SEEK_END
+#define DFS_SEEK_SET SEEK_SET
+#define DFS_SEEK_CUR SEEK_CUR
+#define DFS_SEEK_END SEEK_END
#elif defined(_MSC_VER)
#include <stdio.h>
-#define DFS_SEEK_SET SEEK_SET
-#define DFS_SEEK_CUR SEEK_CUR
-#define DFS_SEEK_END SEEK_END
+#define DFS_SEEK_SET SEEK_SET
+#define DFS_SEEK_CUR SEEK_CUR
+#define DFS_SEEK_END SEEK_END
#else
-#define DFS_SEEK_SET 0
-#define DFS_SEEK_CUR 1
-#define DFS_SEEK_END 2
+#define DFS_SEEK_SET 0
+#define DFS_SEEK_CUR 1
+#define DFS_SEEK_END 2
#endif
/* Stat codes */
-#define DFS_S_IFMT 00170000
-#define DFS_S_IFSOCK 0140000
-#define DFS_S_IFLNK 0120000
-#define DFS_S_IFREG 0100000
-#define DFS_S_IFBLK 0060000
-#define DFS_S_IFDIR 0040000
-#define DFS_S_IFCHR 0020000
-#define DFS_S_IFIFO 0010000
-#define DFS_S_ISUID 0004000
-#define DFS_S_ISGID 0002000
-#define DFS_S_ISVTX 0001000
+#define DFS_S_IFMT 00170000
+#define DFS_S_IFSOCK 0140000
+#define DFS_S_IFLNK 0120000
+#define DFS_S_IFREG 0100000
+#define DFS_S_IFBLK 0060000
+#define DFS_S_IFDIR 0040000
+#define DFS_S_IFCHR 0020000
+#define DFS_S_IFIFO 0010000
+#define DFS_S_ISUID 0004000
+#define DFS_S_ISGID 0002000
+#define DFS_S_ISVTX 0001000
-#define DFS_S_ISLNK(m) (((m) & DFS_S_IFMT) == DFS_S_IFLNK)
-#define DFS_S_ISREG(m) (((m) & DFS_S_IFMT) == DFS_S_IFREG)
-#define DFS_S_ISDIR(m) (((m) & DFS_S_IFMT) == DFS_S_IFDIR)
-#define DFS_S_ISCHR(m) (((m) & DFS_S_IFMT) == DFS_S_IFCHR)
-#define DFS_S_ISBLK(m) (((m) & DFS_S_IFMT) == DFS_S_IFBLK)
-#define DFS_S_ISFIFO(m) (((m) & DFS_S_IFMT) == DFS_S_IFIFO)
-#define DFS_S_ISSOCK(m) (((m) & DFS_S_IFMT) == DFS_S_IFSOCK)
+#define DFS_S_ISLNK(m) (((m) & DFS_S_IFMT) == DFS_S_IFLNK)
+#define DFS_S_ISREG(m) (((m) & DFS_S_IFMT) == DFS_S_IFREG)
+#define DFS_S_ISDIR(m) (((m) & DFS_S_IFMT) == DFS_S_IFDIR)
+#define DFS_S_ISCHR(m) (((m) & DFS_S_IFMT) == DFS_S_IFCHR)
+#define DFS_S_ISBLK(m) (((m) & DFS_S_IFMT) == DFS_S_IFBLK)
+#define DFS_S_ISFIFO(m) (((m) & DFS_S_IFMT) == DFS_S_IFIFO)
+#define DFS_S_ISSOCK(m) (((m) & DFS_S_IFMT) == DFS_S_IFSOCK)
-#define DFS_S_IRWXU 00700
-#define DFS_S_IRUSR 00400
-#define DFS_S_IWUSR 00200
-#define DFS_S_IXUSR 00100
+#define DFS_S_IRWXU 00700
+#define DFS_S_IRUSR 00400
+#define DFS_S_IWUSR 00200
+#define DFS_S_IXUSR 00100
-#define DFS_S_IRWXG 00070
-#define DFS_S_IRGRP 00040
-#define DFS_S_IWGRP 00020
-#define DFS_S_IXGRP 00010
+#define DFS_S_IRWXG 00070
+#define DFS_S_IRGRP 00040
+#define DFS_S_IWGRP 00020
+#define DFS_S_IXGRP 00010
-#define DFS_S_IRWXO 00007
-#define DFS_S_IROTH 00004
-#define DFS_S_IWOTH 00002
-#define DFS_S_IXOTH 00001
+#define DFS_S_IRWXO 00007
+#define DFS_S_IROTH 00004
+#define DFS_S_IWOTH 00002
+#define DFS_S_IXOTH 00001
struct stat
{
- rt_device_t st_dev;
- rt_uint16_t st_mode;
- rt_uint32_t st_size;
- rt_time_t st_mtime;
- rt_uint32_t st_blksize;
+ rt_device_t st_dev;
+ rt_uint16_t st_mode;
+ rt_uint32_t st_size;
+ rt_time_t st_mtime;
+ rt_uint32_t st_blksize;
};
struct statfs
{
- rt_size_t f_bsize; /* block size */
- rt_size_t f_blocks; /* total data blocks in file system */
- rt_size_t f_bfree; /* free blocks in file system */
+ rt_size_t f_bsize; /* block size */
+ rt_size_t f_blocks; /* total data blocks in file system */
+ rt_size_t f_bfree; /* free blocks in 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_REGULAR 0 /* regular file */
+#define FT_SOCKET 1 /* socket file */
+#define FT_DIRECTORY 2 /* directory */
+#define FT_USER 3 /* user defined */
/* Dirent types */
-#define DFS_DT_UNKNOWN 0x00
-#define DFS_DT_REG 0x01
-#define DFS_DT_DIR 0x02
+#define DFS_DT_UNKNOWN 0x00
+#define DFS_DT_REG 0x01
+#define DFS_DT_DIR 0x02
struct dirent
{
- rt_uint8_t d_type; /* The type of the file */
- rt_uint8_t d_namlen; /* The length of the not including the terminating null file name */
- rt_uint16_t d_reclen; /* length of this record */
- char d_name[DFS_PATH_MAX]; /* The null-terminated file name */
+ rt_uint8_t d_type; /* The type of the file */
+ rt_uint8_t d_namlen; /* The length of the not including the terminating null file name */
+ rt_uint16_t d_reclen; /* length of this record */
+ char d_name[DFS_PATH_MAX]; /* The null-terminated file name */
};
#endif
/* file descriptor */
struct dfs_fd
{
- char *path; /* Name (below mount point) */
- int type; /* Type (regular or socket) */
- int ref_count; /* Descriptor reference count */
+ char *path; /* Name (below mount point) */
+ int type; /* Type (regular or socket) */
+ int ref_count; /* Descriptor reference count */
- struct dfs_filesystem *fs; /* Resident file system */
+ struct dfs_filesystem *fs; /* Resident file system */
- rt_uint32_t flags; /* Descriptor flags */
- rt_size_t size; /* Size in bytes */
- rt_off_t pos; /* Current file position */
+ rt_uint32_t flags; /* Descriptor flags */
+ rt_size_t size; /* Size in bytes */
+ rt_off_t pos; /* Current file position */
- void *data; /* Specific file system data */
+ void *data; /* Specific file system data */
};
#endif
diff --git a/components/dfs/include/dfs_elm.h b/components/dfs/include/dfs_elm.h
index 656ba07711..18401ef8ee 100644
--- a/components/dfs/include/dfs_elm.h
+++ b/components/dfs/include/dfs_elm.h
@@ -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
diff --git a/components/dfs/include/dfs_file.h b/components/dfs/include/dfs_file.h
index ba5f348605..a3fba3dada 100644
--- a/components/dfs/include/dfs_file.h
+++ b/components/dfs/include/dfs_file.h
@@ -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>
diff --git a/components/dfs/include/dfs_fs.h b/components/dfs/include/dfs_fs.h
index 90a5b50d69..8d77a252e0 100644
--- a/components/dfs/include/dfs_fs.h
+++ b/components/dfs/include/dfs_fs.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 */
diff --git a/components/dfs/include/dfs_init.h b/components/dfs/include/dfs_init.h
index 176d78981c..4c927a8429 100644
--- a/components/dfs/include/dfs_init.h
+++ b/components/dfs/include/dfs_init.h
@@ -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
diff --git a/components/dfs/include/dfs_posix.h b/components/dfs/include/dfs_posix.h
index 503099cff6..c8d15fcf9e 100644
--- a/components/dfs/include/dfs_posix.h
+++ b/components/dfs/include/dfs_posix.h
@@ -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*/