Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r1557 - trunk: . fsvs/src

fsvs
Discussion topic

Back to topic list

svn commit: r1557 - trunk: . fsvs/src

Author pmarek
Full name P.Marek
Date 2008-03-18 23:42:34 PDT
Message Author: pmarek
Date: 2008-03-18 23:42:34-0700
New Revision: 1557

Modified:
   trunk/ (props changed)
   trunk/fsvs/src/waa.c

Log:
Bugfix for waa__mkdir() - the filename was created as directory on waa_close().


Modified: trunk/fsvs/src/waa.c
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/waa​.c?view=diff&rev​=1557&p1=trunk/f​svs/src/waa.c&p2​=trunk/fsvs/src/waa.​c&r1=1556&r2​=1557
====================​====================​====================​==================
--- trunk/fsvs/src/waa.c (original)
+++ trunk/fsvs/src/waa.c 2008-03-18 23:42:34-0700
@@ -291,41 +291,35 @@
 {
     int status;
     char *last_ps;
+ struct stat buf;
 
 
- /* just trying is faster than checking ?
- * EEXIST does not differentiate type of existing node -
- * so it may be a file. */
- if (mkdir(dir, 0777) == -1)
+ status=0;
+ /* Does something exist here? */
+ if (lstat(dir, &buf) == -1)
     {
- status=errno;
- switch(status)
+ if (errno == ENOENT)
         {
- case EEXIST:
- /* Is ok ... */
- status=0;
- break;
- case ENOENT:
- /* Some intermediate levels are still missing; try again
- * recursively. */
- last_ps=strrchr(dir, PATH_SEPARATOR);
- BUG_ON(!last_ps);
-
- /* Strip last directory, and *always* undo the change. */
- *last_ps=0;
- status=waa__mkdir(dir, 1);
- *last_ps=PATH_SEPARATOR;
- STOPIF( status, NULL);
-
- /* Now the parent was done ... so we should not get ENOENT again. */
- if (including_last)
- STOPIF( waa__mkdir(dir, 1), NULL);
- break;
- default:
- STOPIF(status, "cannot mkdir(%s)", dir);
+ /* Some intermediate levels are still missing; try again
+ * recursively. */
+ last_ps=strrchr(dir, PATH_SEPARATOR);
+ BUG_ON(!last_ps);
+
+ /* Strip last directory, and *always* undo the change. */
+ *last_ps=0;
+ status=waa__mkdir(dir, 1);
+ *last_ps=PATH_SEPARATOR;
+ STOPIF( status, NULL);
+
+ DEBUGP("%s: last is %d", dir, including_last);
+ /* Now the parent was done ... so we should not get ENOENT again. */
+ if (including_last)
+ STOPIF_CODE_ERR( mkdir(dir, 0777) == -1, errno,
+ "cannot mkdir(%s)", dir);
         }
+ else
+ STOPIF(status, "cannot lstat(%s)", dir);
     }
- status=0;
 
 ex:
     return status;
@@ -612,7 +606,7 @@
     target= target_name_array ? target_name_array+filehandle : NULL;
 
     if (target)
- DEBUGP("filehandle %d should be %s", filehandle, target->dest_name);
+ DEBUGP("filehandle %d should be %s", filehandle, target->dest_name);
     else
         DEBUGP("filehandle %d wasn't opened via waa__open()!", filehandle);
 
@@ -623,15 +617,15 @@
 
         if (target)
         {
- /* Now that we know we'd like to keep that file, make the directories
+ /* Now that we know we'd like to keep that file, make the directories
              * as needed. */
             STOPIF( waa__mkdir(target-​>dest_name, 0), NULL);
 
- /* And give it the correct name. */
- STOPIF_CODE_ERR(
- rename(target->temp_name, target->dest_name) == -1,
- errno, "renaming tmp file from %s to %s",
- target->temp_name, target->dest_name);
+ /* And give it the correct name. */
+ STOPIF_CODE_ERR(
+ rename(target->temp_name, target->dest_name) == -1,
+ errno, "renaming tmp file from %s to %s",
+ target->temp_name, target->dest_name);
         }
 
         do_unlink=0;
@@ -651,8 +645,8 @@
 
     if (target)
     {
- IF_FREE(target->temp_name);
- IF_FREE(target->dest_name);
+ IF_FREE(target->temp_name);
+ IF_FREE(target->dest_name);
     }
 
     return status;
@@ -2463,7 +2457,7 @@
     struct estat **list, *sts;
 
 
- status=0;
+ status=0;
 
     if ( !root->by_name)
         STOPIF( dir__sortbyname(root), NULL);

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r1557 - trunk: . fsvs/src pmarek P.Marek 2008-03-18 23:42:34 PDT
Messages per page: