unify the components/dfs coding style according to the /documentation/coding_style_cn.txt
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1866 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
701df33436
commit
44a2d720a0
@ -87,7 +87,8 @@ int dfs_elm_mount(struct dfs_filesystem* fs, unsigned long rwflag, const void* d
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == _VOLUMES) return -DFS_STATUS_ENOSPC;
|
||||
if (index == _VOLUMES)
|
||||
return -DFS_STATUS_ENOSPC;
|
||||
|
||||
/* get device */
|
||||
disk[index] = fs->dev_id;
|
||||
@ -185,7 +186,8 @@ int dfs_elm_statfs(struct dfs_filesystem* fs, struct statfs *buf)
|
||||
|
||||
rt_snprintf(driver, sizeof(driver), "%d:", f->drv);
|
||||
res = f_getfree(driver, &fre_clust, &f);
|
||||
if (res) return elm_result_to_dfs(res);
|
||||
if (res)
|
||||
return elm_result_to_dfs(res);
|
||||
|
||||
/* Get total sectors and free sectors */
|
||||
tot_sect = (f->n_fatent - 2) * f->csize;
|
||||
@ -215,9 +217,11 @@ int dfs_elm_open(struct dfs_fd* file)
|
||||
|
||||
/* add path for ELM FatFS driver support */
|
||||
vol = elm_get_vol((FATFS *)file->fs->data);
|
||||
if (vol < 0) return -DFS_STATUS_ENOENT;
|
||||
if (vol < 0)
|
||||
return -DFS_STATUS_ENOENT;
|
||||
drivers_fn = rt_malloc(256);
|
||||
if (drivers_fn == RT_NULL) return -DFS_STATUS_ENOMEM;
|
||||
if (drivers_fn == RT_NULL)
|
||||
return -DFS_STATUS_ENOMEM;
|
||||
|
||||
rt_snprintf(drivers_fn, 256, "%d:%s", vol, file->path);
|
||||
#else
|
||||
@ -267,14 +271,19 @@ int dfs_elm_open(struct dfs_fd* file)
|
||||
{
|
||||
mode = FA_READ;
|
||||
|
||||
if (file->flags & DFS_O_WRONLY) mode |= FA_WRITE;
|
||||
if ((file->flags & DFS_O_ACCMODE) & DFS_O_RDWR) mode |= FA_WRITE;
|
||||
if (file->flags & DFS_O_WRONLY)
|
||||
mode |= FA_WRITE;
|
||||
if ((file->flags & DFS_O_ACCMODE) & DFS_O_RDWR)
|
||||
mode |= FA_WRITE;
|
||||
/* Opens the file, if it is existing. If not, a new file is created. */
|
||||
if (file->flags & DFS_O_CREAT) mode |= FA_OPEN_ALWAYS;
|
||||
if (file->flags & DFS_O_CREAT)
|
||||
mode |= FA_OPEN_ALWAYS;
|
||||
/* Creates a new file. If the file is existing, it is truncated and overwritten. */
|
||||
if (file->flags & DFS_O_TRUNC) mode |= FA_CREATE_ALWAYS;
|
||||
if (file->flags & DFS_O_TRUNC)
|
||||
mode |= FA_CREATE_ALWAYS;
|
||||
/* Creates a new file. The function fails if the file is already existing. */
|
||||
if (file->flags & DFS_O_EXCL) mode |= FA_CREATE_NEW;
|
||||
if (file->flags & DFS_O_EXCL)
|
||||
mode |= FA_CREATE_NEW;
|
||||
|
||||
/* allocate a fd */
|
||||
fd = (FIL *)rt_malloc(sizeof(FIL));
|
||||
@ -363,7 +372,8 @@ int dfs_elm_read(struct dfs_fd* file, void* buf, rt_size_t len)
|
||||
result = f_read(fd, buf, len, &byte_read);
|
||||
/* update position */
|
||||
file->pos = fd->fptr;
|
||||
if (result == FR_OK) return byte_read;
|
||||
if (result == FR_OK)
|
||||
return byte_read;
|
||||
|
||||
return elm_result_to_dfs(result);
|
||||
}
|
||||
@ -386,7 +396,8 @@ int dfs_elm_write(struct dfs_fd* file, const void* buf, rt_size_t len)
|
||||
/* update position and file size */
|
||||
file->pos = fd->fptr;
|
||||
file->size = fd->fsize;
|
||||
if (result == FR_OK) return byte_write;
|
||||
if (result == FR_OK)
|
||||
return byte_write;
|
||||
|
||||
return elm_result_to_dfs(result);
|
||||
}
|
||||
@ -454,7 +465,8 @@ int dfs_elm_getdents(struct dfs_fd* file, struct dirent* dirp, rt_uint32_t count
|
||||
|
||||
/* make integer count */
|
||||
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
|
||||
/* allocate long file name */
|
||||
@ -470,7 +482,8 @@ int dfs_elm_getdents(struct dfs_fd* file, struct dirent* dirp, rt_uint32_t count
|
||||
d = dirp + index;
|
||||
|
||||
result = f_readdir(dir, &fno);
|
||||
if (result != FR_OK || fno.fname[0] == 0) break;
|
||||
if (result != FR_OK || fno.fname[0] == 0)
|
||||
break;
|
||||
|
||||
#if _USE_LFN
|
||||
fn = *fno.lfname? fno.lfname : fno.fname;
|
||||
@ -479,8 +492,10 @@ int dfs_elm_getdents(struct dfs_fd* file, struct dirent* dirp, rt_uint32_t count
|
||||
#endif
|
||||
|
||||
d->d_type = DFS_DT_UNKNOWN;
|
||||
if (fno.fattrib & AM_DIR) d->d_type = DFS_DT_DIR;
|
||||
else d->d_type = DFS_DT_REG;
|
||||
if (fno.fattrib & AM_DIR)
|
||||
d->d_type = DFS_DT_DIR;
|
||||
else
|
||||
d->d_type = DFS_DT_REG;
|
||||
|
||||
d->d_namlen = rt_strlen(fn);
|
||||
d->d_reclen = (rt_uint16_t)sizeof(struct dirent);
|
||||
@ -514,9 +529,11 @@ int dfs_elm_unlink(struct dfs_filesystem* fs, const char* path)
|
||||
|
||||
/* add path for ELM FatFS driver support */
|
||||
vol = elm_get_vol((FATFS *)fs->data);
|
||||
if (vol < 0) return -DFS_STATUS_ENOENT;
|
||||
if (vol < 0)
|
||||
return -DFS_STATUS_ENOENT;
|
||||
drivers_fn = rt_malloc(256);
|
||||
if (drivers_fn == RT_NULL) return -DFS_STATUS_ENOMEM;
|
||||
if (drivers_fn == RT_NULL)
|
||||
return -DFS_STATUS_ENOMEM;
|
||||
|
||||
rt_snprintf(drivers_fn, 256, "%d:%s", vol, path);
|
||||
#else
|
||||
@ -543,10 +560,12 @@ int dfs_elm_rename(struct dfs_filesystem* fs, const char* oldpath, const char* n
|
||||
|
||||
/* add path for ELM FatFS driver support */
|
||||
vol = elm_get_vol((FATFS *)fs->data);
|
||||
if (vol < 0) return -DFS_STATUS_ENOENT;
|
||||
if (vol < 0)
|
||||
return -DFS_STATUS_ENOENT;
|
||||
|
||||
drivers_oldfn = rt_malloc(256);
|
||||
if (drivers_oldfn == RT_NULL) return -DFS_STATUS_ENOMEM;
|
||||
if (drivers_oldfn == RT_NULL)
|
||||
return -DFS_STATUS_ENOMEM;
|
||||
drivers_newfn = newpath;
|
||||
|
||||
rt_snprintf(drivers_oldfn, 256, "%d:%s", vol, oldpath);
|
||||
@ -577,9 +596,11 @@ int dfs_elm_stat(struct dfs_filesystem* fs, const char *path, struct stat *st)
|
||||
|
||||
/* add path for ELM FatFS driver support */
|
||||
vol = elm_get_vol((FATFS *)fs->data);
|
||||
if (vol < 0) return -DFS_STATUS_ENOENT;
|
||||
if (vol < 0)
|
||||
return -DFS_STATUS_ENOENT;
|
||||
drivers_fn = rt_malloc(256);
|
||||
if (drivers_fn == RT_NULL) return -DFS_STATUS_ENOMEM;
|
||||
if (drivers_fn == RT_NULL)
|
||||
return -DFS_STATUS_ENOMEM;
|
||||
|
||||
rt_snprintf(drivers_fn, 256, "%d:%s", vol, path);
|
||||
#else
|
||||
@ -705,7 +726,8 @@ DRESULT disk_ioctl (BYTE drv, BYTE ctrl, void *buff)
|
||||
{
|
||||
rt_device_t device = disk[drv];
|
||||
|
||||
if (device == RT_NULL) return RES_ERROR;
|
||||
if (device == RT_NULL)
|
||||
return RES_ERROR;
|
||||
|
||||
if (ctrl == GET_SECTOR_COUNT)
|
||||
{
|
||||
@ -715,7 +737,8 @@ DRESULT disk_ioctl (BYTE drv, BYTE ctrl, void *buff)
|
||||
rt_device_control(device, RT_DEVICE_CTRL_BLK_GETGEOME, &geometry);
|
||||
|
||||
*(DWORD *)buff = geometry.sector_count;
|
||||
if (geometry.sector_count == 0) return RES_ERROR;
|
||||
if (geometry.sector_count == 0)
|
||||
return RES_ERROR;
|
||||
}
|
||||
else if (ctrl == GET_SECTOR_SIZE)
|
||||
{
|
||||
@ -739,7 +762,7 @@ DRESULT disk_ioctl (BYTE drv, BYTE ctrl, void *buff)
|
||||
return RES_OK;
|
||||
}
|
||||
|
||||
rt_time_t get_fattime()
|
||||
rt_time_t get_fattime(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -770,7 +793,8 @@ int ff_del_syncobj(_SYNC_t m)
|
||||
|
||||
int ff_req_grant(_SYNC_t m)
|
||||
{
|
||||
if (rt_mutex_take(m, _FS_TIMEOUT) == RT_EOK) return RT_TRUE;
|
||||
if (rt_mutex_take(m, _FS_TIMEOUT) == RT_EOK)
|
||||
return RT_TRUE;
|
||||
|
||||
return RT_FALSE;
|
||||
}
|
||||
|
@ -1,3 +1,16 @@
|
||||
/*
|
||||
* File : dfs_nfs.c
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <rtthread.h>
|
||||
#include <dfs_fs.h>
|
||||
@ -54,16 +67,19 @@ static int nfs_parse_host_export(const char* host_export,
|
||||
for (index = 0; index < host_len; index ++)
|
||||
{
|
||||
/* it's end of string, failed */
|
||||
if (host_export[index] == 0) return -1;
|
||||
if (host_export[index] == 0)
|
||||
return -1;
|
||||
|
||||
/* copy to host buffer */
|
||||
if (host_export[index] != ':')
|
||||
host[index] = host_export[index];
|
||||
else break;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
/* host buffer is not enough, failed */
|
||||
if (index == host_len) return -1;
|
||||
if (index == host_len)
|
||||
return -1;
|
||||
|
||||
/* make RT_NULL */
|
||||
host_len = index;
|
||||
@ -263,7 +279,8 @@ rt_bool_t nfs_is_directory(struct nfs_filesystem* nfs, const char* name)
|
||||
|
||||
result = RT_FALSE;
|
||||
handle = get_handle(nfs, name);
|
||||
if(handle == RT_NULL) return RT_FALSE;
|
||||
if (handle == RT_NULL)
|
||||
return RT_FALSE;
|
||||
|
||||
args.object = *handle;
|
||||
|
||||
@ -282,7 +299,8 @@ rt_bool_t nfs_is_directory(struct nfs_filesystem* nfs, const char* name)
|
||||
|
||||
info=&res.GETATTR3res_u.resok.obj_attributes;
|
||||
|
||||
if (info->type == NFS3DIR) result = RT_TRUE;
|
||||
if (info->type == NFS3DIR)
|
||||
result = RT_TRUE;
|
||||
|
||||
xdr_free((xdrproc_t)xdr_GETATTR3res, (char *)&res);
|
||||
xdr_free((xdrproc_t)xdr_nfs_fh3, (char *)handle);
|
||||
@ -531,7 +549,8 @@ int nfs_read(struct dfs_fd* file, void *buf, rt_size_t count)
|
||||
return -1;
|
||||
|
||||
/* end of file */
|
||||
if (fd->eof == TRUE) return 0;
|
||||
if (fd->eof == TRUE)
|
||||
return 0;
|
||||
|
||||
args.file = fd->handle;
|
||||
args.offset = fd->offset;
|
||||
@ -873,7 +892,8 @@ int nfs_unlink(struct dfs_filesystem* fs, const char* path)
|
||||
nfs_fh3 *handle;
|
||||
|
||||
handle = get_dir_handle(nfs, path);
|
||||
if(handle == RT_NULL) return -1;
|
||||
if (handle == RT_NULL)
|
||||
return -1;
|
||||
|
||||
args.object.dir = *handle;
|
||||
args.object.name = strrchr(path, '/') + 1;
|
||||
@ -906,7 +926,8 @@ int nfs_unlink(struct dfs_filesystem* fs, const char* path)
|
||||
nfs_fh3 *handle;
|
||||
|
||||
handle = get_dir_handle(nfs, path);
|
||||
if(handle==RT_NULL) return -1;
|
||||
if (handle == RT_NULL)
|
||||
return -1;
|
||||
|
||||
args.object.dir = *handle;
|
||||
args.object.name = strrchr(path, '/') + 1;
|
||||
@ -1005,7 +1026,8 @@ int nfs_getdents(struct dfs_fd* file, struct dirent* dirp, rt_uint32_t count)
|
||||
|
||||
/* make integer count */
|
||||
count = (count / sizeof(struct dirent)) * sizeof(struct dirent);
|
||||
if ( count == 0 ) return -DFS_STATUS_EINVAL;
|
||||
if (count == 0)
|
||||
return -DFS_STATUS_EINVAL;
|
||||
|
||||
index = 0;
|
||||
while (1)
|
||||
@ -1015,7 +1037,8 @@ int nfs_getdents(struct dfs_fd* file, struct dirent* dirp, rt_uint32_t count)
|
||||
d = dirp + index;
|
||||
|
||||
name = nfs_readdir(nfs, dir);
|
||||
if (name == RT_NULL) break;
|
||||
if (name == RT_NULL)
|
||||
break;
|
||||
|
||||
d->d_type = DFS_DT_REG;
|
||||
|
||||
|
@ -1,3 +1,16 @@
|
||||
/*
|
||||
* File : dfs_nfs.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
*/
|
||||
|
||||
#ifndef __NFS_H__
|
||||
#define __NFS_H__
|
||||
|
||||
|
@ -1,3 +1,16 @@
|
||||
/*
|
||||
* File : dfs_romfs.c
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <dfs.h>
|
||||
#include <dfs_fs.h>
|
||||
@ -7,7 +20,8 @@ int dfs_romfs_mount(struct dfs_filesystem* fs, unsigned long rwflag, const void*
|
||||
{
|
||||
struct romfs_dirent *root_dirent;
|
||||
|
||||
if (data == RT_NULL) return -DFS_STATUS_EIO;
|
||||
if (data == RT_NULL)
|
||||
return -DFS_STATUS_EIO;
|
||||
|
||||
root_dirent = (struct romfs_dirent *)data;
|
||||
fs->data = root_dirent;
|
||||
@ -45,9 +59,11 @@ struct romfs_dirent* dfs_romfs_lookup(struct romfs_dirent* root_dirent, const ch
|
||||
/* get the end position of this subpath */
|
||||
subpath_end = path;
|
||||
/* skip /// */
|
||||
while (*subpath_end && *subpath_end == '/') subpath_end ++;
|
||||
while (*subpath_end && *subpath_end == '/')
|
||||
subpath_end ++;
|
||||
subpath = subpath_end;
|
||||
while ((*subpath_end != '/') && *subpath_end) subpath_end ++;
|
||||
while ((*subpath_end != '/') && *subpath_end)
|
||||
subpath_end ++;
|
||||
|
||||
while (dirent != RT_NULL)
|
||||
{
|
||||
@ -61,9 +77,11 @@ struct romfs_dirent* dfs_romfs_lookup(struct romfs_dirent* root_dirent, const ch
|
||||
dirent_size = dirent[index].size;
|
||||
|
||||
/* skip /// */
|
||||
while (*subpath_end && *subpath_end == '/') subpath_end ++;
|
||||
while (*subpath_end && *subpath_end == '/')
|
||||
subpath_end ++;
|
||||
subpath = subpath_end;
|
||||
while ((*subpath_end != '/') && *subpath_end) subpath_end ++;
|
||||
while ((*subpath_end != '/') && *subpath_end)
|
||||
subpath_end ++;
|
||||
|
||||
if (!(*subpath))
|
||||
{
|
||||
@ -81,14 +99,16 @@ struct romfs_dirent* dfs_romfs_lookup(struct romfs_dirent* root_dirent, const ch
|
||||
else
|
||||
{
|
||||
/* return file dirent */
|
||||
if (subpath != RT_NULL) break; /* not the end of path */
|
||||
if (subpath != RT_NULL)
|
||||
break; /* not the end of path */
|
||||
|
||||
return &dirent[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) break; /* not found */
|
||||
if (!found)
|
||||
break; /* not found */
|
||||
}
|
||||
|
||||
/* not found */
|
||||
@ -146,7 +166,8 @@ int dfs_romfs_open(struct dfs_fd* file)
|
||||
return -DFS_STATUS_EINVAL;
|
||||
|
||||
dirent = dfs_romfs_lookup(root_dirent, file->path, &size);
|
||||
if (dirent == RT_NULL) return -DFS_STATUS_ENOENT;
|
||||
if (dirent == RT_NULL)
|
||||
return -DFS_STATUS_ENOENT;
|
||||
|
||||
/* entry is a directory file type */
|
||||
if (dirent->type == ROMFS_DIRENT_DIR)
|
||||
@ -177,7 +198,8 @@ int dfs_romfs_stat(struct dfs_filesystem* fs, const char *path, struct stat *st)
|
||||
root_dirent = (struct romfs_dirent *)fs->data;
|
||||
dirent = dfs_romfs_lookup(root_dirent, path, &size);
|
||||
|
||||
if (dirent == RT_NULL) return -DFS_STATUS_ENOENT;
|
||||
if (dirent == RT_NULL)
|
||||
return -DFS_STATUS_ENOENT;
|
||||
|
||||
st->st_dev = 0;
|
||||
st->st_mode = DFS_S_IFREG | DFS_S_IRUSR | DFS_S_IRGRP | DFS_S_IROTH |
|
||||
@ -211,7 +233,8 @@ int dfs_romfs_getdents(struct dfs_fd* file, struct dirent* dirp, rt_uint32_t cou
|
||||
|
||||
/* make integer count */
|
||||
count = (count / sizeof(struct dirent));
|
||||
if ( count == 0 ) return -DFS_STATUS_EINVAL;
|
||||
if (count == 0)
|
||||
return -DFS_STATUS_EINVAL;
|
||||
|
||||
index = 0;
|
||||
for (index = 0; index < count && file->pos < file->size; index ++)
|
||||
|
@ -1,3 +1,16 @@
|
||||
/*
|
||||
* File : dfs_romfs.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
*/
|
||||
|
||||
#ifndef __DFS_ROMFS_H__
|
||||
#define __DFS_ROMFS_H__
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : dfs.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2010, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2004-2011, 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
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2010, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
@ -13,6 +13,7 @@
|
||||
* 2004-10-14 Beranard Clean up the code.
|
||||
* 2005-01-22 Beranard Clean up the code, port to MinGW
|
||||
*/
|
||||
|
||||
#ifndef __DFS_DEF_H__
|
||||
#define __DFS_DEF_H__
|
||||
|
||||
|
@ -1,16 +1,15 @@
|
||||
/*
|
||||
+------------------------------------------------------------------------------
|
||||
| Project : Device Filesystem
|
||||
+------------------------------------------------------------------------------
|
||||
| Copyright 2004, 2005 www.fayfayspace.org.
|
||||
| All rights reserved.
|
||||
|------------------------------------------------------------------------------
|
||||
| File : dfs_efs.h
|
||||
|------------------------------------------------------------------------------
|
||||
| Chang Logs:
|
||||
| Date Author Notes
|
||||
| 2010-02-06 Bernard Add elm_init function declaration
|
||||
+------------------------------------------------------------------------------
|
||||
* File : dfs_elm.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2008-2011, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2010-02-06 Bernard Add elm_init function declaration
|
||||
*/
|
||||
|
||||
#ifndef __DFS_ELM_H__
|
||||
|
@ -1,16 +1,15 @@
|
||||
/*
|
||||
+------------------------------------------------------------------------------
|
||||
| Project : Device Filesystem
|
||||
+------------------------------------------------------------------------------
|
||||
| Copyright 2004, 2005 www.fayfayspace.org.
|
||||
| All rights reserved.
|
||||
|------------------------------------------------------------------------------
|
||||
| File : dfs_raw.h, the raw APIs of Device FileSystem
|
||||
|------------------------------------------------------------------------------
|
||||
| Chang Logs:
|
||||
| Date Author Notes
|
||||
| 2005-01-26 ffxz The first version
|
||||
+------------------------------------------------------------------------------
|
||||
* File : dfs_file.c
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2005-01-26 Bernard The first version.
|
||||
*/
|
||||
|
||||
#ifndef __DFS_RAW_H__
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : dfs_fs.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2010, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
@ -11,6 +11,7 @@
|
||||
* Date Author Notes
|
||||
* 2005-02-22 Bernard The first version.
|
||||
*/
|
||||
|
||||
#ifndef __DFS_FS_H__
|
||||
#define __DFS_FS_H__
|
||||
|
||||
|
@ -1,25 +1,15 @@
|
||||
/*
|
||||
|
||||
+------------------------------------------------------------------------------
|
||||
|
||||
| Project : Device Filesystem
|
||||
|
||||
+------------------------------------------------------------------------------
|
||||
|
||||
| Copyright 2004, 2005 www.fayfayspace.org.
|
||||
|
||||
| All rights reserved.
|
||||
|
||||
|------------------------------------------------------------------------------
|
||||
|
||||
| File : dfs_init.h, the initilization definitions of Device FileSystem
|
||||
|------------------------------------------------------------------------------
|
||||
| Chang Logs:
|
||||
|
||||
| Date Author Notes
|
||||
|
||||
| 2005-02-21 ffxz The first version.
|
||||
+------------------------------------------------------------------------------
|
||||
* File : dfs_init.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2005-02-21 Bernard The first version.
|
||||
*/
|
||||
|
||||
#ifndef __DFS_INIT_H__
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : dfs_def.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2010, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
@ -13,6 +13,7 @@
|
||||
* 2010-07-18 Bernard add stat and statfs structure definitions.
|
||||
* 2011-05-16 Yi.qiu Change parameter name of rename, "new" is C++ key word.
|
||||
*/
|
||||
|
||||
#ifndef __DFS_POSIX_H__
|
||||
#define __DFS_POSIX_H__
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : dfs.c
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2010, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
@ -10,7 +10,6 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2005-02-22 Bernard The first version.
|
||||
* 2010-07-16
|
||||
*/
|
||||
|
||||
#include <dfs.h>
|
||||
@ -44,7 +43,7 @@ struct dfs_fd fd_table[DFS_FD_MAX];
|
||||
/**
|
||||
* this function will initialize device file system.
|
||||
*/
|
||||
void dfs_init()
|
||||
void dfs_init(void)
|
||||
{
|
||||
/* clear filesystem operations table */
|
||||
rt_memset(filesystem_operation_table, 0, sizeof(filesystem_operation_table));
|
||||
@ -68,7 +67,7 @@ void dfs_init()
|
||||
*
|
||||
* @note please don't invoke it on ISR.
|
||||
*/
|
||||
void dfs_lock()
|
||||
void dfs_lock(void)
|
||||
{
|
||||
rt_err_t result;
|
||||
|
||||
@ -84,7 +83,7 @@ void dfs_lock()
|
||||
*
|
||||
* @note please don't invoke it on ISR.
|
||||
*/
|
||||
void dfs_unlock()
|
||||
void dfs_unlock(void)
|
||||
{
|
||||
rt_mutex_release(&fslock);
|
||||
}
|
||||
@ -143,9 +142,11 @@ struct dfs_fd* fd_get(int fd)
|
||||
struct dfs_fd *d;
|
||||
|
||||
#ifdef DFS_USING_STDIO
|
||||
if ( fd < 3 || fd > DFS_FD_MAX + 3) return RT_NULL;
|
||||
if (fd < 3 || fd > DFS_FD_MAX + 3)
|
||||
return RT_NULL;
|
||||
#else
|
||||
if ( fd < 0 || fd > DFS_FD_MAX ) return RT_NULL;
|
||||
if (fd < 0 || fd > DFS_FD_MAX)
|
||||
return RT_NULL;
|
||||
#endif
|
||||
|
||||
dfs_lock();
|
||||
@ -207,16 +208,17 @@ int fd_is_open(const char* pathname)
|
||||
/* get file path name under mounted file system */
|
||||
if (fs->path[0] == '/' && fs->path[1] == '\0')
|
||||
mountpath = fullpath;
|
||||
else mountpath = fullpath + strlen(fs->path);
|
||||
else
|
||||
mountpath = fullpath + strlen(fs->path);
|
||||
|
||||
dfs_lock();
|
||||
for (index = 0; index < DFS_FD_MAX; index++)
|
||||
{
|
||||
fd = &(fd_table[index]);
|
||||
if (fd->fs == RT_NULL) continue;
|
||||
if (fd->fs == RT_NULL)
|
||||
continue;
|
||||
|
||||
if (fd->fs == fs &&
|
||||
strcmp(fd->path, mountpath) == 0)
|
||||
if (fd->fs == fs && strcmp(fd->path, mountpath) == 0)
|
||||
{
|
||||
/* found file in file descriptor table */
|
||||
rt_free(fullpath);
|
||||
@ -311,7 +313,8 @@ char* dfs_normalize_path(const char* directory, const char* filename)
|
||||
/* './' case */
|
||||
src += 2;
|
||||
|
||||
while ((*src == '/') && (*src != '\0')) src ++;
|
||||
while ((*src == '/') && (*src != '\0'))
|
||||
src ++;
|
||||
continue;
|
||||
}
|
||||
else if (src[1] == '.')
|
||||
@ -327,37 +330,47 @@ char* dfs_normalize_path(const char* directory, const char* filename)
|
||||
/* '../' case */
|
||||
src += 3;
|
||||
|
||||
while ((*src == '/') && (*src != '\0')) src ++;
|
||||
while ((*src == '/') && (*src != '\0'))
|
||||
src ++;
|
||||
goto up_one;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* copy up the next '/' and erase all '/' */
|
||||
while ((c = *src++) != '\0' && c != '/') *dst ++ = c;
|
||||
while ((c = *src++) != '\0' && c != '/')
|
||||
*dst ++ = c;
|
||||
|
||||
if (c == '/')
|
||||
{
|
||||
*dst ++ = '/';
|
||||
while (c == '/') c = *src++;
|
||||
while (c == '/')
|
||||
c = *src++;
|
||||
|
||||
src --;
|
||||
}
|
||||
else if (!c) break;
|
||||
else if (!c)
|
||||
break;
|
||||
|
||||
continue;
|
||||
|
||||
up_one:
|
||||
dst --;
|
||||
if (dst < dst0) { rt_free(fullpath); return NULL;}
|
||||
while (dst0 < dst && dst[-1] != '/') dst --;
|
||||
if (dst < dst0)
|
||||
{
|
||||
rt_free(fullpath);
|
||||
return NULL;
|
||||
}
|
||||
while (dst0 < dst && dst[-1] != '/')
|
||||
dst --;
|
||||
}
|
||||
|
||||
*dst = '\0';
|
||||
|
||||
/* remove '/' in the end of path if exist */
|
||||
dst --;
|
||||
if ((dst != fullpath) && (*dst == '/')) *dst = '\0';
|
||||
if ((dst != fullpath) && (*dst == '/'))
|
||||
*dst = '\0';
|
||||
|
||||
return fullpath;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : dfs_file.c
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2010, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
@ -11,6 +11,7 @@
|
||||
* Date Author Notes
|
||||
* 2005-02-22 Bernard The first version.
|
||||
*/
|
||||
|
||||
#include <dfs.h>
|
||||
#include <dfs_file.h>
|
||||
|
||||
@ -35,7 +36,8 @@ int dfs_file_open(struct dfs_fd* fd, const char *path, int flags)
|
||||
int result;
|
||||
|
||||
/* parameter check */
|
||||
if ( fd == RT_NULL ) return -DFS_STATUS_EINVAL;
|
||||
if (fd == RT_NULL)
|
||||
return -DFS_STATUS_EINVAL;
|
||||
|
||||
/* make sure we have an absolute path */
|
||||
fullpath = dfs_normalize_path(RT_NULL, path);
|
||||
@ -113,10 +115,12 @@ int dfs_file_close(struct dfs_fd* fd)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (fd != RT_NULL && fd->fs->ops->close != RT_NULL) result = fd->fs->ops->close(fd);
|
||||
if (fd != RT_NULL && fd->fs->ops->close != RT_NULL)
|
||||
result = fd->fs->ops->close(fd);
|
||||
|
||||
/* close fd error, return */
|
||||
if ( result < 0 ) return result;
|
||||
if (result < 0)
|
||||
return result;
|
||||
|
||||
rt_free(fd->path);
|
||||
rt_memset(fd, 0, sizeof(struct dfs_fd));
|
||||
@ -137,10 +141,12 @@ int dfs_file_ioctl(struct dfs_fd* fd, int cmd, void *args)
|
||||
{
|
||||
struct dfs_filesystem *fs;
|
||||
|
||||
if (fd == RT_NULL || fd->type != FT_REGULAR) return -DFS_STATUS_EINVAL;
|
||||
if (fd == RT_NULL || fd->type != FT_REGULAR)
|
||||
return -DFS_STATUS_EINVAL;
|
||||
|
||||
fs = fd->fs;
|
||||
if (fs->ops->ioctl != RT_NULL) return fs->ops->ioctl(fd, cmd, args);
|
||||
if (fs->ops->ioctl != RT_NULL)
|
||||
return fs->ops->ioctl(fd, cmd, args);
|
||||
|
||||
return -DFS_STATUS_ENOSYS;
|
||||
}
|
||||
@ -159,12 +165,15 @@ int dfs_file_read(struct dfs_fd* fd, void *buf, rt_size_t len)
|
||||
struct dfs_filesystem *fs;
|
||||
int result = 0;
|
||||
|
||||
if (fd == RT_NULL) return -DFS_STATUS_EINVAL;
|
||||
if (fd == RT_NULL)
|
||||
return -DFS_STATUS_EINVAL;
|
||||
|
||||
fs = (struct dfs_filesystem *)fd->fs;
|
||||
if (fs->ops->read == RT_NULL) return -DFS_STATUS_ENOSYS;
|
||||
if (fs->ops->read == RT_NULL)
|
||||
return -DFS_STATUS_ENOSYS;
|
||||
|
||||
if ( (result = fs->ops->read(fd, buf, len)) < 0 ) fd->flags |= DFS_F_EOF;
|
||||
if ((result = fs->ops->read(fd, buf, len)) < 0)
|
||||
fd->flags |= DFS_F_EOF;
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -183,10 +192,12 @@ int dfs_file_getdents(struct dfs_fd* fd, struct dirent* dirp, rt_size_t nbytes)
|
||||
struct dfs_filesystem *fs;
|
||||
|
||||
/* parameter check */
|
||||
if (fd == RT_NULL || fd->type != FT_DIRECTORY) return -DFS_STATUS_EINVAL;
|
||||
if (fd == RT_NULL || fd->type != FT_DIRECTORY)
|
||||
return -DFS_STATUS_EINVAL;
|
||||
|
||||
fs = (struct dfs_filesystem *)fd->fs;
|
||||
if (fs->ops->getdents != RT_NULL) return fs->ops->getdents(fd, dirp, nbytes);
|
||||
if (fs->ops->getdents != RT_NULL)
|
||||
return fs->ops->getdents(fd, dirp, nbytes);
|
||||
|
||||
return -DFS_STATUS_ENOSYS;
|
||||
}
|
||||
@ -254,10 +265,12 @@ int dfs_file_write(struct dfs_fd* fd, const void *buf, rt_size_t len)
|
||||
{
|
||||
struct dfs_filesystem *fs;
|
||||
|
||||
if (fd == RT_NULL) return -DFS_STATUS_EINVAL;
|
||||
if (fd == RT_NULL)
|
||||
return -DFS_STATUS_EINVAL;
|
||||
|
||||
fs = fd->fs;
|
||||
if (fs->ops->write == RT_NULL) return -DFS_STATUS_ENOSYS;
|
||||
if (fs->ops->write == RT_NULL)
|
||||
return -DFS_STATUS_ENOSYS;
|
||||
|
||||
return fs->ops->write(fd, buf, len);
|
||||
}
|
||||
@ -273,10 +286,12 @@ int dfs_file_flush(struct dfs_fd* fd)
|
||||
{
|
||||
struct dfs_filesystem *fs;
|
||||
|
||||
if (fd == RT_NULL) return -DFS_STATUS_EINVAL;
|
||||
if (fd == RT_NULL)
|
||||
return -DFS_STATUS_EINVAL;
|
||||
|
||||
fs = fd->fs;
|
||||
if (fs->ops->flush == RT_NULL) return -DFS_STATUS_ENOSYS;
|
||||
if (fs->ops->flush == RT_NULL)
|
||||
return -DFS_STATUS_ENOSYS;
|
||||
|
||||
return fs->ops->flush(fd);
|
||||
}
|
||||
@ -294,8 +309,10 @@ int dfs_file_lseek(struct dfs_fd* fd, rt_off_t offset)
|
||||
int result;
|
||||
struct dfs_filesystem *fs = fd->fs;
|
||||
|
||||
if (fd == RT_NULL) return -DFS_STATUS_EINVAL;
|
||||
if (fs->ops->lseek == RT_NULL) return -DFS_STATUS_ENOSYS;
|
||||
if (fd == RT_NULL)
|
||||
return -DFS_STATUS_EINVAL;
|
||||
if (fs->ops->lseek == RT_NULL)
|
||||
return -DFS_STATUS_ENOSYS;
|
||||
|
||||
result = fs->ops->lseek(fd, offset);
|
||||
|
||||
@ -476,7 +493,8 @@ void ls(const char* pathname)
|
||||
|
||||
/* build full path for each file */
|
||||
fullpath = dfs_normalize_path(path, dirent.d_name);
|
||||
if (fullpath == RT_NULL) break;
|
||||
if (fullpath == RT_NULL)
|
||||
break;
|
||||
|
||||
if (dfs_file_stat(fullpath, &stat) == 0)
|
||||
{
|
||||
@ -502,7 +520,8 @@ void ls(const char* pathname)
|
||||
{
|
||||
rt_kprintf("No such directory\n");
|
||||
}
|
||||
if (pathname == RT_NULL) rt_free(path);
|
||||
if (pathname == RT_NULL)
|
||||
rt_free(path);
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT(ls, list directory contents)
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : dfs_fs.c
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2010, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
@ -13,6 +13,7 @@
|
||||
* 2010-06-30 Bernard Optimize for RT-Thread RTOS
|
||||
* 2011-03-12 Bernard fix the filesystem lookup issue.
|
||||
*/
|
||||
|
||||
#include <dfs_fs.h>
|
||||
#include <dfs_file.h>
|
||||
|
||||
@ -89,19 +90,21 @@ struct dfs_filesystem* dfs_filesystem_lookup(const char *path)
|
||||
/* lookup it in the filesystem table */
|
||||
for (index = 0; index < DFS_FILESYSTEMS_MAX; index++)
|
||||
{
|
||||
if (filesystem_table[index].path == RT_NULL) continue;
|
||||
if (filesystem_table[index].path == RT_NULL)
|
||||
continue;
|
||||
else
|
||||
{
|
||||
fspath = strlen(filesystem_table[index].path);
|
||||
if (fspath < prefixlen) continue;
|
||||
if (fspath < prefixlen)
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((filesystem_table[index].ops != RT_NULL) &&
|
||||
(strncmp(filesystem_table[index].path, path, fspath) == 0))
|
||||
{
|
||||
/* check next path separator */
|
||||
if ( fspath > 1 && (strlen(path) > fspath) &&
|
||||
(path[fspath] != '/')) continue;
|
||||
if (fspath > 1 && (strlen(path) > fspath) && (path[fspath] != '/'))
|
||||
continue;
|
||||
|
||||
fs = &filesystem_table[index];
|
||||
prefixlen = fspath;
|
||||
@ -154,13 +157,10 @@ rt_err_t dfs_filesystem_get_partition(struct dfs_partition* part, rt_uint8_t* bu
|
||||
part->type = type;
|
||||
|
||||
/* get partition offset and size */
|
||||
part->offset = *(dpt+ 8) | *(dpt+ 9) << 8 |
|
||||
*(dpt+10) << 16 | *(dpt+11) << 24;
|
||||
part->size = *(dpt+12) | *(dpt+13) << 8 |
|
||||
*(dpt+14) << 16 | *(dpt+15) << 24;
|
||||
part->offset = *(dpt+8) | *(dpt+9)<<8 | *(dpt+10)<<16 | *(dpt+11)<<24;
|
||||
part->size = *(dpt+12) | *(dpt+13)<<8 | *(dpt+14)<<16 | *(dpt+15)<<24;
|
||||
|
||||
rt_kprintf("found part[%d], begin: %d, size: ",
|
||||
pindex, part->offset * 512);
|
||||
rt_kprintf("found part[%d], begin: %d, size: ", pindex, part->offset*512);
|
||||
if ((part->size>>11) > 0) /* MB */
|
||||
{
|
||||
unsigned int part_size;
|
||||
@ -229,7 +229,8 @@ int dfs_mount(const char* device_name, const char* path,
|
||||
dfs_lock();
|
||||
for (index = 0; index < DFS_FILESYSTEM_TYPES_MAX; index++)
|
||||
{
|
||||
if (strcmp(filesystem_operation_table[index]->name, filesystemtype) == 0)break;
|
||||
if (strcmp(filesystem_operation_table[index]->name, filesystemtype) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
/* can't find filesystem */
|
||||
@ -294,11 +295,13 @@ int dfs_mount(const char* device_name, const char* path,
|
||||
dfs_unlock();
|
||||
|
||||
/* open device, but do not check the status of device */
|
||||
if (dev_id != RT_NULL) rt_device_open(fs->dev_id, RT_DEVICE_OFLAG_RDWR);
|
||||
if (dev_id != RT_NULL)
|
||||
rt_device_open(fs->dev_id, RT_DEVICE_OFLAG_RDWR);
|
||||
|
||||
if (ops->mount == RT_NULL) /* there is no mount implementation */
|
||||
{
|
||||
if (dev_id != RT_NULL) rt_device_close(dev_id);
|
||||
if (dev_id != RT_NULL)
|
||||
rt_device_close(dev_id);
|
||||
dfs_lock();
|
||||
/* clear filesystem table entry */
|
||||
rt_memset(fs, 0, sizeof(struct dfs_filesystem));
|
||||
@ -312,7 +315,8 @@ int dfs_mount(const char* device_name, const char* path,
|
||||
else if (ops->mount(fs, rwflag, data) < 0)
|
||||
{
|
||||
/* close device */
|
||||
if (dev_id != RT_NULL) rt_device_close(fs->dev_id);
|
||||
if (dev_id != RT_NULL)
|
||||
rt_device_close(fs->dev_id);
|
||||
|
||||
/* mount failed */
|
||||
dfs_lock();
|
||||
@ -328,7 +332,8 @@ int dfs_mount(const char* device_name, const char* path,
|
||||
|
||||
err1:
|
||||
dfs_unlock();
|
||||
if (fullpath != RT_NULL) rt_free(fullpath);
|
||||
if (fullpath != RT_NULL)
|
||||
rt_free(fullpath);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : dfs_posix.c
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2010, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
@ -37,7 +37,8 @@ int open(const char *file, int flags, int mode)
|
||||
|
||||
/* allocate a fd */
|
||||
fd = fd_new();
|
||||
if (fd < 0) return -1;
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
d = fd_get(fd);
|
||||
|
||||
result = dfs_file_open(d, file, flags);
|
||||
@ -360,7 +361,11 @@ int mkdir (const char *path, mode_t mode)
|
||||
int result;
|
||||
|
||||
fd = fd_new();
|
||||
if (fd == -1) { rt_kprintf("no fd\n"); return -1; }
|
||||
if (fd == -1)
|
||||
{
|
||||
rt_kprintf("no fd\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
d = fd_get(fd);
|
||||
|
||||
@ -420,7 +425,11 @@ DIR* opendir(const char* name)
|
||||
|
||||
/* allocate a fd */
|
||||
fd = fd_new();
|
||||
if (fd == -1) { rt_kprintf("no fd\n"); return RT_NULL; }
|
||||
if (fd == -1)
|
||||
{
|
||||
rt_kprintf("no fd\n");
|
||||
return RT_NULL;
|
||||
}
|
||||
d = fd_get(fd);
|
||||
|
||||
result = dfs_file_open(d, name, DFS_O_RDONLY | DFS_O_DIRECTORY);
|
||||
@ -536,7 +545,8 @@ void seekdir(DIR *d, off_t offset)
|
||||
}
|
||||
|
||||
/* seek to the offset position of directory */
|
||||
if (dfs_file_lseek(fd, offset) >= 0) d->num = d->cur = 0;
|
||||
if (dfs_file_lseek(fd, offset) >= 0)
|
||||
d->num = d->cur = 0;
|
||||
fd_put(fd);
|
||||
}
|
||||
|
||||
@ -557,7 +567,8 @@ void rewinddir(DIR *d)
|
||||
}
|
||||
|
||||
/* seek to the beginning of directory */
|
||||
if (dfs_file_lseek(fd, 0) >= 0) d->num = d->cur = 0;
|
||||
if (dfs_file_lseek(fd, 0) >= 0)
|
||||
d->num = d->cur = 0;
|
||||
fd_put(fd);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user