#2924: createDirectory: permission denied
------------------------------------+---------------------------------------
    Reporter:  simonmar             |        Owner:              
        Type:  bug                  |       Status:  new         
    Priority:  normal               |    Milestone:  6.12.2      
   Component:  libraries/directory  |      Version:  6.10.1      
    Keywords:                       |   Difficulty:  Unknown     
          Os:  Windows              |     Testcase:              
Architecture:  x86                  |      Failure:  None/Unknown
------------------------------------+---------------------------------------

Comment(by igloo):

 Why shouldn't this permission denied be possible, where one thread is
 getting a directory listing to work out what to remove, while the other is
 actually doing the remove?
 {{{
 $ cat q.c
 #include <sys/types.h>
 #include <dirent.h>
 #include <stdio.h>

 void die(char *str) {
     perror("Failing");
     printf("while calling: %s\n", str);
     exit(1);
 }

 int main(void) {
     DIR *d;
     struct dirent *e;
     int n;

     n = 0;
     printf("opening directory\n");
     d = opendir("foo");
     if (d == NULL) die("opendir");

     while ((e = readdir(d)) != NULL) {
         printf("Read: %s\n", e->d_name);
         n++;
         if (n == 3) {
             printf("Cleaning\n");
             if (unlink("foo/file1") != 0) die("unlink 1");
             if (unlink("foo/file2") != 0) die("unlink 2");
             if (unlink("foo/file3") != 0) die("unlink 3");
             if (rmdir("foo") != 0) die("rmdir");
         }
     }

     printf("closing directory\n");
     if (closedir(d) != 0) die("closedir");

     return 0;
 }

 $ mkdir foo; touch foo/file1; touch foo/file2; touch foo/file3
 $ ../ghc/inplace/mingw/bin/gcc q.c -o q
 $ ./q
 opening directory
 Read: .
 Read: ..
 Read: file1
 Cleaning
 Failing: Permission denied
 while calling: rmdir
 $
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2924#comment:14>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to