فهرست منبع

change dfs_stat/dfs_statfs to _stat/_statfs.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@822 bbd45198-f89e-11dd-88c7-29a3b14d5316
bernard.xiong 14 سال پیش
والد
کامیت
8772a35e3b

+ 0 - 11
components/dfs/SConscript

@@ -10,17 +10,6 @@ src/dfs_file.c
 src/dfs_posix.c
 src/dfs_posix.c
 """)
 """)
 
 
-# DFS-FatFs options
-fatfs = Split("""
-filesystems/fatfs/fatfs_cache.c
-filesystems/fatfs/fatfs_direntry.c
-filesystems/fatfs/fatfs_fat.c
-filesystems/fatfs/fatfs_file.c
-filesystems/fatfs/fatfs_filename.c
-filesystems/fatfs/fatfs_init.c
-filesystems/fatfs_misc.c
-filesystems/fatfs/fatfs_mount.c""")
-
 # DFS-ELMFAT options
 # DFS-ELMFAT options
 elmfat = Split("""
 elmfat = Split("""
 filesystems/elmfat/dfs_elm.c
 filesystems/elmfat/dfs_elm.c

+ 8 - 8
components/dfs/filesystems/elmfat/dfs_elm.c

@@ -134,7 +134,7 @@ int dfs_elm_mkfs(const char* device_name)
 	return -DFS_STATUS_EIO;
 	return -DFS_STATUS_EIO;
 }
 }
 
 
-int dfs_elm_statfs(struct dfs_filesystem* fs, struct dfs_statfs *buf)
+int dfs_elm_statfs(struct dfs_filesystem* fs, struct _statfs *buf)
 {
 {
 	FATFS *f;
 	FATFS *f;
 	FRESULT res;
 	FRESULT res;
@@ -373,19 +373,19 @@ int dfs_elm_lseek(struct dfs_fd* file, rt_off_t offset)
 	return elm_result_to_dfs(result);
 	return elm_result_to_dfs(result);
 }
 }
 
 
-int dfs_elm_getdents(struct dfs_fd* file, struct dfs_dirent* dirp, rt_uint32_t count)
+int dfs_elm_getdents(struct dfs_fd* file, struct _dirent* dirp, rt_uint32_t count)
 {
 {
 	DIR* dir;
 	DIR* dir;
 	FILINFO fno;
 	FILINFO fno;
 	FRESULT result;
 	FRESULT result;
 	rt_uint32_t index;
 	rt_uint32_t index;
-	struct dfs_dirent* d;
+	struct _dirent* d;
 
 
 	dir = (DIR*)(file->data);
 	dir = (DIR*)(file->data);
 	RT_ASSERT(dir != RT_NULL);
 	RT_ASSERT(dir != RT_NULL);
 
 
 	/* make integer count */
 	/* make integer count */
-	count = (count / sizeof(struct dfs_dirent)) * sizeof(struct dfs_dirent);
+	count = (count / sizeof(struct _dirent)) * sizeof(struct _dirent);
 	if ( count == 0 ) return -DFS_STATUS_EINVAL;
 	if ( count == 0 ) return -DFS_STATUS_EINVAL;
 
 
 #if _USE_LFN
 #if _USE_LFN
@@ -415,11 +415,11 @@ int dfs_elm_getdents(struct dfs_fd* file, struct dfs_dirent* dirp, rt_uint32_t c
 		else d->d_type &= DFS_DT_REG;
 		else d->d_type &= DFS_DT_REG;
 
 
 		d->d_namlen = rt_strlen(fn);
 		d->d_namlen = rt_strlen(fn);
-		d->d_reclen = (rt_uint16_t)sizeof(struct dfs_dirent);
+		d->d_reclen = (rt_uint16_t)sizeof(struct _dirent);
 		rt_strncpy(d->d_name, fn, rt_strlen(fn) + 1);
 		rt_strncpy(d->d_name, fn, rt_strlen(fn) + 1);
 
 
 		index ++;
 		index ++;
-		if ( index * sizeof(struct dfs_dirent) >= count )
+		if ( index * sizeof(struct _dirent) >= count )
 			break;
 			break;
 	}
 	}
 
 
@@ -430,7 +430,7 @@ int dfs_elm_getdents(struct dfs_fd* file, struct dfs_dirent* dirp, rt_uint32_t c
 	if (index == 0)
 	if (index == 0)
 		return elm_result_to_dfs(result);
 		return elm_result_to_dfs(result);
 
 
-	return index * sizeof(struct dfs_dirent);
+	return index * sizeof(struct _dirent);
 }
 }
 
 
 int dfs_elm_unlink(struct dfs_filesystem* fs, const char* path)
 int dfs_elm_unlink(struct dfs_filesystem* fs, const char* path)
