This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: fatfs patch


On Fri, Jun 15, 2007 at 10:24:48PM +0900, Hajime Ishitani wrote:
> Hello all,
> 
> This patch revise problems in rmdir() and chdir() operation.
> 
> 1.Eliminated ".." and "." node link in rmdir() operation.

This patch of the part is O.K. I made one minor change, placing the
fatfs_node_free() at the end of the if () not at the beginning. There
might be some danger in removing . and .. if you have already removed
the directory? So to me it seems safer to remove the directory last.

> 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.

This part of the patch i have problems with. It causes the test case.
fs/fat/current/tests/fatfs1.c to fail. 

Please could you take a second look at the second half of your patch.

Attached is what i have committed for the rmdir fix.

     Thanks

         Andrew
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/fs/fat/current/ChangeLog,v
retrieving revision 1.15
diff -u -r1.15 ChangeLog
--- ChangeLog	6 Feb 2007 08:46:11 -0000	1.15
+++ ChangeLog	31 Jul 2007 18:41:25 -0000
@@ -1,3 +1,8 @@
+2007-07-31  Hajime Ishitani <pigmon@mail.snd.co.jp>
+
+	* src/fatfs.c: When removing a directory, first remove . and
+	.. nodes.
+	
 2007-02-05  Ya-Chau Yang <a8850607@stmail.fju.edu.tw> 
             Savin Zlobec <savinz@users.sourceforge.net>
 
Index: 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
--- src/fatfs.c	4 Aug 2006 09:22:05 -0000	1.5
+++ src/fatfs.c	31 Jul 2007 18:41:27 -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)
+    {
+        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);
+
         fatfs_node_free(disk, ds.node);
-    
+    }
     return err;
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]