summaryrefslogtreecommitdiff
path: root/filesystem/dfs/src
diff options
context:
space:
mode:
authorbernard.xiong <[email protected]>2009-11-15 14:47:26 +0000
committerbernard.xiong <[email protected]>2009-11-15 14:47:26 +0000
commit2ea68440811d431d0e0ab1910d0d1b4a2c4285d7 (patch)
treed192a61e99b302706db68c1e93795457c317f71c /filesystem/dfs/src
parent3344963e4b343950d46217b36bdc6760f06d805f (diff)
add rt_memory_info function in kernel; cleanup code in dfs_posix.c; add Chinese Font(file cached) support in RTGUI;
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@166 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'filesystem/dfs/src')
-rw-r--r--filesystem/dfs/src/dfs_posix.c61
1 files changed, 55 insertions, 6 deletions
diff --git a/filesystem/dfs/src/dfs_posix.c b/filesystem/dfs/src/dfs_posix.c
index 9a903cf790..96ae60e7fb 100644
--- a/filesystem/dfs/src/dfs_posix.c
+++ b/filesystem/dfs/src/dfs_posix.c
@@ -63,16 +63,21 @@ int open(const char *file, int flags, int mode)
|
+------------------------------------------------------------------------------
*/
-int close(int d)
+int close(int fd)
{
int result;
- struct dfs_fd* fd;
+ struct dfs_fd* d;
- fd = fd_get(d);
+ d = fd_get(fd);
+ if (d == RT_NULL)
+ {
+ rt_set_errno(-RT_ERROR);
+ return -1;
+ }
- result = dfile_raw_close(fd);
- fd_put(fd);
- fd_put(fd);
+ result = dfile_raw_close(d);
+ fd_put(d);
+ fd_put(d);
if (result < 0)
{
@@ -100,6 +105,11 @@ int read(int fd, char *buf, int len)
/* get the fd */
d = fd_get(fd);
+ if (d == RT_NULL)
+ {
+ rt_set_errno(-RT_ERROR);
+ return -1;
+ }
result = dfile_raw_read(d, buf, len);
if (result < 0)
@@ -133,6 +143,11 @@ int write(int fd, char *buf, int len)
/* get the fd */
d = fd_get(fd);
+ if (d == RT_NULL)
+ {
+ rt_set_errno(-RT_ERROR);
+ return -1;
+ }
result = dfile_raw_write(d, buf, len);
if (result < 0)
@@ -165,6 +180,11 @@ int lseek(int fd, int offset, int dir)
struct dfs_fd* d;
d = fd_get(fd);
+ if (d == RT_NULL)
+ {
+ rt_set_errno(-RT_ERROR);
+ return -1;
+ }
switch (dir)
{
@@ -391,6 +411,11 @@ struct dfs_dirent* readdir(DIR *d)
struct dfs_fd* fd;
fd = fd_get(d->fd);
+ if (fd == RT_NULL)
+ {
+ rt_set_errno(-RT_ERROR);
+ return RT_NULL;
+ }
if (!d->num || (d->cur += ((struct dfs_dirent*)(d->buf + d->cur))->d_reclen) >= d->num)
{
@@ -428,6 +453,12 @@ rt_off_t telldir(DIR *d)
rt_off_t result;
fd = fd_get(d->fd);
+ if (fd == RT_NULL)
+ {
+ rt_set_errno(-RT_ERROR);
+ return 0;
+ }
+
result = fd->pos - d->num + d->cur;
fd_put(fd);
@@ -450,6 +481,12 @@ void seekdir(DIR *d, rt_off_t offset)
struct dfs_fd* fd;
fd = fd_get(d->fd);
+ if (fd == RT_NULL)
+ {
+ rt_set_errno(-RT_ERROR);
+ return ;
+ }
+
if (dfile_raw_lseek(fd, offset) >= 0) d->num = d->cur = 0;
fd_put(fd);
}
@@ -470,6 +507,12 @@ void rewinddir(DIR *d)
struct dfs_fd* fd;
fd = fd_get(d->fd);
+ if (fd == RT_NULL)
+ {
+ rt_set_errno(-RT_ERROR);
+ return ;
+ }
+
if (dfile_raw_lseek(fd, 0) >= 0) d->num = d->cur = 0;
fd_put(fd);
}
@@ -491,6 +534,12 @@ int closedir(DIR* d)
struct dfs_fd* fd;
fd = fd_get(d->fd);
+ if (fd == RT_NULL)
+ {
+ rt_set_errno(-RT_ERROR);
+ return -1;
+ }
+
result = dfile_raw_close(fd);
fd_put(fd);