提交 49a0ca30 编写于 作者: B bernard.xiong

add ELM fat implementation.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@138 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 36dfee40
......@@ -37,6 +37,13 @@ filesystems/efsl/src/fs/vfat/time.c
filesystems/efsl/src/fs/vfat/ui.c
""")
# DFS-ELMFAT options
elmfat = Split("""
filesystems/elmfat/dfs_elm.c
filesystems/elmfat/ff.c
filesystems/elmfat/option/cc936.c
""")
# DFS-YAFFS2 options
yaffs2_main = Split("""
filesystems/yaffs2/direct/yaffscfg.c
......@@ -69,6 +76,10 @@ if rtconfig.RT_USING_DFS_EFSL:
src_local = src_local + efsl
path = path + [RTT_ROOT + '/filesystem/dfs/filesystems/efsl/src/include', RTT_ROOT + '/filesystem/dfs/filesystems/efsl/src/base/include', RTT_ROOT + '/filesystem/dfs/filesystems/efsl/src/fs/vfat/include']
if rtconfig.RT_USING_DFS_ELMFAT:
src_local = src_local + elmfat
path = path + [RTT_ROOT + '/filesystem/dfs/filesystems/elmfat']
env.Append(CPPPATH = path)
obj = env.Object(src_local)
......
FatFs Module Source Files R0.07c (C)ChaN, 2009
FILES
ff.h Common include file for FatFs and application module.
ff.c FatFs module.
diskio.h Common include file for FatFs and disk I/O module.
diskio.c Skeleton of low level disk I/O module.
integer.h Alternative type definitions for integer variables.
option Optional external functions.
Low level disk I/O module is not included in this archive because the FatFs
module is only a generic file system layer and not depend on any specific
storage device. You have to provide a low level disk I/O module that written
to control your storage device.
AGREEMENTS
FatFs module is an open source software to implement FAT file system to
small embedded systems. This is a free software and is opened for education,
research and commercial developments under license policy of following trems.
Copyright (C) 2009, ChaN, all right reserved.
* The FatFs module is a free software and there is NO WARRANTY.
* No restriction on use. You can use, modify and redistribute it for
personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
* Redistributions of source code must retain the above copyright notice.
REVISION HISTORY
Feb 26, 2006 R0.00 Prototype
Apr 29, 2006 R0.01 First release.
Jun 01, 2006 R0.02 Added FAT12.
Removed unbuffered mode.
Fixed a problem on small (<32M) patition.
Jun 10, 2006 R0.02a Added a configuration option _FS_MINIMUM.
Sep 22, 2006 R0.03 Added f_rename.
Changed option _FS_MINIMUM to _FS_MINIMIZE.
Dec 11, 2006 R0.03a Improved cluster scan algolithm to write files fast.
Fixed f_mkdir creates incorrect directory on FAT32.
Feb 04, 2007 R0.04 Supported multiple drive system. (FatFs)
Changed some APIs for multiple drive system.
Added f_mkfs. (FatFs)
Added _USE_FAT32 option. (Tiny-FatFs)
Apr 01, 2007 R0.04a Supported multiple partitions on a plysical drive. (FatFs)
Fixed an endian sensitive code in f_mkfs. (FatFs)
Added a capability of extending the file size to f_lseek.
Added minimization level 3.
Fixed a problem that can collapse a sector when recreate an
existing file in any sub-directory at non FAT32 cfg. (Tiny-FatFs)
May 05, 2007 R0.04b Added _USE_NTFLAG option.
Added FSInfo support.
Fixed some problems corresponds to FAT32. (Tiny-FatFs)
Fixed DBCS name can result FR_INVALID_NAME.
Fixed short seek (0 < ofs <= csize) collapses the file object.
Aug 25, 2007 R0.05 Changed arguments of f_read, f_write.
Changed arguments of f_mkfs. (FatFs)
Fixed f_mkfs on FAT32 creates incorrect FSInfo. (FatFs)
Fixed f_mkdir on FAT32 creates incorrect directory. (FatFs)
Feb 03, 2008 R0.05a Added f_truncate().
Added f_utime().
Fixed off by one error at FAT sub-type determination.
Fixed btr in f_read() can be mistruncated.
Fixed cached sector is not flushed when create and close without write.
Apr 01, 2008 R0.06 Added f_forward(). (Tiny-FatFs)
Added string functions: fputc(), fputs(), fprintf() and fgets().
Improved performance of f_lseek() on move to the same or following cluster.
Apr 01, 2009, R0.07 Merged Tiny-FatFs as a buffer configuration option.
Added long file name support.
Added multiple code page support.
Added re-entrancy for multitask operation.
Added auto cluster size selection to f_mkfs().
Added rewind option to f_readdir().
Changed result code of critical errors.
Renamed string functions to avoid name collision.
Apr 14, 2009, R0.07a Separated out OS dependent code on reentrant cfg.
Added multiple sector size support.
Jun 21, 2009, R0.07c Fixed f_unlink() may return FR_OK on error.
Fixed wrong cache control in f_lseek().
Added relative path feature.
Added f_chdir().
Added f_chdrive().
Added proper case conversion to extended char.
#include <dfs_fs.h>
#include <dfs_def.h>
#include "ff.h"
#define ELM_MAX_DISK 4
static rt_device_t disk[ELM_MAX_DISK] = {0};
static int elm_result_to_dfs(FRESULT result)
{
int status = DFS_STATUS_OK;
switch (result)
{
case FR_OK:
break;
case FR_NO_FILE:
case FR_NO_PATH:
case FR_NO_FILESYSTEM:
status = -DFS_STATUS_ENOENT;
break;
case FR_INVALID_NAME:
status = -DFS_STATUS_EINVAL;
break;
case FR_EXIST:
case FR_INVALID_OBJECT:
status = -DFS_STATUS_EEXIST;
break;
case FR_DISK_ERR:
case FR_NOT_READY:
case FR_INT_ERR:
status = -DFS_STATUS_EIO;
break;
case FR_WRITE_PROTECTED:
case FR_DENIED:
status = -DFS_STATUS_EROFS;
break;
default:
status = -1;
break;
}
return status;
}
int dfs_elm_mount(struct dfs_filesystem* fs)
{
FATFS *fat;
FRESULT result;
rt_uint32_t index;
/* handle RT-Thread device routine */
for (index = 0; index < ELM_MAX_DISK; index ++)
{
if (disk[index] == RT_NULL)
{
break;
}
}
if (index == ELM_MAX_DISK) return -DFS_STATUS_EMMOUNT;
/* get device */
disk[index] = fs->dev_id;
fat = (FATFS *) rt_malloc(sizeof(FATFS));
if (fat == RT_NULL)
{
return -1;
}
/* mount fatfs, always 0 logic driver */
result = f_mount(index, fat);
if (result == FR_OK)
fs->data = fat;
else
{
rt_free(fat);
return elm_result_to_dfs(result);
}
return 0;
}
int dfs_elm_unmount(struct dfs_filesystem* fs)
{
FATFS *fat;
fat = (FATFS*) fs->data;
RT_ASSERT(fat != RT_NULL);
/* elm not support unmount */
RT_ASSERT(0);
return 0;
}
int dfs_elm_open(struct dfs_fd* file)
{
FIL* fd;
BYTE mode;
FRESULT result;
if (file->flags & DFS_O_DIRECTORY)
{
DIR *dir;
if (file->flags & DFS_O_CREAT)
{
result = f_mkdir(file->path);
if (result != FR_OK)
{
return elm_result_to_dfs(result);
}
}
/* open directory */
dir = (DIR *)rt_malloc(sizeof(DIR));
if (dir == RT_NULL)
{
return -DFS_STATUS_ENOMEM;
}
result = f_opendir(dir, file->path);
if (result != FR_OK)
{
rt_free(dir);
return elm_result_to_dfs(result);
}
file->data = dir;
return DFS_STATUS_OK;
}
else
{
mode = FA_READ;
if (file->flags & DFS_O_CREAT) mode |= FA_CREATE_NEW;
if (file->flags & DFS_O_WRONLY) mode |= FA_WRITE;
/* allocate a fd */
fd = (FIL*)rt_malloc(sizeof(FIL));
if (fd == RT_NULL)
{
return -DFS_STATUS_ENOMEM;
}
result = f_open(fd, file->path, mode);
if (result == FR_OK)
{
file->pos = fd->fptr;
file->size = fd->fsize;
file->data = fd;
}
else
{
/* open failed, return */
rt_free(fd);
return elm_result_to_dfs(result);
}
}
return DFS_STATUS_OK;
}
int dfs_elm_close(struct dfs_fd* file)
{
FRESULT result;
result = FR_OK;
if (file->type == FT_DIRECTORY)
{
DIR* dir;
dir = (DIR*)(file->data);
RT_ASSERT(dir != RT_NULL);
/* release memory */
rt_free(dir);
}
else if (file->type == FT_REGULAR)
{
FIL* fd;
fd = (FIL*)(file->data);
RT_ASSERT(fd != RT_NULL);
result = f_close(fd);
if (result == FR_OK)
{
/* release memory */
rt_free(fd);
}
}
return elm_result_to_dfs(result);
}
int dfs_elm_ioctl(struct dfs_fd* file, int cmd, void* args)
{
return -DFS_STATUS_ENOSYS;
}
int dfs_elm_read(struct dfs_fd* file, void* buf, rt_size_t len)
{
FIL* fd;
FRESULT result;
UINT byte_read;
if (file->type == FT_DIRECTORY)
{
return -DFS_STATUS_EISDIR;
}
fd = (FIL*)(file->data);
RT_ASSERT(fd != RT_NULL);
result = f_read(fd, buf, len, &byte_read);
if (result == FR_OK) return byte_read;
return elm_result_to_dfs(result);
}
int dfs_elm_write(struct dfs_fd* file, const void* buf, rt_size_t len)
{
FIL* fd;
FRESULT result;
UINT byte_write;
if (file->type == FT_DIRECTORY)
{
return -DFS_STATUS_EISDIR;
}
fd = (FIL*)(file->data);
RT_ASSERT(fd != RT_NULL);
result = f_write(fd, buf, len, &byte_write);
if (result == FR_OK) return byte_write;
return elm_result_to_dfs(result);
}
int dfs_elm_lseek(struct dfs_fd* file, rt_off_t offset)
{
FIL* fd;
FRESULT result;
fd = (FIL*)(file->data);
RT_ASSERT(fd != RT_NULL);
result = f_lseek(fd, offset);
return elm_result_to_dfs(result);
}
int dfs_elm_getdents(struct dfs_fd* file, struct dfs_dirent* dirp, rt_uint32_t count)
{
DIR* dir;
FILINFO fno;
FRESULT result;
rt_uint32_t index;
struct dfs_dirent* d;
if (file->type != FT_DIRECTORY) return -DFS_STATUS_EBADF;
dir = (DIR*)(file->data);
RT_ASSERT(dir != RT_NULL);
/* make integer count */
count = (count / sizeof(struct dfs_dirent)) * sizeof(struct dfs_dirent);
if ( count == 0 ) return -DFS_STATUS_EINVAL;
index = 0;
while (1)
{
char *fn;
d = dirp + index;
result = f_readdir(dir, &fno);
if (result != FR_OK) break;
#if _USE_LFN
fn = *fno.lfname? fno.lfname : fno.fname;
#else
fn = fno.fname;
#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;
d->d_namlen = strlen(fn) - 1;
d->d_reclen = (rt_uint16_t)sizeof(struct dfs_dirent);
strcpy(d->d_name, fn);
index ++;
if ( index * sizeof(struct dfs_dirent) >= count )
break;
}
if (index == 0)
return elm_result_to_dfs(result);
return index * sizeof(struct dfs_dirent);
}
int dfs_elm_unlink(struct dfs_filesystem* fs, const char* path)
{
FRESULT result;
result = f_unlink(path);
return elm_result_to_dfs(result);
}
int dfs_elm_rename(struct dfs_filesystem* fs, const char* oldpath, const char* newpath)
{
FRESULT result;
result = f_rename(oldpath, newpath);
return elm_result_to_dfs(result);
}
int dfs_elm_stat(struct dfs_filesystem* fs, const char *path, struct dfs_stat *st)
{
FILINFO file_info;
FRESULT result;
result = f_stat(path, &file_info);
if (result == FR_OK)
{
/* convert to dfs stat structure */
st->st_dev = 0;
if (file_info.fattrib & AM_DIR) st->st_mode = FT_DIRECTORY;
else st->st_mode = FT_REGULAR;
st->st_size = file_info.fsize;
st->st_mtime = file_info.ftime;
st->st_blksize = 512;
}
return elm_result_to_dfs(result);
}
static struct dfs_filesystem_operation dfs_elm;
int elm_init(void)
{
rt_strncpy(dfs_elm.name, "elmfat", DFS_FS_NAME_MAX);
dfs_elm.mount = dfs_elm_mount;
dfs_elm.unmount = dfs_elm_unmount;
dfs_elm.open = dfs_elm_open;
dfs_elm.close = dfs_elm_close;
dfs_elm.ioctl = dfs_elm_ioctl;
dfs_elm.read = dfs_elm_read;
dfs_elm.write = dfs_elm_write;
dfs_elm.lseek = dfs_elm_lseek;
dfs_elm.getdents= dfs_elm_getdents;
dfs_elm.unlink = dfs_elm_unlink;
dfs_elm.stat = dfs_elm_stat;
dfs_elm.rename = dfs_elm_rename;
/* register fatfs file system */
dfs_register(&dfs_elm);
return 0;
}
/*
* RT-Thread Device Interface for ELM FatFs
*/
#include "diskio.h"
/* Inidialize a Drive */
DSTATUS disk_initialize (BYTE drv)
{
return 0;
}
/* Return Disk Status */
DSTATUS disk_status (BYTE drv)
{
return 0;
}
/* Read Sector(s) */
DRESULT disk_read (BYTE drv, BYTE *buff, DWORD sector, BYTE count)
{
rt_size_t result;
rt_device_t device = disk[drv];
result = rt_device_read(device, sector * 512, buff, count * 512);
if (result == count * 512)
{
return RES_OK;
}
return RES_ERROR;
}
/* Write Sector(s) */
DRESULT disk_write (BYTE drv, const BYTE *buff, DWORD sector, BYTE count)
{
rt_size_t result;
rt_device_t device = disk[drv];
result = rt_device_write(device, sector * 512, buff, count * 512);
if (result == count * 512)
{
return RES_OK;
}
return RES_ERROR;
}
/* Miscellaneous Functions */
DRESULT disk_ioctl (BYTE drv, BYTE ctrl, void *buff)
{
return RES_OK;
}
rt_time_t get_fattime()
{
return 0;
}
/*-----------------------------------------------------------------------*/
/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2007 */
/*-----------------------------------------------------------------------*/
/* This is a stub disk I/O module that acts as front end of the existing */
/* disk I/O modules and attach it to FatFs module with common interface. */
/*-----------------------------------------------------------------------*/
#include "diskio.h"
/*-----------------------------------------------------------------------*/
/* Correspondence between physical drive number and physical drive. */
#define ATA 0
#define MMC 1
#define USB 2
/*-----------------------------------------------------------------------*/
/* Inidialize a Drive */
DSTATUS disk_initialize (
BYTE drv /* Physical drive nmuber (0..) */
)
{
DSTATUS stat;
int result;
switch (drv) {
case ATA :
result = ATA_disk_initialize();
// translate the reslut code here
return stat;
case MMC :
result = MMC_disk_initialize();
// translate the reslut code here
return stat;
case USB :
result = USB_disk_initialize();
// translate the reslut code here
return stat;
}
return STA_NOINIT;
}
/*-----------------------------------------------------------------------*/
/* Return Disk Status */
DSTATUS disk_status (
BYTE drv /* Physical drive nmuber (0..) */
)
{
DSTATUS stat;
int result;
switch (drv) {
case ATA :
result = ATA_disk_status();
// translate the reslut code here
return stat;
case MMC :
result = MMC_disk_status();
// translate the reslut code here
return stat;
case USB :
result = USB_disk_status();
// translate the reslut code here
return stat;
}
return STA_NOINIT;
}
/*-----------------------------------------------------------------------*/
/* Read Sector(s) */
DRESULT disk_read (
BYTE drv, /* Physical drive nmuber (0..) */
BYTE *buff, /* Data buffer to store read data */
DWORD sector, /* Sector address (LBA) */
BYTE count /* Number of sectors to read (1..255) */
)
{
DRESULT res;
int result;
switch (drv) {
case ATA :
result = ATA_disk_read(buff, sector, count);
// translate the reslut code here
return res;
case MMC :
result = MMC_disk_read(buff, sector, count);
// translate the reslut code here
return res;
case USB :
result = USB_disk_read(buff, sector, count);
// translate the reslut code here
return res;
}
return RES_PARERR;
}
/*-----------------------------------------------------------------------*/
/* Write Sector(s) */
#if _READONLY == 0
DRESULT disk_write (
BYTE drv, /* Physical drive nmuber (0..) */
const BYTE *buff, /* Data to be written */
DWORD sector, /* Sector address (LBA) */
BYTE count /* Number of sectors to write (1..255) */
)
{
DRESULT res;
int result;
switch (drv) {
case ATA :
result = ATA_disk_write(buff, sector, count);
// translate the reslut code here
return res;
case MMC :
result = MMC_disk_write(buff, sector, count);
// translate the reslut code here
return res;
case USB :
result = USB_disk_write(buff, sector, count);
// translate the reslut code here
return res;
}
return RES_PARERR;
}
#endif /* _READONLY */
/*-----------------------------------------------------------------------*/
/* Miscellaneous Functions */
DRESULT disk_ioctl (
BYTE drv, /* Physical drive nmuber (0..) */
BYTE ctrl, /* Control code */
void *buff /* Buffer to send/receive control data */
)
{
DRESULT res;
int result;
switch (drv) {
case ATA :
// pre-process here
result = ATA_disk_ioctl(ctrl, buff);
// post-process here
return res;
case MMC :
// pre-process here
result = MMC_disk_ioctl(ctrl, buff);
// post-process here
return res;
case USB :
// pre-process here
result = USB_disk_ioctl(ctrl, buff);
// post-process here
return res;
}
return RES_PARERR;
}
/*-----------------------------------------------------------------------
/ Low level disk interface modlue include file R0.07 (C)ChaN, 2009
/-----------------------------------------------------------------------*/
#ifndef _DISKIO
#define _READONLY 0 /* 1: Read-only mode */
#define _USE_IOCTL 1
#include "integer.h"
/* Status of Disk Functions */
typedef BYTE DSTATUS;
/* Results of Disk Functions */
typedef enum {
RES_OK = 0, /* 0: Successful */
RES_ERROR, /* 1: R/W Error */
RES_WRPRT, /* 2: Write Protected */
RES_NOTRDY, /* 3: Not Ready */
RES_PARERR /* 4: Invalid Parameter */
} DRESULT;
/*---------------------------------------*/
/* Prototypes for disk control functions */
BOOL assign_drives (int argc, char *argv[]);
DSTATUS disk_initialize (BYTE);
DSTATUS disk_status (BYTE);
DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE);
#if _READONLY == 0
DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE);
#endif
DRESULT disk_ioctl (BYTE, BYTE, void*);
/* Disk Status Bits (DSTATUS) */
#define STA_NOINIT 0x01 /* Drive not initialized */
#define STA_NODISK 0x02 /* No medium in the drive */
#define STA_PROTECT 0x04 /* Write protected */
/* Command code for disk_ioctrl() */
/* Generic command */
#define CTRL_SYNC 0 /* Mandatory for write functions */
#define GET_SECTOR_COUNT 1 /* Mandatory for only f_mkfs() */
#define GET_SECTOR_SIZE 2
#define GET_BLOCK_SIZE 3 /* Mandatory for only f_mkfs() */
#define CTRL_POWER 4
#define CTRL_LOCK 5
#define CTRL_EJECT 6
/* MMC/SDC command */
#define MMC_GET_TYPE 10
#define MMC_GET_CSD 11
#define MMC_GET_CID 12
#define MMC_GET_OCR 13
#define MMC_GET_SDSTAT 14
/* ATA/CF command */
#define ATA_GET_REV 20
#define ATA_GET_MODEL 21
#define ATA_GET_SN 22
#define _DISKIO
#endif
此差异已折叠。
此差异已折叠。
/*-------------------------------------------*/
/* Integer type definitions for FatFs module */
/*-------------------------------------------*/
#ifndef _INTEGER
#if 0
#include <windows.h>
#else
/* These types must be 16-bit, 32-bit or larger integer */
typedef int INT;
typedef unsigned int UINT;
/* These types must be 8-bit integer */
typedef signed char CHAR;
typedef unsigned char UCHAR;
typedef unsigned char BYTE;
/* These types must be 16-bit integer */
typedef short SHORT;
typedef unsigned short USHORT;
typedef unsigned short WORD;
typedef unsigned short WCHAR;
/* These types must be 32-bit integer */
typedef long LONG;
typedef unsigned long ULONG;
typedef unsigned long DWORD;
/* Boolean type */
typedef enum { FALSE = 0, TRUE } BOOL;
#endif
#define _INTEGER
#endif
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
/*------------------------------------------------------------------------*/
/* Sample code of OS dependent synchronization object controls */
/* for FatFs R0.07a (C)ChaN, 2009 */
/*------------------------------------------------------------------------*/
#include <windows.h> // Win32
//#include <ucos_ii.h> // uC/OS-II
#include "../ff.h"
#if _FS_REENTRANT
/*------------------------------------------------------------------------*/
/* Create a Synchronization Object for a Volume
/*------------------------------------------------------------------------*/
/* This function is called in f_mount function to create a new
/ synchronization object, such as semaphore and mutex. When a FALSE is
/ returned, the f_mount function fails with FR_INT_ERR.
*/
BOOL ff_cre_syncobj ( /* TRUE:Function succeeded, FALSE:Could not create due to any error */
BYTE vol, /* Corresponding logical drive being processed */
_SYNC_t *sobj /* Pointer to return the created sync object */
)
{
BOOL ret;
*sobj = CreateMutex(NULL, FALSE, NULL); // Win32
ret = (*sobj != INVALID_HANDLE_VALUE) ? TRUE : FALSE; //
// *sobj = VolumeSemId[vol]; // uITRON (give a static created sync object)
// ret = TRUE; // The initial value of the semaphore must be 1.
// *sobj = OSMutexCreate(0, &err); // uC/OS-II
// ret = (err == OS_NO_ERR) ? TRUE : FALSE; //
return ret;
}
/*------------------------------------------------------------------------*/
/* Delete a Synchronization Object */
/*------------------------------------------------------------------------*/
/* This function is called in f_mount function to delete a synchronization
/ object that created with ff_cre_syncobj function. When a FALSE is
/ returned, the f_mount function fails with FR_INT_ERR.
*/
BOOL ff_del_syncobj ( /* TRUE:Function succeeded, FALSE:Could not delete due to any error */
_SYNC_t sobj /* Sync object tied to the logical drive to be deleted */
)
{
BOOL ret;
ret = CloseHandle(sobj); // Win32
// ret = TRUE; // uITRON (nothing to do)
// OSMutexDel(sobj, OS_DEL_ALWAYS, &err); // uC/OS-II
// ret = (err == OS_NO_ERR) ? TRUE : FALSE; //
return ret;
}
/*------------------------------------------------------------------------*/
/* Request Grant to Access the Volume */
/*------------------------------------------------------------------------*/
/* This function is called on entering file functions to lock the volume.
/ When a FALSE is returned, the file function fails with FR_TIMEOUT.
*/
BOOL ff_req_grant ( /* TRUE:Got a grant to access the volume, FALSE:Could not get a grant */
_SYNC_t sobj /* Sync object to wait */
)
{
BOOL ret;
ret = (WaitForSingleObject(sobj, _TIMEOUT) == WAIT_OBJECT_0) ? TRUE : FALSE; // Win32
// ret = (wai_sem(sobj) == E_OK) ? TRUE : FALSE; // uITRON
// OSMutexPend(sobj, _TIMEOUT, &err)); // uC/OS-II
// ret = (err == OS_NO_ERR) ? TRUE : FALSE; //
return ret;
}
/*------------------------------------------------------------------------*/
/* Release Grant to Access the Volume */
/*------------------------------------------------------------------------*/
/* This function is called on leaving file functions to unlock the volume.
*/
void ff_rel_grant (
_SYNC_t sobj /* Sync object to be signaled */
)
{
ReleaseMutex(sobj); // Win32
// sig_sem(sobj); // uITRON
// OSMutexPost(sobj); // uC/OS-II
}
#else
#error This file is not needed in this configuration.
#endif
......@@ -133,9 +133,10 @@ struct dfs_stat
#define stat dfs_stat
/* File types */
#define FT_REGULAR 0
#define FT_SOCKET 1
#define FT_DIRECTORY 2
#define FT_REGULAR 0 /* regular file */
#define FT_SOCKET 1 /* socket file */
#define FT_DIRECTORY 2 /* directory */
#define FT_USER 3 /* user defined */
/* file descriptor */
struct dfs_fd
......
......@@ -208,7 +208,11 @@ int dfile_raw_open(struct dfs_fd* fd, const char *path, int flags)
}
fd->flags |= DFS_F_OPEN;
if ( flags & DFS_O_DIRECTORY ) fd->flags |= DFS_F_DIRECTORY;
if ( flags & DFS_O_DIRECTORY )
{
fd->type = FT_DIRECTORY;
fd->flags |= DFS_F_DIRECTORY;
}
dfs_log(DFS_DEBUG_INFO, ("open successful"));
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册