Browse Source

1) elm fatfs can do mkfs without mounting first, 2) use new mkfs 3)change linebreak in dfs_uffs.c to unix

prife 12 years ago
parent
commit
b3cf278502

File diff suppressed because it is too large
+ 560 - 516
components/dfs/filesystems/elmfat/dfs_elm.c


+ 1 - 1
components/dfs/filesystems/jffs2/dfs_jffs2.c

@@ -222,7 +222,7 @@ static int dfs_jffs2_unmount(struct dfs_filesystem* fs)
 	return -DFS_STATUS_ENOENT;
 }
 
-static int dfs_jffs2_mkfs(const char* device_name)
+static int dfs_jffs2_mkfs(rt_device_t dev_id)
 {
 	/* just erase all blocks on this nand partition */
 	return -DFS_STATUS_ENOSYS; 

+ 2 - 4
components/dfs/filesystems/uffs/dfs_uffs.c

@@ -207,7 +207,7 @@ static int dfs_uffs_unmount(struct dfs_filesystem* fs)
 	return -DFS_STATUS_ENOENT;
 }
 
-static int dfs_uffs_mkfs(const char* device_name)
+static int dfs_uffs_mkfs(rt_device_t dev_id)
 {
 	rt_base_t index;
 	rt_uint32_t block;
@@ -216,15 +216,13 @@ static int dfs_uffs_mkfs(const char* device_name)
 	/*1. find the device index */
 	for (index = 0; index < UFFS_DEVICE_MAX; index++)
 	{
-		if (rt_strncmp(nand_part[index].dev->parent.parent.name,
-				       device_name, RT_NAME_MAX) == 0)
+		if (nand_part[index].dev == (struct rt_mtd_nand_device *)dev_id)
 			break;
 	}
 
 	if (index == UFFS_DEVICE_MAX)
 	{
 		/* can't find device driver */
-		rt_kprintf("can not find device driver: %s\n", device_name);
 		return -DFS_STATUS_ENOENT;
 	}
 

+ 1 - 1
components/dfs/include/dfs_fs.h

@@ -35,7 +35,7 @@ struct dfs_filesystem_operation
     int (*unmount)  (struct dfs_filesystem *fs);
 
     /* make a file system */
-    int (*mkfs)     (const char *device_name);
+    int (*mkfs)     (rt_device_t devid);
     int (*statfs)   (struct dfs_filesystem *fs, struct statfs *buf);
 
     int (*open)     (struct dfs_fd *fd);

+ 14 - 1
components/dfs/src/dfs_fs.c

@@ -424,6 +424,19 @@ err1:
 int dfs_mkfs(const char *fs_name, const char *device_name)
 {
     int index;
+    rt_device_t dev_id;
+
+    /* check device name, and it should not be NULL */
+    if (device_name == RT_NULL)
+        dev_id = RT_NULL;
+    else
+        dev_id = rt_device_find(device_name);
+
+    if (dev_id == RT_NULL)
+    {
+        rt_set_errno(-DFS_STATUS_ENODEV);
+        return -1;
+    }
 
     /* lock file system */
     dfs_lock();
@@ -438,7 +451,7 @@ int dfs_mkfs(const char *fs_name, const char *device_name)
             dfs_unlock();
 
             if (ops->mkfs != RT_NULL)
-                return ops->mkfs(device_name);
+                return ops->mkfs(dev_id);
 
             break;
         }

Some files were not shown because too many files changed in this diff