Index: uspace/lib/posix/Makefile
===================================================================
--- uspace/lib/posix/Makefile	(revision d4d74dc3a5ed0e53be6d43c318f9f3798e9f4c49)
+++ uspace/lib/posix/Makefile	(revision e61aa802b6438793f4a350ef8eec5266ca467d80)
@@ -43,4 +43,5 @@
 	fcntl.c \
 	fnmatch.c \
+	getopt.c \
 	locale.c \
 	math.c \
Index: uspace/lib/posix/getopt.c
===================================================================
--- uspace/lib/posix/getopt.c	(revision e61aa802b6438793f4a350ef8eec5266ca467d80)
+++ uspace/lib/posix/getopt.c	(revision e61aa802b6438793f4a350ef8eec5266ca467d80)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2012 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libposix
+ * @{
+ */
+/** @file Command line argument parsing.
+ */
+#define LIBPOSIX_INTERNAL
+
+#include "internal/common.h"
+#include "libc/getopt.h"
+#include "getopt.h"
+
+
+int posix_getopt_long(int argc, char * const argv[],
+    const char *opt_string, const struct option *long_opts, int *long_index)
+{
+	return getopt_long(argc, argv, opt_string, long_opts, long_index);
+}
+
Index: uspace/lib/posix/getopt.h
===================================================================
--- uspace/lib/posix/getopt.h	(revision e61aa802b6438793f4a350ef8eec5266ca467d80)
+++ uspace/lib/posix/getopt.h	(revision e61aa802b6438793f4a350ef8eec5266ca467d80)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2012 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libposix
+ * @{
+ */
+/** @file Command line argument parsing.
+ */
+#ifndef POSIX_GETOPT_H
+#define POSIX_GETOPT_H
+
+#include "unistd.h"
+
+/* Option Arguments */
+#define no_argument        0
+#define required_argument  1
+#define optional_argument  2
+
+#ifndef LIBPOSIX_INTERNAL
+struct option {
+	const char *name;
+	int has_arg;
+	int *flag;
+	int val;
+};
+#endif
+
+extern int posix_getopt_long(int, char * const [], const char *, const struct option *, int *);
+
+
+#ifndef LIBPOSIX_INTERNAL
+	#define getopt_long posix_getopt_long
+#endif
+
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/posix/stdbool.h
===================================================================
--- uspace/lib/posix/stdbool.h	(revision d4d74dc3a5ed0e53be6d43c318f9f3798e9f4c49)
+++ uspace/lib/posix/stdbool.h	(revision e61aa802b6438793f4a350ef8eec5266ca467d80)
@@ -37,5 +37,9 @@
 
 #ifdef LIBC_BOOL_H_
-	#error "You can't include bool.h and stdbool.h at the same time."
+#	ifndef POSIX_STDIO_H_
+#		ifndef POSIX_STDLIB_H_
+#			error "You can't include bool.h and stdbool.h at the same time."
+#		endif
+#	endif
 #endif
 #define LIBC_BOOL_H_
Index: uspace/lib/posix/unistd.c
===================================================================
--- uspace/lib/posix/unistd.c	(revision d4d74dc3a5ed0e53be6d43c318f9f3798e9f4c49)
+++ uspace/lib/posix/unistd.c	(revision e61aa802b6438793f4a350ef8eec5266ca467d80)
@@ -49,4 +49,5 @@
 /* Array of environment variable strings (NAME=VALUE). */
 char **posix_environ = NULL;
+char *posix_optarg;
 
 /**
Index: uspace/lib/posix/unistd.h
===================================================================
--- uspace/lib/posix/unistd.h	(revision d4d74dc3a5ed0e53be6d43c318f9f3798e9f4c49)
+++ uspace/lib/posix/unistd.h	(revision e61aa802b6438793f4a350ef8eec5266ca467d80)
@@ -43,6 +43,5 @@
 #define _exit exit
 
-/* Option Arguments */
-extern char *optarg;
+extern char *posix_optarg;
 extern int optind, opterr, optopt;
 extern int getopt(int, char * const [], const char *);
@@ -144,4 +143,6 @@
 
 #ifndef LIBPOSIX_INTERNAL
+	#define optarg posix_optarg
+
 	#define environ posix_environ
 
