This is the mail archive of the
ecos-patches@sourceware.org
mailing list for the eCos project.
fatfs patch
- From: Hajime Ishitani <pigmon at snd dot co dot jp>
- To: ecos-patches at sources dot redhat dot com
- Date: Fri, 15 Jun 2007 22:24:48 +0900
- Subject: fatfs patch
Hello all,
This patch revise problems in rmdir() and chdir() operation.
1.Eliminated ".." and "." node link in rmdir() operation.
2.Do not set a current node in a ".." in "chdir .." operation.
When a ".." operates rmdir() in a current node,
there is the case that a problem occurs.
Thanks
Hajime Ishitani
Index: ecos/packages/fs/fat/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/fs/fat/current/ChangeLog,v
retrieving revision 1.15
diff -u -r1.15 ChangeLog
--- ecos/packages/fs/fat/current/ChangeLog 6 Feb 2007 08:46:11 -0000 1.15
+++ ecos/packages/fs/fat/current/ChangeLog 15 Jun 2007 12:36:32 -0000
@@ -1,3 +1,7 @@
+2007-06-15 Hajime Ishitani <pigmon@mail.snd.co.jp>
+
+ * src/fatfs.c: Revise problems in rmdir() and chdir() operation.
+
2007-02-05 Ya-Chau Yang <a8850607@stmail.fju.edu.tw>
Savin Zlobec <savinz@users.sourceforge.net>
Index: ecos/packages/fs/fat/current/src/fatfs.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/fs/fat/current/src/fatfs.c,v
retrieving revision 1.5
diff -u -r1.5 fatfs.c
--- ecos/packages/fs/fat/current/src/fatfs.c 4 Aug 2006 09:22:05 -0000 1.5
+++ ecos/packages/fs/fat/current/src/fatfs.c 15 Jun 2007 12:36:38 -0000
@@ -756,6 +756,7 @@
fatfs_disk_t *disk = (fatfs_disk_t *) mte->data;
fatfs_dirsearch_t ds;
int err;
+ fatfs_node_t *node;
CYG_TRACE3(TFS, "rmdir mte=%p dir=%p name='%s'", mte, dir, name);
@@ -774,8 +775,17 @@
err = fatfs_delete_file(disk, &ds.node->dentry);
if (err == ENOERR)
+ {
fatfs_node_free(disk, ds.node);
-
+
+ node = fatfs_node_find( disk, ".", 1, ds.node->dentry.cluster );
+ if (node != NULL)
+ fatfs_node_free(disk, node);
+
+ node = fatfs_node_find( disk, "..", 2, ds.node->dentry.cluster );
+ if (node != NULL)
+ fatfs_node_free(disk, node);
+ }
return err;
}
@@ -944,23 +954,40 @@
if (dir_out != NULL)
{
// This is a request to get a new directory pointer in *dir_out
-
- fatfs_dirsearch_t ds;
+
+ fatfs_dirsearch_t ds1, ds2, *ds_out;
int err;
- init_dirsearch(&ds, disk, (fatfs_node_t *) dir, name);
+ init_dirsearch(&ds1, disk, (fatfs_node_t *) dir, name);
- err = fatfs_find(&ds);
+ err = fatfs_find(&ds1);
if (err != ENOERR)
return err;
- if (!S_ISDIR(ds.node->dentry.mode))
+ if (!S_ISDIR(ds1.node->dentry.mode))
return ENOTDIR;
- if (ds.node != disk->root)
- fatfs_node_ref(disk, ds.node);
-
- *dir_out = (cyg_dir) ds.node;
+ if ((ds1.node->dentry.filename[0] == '.')&&
+ (ds1.node->dentry.filename[1] == '.')&&
+ (ds1.node->dentry.filename[2] == 0))
+ {
+ init_dirsearch(&ds2, disk, ds1.node, ".");
+
+ err = fatfs_find(&ds2);
+ if (err != ENOERR)
+ return err;
+
+ ds_out = &ds2;
+ }
+ else
+ {
+ ds_out = &ds1;
+ }
+
+ if (ds_out->node != disk->root)
+ fatfs_node_ref(disk, ds_out->node);
+
+ *dir_out = (cyg_dir) ds_out->node;
}
else
{