src/server/daemon/vfs.c

changeset 72
9b888965f3ee
parent 70
4e6e812c1d97
child 87
bdec069d2239
--- a/src/server/daemon/vfs.c	Fri Jun 21 12:10:44 2013 +0200
+++ b/src/server/daemon/vfs.c	Sat Jun 22 13:08:36 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