Index: uspace/lib/posix/fcntl.c
===================================================================
--- uspace/lib/posix/fcntl.c	(revision 8b5fb5e05bd2ac578f56a26a49549e6b05a591a7)
+++ uspace/lib/posix/fcntl.c	(revision 4ec6820f265a308f6208e8d7ba4175dd5477ceb9)
@@ -37,16 +37,84 @@
 #include "internal/common.h"
 #include "fcntl.h"
+#include "libc/unistd.h"
+#include "libc/vfs/vfs.h"
+#include <errno.h>
 
 /**
- * 
- * @param fd
- * @param cmd
- * @param ...
- * @return
+ * Performs set of operations on the opened files.
+ *
+ * @param fd File descriptor of the opened file.
+ * @param cmd Operation to carry out.
+ * @return Non-negative on success. Might have special meaning corresponding
+ *     to the requested operation.
  */
 int posix_fcntl(int fd, int cmd, ...)
 {
-	// TODO
-	not_implemented();
+	int rc;
+	int flags;
+
+	switch (cmd) {
+	case F_DUPFD:
+	case F_DUPFD_CLOEXEC: /* FD_CLOEXEC is not supported. */
+		/* VFS does not provide means to express constraints on the new
+		 * file descriptor so the third argument is ignored. */
+
+		/* Retrieve node triplet corresponding to the file descriptor. */
+		/* Empty statement after label. */;
+		fdi_node_t node;
+		rc = fd_node(fd, &node);
+		if (rc != EOK) {
+			// TODO: propagate a POSIX compatible errno
+			return -1;
+		}
+
+		/* Reopen the node so the fresh file descriptor is generated. */
+		int newfd = open_node(&node, 0);
+		if (newfd < 0) {
+			// TODO: propagate a POSIX compatible errno
+			return -1;
+		}
+
+		/* Associate the newly generated descriptor to the file description
+		 * of the old file descriptor. Just reopened node will be automatically
+		 * closed. */
+		rc = dup2(fd, newfd);
+		if (rc != EOK) {
+			// TODO: propagate a POSIX compatible errno
+			return -1;
+		}
+
+		return newfd;
+	case F_GETFD:
+		/* FD_CLOEXEC is not supported. There are no other flags. */
+		return 0;
+	case F_SETFD:
+		/* FD_CLOEXEC is not supported. Ignore arguments and report success. */
+		return 0;
+	case F_GETFL:
+		/* File status flags (i.e. O_APPEND) are currently private to the
+		 * VFS server so it cannot be easily retrieved. */
+		flags = 0;
+		/* File access flags are currently not supported for file descriptors.
+		 * Provide full access. */
+		flags |= O_RDWR;
+		return flags;
+	case F_SETFL:
+		/* File access flags are currently not supported for file descriptors.
+		 * Ignore arguments and report success. */
+		return 0;
+	case F_GETOWN:
+	case F_SETOWN:
+	case F_GETLK:
+	case F_SETLK:
+	case F_SETLKW:
+		/* Signals (SIGURG) and file locks are not supported. */
+		errno = ENOTSUP;
+		return -1;
+	default:
+		/* Unknown command */
+		errno = EINVAL;
+		return -1;
+	}
 }
 
Index: uspace/lib/posix/fcntl.h
===================================================================
--- uspace/lib/posix/fcntl.h	(revision 8b5fb5e05bd2ac578f56a26a49549e6b05a591a7)
+++ uspace/lib/posix/fcntl.h	(revision 4ec6820f265a308f6208e8d7ba4175dd5477ceb9)
@@ -36,8 +36,14 @@
 #define POSIX_FCNTL_H_
 
+#include "sys/types.h"
 #include "libc/fcntl.h"
+
+/* Mask for file access modes. */
+#undef O_ACCMODE
+#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
 
 /* fcntl commands */
 #undef F_DUPFD
+#undef F_DUPFD_CLOEXEC
 #undef F_GETFD
 #undef F_SETFD
@@ -46,15 +52,22 @@
 #undef F_GETOWN
 #undef F_SETOWN
-#define	F_DUPFD	  	0	/* Duplicate file descriptor. */
-#define	F_GETFD		1	/* Get file descriptor flags. */
-#define	F_SETFD		2	/* Set file descriptor flags. */
-#define	F_GETFL		3	/* Get file status flags. */
-#define	F_SETFL		4	/* Set file status flags. */
-#define F_GETOWN	5	/* Get owner. */
-#define F_SETOWN	6	/* Set owner. */
+#undef F_GETLK
+#undef F_SETLK
+#undef F_SETLKW
+#define	F_DUPFD            0 /* Duplicate file descriptor. */
+#define F_DUPFD_CLOEXEC    1 /* Same as F_DUPFD but with FD_CLOEXEC flag set. */
+#define	F_GETFD            2 /* Get file descriptor flags. */
+#define	F_SETFD            3 /* Set file descriptor flags. */
+#define	F_GETFL            4 /* Get file status and access flags. */
+#define	F_SETFL            5 /* Set file status flags. */
+#define F_GETOWN           6 /* Get socket owner. */
+#define F_SETOWN           7 /* Set socket owner. */
+#define F_GETLK            8 /* Get locking information. */
+#define F_SETLK            9 /* Set locking information. */
+#define F_SETLKW          10 /* Set locking information; wait if blocked. */
 
 /* File descriptor flags used with F_GETFD and F_SETFD. */
 #undef FD_CLOEXEC
-#define	FD_CLOEXEC	1	/* Close on exec. */
+#define	FD_CLOEXEC         1 /* Close on exec. */
 
 extern int posix_fcntl(int fd, int cmd, ...);
