src/server/daemon/vfs.c

changeset 75
6195c92262a2
parent 72
9b888965f3ee
child 87
bdec069d2239
--- a/src/server/daemon/vfs.c	Sun Jun 23 13:49:17 2013 +0200
+++ b/src/server/daemon/vfs.c	Sun Jun 23 13:51:49 2013 +0200
@@ -292,8 +292,23 @@
         }
     }
     
-    // open file  
+    // open directory
+#ifdef BSD
     DIR *sys_dir = opendir(path);
+    if(sys_dir) {
+        int dir_fd = dirfd(sys_dir);
+    }
+#else
+    int dir_fd = open(path, O_RDONLY);
+    if(dir_fd == -1) {
+        if(ctx) {
+            ctx->vfs_errno = errno;
+            sys_set_error_status(ctx);
+        }
+        return NULL;
+    }
+    DIR *sys_dir = fdopendir(dir_fd);
+#endif
     if(!sys_dir) {
         if(ctx) {
             ctx->vfs_errno = errno;
@@ -310,7 +325,7 @@
     }
     dir->ctx = ctx;
     dir->data = sys_dir;
-    dir->fd = dirfd(sys_dir);
+    dir->fd = dir_fd;
     dir->io = &sys_dir_io;
     return dir;
 }

mercurial