@@ -500,7 +500,7 @@ int dfs_elm_rename(struct dfs_filesystem* fs, const char* oldpath, const char* n
 	return elm_result_to_dfs(result);
 	return elm_result_to_dfs(result);
 }
 }
 
 
-int dfs_elm_stat(struct dfs_filesystem* fs, const char *path, struct dfs_stat *st)
+int dfs_elm_stat(struct dfs_filesystem* fs, const char *path, struct _stat *st)
 {
 {
 	FILINFO file_info;
 	FILINFO file_info;
 	FRESULT result;
 	FRESULT result;

+ 9 - 7
components/dfs/filesystems/nfs/dfs_nfs.c

@@ -717,7 +717,7 @@ int nfs_open(struct dfs_fd* file)
 	return 0;
 	return 0;
 }
 }
 
 
-int nfs_stat(struct dfs_filesystem* fs, const char *path, struct dfs_stat *st)
+int nfs_stat(struct dfs_filesystem* fs, const char *path, struct _stat *st)
 {
 {
 	GETATTR3args args;
 	GETATTR3args args;
 	GETATTR3res res;
 	GETATTR3res res;
@@ -729,6 +729,8 @@ int nfs_stat(struct dfs_filesystem* fs, const char *path, struct dfs_stat *st)
 	RT_ASSERT(fs->data != RT_NULL);
 	RT_ASSERT(fs->data != RT_NULL);
 	nfs = (struct nfs_filesystem *)fs->data;
 	nfs = (struct nfs_filesystem *)fs->data;
 
 
+	rt_kprintf("get path:%s stat\n", path);
+
 	handle = get_handle(nfs, path);
 	handle = get_handle(nfs, path);
 	if(handle == RT_NULL)
 	if(handle == RT_NULL)
 		return -1;
 		return -1;
@@ -975,11 +977,11 @@ int nfs_rename(struct dfs_filesystem* fs, const char *src, const char *dest)
 	return ret;
 	return ret;
 }
 }
 
 
-int nfs_getdents(struct dfs_fd* file, struct dfs_dirent* dirp, rt_uint32_t count)
+int nfs_getdents(struct dfs_fd* file, struct _dirent* dirp, rt_uint32_t count)
 {
 {
 	nfs_dir *dir;
 	nfs_dir *dir;
 	rt_uint32_t index;
 	rt_uint32_t index;
-	struct dfs_dirent* d;
+	struct _dirent* d;
 	struct nfs_filesystem* nfs;
 	struct nfs_filesystem* nfs;
 	char *name;
 	char *name;
 
 
@@ -990,7 +992,7 @@ int nfs_getdents(struct dfs_fd* file, struct dfs_dirent* dirp, rt_uint32_t count
 	nfs = (struct nfs_filesystem *)file->fs->data;
 	nfs = (struct nfs_filesystem *)file->fs->data;
 
 
 	/* make integer count */
 	/* make integer count */
-	count = (count / sizeof(struct dfs_dirent)) * sizeof(struct dfs_dirent);
+	count = (count / sizeof(struct _dirent)) * sizeof(struct _dirent);
 	if ( count == 0 ) return -DFS_STATUS_EINVAL;
 	if ( count == 0 ) return -DFS_STATUS_EINVAL;
 
 
 	index = 0;
 	index = 0;
@@ -1006,15 +1008,15 @@ int nfs_getdents(struct dfs_fd* file, struct dfs_dirent* dirp, rt_uint32_t count
 		d->d_type &= DFS_DT_REG;
 		d->d_type &= DFS_DT_REG;
 
 
 		d->d_namlen = rt_strlen(name);
 		d->d_namlen = rt_strlen(name);
-		d->d_reclen = (rt_uint16_t)sizeof(struct dfs_dirent);
+		d->d_reclen = (rt_uint16_t)sizeof(struct _dirent);
 		rt_strncpy(d->d_name, name, rt_strlen(name) + 1);
 		rt_strncpy(d->d_name, name, rt_strlen(name) + 1);
 
 
 		index ++;
 		index ++;
-		if ( index * sizeof(struct dfs_dirent) >= count )
+		if ( index * sizeof(struct _dirent) >= count )
 			break;
 			break;
 	}
 	}
 
 
-	return index * sizeof(struct dfs_dirent);
+	return index * sizeof(struct _dirent);
 }
 }
 
 
 static const struct dfs_filesystem_operation _nfs = 
 static const struct dfs_filesystem_operation _nfs = 

+ 3 - 4
components/dfs/include/dfs_def.h

@@ -111,7 +111,7 @@
 #define DEVICE_FORMAT 			2
 #define DEVICE_FORMAT 			2
 #define DEVICE_CLEAN_SECTOR 	3
 #define DEVICE_CLEAN_SECTOR 	3
 
 
-struct dfs_stat
+struct _stat
 {
 {
 	rt_device_t st_dev;
 	rt_device_t st_dev;
 	rt_uint16_t st_mode;
 	rt_uint16_t st_mode;
@@ -120,7 +120,7 @@ struct dfs_stat
 	rt_uint32_t st_blksize;
 	rt_uint32_t st_blksize;
 };
 };
 
 
-struct dfs_statfs
+struct _statfs
 {
 {
 	rt_size_t f_bsize; 	 /* block size */
 	rt_size_t f_bsize; 	 /* block size */
 	rt_size_t f_blocks;  /* total data blocks in file system */
 	rt_size_t f_blocks;  /* total data blocks in file system */
@@ -153,13 +153,12 @@ struct dfs_fd
 #define DFS_DT_REG		0x01
 #define DFS_DT_REG		0x01
 #define DFS_DT_DIR		0x02
 #define DFS_DT_DIR		0x02
 
 
-struct dfs_dirent
+struct _dirent
 {
 {
 	rt_uint8_t d_type;				/* The type of the file */
 	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_uint8_t d_namlen;			/* The length of the not including the terminating null file name */
 	rt_uint16_t d_reclen;			/* length of this record */
 	rt_uint16_t d_reclen;			/* length of this record */
 	char d_name[DFS_PATH_MAX];		/* The null-terminated file name */
 	char d_name[DFS_PATH_MAX];		/* The null-terminated file name */
 };
 };
-#define dirent dfs_dirent
 
 
 #endif
 #endif

+ 2 - 2
components/dfs/include/dfs_file.h

@@ -24,11 +24,11 @@ int dfs_file_open(struct dfs_fd* fd, const char *path, int flags);
 int dfs_file_close(struct dfs_fd* fd);
 int dfs_file_close(struct dfs_fd* fd);
 int dfs_file_ioctl(struct dfs_fd* fd, int cmd, void *args);
 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_read(struct dfs_fd* fd, void *buf, rt_size_t len);
-int dfs_file_getdents(struct dfs_fd* fd, struct dfs_dirent* dirp, rt_size_t nbytes);
+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_unlink(const char *path);
 int dfs_file_write(struct dfs_fd* fd, const void *buf, rt_size_t len);
 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_lseek(struct dfs_fd* fd, rt_off_t offset);
-int dfs_file_stat(const char *path, struct dfs_stat *buf);
+int dfs_file_stat(const char *path, struct _stat *buf);
 int dfs_file_rename(const char* oldpath, const char* newpath);
 int dfs_file_rename(const char* oldpath, const char* newpath);
 
 
 #endif
 #endif

+ 4 - 4
components/dfs/include/dfs_fs.h

@@ -33,7 +33,7 @@ struct dfs_filesystem_operation
 
 
 	/* make a file system */
 	/* make a file system */
 	int (*mkfs)     (const char* device_name);
 	int (*mkfs)     (const char* device_name);
-	int (*statfs)   (struct dfs_filesystem* fs, struct dfs_statfs *buf);
+	int (*statfs)   (struct dfs_filesystem* fs, struct _statfs *buf);
 
 
 	int (*open)		(struct dfs_fd* fd);
 	int (*open)		(struct dfs_fd* fd);
 	int (*close)	(struct dfs_fd* fd);
 	int (*close)	(struct dfs_fd* fd);
@@ -42,10 +42,10 @@ struct dfs_filesystem_operation
 	int (*write)	(struct dfs_fd* fd, const 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 (*flush)    (struct dfs_fd* fd);
 	int (*lseek)	(struct dfs_fd* fd, rt_off_t offset);
 	int (*lseek)	(struct dfs_fd* fd, rt_off_t offset);
-	int (*getdents)	(struct dfs_fd* fd, struct dfs_dirent* dirp, rt_uint32_t count);
+	int (*getdents)	(struct dfs_fd* fd, struct _dirent* dirp, rt_uint32_t count);
 
 
 	int (*unlink)	(struct dfs_filesystem* fs, const char* pathname);
 	int (*unlink)	(struct dfs_filesystem* fs, const char* pathname);
-	int (*stat)		(struct dfs_filesystem* fs, const char* filename, struct dfs_stat* buf);
+	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 (*rename)	(struct dfs_filesystem* fs, const char* oldpath, const char* newpath);
 };
 };
 
 
@@ -86,6 +86,6 @@ extern char working_directory[];
 
 
 void dfs_lock(void);
 void dfs_lock(void);
 void dfs_unlock(void);
 void dfs_unlock(void);
-int dfs_statfs(const char* path, struct dfs_statfs* buffer);
+int dfs_statfs(const char* path, struct _statfs* buffer);
 
 
 #endif
 #endif

+ 7 - 11
components/dfs/include/dfs_posix.h

@@ -16,6 +16,7 @@
 #define __DFS_POSIX_H__
 #define __DFS_POSIX_H__
 
 
 #include <dfs_file.h>
 #include <dfs_file.h>
+#include <dfs_def.h>
 
 
 #define O_RDONLY	DFS_O_RDONLY
 #define O_RDONLY	DFS_O_RDONLY
 #define O_WRONLY 	DFS_O_WRONLY
 #define O_WRONLY 	DFS_O_WRONLY
@@ -74,14 +75,9 @@ typedef struct
 	int cur;
 	int cur;
 } DIR;
 } DIR;
 
 
