From 27112267e968419c1d2ab47ea2456eb3d9b54598 Mon Sep 17 00:00:00 2001 From: prife Date: Sat, 21 Dec 2013 10:58:52 +0800 Subject: [PATCH 1/3] dfs: rename varialbe name in dfs_filesystem_lookup empty is confused in dfs_filesystem_lookup. --- components/dfs/src/dfs_fs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/dfs/src/dfs_fs.c b/components/dfs/src/dfs_fs.c index 7e1dbd3584..770fd71cfb 100644 --- a/components/dfs/src/dfs_fs.c +++ b/components/dfs/src/dfs_fs.c @@ -80,7 +80,7 @@ int dfs_register(const struct dfs_filesystem_operation *ops) struct dfs_filesystem *dfs_filesystem_lookup(const char *path) { struct dfs_filesystem *iter; - struct dfs_filesystem *empty = RT_NULL; + struct dfs_filesystem *fs = RT_NULL; rt_uint32_t fspath, prefixlen; prefixlen = 0; @@ -104,13 +104,13 @@ struct dfs_filesystem *dfs_filesystem_lookup(const char *path) if (fspath > 1 && (strlen(path) > fspath) && (path[fspath] != '/')) continue; - empty = iter; + fs = iter; prefixlen = fspath; } dfs_unlock(); - return empty; + return fs; } /** From 4f9dc273ec03c91d32a8762518c5491050b7cdc6 Mon Sep 17 00:00:00 2001 From: prife Date: Sat, 21 Dec 2013 11:35:09 +0800 Subject: [PATCH 2/3] dfs: fix dfs_unmount bug fix #211 --- components/dfs/src/dfs_fs.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/components/dfs/src/dfs_fs.c b/components/dfs/src/dfs_fs.c index 770fd71cfb..4c5982cf3b 100644 --- a/components/dfs/src/dfs_fs.c +++ b/components/dfs/src/dfs_fs.c @@ -320,6 +320,7 @@ err1: int dfs_unmount(const char *specialfile) { char *fullpath; + struct dfs_filesystem *iter; struct dfs_filesystem *fs = RT_NULL; fullpath = dfs_normalize_path(RT_NULL, specialfile); @@ -333,7 +334,17 @@ int dfs_unmount(const char *specialfile) /* lock filesystem */ dfs_lock(); - fs = dfs_filesystem_lookup(fullpath); + for (iter = &filesystem_table[0]; + iter < &filesystem_table[DFS_FILESYSTEMS_MAX]; iter++) + { + /* check if the PATH is mounted */ + if ((iter->path != NULL) && (strcmp(iter->path, fullpath) == 0)) + { + fs = iter; + break; + } + } + if (fs == RT_NULL || fs->ops->unmount == RT_NULL || fs->ops->unmount(fs) < 0) From 26a31d662d2efcae41e723d0928569fbb587dfd0 Mon Sep 17 00:00:00 2001 From: prife Date: Sat, 21 Dec 2013 12:04:19 +0800 Subject: [PATCH 3/3] dfs: make elmfatfs check secter size everytime more infomation: http://www.rt-thread.org/phpBB3/topic2965.html --- components/dfs/filesystems/elmfat/ff.c | 15 ++++++--------- components/dfs/filesystems/elmfat/ff.h | 2 -- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/components/dfs/filesystems/elmfat/ff.c b/components/dfs/filesystems/elmfat/ff.c index 014d70f590..e1f2f60c78 100644 --- a/components/dfs/filesystems/elmfat/ff.c +++ b/components/dfs/filesystems/elmfat/ff.c @@ -108,12 +108,8 @@ #if _MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096 #error Wrong sector size. #endif -#if _MAX_SS != 512 -#define SS(fs) ((fs)->ssize) /* Multiple sector size */ -#else -#define SS(fs) 512U /* Fixed sector size */ -#endif +#define SS(fs) ((fs)->ssize) /* sector size */ /* Reentrancy related */ #if _FS_REENTRANT @@ -2058,10 +2054,11 @@ FRESULT chk_mounted ( /* FR_OK(0): successful, !=0: any error occurred */ stat = disk_initialize(fs->drv); /* Initialize low level disk I/O layer */ if (stat & STA_NOINIT) /* Check if the initialization succeeded */ return FR_NOT_READY; /* Failed to initialize due to no media or hard error */ -#if _MAX_SS != 512 /* Get disk sector size (variable sector size cfg only) */ + + /* Get disk sector size (variable sector size cfg only) */ if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &fs->ssize) != RES_OK) return FR_DISK_ERR; -#endif + #if !_FS_READONLY if (chk_wp && (stat & STA_PROTECT)) /* Check disk write protection if needed */ return FR_WRITE_PROTECTED; @@ -3601,10 +3598,10 @@ FRESULT f_mkfs ( stat = disk_initialize(drv); if (stat & STA_NOINIT) return FR_NOT_READY; if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; -#if _MAX_SS != 512 /* Get disk sector size */ + /* Get disk sector size */ if (disk_ioctl(drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK) return FR_DISK_ERR; -#endif + if (disk_ioctl(drv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) return FR_DISK_ERR; b_vol = (sfd) ? 0 : 63; /* Volume start sector */ diff --git a/components/dfs/filesystems/elmfat/ff.h b/components/dfs/filesystems/elmfat/ff.h index dfbc100fff..061dd76dca 100644 --- a/components/dfs/filesystems/elmfat/ff.h +++ b/components/dfs/filesystems/elmfat/ff.h @@ -84,9 +84,7 @@ typedef struct { BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */ WORD id; /* File system mount ID */ WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ -#if _MAX_SS != 512 WORD ssize; /* Bytes per sector (512,1024,2048,4096) */ -#endif #if _FS_REENTRANT _SYNC_t sobj; /* Identifier of sync object */ #endif