Index: uspace/lib/c/generic/vfs/vfs.c
===================================================================
--- uspace/lib/c/generic/vfs/vfs.c	(revision 80743a1b2ba5306f70559161509a3376fa381a08)
+++ uspace/lib/c/generic/vfs/vfs.c	(revision b19e892c22afbf67aa5988554dd3f003efeadc04)
@@ -41,5 +41,4 @@
 #include <unistd.h>
 #include <dirent.h>
-#include <fcntl.h>
 #include <stdio.h>
 #include <sys/types.h>
@@ -155,11 +154,26 @@
 }
 
-int _vfs_open(int fildes, int mode)
-{
-	async_exch_t *exch = vfs_exchange_begin();
-	sysarg_t rc = async_req_2_0(exch, VFS_IN_OPEN, fildes, mode);
-	vfs_exchange_end(exch);
-	
-	return (int) rc;
+int vfs_open(int file, int mode)
+{
+	async_exch_t *exch = vfs_exchange_begin();
+	int rc = async_req_2_0(exch, VFS_IN_OPEN, file, mode);
+	vfs_exchange_end(exch);
+	
+	return rc;
+}
+
+int vfs_lookup_open(const char *path, int flags, int mode)
+{
+	int file = vfs_lookup(path, flags);
+	if (file < 0)
+		return file;
+
+	int rc = vfs_open(file, mode);
+	if (rc != EOK) {
+		close(file);
+		return rc;
+	}
+	
+	return file;
 }
 
@@ -353,64 +367,4 @@
 }
 
-static int walk_flags(int oflags)
-{
-	int flags = 0;
-	if (oflags & O_CREAT) {
-		if (oflags & O_EXCL)
-			flags |= WALK_MUST_CREATE;
-		else
-			flags |= WALK_MAY_CREATE;
-	}
-	return flags;
-}
-
-/** Open file.
- *
- * @param path File path
- * @param oflag O_xxx flags
- * @param mode File mode (only with O_CREAT)
- *
- * @return Nonnegative file descriptor on success. On error -1 is returned
- *         and errno is set.
- */
-int open(const char *path, int oflag, ...)
-{
-	if (((oflag & (O_RDONLY | O_WRONLY | O_RDWR)) == 0) ||
-	    ((oflag & (O_RDONLY | O_WRONLY)) == (O_RDONLY | O_WRONLY)) ||
-	    ((oflag & (O_RDONLY | O_RDWR)) == (O_RDONLY | O_RDWR)) ||
-	    ((oflag & (O_WRONLY | O_RDWR)) == (O_WRONLY | O_RDWR))) {
-		errno = EINVAL;
-		return -1;
-	}
-	
-	int fd = vfs_lookup(path, walk_flags(oflag) | WALK_REGULAR);
-	if (fd < 0) {
-		errno = fd;
-		return -1;
-	}
-	
-	int mode =
-	    ((oflag & O_RDWR) ? MODE_READ | MODE_WRITE : 0) |
-	    ((oflag & O_RDONLY) ? MODE_READ : 0) |
-	    ((oflag & O_WRONLY) ? MODE_WRITE : 0) |
-	    ((oflag & O_APPEND) ? MODE_APPEND : 0);
-	
-	int rc = _vfs_open(fd, mode); 
-	if (rc < 0) {
-		close(fd);
-		errno = rc;
-		return -1;
-	}
-	
-	if (oflag & O_TRUNC) {
-		assert(oflag & O_WRONLY || oflag & O_RDWR);
-		assert(!(oflag & O_APPEND));
-		
-		(void) vfs_resize(fd, 0);
-	}
-
-	return fd;
-}
-
 /** Close file.
  *
@@ -703,5 +657,5 @@
 	}
 	
-	int rc = _vfs_open(fd, MODE_READ);
+	int rc = vfs_open(fd, MODE_READ);
 	if (rc < 0) {
 		free(dirp);
