summaryrefslogtreecommitdiff
path: root/components/dfs/src
diff options
context:
space:
mode:
author[email protected] <[email protected]>2010-11-17 23:36:33 +0000
committer[email protected] <[email protected]>2010-11-17 23:36:33 +0000
commitd4c03d07cf5e722c32df372c17f625153acabc4b (patch)
tree996e80c39c74b9c849d919fac3d231f0cf739e5e /components/dfs/src
parent32f65989126fbe1fb31013c577c11bbaa46a5e72 (diff)
add fstat implementation.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1057 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/dfs/src')
-rw-r--r--components/dfs/src/dfs_posix.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/components/dfs/src/dfs_posix.c b/components/dfs/src/dfs_posix.c
index 26395aafc6..f1c01605f9 100644
--- a/components/dfs/src/dfs_posix.c
+++ b/components/dfs/src/dfs_posix.c
@@ -257,7 +257,7 @@ int unlink(const char *pathname)
* this function is a POSIX compliant version, which will get file information.
*
* @param file the file name
- * @param buf the the data buffer to save stat description.
+ * @param buf the data buffer to save stat description.
*
* @return 0 on successful, -1 on failed.
*/
@@ -275,6 +275,45 @@ int stat(const char *file, struct stat *buf)
}
/**
+ * this function is a POSIX compliant version, which will get file status.
+ *
+ * @param fildes the file description
+ * @param buf the data buffer to save stat description.
+ */
+int fstat(int fildes, struct stat *buf)
+{
+ int result;
+ struct dfs_fd* d;
+
+ /* get the fd */
+ d = fd_get(fildes);
+ if (d == RT_NULL)
+ {
+ rt_set_errno(-RT_ERROR);
+ return -1;
+ }
+
+ /* it's the root directory */
+ buf->st_dev = 0;
+
+ buf->st_mode = DFS_S_IFREG | DFS_S_IRUSR | DFS_S_IRGRP | DFS_S_IROTH |
+ DFS_S_IWUSR | DFS_S_IWGRP | DFS_S_IWOTH;
+ if (d->type == FT_DIRECTORY)
+ {
+ buf->st_mode &= ~DFS_S_IFREG;
+ buf->st_mode |= DFS_S_IFDIR | DFS_S_IXUSR | DFS_S_IXGRP | DFS_S_IXOTH;
+ }
+
+ buf->st_size = d->size;
+ buf->st_mtime = 0;
+ buf->st_blksize = 512;
+
+ fd_put(d);
+
+ return DFS_STATUS_OK;
+}
+
+/**
* this function is a POSIX compliant version, which will return the
* information about a mounted file system.
*