PHYSFS_mkdir breakage

David Hedbor david at hedbor.org
Tue Mar 18 01:08:10 EST 2003


This method is broken as shown:

stat64("/home/neotron/", {st_mode=S_IFDIR|0755, st_size=27040, ...}) = 0
lstat64("/home/neotron/.eongames", {st_mode=S_IFDIR|0700, st_size=72, ...}) = 0
lstat64("/home/neotron/.eongames/testapp", 0xbffff730) = -1 ENOENT (No such file or directory)
mkdir("/home/neotron/.eongames", 0700)  = -1 EEXIST (File exists)

It's pretty self-explanatory - mkdir fails because the directory
already exists and then exits, not creating the next step of the
path. I'm not quite sure what the best fix is. My guess is to not even
try to make the directory if it already exists. The second option is
to make mkdir not fail if errno == EEXIST. If that is ok, here's a
diff for the posix case:

Index: platform/posix.c
===================================================================
RCS file: /cvs/cvsroot/physfs/platform/posix.c,v
retrieving revision 1.12
diff -u -r1.12 posix.c
--- platform/posix.c    2002/11/22 06:24:10     1.12
+++ platform/posix.c    2003/03/18 06:07:46
@@ -317,7 +317,7 @@
     int rc;
     errno = 0;
     rc = mkdir(path, S_IRWXU);
-    BAIL_IF_MACRO(rc == -1, strerror(errno), 0);
+    BAIL_IF_MACRO(rc == -1 && errno != EEXIST, strerror(errno), 0);
     return(1);
 } /* __PHYSFS_platformMkDir */



-- 
[ Below is a random fortune, which is unrelated to the above message. ]
Write yourself a threatening letter and pen a defiant reply.




More information about the physfs mailing list