-struct stat
-{
-	struct dfs_stat parent;
-};
-struct statfs
-{
-	struct dfs_statfs parent;
-};
+#define stat _stat
+#define statfs _statfs
+#define dirent _dirent
 
 
 /* file api*/
 /* file api*/
 int open(const char *file, int flags, int mode);
 int open(const char *file, int flags, int mode);
@@ -91,14 +87,14 @@ int write(int fd, char *buf, int len);
 int lseek(int fd, int offset, int dir);
 int lseek(int fd, int offset, int dir);
 int rename(const char* old, const char* new );
 int rename(const char* old, const char* new );
 int unlink(const char *pathname);
 int unlink(const char *pathname);
-int stat(const char *file, struct dfs_stat *buf);
-int statfs(const char *path, struct dfs_statfs *buf);
+int stat(const char *file, struct _stat *buf);
+int statfs(const char *path, struct _statfs *buf);
 
 
 /* directory api*/
 /* directory api*/
 int mkdir (const char *path, rt_uint16_t mode);
 int mkdir (const char *path, rt_uint16_t mode);
 int rmdir(const char *path);
 int rmdir(const char *path);
 DIR* opendir(const char* name);
 DIR* opendir(const char* name);
-struct dfs_dirent* readdir(DIR *d);
+struct _dirent* readdir(DIR *d);
 rt_off_t telldir(DIR *d);
 rt_off_t telldir(DIR *d);
 void seekdir(DIR *d, rt_off_t offset);
 void seekdir(DIR *d, rt_off_t offset);
 void rewinddir(DIR *d);
 void rewinddir(DIR *d);

+ 7 - 7
components/dfs/src/dfs_file.c

@@ -173,7 +173,7 @@ int dfs_file_read(struct dfs_fd* fd, void *buf, rt_size_t len)
  *
  *
  * @return the read dirent, others on failed.
  * @return the read dirent, others on failed.
  */
  */
-int dfs_file_getdents(struct dfs_fd* fd, struct dfs_dirent* dirp, rt_size_t nbytes)
+int dfs_file_getdents(struct dfs_fd* fd, struct _dirent* dirp, rt_size_t nbytes)
 {
 {
 	struct dfs_filesystem* fs;
 	struct dfs_filesystem* fs;
 
 
@@ -298,7 +298,7 @@ int dfs_file_lseek(struct dfs_fd* fd, rt_off_t offset)
  *
  *
  * @return 0 on successful, -1 on failed.
  * @return 0 on successful, -1 on failed.
  */
  */
-int dfs_file_stat(const char *path, struct dfs_stat *buf)
+int dfs_file_stat(const char *path, struct _stat *buf)
 {
 {
 	int result;
 	int result;
 	char* fullpath;
 	char* fullpath;
@@ -422,10 +422,10 @@ __exit:
 #include <finsh.h>
 #include <finsh.h>
 
 
 static struct dfs_fd fd;
 static struct dfs_fd fd;
-static struct dfs_dirent dirent;
+static struct _dirent dirent;
 void ls(const char* pathname)
 void ls(const char* pathname)
 {
 {
-	struct dfs_stat stat;
+	struct _stat stat;
 	int length;
 	int length;
 	char* fullpath;
 	char* fullpath;
 
 
@@ -437,11 +437,11 @@ void ls(const char* pathname)
 		rt_kprintf("Directory %s:\n", pathname);
 		rt_kprintf("Directory %s:\n", pathname);
 		do
 		do
 		{
 		{
-			rt_memset(&dirent, 0, sizeof(struct dfs_dirent));
-			length = dfs_file_getdents(&fd, &dirent, sizeof(struct dfs_dirent));
+			rt_memset(&dirent, 0, sizeof(struct _dirent));
+			length = dfs_file_getdents(&fd, &dirent, sizeof(struct _dirent));
 			if ( length > 0 ) 
 			if ( length > 0 ) 
 			{
 			{
-				rt_memset(&stat, 0, sizeof(struct dfs_stat));
+				rt_memset(&stat, 0, sizeof(struct _stat));
 
 
 				/* build full path for each file */
 				/* build full path for each file */
 				if (pathname[strlen(pathname) - 1] != '/')
 				if (pathname[strlen(pathname) - 1] != '/')

+ 2 - 2
components/dfs/src/dfs_fs.c

@@ -408,7 +408,7 @@ int dfs_mkfs(const char* fs_name, const char* device_name)
  *
  *
  * @return 0 on successful, others on failed.
  * @return 0 on successful, others on failed.
  */
  */
-int dfs_statfs(const char* path, struct dfs_statfs* buffer)
+int dfs_statfs(const char* path, struct _statfs* buffer)
 {
 {
 	struct dfs_filesystem* fs;
 	struct dfs_filesystem* fs;
 
 
@@ -432,7 +432,7 @@ FINSH_FUNCTION_EXPORT(mkfs, make a file system);
 
 
 void df(const char* path)
 void df(const char* path)
 {
 {
-	struct dfs_statfs buffer;
+	struct _statfs buffer;
 
 
 	if (dfs_statfs(path, &buffer) == 0)
 	if (dfs_statfs(path, &buffer) == 0)
 	{
 	{

+ 6 - 6
components/dfs/src/dfs_posix.c

@@ -261,7 +261,7 @@ int unlink(const char *pathname)
  *
  *
  * @return 0 on successful, -1 on failed.
  * @return 0 on successful, -1 on failed.
  */
  */
-int stat(const char *file, struct dfs_stat *buf)
+int stat(const char *file, struct _stat *buf)
 {
 {
 	int result;
 	int result;
 
 
@@ -283,7 +283,7 @@ int stat(const char *file, struct dfs_stat *buf)
  *
  *
  * @return 0 on successful, others on failed.
  * @return 0 on successful, others on failed.
  */
  */
-int statfs(const char *path, struct dfs_statfs *buf)
+int statfs(const char *path, struct _statfs *buf)
 {
 {
 	int result;
 	int result;
 
 
@@ -404,7 +404,7 @@ DIR* opendir(const char* name)
  *
  *
  * @return the next directory entry, NULL on the end of directory or failed.
  * @return the next directory entry, NULL on the end of directory or failed.
  */
  */
-struct dfs_dirent* readdir(DIR *d)
+struct _dirent* readdir(DIR *d)
 {
 {
 	int result;
 	int result;
 	struct dfs_fd* fd;
 	struct dfs_fd* fd;
@@ -416,9 +416,9 @@ struct dfs_dirent* readdir(DIR *d)
 		return RT_NULL;
 		return RT_NULL;
 	}
 	}
 
 
-	if (!d->num || (d->cur += ((struct dfs_dirent*)(d->buf + d->cur))->d_reclen) >= d->num)
+	if (!d->num || (d->cur += ((struct _dirent*)(d->buf + d->cur))->d_reclen) >= d->num)
 	{
 	{
-		result = dfs_file_getdents(fd, (struct dfs_dirent*)d->buf, sizeof(d->buf) - 1);
+		result = dfs_file_getdents(fd, (struct _dirent*)d->buf, sizeof(d->buf) - 1);
 		if (result <= 0)
 		if (result <= 0)
 		{
 		{
 			rt_set_errno(result);
 			rt_set_errno(result);
@@ -432,7 +432,7 @@ struct dfs_dirent* readdir(DIR *d)
 	}
 	}
 
 
 	fd_put(fd);
 	fd_put(fd);
-	return (struct dfs_dirent*)(d->buf+d->cur);
+	return (struct _dirent*)(d->buf+d->cur);
 }
 }
 
 
 /**
 /**