aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys-libs/musl/Manifest14
-rw-r--r--sys-libs/musl/files/getconf.194
-rw-r--r--sys-libs/musl/files/getconf.c338
-rw-r--r--sys-libs/musl/files/getent.1145
-rw-r--r--sys-libs/musl/files/getent.c437
-rw-r--r--sys-libs/musl/files/iconv.c110
-rw-r--r--sys-libs/musl/files/ldconfig143
-rw-r--r--sys-libs/musl/files/ldconfig.in144
-rw-r--r--sys-libs/musl/files/musl-1.1.15-pthread_setname_np.patch64
-rw-r--r--sys-libs/musl/metadata.xml15
-rw-r--r--sys-libs/musl/musl-1.1.15-r1.ebuild147
11 files changed, 1651 insertions, 0 deletions
diff --git a/sys-libs/musl/Manifest b/sys-libs/musl/Manifest
new file mode 100644
index 0000000..cc56e68
--- /dev/null
+++ b/sys-libs/musl/Manifest
@@ -0,0 +1,14 @@
+AUX getconf.1 2607 SHA256 887540a54dff24690eb4939cf2c212815af2084dbaa2f6b6f0f5579762217e69 SHA512 46d78f391c841b01723201eb5083c08717dc483a3be9acc318a4504d40f73ef7db9193b065883fd2ddeae50eb5775ea6c2975b9abd532841e11accb41ab246f9 WHIRLPOOL 403807378ade796af5d410e59a2317413b07129278f7d8c2cecea862473db5b849833eca96cb9d21acd803cc0abffdc6c418dc589bf16c4c551b6a376db582d1
+AUX getconf.c 11614 SHA256 d87d0cbb3690ae2c5d8cc218349fd8278b93855dd625deaf7ae50e320aad247c SHA512 0d80f37b34a35e3d14b012257c50862dfeb9d2c81139ea2dfa101d981d093b009b9fa450ba27a708ac59377a48626971dfc58e20a3799084a65777a0c32cbc7d WHIRLPOOL 279170a21cd6d5b560b0c834236acf4989f1a7f5e9ecf9d7e594abc21b65f8aeb26a26475c49f4052d5f9b4f9d95032d22b1790dbd99e3f55c3677eb9fc6df8b
+AUX getent.1 4158 SHA256 def855f6a97422ebd179b8e5591b364a5c77c94b3504cc25c86927f8b1afc324 SHA512 c6ff410ebe1d56988551306de496c96a8692ec798cb0162a442c92e41ba0dafedd37a9b388b9b6e383eb33e50d8274a1ed41bb137f786358b8ee3e9d136dcfc1 WHIRLPOOL 6005ef712e8c05f35d5438aef9716109a7b33be4dd4c597b9c124ccfce60c3a8e48f25dfab22b141c0979ba52729d6f3cb7d05bcab30eb4f29db9db20b2e227c
+AUX getent.c 9438 SHA256 68373a55e89ce85c562d941ccf588337d6cc6c9c17689d695f65cd7607134bbe SHA512 b35de9847353b273516162ed4828a810c6130fc5b7de44ee4433003b3f99647b25792d9b1c40dfc67069add11f3fb850e5c35d4f1912dccac108059bbbdfd5a2 WHIRLPOOL 473e54a9158e70c411f4c84e590bcfd245051212a3346a3c6dd45df9f09a5fbccbc8900ad7f8691eb5ebb8cd1002caf9519abaffb1753175d4f8acb1d32236b4
+AUX iconv.c 2577 SHA256 f79a2930a2e5bb0624321589edf8b889d1e9b603e01e6b7ae214616605b3fdd7 SHA512 9d42d66fb1facce2b85dad919be5be819ee290bd26ca2db00982b2f8e055a0196290a008711cbe2b18ec9eee8d2270e3b3a4692c5a1b807013baa5c2b70a2bbf WHIRLPOOL 8b067d7f3e5b8c9862cf78cf727fa748d9b6b23be518df382251d1e3e0a6eb386b1fd7788ba3b36dadba03aa5b43e25eb25528efcadc74fa543c38a61650c5bc
+AUX ldconfig 2542 SHA256 e58f98ddd14206a43439bf3431abee786f800867b3e53ac50d43cc8528304621 SHA512 384213cec3842bf9305c9093d7f52c11f8b448c3dcfd78c34e90c28a0ce3848046724f196b1146238ee8fa5f7e337289305efa82cb1f6948f3e171566f71d9b6 WHIRLPOOL 73fcd097ad68b6ae5f33099e45d129fd89ee74c23760fc1eca6b4612fd1a8030df85a8fe019c2bf4e6ed4b0b3a969d2f3678ddd2f6955685037eaff9503cab93
+AUX ldconfig.in 2558 SHA256 d0b0d5d4c955c0a0385ebb4f897afceeb64349089b97f41300cd088eb84d7d3a SHA512 dd18cb4f9910f338a840ceb192525159dd199263bd7d63cb98bc27cc0d876956756881da6ce589e2db13874bfe1b9ce23e7ab2a9ca6aafe360ab6797f580f84f WHIRLPOOL 1fb87b774e8ea06d33f1a502408342847893b4259e83ca6e817f1592a3b6ba3ce3d10cebe5c30c6761e93c7fa3b970011ae5bcdcd01815e3b4ce8451fabc22a0
+AUX musl-1.1.15-pthread_setname_np.patch 1916 SHA256 19e4434063b008b6f5ff3d58310797170136f8c2ffc7e24d0d907de58c4432a1 SHA512 7a94c9d96b0978622dd9ee76a34ce7764bce3df75d0573ad63a40922c18cc226de395258f97a520c2d100c391f98c91119ce1a5b4173fee70a8a1c9343206131 WHIRLPOOL 7ad5b6f064e2b05903163b882f4392d955ad4638b0d44340d07c3b11e1b7bddf31f2142231734fd9b8fdd6371c6625096a311b9d5629121ae01b5d3de47a54ed
+DIST getconf.c 11614 SHA256 d87d0cbb3690ae2c5d8cc218349fd8278b93855dd625deaf7ae50e320aad247c SHA512 0d80f37b34a35e3d14b012257c50862dfeb9d2c81139ea2dfa101d981d093b009b9fa450ba27a708ac59377a48626971dfc58e20a3799084a65777a0c32cbc7d WHIRLPOOL 279170a21cd6d5b560b0c834236acf4989f1a7f5e9ecf9d7e594abc21b65f8aeb26a26475c49f4052d5f9b4f9d95032d22b1790dbd99e3f55c3677eb9fc6df8b
+DIST getent.c 9438 SHA256 68373a55e89ce85c562d941ccf588337d6cc6c9c17689d695f65cd7607134bbe SHA512 b35de9847353b273516162ed4828a810c6130fc5b7de44ee4433003b3f99647b25792d9b1c40dfc67069add11f3fb850e5c35d4f1912dccac108059bbbdfd5a2 WHIRLPOOL 473e54a9158e70c411f4c84e590bcfd245051212a3346a3c6dd45df9f09a5fbccbc8900ad7f8691eb5ebb8cd1002caf9519abaffb1753175d4f8acb1d32236b4
+DIST iconv.c 2577 SHA256 f79a2930a2e5bb0624321589edf8b889d1e9b603e01e6b7ae214616605b3fdd7 SHA512 9d42d66fb1facce2b85dad919be5be819ee290bd26ca2db00982b2f8e055a0196290a008711cbe2b18ec9eee8d2270e3b3a4692c5a1b807013baa5c2b70a2bbf WHIRLPOOL 8b067d7f3e5b8c9862cf78cf727fa748d9b6b23be518df382251d1e3e0a6eb386b1fd7788ba3b36dadba03aa5b43e25eb25528efcadc74fa543c38a61650c5bc
+DIST musl-1.1.15.tar.gz 911600 SHA256 97e447c7ee2a7f613186ec54a93054fe15469fe34d7d323080f7ef38f5ecb0fa SHA512 9e923572c0d6bad3dc2d2646d4b0699c10b477ce6300ac6c6224895192a90667f581ddf6eda2ab8c4c16f47bde4bccb03bb90478638d136d9df721430f4d0163 WHIRLPOOL 68c510cf7d4216ccc5775466fa23f76ebecf1658552d613dee523bb7cc3a9f824959fe76355d1ce47326b276bf2657c9b4f3f557d81bf9c1a873f18405ad8ebf
+EBUILD musl-1.1.15-r1.ebuild 3789 SHA256 704f10badc1a14d199cd35e7550dde15f4ba9ee2668a66b3dfcad29c2ff88be0 SHA512 d248278aa1dd0123cecc1a1fb1fa017d78dfccaf9be4f35842ae55159bd846b5fd3d1e7662e088185102b5f34a8f8e2414831ac3eaa4423b8816c5cf9acf0c20 WHIRLPOOL 4641605122ced6f4437af2d0375ebcfc6e5da22b2832ebbc6d13c8bf7a30d796f019d83d3421cd27c84b2f783ccb62e5ab7390c86a146875ff65c6f308c60ed4
+MISC metadata.xml 452 SHA256 90358b6f07879cb68c7a5f476ea8e1ce1db78e286fdb5ed005963427b2267fed SHA512 676d8122179a5cb56e0b9c7aeb7f0aec8c19b5d7b604a19c9ee01aeca837a74cc4284e87cc743d0eaf527f0c79afdfeb1f238c204a8a6c1c5590b2718bbc9b03 WHIRLPOOL ed9e1e5b6ba088a271d5080803449aecfc3110ba4f0f5b373f6fb5cc089344fe2ad952d05a970ad5c3f5acaa9a187b891b89a5e0404ff9ff5949470c31173033
diff --git a/sys-libs/musl/files/getconf.1 b/sys-libs/musl/files/getconf.1
new file mode 100644
index 0000000..520a688
--- /dev/null
+++ b/sys-libs/musl/files/getconf.1
@@ -0,0 +1,94 @@
+.\" $NetBSD: getconf.1,v 1.13 2014/04/13 01:45:34 snj Exp $
+.\"
+.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by J.T. Conklin.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. 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.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``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 FOUNDATION OR CONTRIBUTORS
+.\" 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.
+.\"
+.Dd August 9, 2011
+.Dt GETCONF 1
+.Os
+.Sh NAME
+.Nm getconf
+.Nd get configuration values
+.Sh SYNOPSIS
+.Nm
+.Ar system_var
+.Nm
+.Fl a
+.Nm
+.Ar path_var
+.Ar pathname
+.Nm
+.Fl a
+.Ar pathname
+.Sh DESCRIPTION
+The
+.Nm
+utility writes the current value of a configurable system limit or
+option variable to the standard output.
+.Pp
+The
+.Ar system_var
+argument specifies the system variable to be queried.
+The names of the system variables are from
+.Xr sysconf 3
+with the leading
+.Dq Li _SC_
+removed.
+.Pp
+The
+.Ar path_var
+argument specifies the pathname variable to be queried for the specified
+.Ar pathname
+argument.
+The names of the pathname variables are from
+.Xr pathconf 2
+with the leading
+.Dq Li _PC_
+removed.
+.Pp
+When invoked with the option
+.Fl a ,
+.Nm
+writes a list of all applicable variables and their values to the
+standard output, in the format
+.Do
+.Va name
+=
+.Va value
+.Dc .
+.Sh EXIT STATUS
+.Ex -std
+.Sh SEE ALSO
+.Xr pathconf 2 ,
+.Xr confstr 3 ,
+.Xr limits 3 ,
+.Xr sysconf 3
+.Sh STANDARDS
+The
+.Nm
+utility conforms to
+.St -p1003.2-92 .
diff --git a/sys-libs/musl/files/getconf.c b/sys-libs/musl/files/getconf.c
new file mode 100644
index 0000000..c423524
--- /dev/null
+++ b/sys-libs/musl/files/getconf.c
@@ -0,0 +1,338 @@
+/*-
+ * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by J.T. Conklin.
+ *
+ * Mostly rewritten to be used in Alpine Linux (with musl c-library)
+ * by Timo Teräs.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+#include <err.h>
+#include <errno.h>
+#include <values.h>
+#include <limits.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+struct conf_variable {
+ const char *name;
+ enum { SYSCONF, CONFSTR, PATHCONF, CONSTANT, UCONSTANT, NUM_TYPES } type;
+ long value;
+};
+
+static const struct conf_variable conf_table[] = {
+{ "PATH", CONFSTR, _CS_PATH },
+
+/* Utility Limit Minimum Values */
+{ "POSIX2_BC_BASE_MAX", CONSTANT, _POSIX2_BC_BASE_MAX },
+{ "POSIX2_BC_DIM_MAX", CONSTANT, _POSIX2_BC_DIM_MAX },
+{ "POSIX2_BC_SCALE_MAX", CONSTANT, _POSIX2_BC_SCALE_MAX },
+{ "POSIX2_BC_STRING_MAX", CONSTANT, _POSIX2_BC_STRING_MAX },
+{ "POSIX2_COLL_WEIGHTS_MAX", CONSTANT, _POSIX2_COLL_WEIGHTS_MAX },
+{ "POSIX2_EXPR_NEST_MAX", CONSTANT, _POSIX2_EXPR_NEST_MAX },
+{ "POSIX2_LINE_MAX", CONSTANT, _POSIX2_LINE_MAX },
+{ "POSIX2_RE_DUP_MAX", CONSTANT, _POSIX2_RE_DUP_MAX },
+{ "POSIX2_VERSION", CONSTANT, _POSIX2_VERSION },
+
+/* POSIX.1 Minimum Values */
+{ "_POSIX_AIO_LISTIO_MAX", CONSTANT, _POSIX_AIO_LISTIO_MAX },
+{ "_POSIX_AIO_MAX", CONSTANT, _POSIX_AIO_MAX },
+{ "_POSIX_ARG_MAX", CONSTANT, _POSIX_ARG_MAX },
+{ "_POSIX_CHILD_MAX", CONSTANT, _POSIX_CHILD_MAX },
+{ "_POSIX_LINK_MAX", CONSTANT, _POSIX_LINK_MAX },
+{ "_POSIX_MAX_CANON", CONSTANT, _POSIX_MAX_CANON },
+{ "_POSIX_MAX_INPUT", CONSTANT, _POSIX_MAX_INPUT },
+{ "_POSIX_MQ_OPEN_MAX", CONSTANT, _POSIX_MQ_OPEN_MAX },
+{ "_POSIX_MQ_PRIO_MAX", CONSTANT, _POSIX_MQ_PRIO_MAX },
+{ "_POSIX_NAME_MAX", CONSTANT, _POSIX_NAME_MAX },
+{ "_POSIX_NGROUPS_MAX", CONSTANT, _POSIX_NGROUPS_MAX },
+{ "_POSIX_OPEN_MAX", CONSTANT, _POSIX_OPEN_MAX },
+{ "_POSIX_PATH_MAX", CONSTANT, _POSIX_PATH_MAX },
+{ "_POSIX_PIPE_BUF", CONSTANT, _POSIX_PIPE_BUF },
+{ "_POSIX_SSIZE_MAX", CONSTANT, _POSIX_SSIZE_MAX },
+{ "_POSIX_STREAM_MAX", CONSTANT, _POSIX_STREAM_MAX },
+{ "_POSIX_TZNAME_MAX", CONSTANT, _POSIX_TZNAME_MAX },
+
+/* Symbolic Utility Limits */
+{ "BC_BASE_MAX", SYSCONF, _SC_BC_BASE_MAX },
+{ "BC_DIM_MAX", SYSCONF, _SC_BC_DIM_MAX },
+{ "BC_SCALE_MAX", SYSCONF, _SC_BC_SCALE_MAX },
+{ "BC_STRING_MAX", SYSCONF, _SC_BC_STRING_MAX },
+{ "COLL_WEIGHTS_MAX", SYSCONF, _SC_COLL_WEIGHTS_MAX },
+{ "EXPR_NEST_MAX", SYSCONF, _SC_EXPR_NEST_MAX },
+{ "LINE_MAX", SYSCONF, _SC_LINE_MAX },
+{ "RE_DUP_MAX", SYSCONF, _SC_RE_DUP_MAX },
+
+/* Optional Facility Configuration Values */
+{ "_POSIX2_C_BIND", SYSCONF, _SC_2_C_BIND },
+{ "POSIX2_C_DEV", SYSCONF, _SC_2_C_DEV },
+{ "POSIX2_CHAR_TERM", SYSCONF, _SC_2_CHAR_TERM },
+{ "POSIX2_FORT_DEV", SYSCONF, _SC_2_FORT_DEV },
+{ "POSIX2_FORT_RUN", SYSCONF, _SC_2_FORT_RUN },
+{ "POSIX2_LOCALEDEF", SYSCONF, _SC_2_LOCALEDEF },
+{ "POSIX2_SW_DEV", SYSCONF, _SC_2_SW_DEV },
+{ "POSIX2_UPE", SYSCONF, _SC_2_UPE },
+
+/* POSIX.1 Configurable System Variables */
+{ "AIO_LISTIO_MAX", SYSCONF, _SC_AIO_LISTIO_MAX },
+{ "AIO_MAX", SYSCONF, _SC_AIO_MAX },
+{ "ARG_MAX", SYSCONF, _SC_ARG_MAX },
+{ "CHILD_MAX", SYSCONF, _SC_CHILD_MAX },
+{ "CLK_TCK", SYSCONF, _SC_CLK_TCK },
+{ "MQ_OPEN_MAX", SYSCONF, _SC_MQ_OPEN_MAX },
+{ "MQ_PRIO_MAX", SYSCONF, _SC_MQ_PRIO_MAX },
+{ "NGROUPS_MAX", SYSCONF, _SC_NGROUPS_MAX },
+{ "OPEN_MAX", SYSCONF, _SC_OPEN_MAX },
+{ "STREAM_MAX", SYSCONF, _SC_STREAM_MAX },
+{ "TZNAME_MAX", SYSCONF, _SC_TZNAME_MAX },
+{ "_POSIX_JOB_CONTROL", SYSCONF, _SC_JOB_CONTROL },
+{ "_POSIX_SAVED_IDS", SYSCONF, _SC_SAVED_IDS },
+{ "_POSIX_VERSION", SYSCONF, _SC_VERSION },
+
+{ "LINK_MAX", PATHCONF, _PC_LINK_MAX },
+{ "MAX_CANON", PATHCONF, _PC_MAX_CANON },
+{ "MAX_INPUT", PATHCONF, _PC_MAX_INPUT },
+{ "NAME_MAX", PATHCONF, _PC_NAME_MAX },
+{ "PATH_MAX", PATHCONF, _PC_PATH_MAX },
+{ "PIPE_BUF", PATHCONF, _PC_PIPE_BUF },
+{ "_POSIX_CHOWN_RESTRICTED", PATHCONF, _PC_CHOWN_RESTRICTED },
+{ "_POSIX_NO_TRUNC", PATHCONF, _PC_NO_TRUNC },
+{ "_POSIX_VDISABLE", PATHCONF, _PC_VDISABLE },
+
+/* POSIX.1b Configurable System Variables */
+{ "PAGESIZE", SYSCONF, _SC_PAGESIZE },
+{ "_POSIX_ASYNCHRONOUS_IO", SYSCONF, _SC_ASYNCHRONOUS_IO },
+{ "_POSIX_FSYNC", SYSCONF, _SC_FSYNC },
+{ "_POSIX_MAPPED_FILES", SYSCONF, _SC_MAPPED_FILES },
+{ "_POSIX_MEMLOCK", SYSCONF, _SC_MEMLOCK },
+{ "_POSIX_MEMLOCK_RANGE", SYSCONF, _SC_MEMLOCK_RANGE },
+{ "_POSIX_MEMORY_PROTECTION", SYSCONF, _SC_MEMORY_PROTECTION },
+{ "_POSIX_MESSAGE_PASSING", SYSCONF, _SC_MESSAGE_PASSING },
+{ "_POSIX_MONOTONIC_CLOCK", SYSCONF, _SC_MONOTONIC_CLOCK },
+{ "_POSIX_PRIORITY_SCHEDULING", SYSCONF, _SC_PRIORITY_SCHEDULING },
+{ "_POSIX_SEMAPHORES", SYSCONF, _SC_SEMAPHORES },
+{ "_POSIX_SHARED_MEMORY_OBJECTS", SYSCONF, _SC_SHARED_MEMORY_OBJECTS },
+{ "_POSIX_SYNCHRONIZED_IO", SYSCONF, _SC_SYNCHRONIZED_IO },
+{ "_POSIX_TIMERS", SYSCONF, _SC_TIMERS },
+
+{ "_POSIX_SYNC_IO", PATHCONF, _PC_SYNC_IO },
+
+/* POSIX.1c Configurable System Variables */
+{ "LOGIN_NAME_MAX", SYSCONF, _SC_LOGIN_NAME_MAX },
+{ "_POSIX_THREADS", SYSCONF, _SC_THREADS },
+
+/* POSIX.1j Configurable System Variables */
+{ "_POSIX_BARRIERS", SYSCONF, _SC_BARRIERS },
+{ "_POSIX_READER_WRITER_LOCKS", SYSCONF, _SC_READER_WRITER_LOCKS },
+{ "_POSIX_SPIN_LOCKS", SYSCONF, _SC_SPIN_LOCKS },
+
+/* XPG4.2 Configurable System Variables */
+{ "IOV_MAX", SYSCONF, _SC_IOV_MAX },
+{ "PAGE_SIZE", SYSCONF, _SC_PAGE_SIZE },
+{ "_XOPEN_SHM", SYSCONF, _SC_XOPEN_SHM },
+
+/* X/Open CAE Spec. Issue 5 Version 2 Configurable System Variables */
+{ "FILESIZEBITS", PATHCONF, _PC_FILESIZEBITS },
+
+/* POSIX.1-2001 XSI Option Group Configurable System Variables */
+{ "ATEXIT_MAX", SYSCONF, _SC_ATEXIT_MAX },
+
+/* POSIX.1-2001 TSF Configurable System Variables */
+{ "GETGR_R_SIZE_MAX", SYSCONF, _SC_GETGR_R_SIZE_MAX },
+{ "GETPW_R_SIZE_MAX", SYSCONF, _SC_GETPW_R_SIZE_MAX },
+
+/* Commonly provided extensions */
+{ "_PHYS_PAGES", SYSCONF, _SC_PHYS_PAGES },
+{ "_AVPHYS_PAGES", SYSCONF, _SC_AVPHYS_PAGES },
+{ "_NPROCESSORS_CONF", SYSCONF, _SC_NPROCESSORS_CONF },
+{ "_NPROCESSORS_ONLN", SYSCONF, _SC_NPROCESSORS_ONLN },
+
+/* Data type related extensions */
+{ "CHAR_BIT", CONSTANT, CHAR_BIT },
+{ "CHAR_MAX", CONSTANT, CHAR_MAX },
+{ "CHAR_MIN", CONSTANT, CHAR_MIN },
+{ "INT_MAX", CONSTANT, INT_MAX },
+{ "INT_MIN", CONSTANT, INT_MIN },
+{ "LONG_BIT", CONSTANT, LONG_BIT },
+{ "LONG_MAX", CONSTANT, LONG_MAX },
+{ "LONG_MIN", CONSTANT, LONG_MIN },
+{ "SCHAR_MAX", CONSTANT, SCHAR_MAX },
+{ "SCHAR_MIN", CONSTANT, SCHAR_MIN },
+{ "SHRT_MAX", CONSTANT, SHRT_MAX },
+{ "SHRT_MIN", CONSTANT, SHRT_MIN },
+{ "SSIZE_MAX", CONSTANT, SSIZE_MAX },
+{ "UCHAR_MAX", UCONSTANT, (long) UCHAR_MAX },
+{ "UINT_MAX", UCONSTANT, (long) UINT_MAX },
+{ "ULONG_MAX", UCONSTANT, (long) ULONG_MAX },
+{ "USHRT_MAX", UCONSTANT, (long) USHRT_MAX },
+{ "WORD_BIT", CONSTANT, WORD_BIT },
+
+{ NULL, CONSTANT, 0L }
+};
+
+static int all = 0;
+
+static void usage(const char *p)
+{
+ (void)fprintf(stderr, "Usage: %s system_var\n\t%s -a\n"
+ "\t%s path_var pathname\n\t%s -a pathname\n", p, p, p, p);
+ exit(EXIT_FAILURE);
+}
+
+static void print_long(const char *name, long val)
+{
+ if (all) printf("%s = %ld\n", name, val);
+ else printf("%ld\n", val);
+}
+
+static void print_ulong(const char *name, unsigned long val)
+{
+ if (all) printf("%s = %lu\n", name, val);
+ else printf("%lu\n", val);
+}
+
+static void print_string(const char *name, const char *val)
+{
+ if (all) printf("%s = %s\n", name, val);
+ else printf("%s\n", val);
+}
+
+static int print_constant(const struct conf_variable *cp, const char *pathname)
+{
+ print_long(cp->name, cp->value);
+ return 0;
+}
+
+static int print_uconstant(const struct conf_variable *cp, const char *pathname)
+{
+ print_ulong(cp->name, (unsigned long) cp->value);
+ return 0;
+}
+
+static int print_sysconf(const struct conf_variable *cp, const char *pathname)
+{
+ long val;
+
+ errno = 0;
+ if ((val = sysconf((int)cp->value)) == -1) {
+ if (errno != 0) err(EXIT_FAILURE, "sysconf(%ld)", cp->value);
+ return -1;
+ }
+ print_long(cp->name, val);
+ return 0;
+}
+
+static int print_confstr(const struct conf_variable *cp, const char *pathname)
+{
+ size_t len;
+ char *val;
+
+ errno = 0;
+ if ((len = confstr((int)cp->value, NULL, 0)) == 0) goto error;
+ if ((val = malloc(len)) == NULL) err(EXIT_FAILURE, "Can't allocate %zu bytes", len);
+ errno = 0;
+ if (confstr((int)cp->value, val, len) == 0) goto error;
+ print_string(cp->name, val);
+ free(val);
+ return 0;
+error:
+ if (errno != EINVAL) err(EXIT_FAILURE, "confstr(%ld)", cp->value);
+ return -1;
+}
+
+static int print_pathconf(const struct conf_variable *cp, const char *pathname)
+{
+ long val;
+
+ errno = 0;
+ if ((val = pathconf(pathname, (int)cp->value)) == -1) {
+ if (all && errno == EINVAL) return 0;
+ if (errno != 0) err(EXIT_FAILURE, "pathconf(%s, %ld)", pathname, cp->value);
+ return -1;
+ }
+ print_long(cp->name, val);
+ return 0;
+}
+
+typedef int (*handler_t)(const struct conf_variable *cp, const char *pathname);
+static const handler_t type_handlers[NUM_TYPES] = {
+ [SYSCONF] = print_sysconf,
+ [CONFSTR] = print_confstr,
+ [PATHCONF] = print_pathconf,
+ [CONSTANT] = print_constant,
+ [UCONSTANT] = print_uconstant,
+};
+
+int main(int argc, char **argv)
+{
+ const char *progname = argv[0];
+ const struct conf_variable *cp;
+ const char *varname, *pathname;
+ int ch, found = 0;
+
+ (void)setlocale(LC_ALL, "");
+ while ((ch = getopt(argc, argv, "a")) != -1) {
+ switch (ch) {
+ case 'a':
+ all = 1;
+ break;
+ case '?':
+ default:
+ usage(progname);
+ }
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (!all) {
+ if (argc == 0)
+ usage(progname);
+ varname = argv[0];
+ argc--;
+ argv++;
+ } else
+ varname = NULL;
+
+ if (argc > 1)
+ usage(progname);
+ pathname = argv[0]; /* may be NULL */
+
+ for (cp = conf_table; cp->name != NULL; cp++) {
+ if (!all && strcmp(varname, cp->name) != 0) continue;
+ if ((cp->type == PATHCONF) == (pathname != NULL)) {
+ if (type_handlers[cp->type](cp, pathname) < 0)
+ print_string(cp->name, "undefined");
+ found = 1;
+ } else if (!all)
+ errx(EXIT_FAILURE, "%s: invalid variable type", cp->name);
+ }
+ if (!all && !found) errx(EXIT_FAILURE, "%s: unknown variable", varname);
+ (void)fflush(stdout);
+ return ferror(stdout) ? EXIT_FAILURE : EXIT_SUCCESS;
+}
diff --git a/sys-libs/musl/files/getent.1 b/sys-libs/musl/files/getent.1
new file mode 100644
index 0000000..0e07058
--- /dev/null
+++ b/sys-libs/musl/files/getent.1
@@ -0,0 +1,145 @@
+.\" $NetBSD: getent.1,v 1.23 2011/10/11 20:39:40 wiz Exp $
+.\"
+.\" Copyright (c) 2004 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Luke Mewburn.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. 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.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``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 FOUNDATION OR CONTRIBUTORS
+.\" 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.
+.\"
+.Dd October 11, 2011
+.Dt GETENT 1
+.Os
+.Sh NAME
+.Nm getent
+.Nd get entries from administrative databases
+.Sh SYNOPSIS
+.Nm getent
+.Ar database
+.Op Ar key ...
+.Nm getcap
+.Ar database
+.Op Ar key ...
+.Sh DESCRIPTION
+The
+.Nm
+program retrieves and displays entries from the administrative
+database specified by
+.Ar database ,
+using the lookup order specified in
+.Xr nsswitch.conf 5 .
+The display format for a given
+.Ar database
+is as per the
+.Dq traditional
+file format for that database.
+.Pp
+.Ar database
+may be one of:
+.Bl -column "protocols" "user:passwd:uid:gid:gecos:home_dir:shell" -offset indent -compact
+.It Sy Database Ta Sy Display format
+.It disktab Ta entry
+.It ethers Ta address name
+.It gettytab Ta entry
+.It group Ta group:passwd:gid:[member[,member]...]
+.It hosts Ta address name [alias ...]
+.It netgroup Ta (host,user,domain) [...]
+.It networks Ta name network [alias ...]
+.It passwd Ta user:passwd:uid:gid:gecos:home_dir:shell
+.It printcap Ta entry
+.It protocols Ta name protocol [alias ...]
+.It rpc Ta name number [alias ...]
+.It services Ta name port/protocol [alias ...]
+.It shells Ta /path/to/shell
+.El
+.Pp
+If one or more
+.Ar key
+arguments are provided, they will be looked up in
+.Ar database
+using the appropriate function.
+For example,
+.Sy passwd
+supports a numeric UID or user name;
+.Sy hosts
+supports an IPv4 address, IPv6 address, or host name;
+and
+.Sy services
+supports a service name, service name/protocol name, numeric port, or
+numeric port/protocol name.
+.Pp
+If no
+.Ar key
+is provided and
+.Ar database
+supports enumeration, all entries for
+.Ar database
+will be retrieved using the appropriate enumeration function and printed.
+.Pp
+For
+.Xr cgetcap 3
+style databases
+.Sy ( disktab ,
+.Sy printcap )
+specifying a key, lists the entry for that key, and specifying more arguments
+after the key are used as fields in that key, and only the values of the keys
+are returned.
+For boolean keys
+.Dv true
+is returned if the key is found.
+If a key is not found, then
+.Dv false
+is always
+returned.
+.Sh DIAGNOSTICS
+.Nm
+exits 0 on success,
+1 if there was an error in the command syntax,
+2 if one of the specified key names was not found in
+.Ar database ,
+or 3 if there is no support for enumeration on
+.Ar database .
+.Sh SEE ALSO
+.Xr cgetcap 3 ,
+.Xr disktab 5 ,
+.Xr ethers 5 ,
+.Xr gettytab 5 ,
+.Xr group 5 ,
+.Xr hosts 5 ,
+.Xr networks 5 ,
+.Xr nsswitch.conf 5 ,
+.Xr passwd 5 ,
+.Xr printcap 5 ,
+.Xr protocols 5 ,
+.Xr rpc 5 ,
+.Xr services 5 ,
+.Xr shells 5
+.Sh HISTORY
+A
+.Nm
+command appeared in
+.Nx 3.0 .
+It was based on the command of the same name in
+.Tn Solaris
+and
+.Tn Linux .
diff --git a/sys-libs/musl/files/getent.c b/sys-libs/musl/files/getent.c
new file mode 100644
index 0000000..1f97f8f
--- /dev/null
+++ b/sys-libs/musl/files/getent.c
@@ -0,0 +1,437 @@
+/*-
+ * Copyright (c) 2004-2006 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Luke Mewburn.
+ * Timo Teräs cleaned up the code for use in Alpine Linux with musl libc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+#include <sys/socket.h>
+#include <sys/param.h>
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <netdb.h>
+#include <pwd.h>
+#include <grp.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <paths.h>
+#include <err.h>
+
+#include <arpa/inet.h>
+#include <arpa/nameser.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <netinet/ether.h>
+#include <netinet/in.h>
+
+enum {
+ RV_OK = 0,
+ RV_USAGE = 1,
+ RV_NOTFOUND = 2,
+ RV_NOENUM = 3
+};
+
+static int usage(const char *);
+
+static int parsenum(const char *word, unsigned long *result)
+{
+ unsigned long num;
+ char *ep;
+
+ if (!isdigit((unsigned char)word[0]))
+ return 0;
+ errno = 0;
+ num = strtoul(word, &ep, 10);
+ if (num == ULONG_MAX && errno == ERANGE)
+ return 0;
+ if (*ep != '\0')
+ return 0;
+ *result = num;
+ return 1;
+}
+
+/*
+ * printfmtstrings --
+ * vprintf(format, ...),
+ * then the aliases (beginning with prefix, separated by sep),
+ * then a newline
+ */
+__attribute__ ((format (printf, 4, 5)))
+static void printfmtstrings(char *strings[], const char *prefix, const char *sep,
+ const char *fmt, ...)
+{
+ va_list ap;
+ const char *curpref;
+ size_t i;
+
+ va_start(ap, fmt);
+ (void)vprintf(fmt, ap);
+ va_end(ap);
+
+ curpref = prefix;
+ for (i = 0; strings[i] != NULL; i++) {
+ (void)printf("%s%s", curpref, strings[i]);
+ curpref = sep;
+ }
+ (void)printf("\n");
+}
+
+static int ethers(int argc, char *argv[])
+{
+ char hostname[MAXHOSTNAMELEN + 1], *hp;
+ struct ether_addr ea, *eap;
+ int i, rv;
+
+ if (argc == 2) {
+ warnx("Enumeration not supported on ethers");
+ return RV_NOENUM;
+ }
+
+ rv = RV_OK;
+ for (i = 2; i < argc; i++) {
+ if ((eap = ether_aton(argv[i])) == NULL) {
+ eap = &ea;
+ hp = argv[i];
+ if (ether_hostton(hp, eap) != 0) {
+ rv = RV_NOTFOUND;
+ break;
+ }
+ } else {
+ hp = hostname;
+ if (ether_ntohost(hp, eap) != 0) {
+ rv = RV_NOTFOUND;
+ break;
+ }
+ }
+ (void)printf("%-17s %s\n", ether_ntoa(eap), hp);
+ }
+ return rv;
+}
+
+static void groupprint(const struct group *gr)
+{
+ printfmtstrings(gr->gr_mem, ":", ",", "%s:%s:%u",
+ gr->gr_name, gr->gr_passwd, gr->gr_gid);
+}
+
+static int group(int argc, char *argv[])
+{
+ struct group *gr;
+ unsigned long id;
+ int i, rv;
+
+ rv = RV_OK;
+ if (argc == 2) {
+ while ((gr = getgrent()) != NULL)
+ groupprint(gr);
+ } else {
+ for (i = 2; i < argc; i++) {
+ if (parsenum(argv[i], &id))
+ gr = getgrgid((gid_t)id);
+ else
+ gr = getgrnam(argv[i]);
+ if (gr == NULL) {
+ rv = RV_NOTFOUND;
+ break;
+ }
+ groupprint(gr);
+ }
+ }
+ endgrent();
+ return rv;
+}
+
+static void hostsprint(const struct hostent *he)
+{
+ char buf[INET6_ADDRSTRLEN];
+
+ if (inet_ntop(he->h_addrtype, he->h_addr, buf, sizeof(buf)) == NULL)
+ (void)strlcpy(buf, "# unknown", sizeof(buf));
+ printfmtstrings(he->h_aliases, " ", " ", "%-16s %s", buf, he->h_name);
+}
+
+static int hosts(int argc, char *argv[])
+{
+ struct hostent *he;
+ char addr[IN6ADDRSZ];
+ int i, rv;
+
+ sethostent(1);
+ rv = RV_OK;
+ if (argc == 2) {
+ while ((he = gethostent()) != NULL)
+ hostsprint(he);
+ } else {
+ for (i = 2; i < argc; i++) {
+ if (inet_pton(AF_INET6, argv[i], (void *)addr) > 0)
+ he = gethostbyaddr(addr, IN6ADDRSZ, AF_INET6);
+ else if (inet_pton(AF_INET, argv[i], (void *)addr) > 0)
+ he = gethostbyaddr(addr, INADDRSZ, AF_INET);
+ else
+ he = gethostbyname(argv[i]);
+ if (he == NULL) {
+ rv = RV_NOTFOUND;
+ break;
+ }
+ hostsprint(he);
+ }
+ }
+ endhostent();
+ return rv;
+}
+
+static void networksprint(const struct netent *ne)
+{
+ char buf[INET6_ADDRSTRLEN];
+ struct in_addr ianet;
+
+ ianet = inet_makeaddr(ne->n_net, 0);
+ if (inet_ntop(ne->n_addrtype, &ianet, buf, sizeof(buf)) == NULL)
+ (void)strlcpy(buf, "# unknown", sizeof(buf));
+ printfmtstrings(ne->n_aliases, " ", " ", "%-16s %s", ne->n_name, buf);
+}
+
+static int networks(int argc, char *argv[])
+{
+ struct netent *ne;
+ in_addr_t net;
+ int i, rv;
+
+ setnetent(1);
+ rv = RV_OK;
+ if (argc == 2) {
+ while ((ne = getnetent()) != NULL)
+ networksprint(ne);
+ } else {
+ for (i = 2; i < argc; i++) {
+ net = inet_network(argv[i]);
+ if (net != INADDR_NONE)
+ ne = getnetbyaddr(net, AF_INET);
+ else
+ ne = getnetbyname(argv[i]);
+ if (ne != NULL) {
+ rv = RV_NOTFOUND;
+ break;
+ }
+ networksprint(ne);
+ }
+ }
+ endnetent();
+ return rv;
+}
+
+static void passwdprint(struct passwd *pw)
+{
+ (void)printf("%s:%s:%u:%u:%s:%s:%s\n",
+ pw->pw_name, pw->pw_passwd, pw->pw_uid,
+ pw->pw_gid, pw->pw_gecos, pw->pw_dir, pw->pw_shell);
+}
+
+static int passwd(int argc, char *argv[])
+{
+ struct passwd *pw;
+ unsigned long id;
+ int i, rv;
+
+ rv = RV_OK;
+ if (argc == 2) {
+ while ((pw = getpwent()) != NULL)
+ passwdprint(pw);
+ } else {
+ for (i = 2; i < argc; i++) {
+ if (parsenum(argv[i], &id))
+ pw = getpwuid((uid_t)id);
+ else
+ pw = getpwnam(argv[i]);
+ if (pw == NULL) {
+ rv = RV_NOTFOUND;
+ break;
+ }
+ passwdprint(pw);
+ }
+ }
+ endpwent();
+ return rv;
+}
+
+static void protocolsprint(struct protoent *pe)
+{
+ printfmtstrings(pe->p_aliases, " ", " ",
+ "%-16s %5d", pe->p_name, pe->p_proto);
+}
+
+static int protocols(int argc, char *argv[])
+{
+ struct protoent *pe;
+ unsigned long id;
+ int i, rv;
+
+ setprotoent(1);
+ rv = RV_OK;
+ if (argc == 2) {
+ while ((pe = getprotoent()) != NULL)
+ protocolsprint(pe);
+ } else {
+ for (i = 2; i < argc; i++) {
+ if (parsenum(argv[i], &id))
+ pe = getprotobynumber((int)id);
+ else
+ pe = getprotobyname(argv[i]);
+ if (pe == NULL) {
+ rv = RV_NOTFOUND;
+ break;
+ }
+ protocolsprint(pe);
+ }
+ }
+ endprotoent();
+ return rv;
+}
+
+static void servicesprint(struct servent *se)
+{
+ printfmtstrings(se->s_aliases, " ", " ",
+ "%-16s %5d/%s",
+ se->s_name, ntohs(se->s_port), se->s_proto);
+
+}
+
+static int services(int argc, char *argv[])
+{
+ struct servent *se;
+ unsigned long id;
+ char *proto;
+ int i, rv;
+
+ setservent(1);
+ rv = RV_OK;
+ if (argc == 2) {
+ while ((se = getservent()) != NULL)
+ servicesprint(se);
+ } else {
+ for (i = 2; i < argc; i++) {
+ proto = strchr(argv[i], '/');
+ if (proto != NULL)
+ *proto++ = '\0';
+ if (parsenum(argv[i], &id))
+ se = getservbyport(htons(id), proto);
+ else
+ se = getservbyname(argv[i], proto);
+ if (se == NULL) {
+ rv = RV_NOTFOUND;
+ break;
+ }
+ servicesprint(se);
+ }
+ }
+ endservent();
+ return rv;
+}
+
+static int shells(int argc, char *argv[])
+{
+ const char *sh;
+ int i, rv;
+
+ setusershell();
+ rv = RV_OK;
+ if (argc == 2) {
+ while ((sh = getusershell()) != NULL)
+ (void)printf("%s\n", sh);
+ } else {
+ for (i = 2; i < argc; i++) {
+ setusershell();
+ while ((sh = getusershell()) != NULL) {
+ if (strcmp(sh, argv[i]) == 0) {
+ (void)printf("%s\n", sh);
+ break;
+ }
+ }
+ if (sh == NULL) {
+ rv = RV_NOTFOUND;
+ break;
+ }
+ }
+ }
+ endusershell();
+ return rv;
+}
+
+static struct getentdb {
+ const char *name;
+ int (*callback)(int, char *[]);
+} databases[] = {
+ { "ethers", ethers, },
+ { "group", group, },
+ { "hosts", hosts, },
+ { "networks", networks, },
+ { "passwd", passwd, },
+ { "protocols", protocols, },
+ { "services", services, },
+ { "shells", shells, },
+
+ { NULL, NULL, },
+};
+
+static int usage(const char *arg0)
+{
+ struct getentdb *curdb;
+ size_t i;
+
+ (void)fprintf(stderr, "Usage: %s database [key ...]\n", arg0);
+ (void)fprintf(stderr, "\tdatabase may be one of:");
+ for (i = 0, curdb = databases; curdb->name != NULL; curdb++, i++) {
+ if (i % 7 == 0)
+ (void)fputs("\n\t\t", stderr);
+ (void)fprintf(stderr, "%s%s", i % 7 == 0 ? "" : " ",
+ curdb->name);
+ }
+ (void)fprintf(stderr, "\n");
+ exit(RV_USAGE);
+ /* NOTREACHED */
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct getentdb *curdb;
+
+ if (argc < 2)
+ usage(argv[0]);
+ for (curdb = databases; curdb->name != NULL; curdb++)
+ if (strcmp(curdb->name, argv[1]) == 0)
+ return (*curdb->callback)(argc, argv);
+
+ warn("Unknown database `%s'", argv[1]);
+ usage(argv[0]);
+ /* NOTREACHED */
+}
diff --git a/sys-libs/musl/files/iconv.c b/sys-libs/musl/files/iconv.c
new file mode 100644
index 0000000..f5d5ce2
--- /dev/null
+++ b/sys-libs/musl/files/iconv.c
@@ -0,0 +1,110 @@
+/*
+ * iconv.c
+ * Implementation of SUSv4 XCU iconv utility
+ * Copyright © 2011 Rich Felker
+ * Licensed under the terms of the GNU General Public License, v2 or later
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <iconv.h>
+#include <locale.h>
+#include <langinfo.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+
+int main(int argc, char **argv)
+{
+ const char *from=0, *to=0;
+ int b;
+ iconv_t cd;
+ char buf[BUFSIZ];
+ char outbuf[BUFSIZ*4];
+ char *in, *out;
+ size_t inb;
+ size_t l;
+ size_t unitsize=0;
+ int err=0;
+ FILE *f;
+
+ while ((b = getopt(argc, argv, "f:t:csl")) != EOF) switch(b) {
+ case 'l':
+ puts("UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF32-LE, UCS-2BE, UCS-2LE, WCHAR_T,\n"
+ "US_ASCII, ISO8859-1, ISO8859-2, ISO8859-3, ISO8859-4, ISO8859-5,\n"
+ "ISO8859-6, ISO8859-7, ...");
+ exit(0);
+ case 'c': case 's': break;
+ case 'f': from=optarg; break;
+ case 't': to=optarg; break;
+ default: exit(1);
+ }
+
+ if (!from || !to) {
+ setlocale(LC_CTYPE, "");
+ if (!to) to = nl_langinfo(CODESET);
+ if (!from) from = nl_langinfo(CODESET);
+ }
+ cd = iconv_open(to, from);
+ if (cd == (iconv_t)-1) {
+ if (iconv_open(to, "WCHAR_T") == (iconv_t)-1)
+ fprintf(stderr, "iconv: destination charset %s: ", to);
+ else
+ fprintf(stderr, "iconv: source charset %s: ", from);
+ perror("");
+ exit(1);
+ }
+ if (optind == argc) argv[argc++] = "-";
+
+ for (; optind < argc; optind++) {
+ if (argv[optind][0]=='-' && !argv[optind][1]) {
+ f = stdin;
+ argv[optind] = "(stdin)";
+ } else if (!(f = fopen(argv[optind], "rb"))) {
+ fprintf(stderr, "iconv: %s: ", argv[optind]);
+ perror("");
+ err = 1;
+ continue;
+ }
+ inb = 0;
+ for (;;) {
+ in = buf;
+ out = outbuf;
+ l = fread(buf+inb, 1, sizeof(buf)-inb, f);
+ inb += l;
+ if (!inb) break;
+ if (iconv(cd, &in, &inb, &out, (size_t [1]){sizeof outbuf})==-1
+ && errno == EILSEQ) {
+ if (!unitsize) {
+ wchar_t wc='0';
+ char dummy[4], *dummyp=dummy;
+ iconv_t cd2 = iconv_open(from, "WCHAR_T");
+ if (cd == (iconv_t)-1) {
+ unitsize = 1;
+ } else {
+ iconv(cd2,
+ (char *[1]){(char *)&wc},
+ (size_t[1]){1},
+ &dummyp, (size_t[1]){4});
+ unitsize = dummyp-dummy;
+ if (!unitsize) unitsize=1;
+ }
+ }
+ inb-=unitsize;
+ in+=unitsize;
+ }
+ if (inb && !l && errno==EINVAL) break;
+ if (out>outbuf && !fwrite(outbuf, out-outbuf, 1, stdout)) {
+ perror("iconv: write error");
+ exit(1);
+ }
+ if (inb) memmove(buf, in, inb);
+ }
+ if (ferror(f)) {
+ fprintf(stderr, "iconv: %s: ", argv[optind]);
+ perror("");
+ err = 1;
+ }
+ }
+ return err;
+}
diff --git a/sys-libs/musl/files/ldconfig b/sys-libs/musl/files/ldconfig
new file mode 100644
index 0000000..be0aa2b
--- /dev/null
+++ b/sys-libs/musl/files/ldconfig
@@ -0,0 +1,143 @@
+#!/bin/bash -e
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+ROOT="/"
+
+LDSO_CONF="/etc/ld.so.conf"
+if [[ ! -e $LDSO_CONF ]]; then
+ echo "$LDSO_CONF not found" >&2
+ exit 1
+fi
+
+LDSO_CONF_DIR=$(dirname $LDSO_CONF)
+
+VERBOSE=0
+
+UPDATE_LINKS=1
+
+get_options() {
+ while getopts "vnNXf:C:r:p" opt "$@"; do
+ case $opt in
+ v)
+ echo "ldconfig for musl in Gentoo"
+ VERBOSE=1
+ ;;
+ r)
+ ROOT=$OPTARG
+ ;;
+ f)
+ LDSO_CONF=$OPTARG
+ ;;
+ X)
+ UPDATE_LINKS=0
+ ;;
+ \?)
+ echo "Invalid option: -$opt" >&2
+ exit 1
+ ;;
+ n|N|C|p)
+ echo "Unimplemented option: -$opt" >&2
+ exit 1
+ ;;
+ esac
+ done
+
+ if [[ $UPDATE_LINKS == 1 ]]; then
+ echo "Updating links is not implemented."
+ fi
+}
+
+
+repeated() {
+ local l=$1
+ local drs="${@:2}"
+ for m in $drs; do
+ [[ $m == $l ]] && return 0
+ done
+ return 1
+}
+
+expand() {
+ # We are assuming the ld.so.conf's 'include' is not recursive
+ local f line l
+ local glob="$LDSO_CONF_DIR/$1"
+ local drs="${@:2} "
+
+ for f in $glob; do
+ [[ ! -f $f ]] && continue
+ while read line; do
+ line=${line%%#*}
+ line=${line//:/ }
+ line=${line//,/ }
+ for l in $line; do
+ #We must add this whether or not the directory exists
+ repeated $l $drs && continue
+ drs+=" $l "
+ done
+ done < $f
+ done
+
+ echo $drs
+}
+
+read_ldso_conf() {
+ local drs=" "
+
+ while read line; do
+ # Sanitize the line - see ldconfig(8) for delimiters
+ # Note: bash read turns tabs into spaces and read already
+ # delimits on newlines with the default $IFS
+ line=${line%%#*} # Remove comments
+ line=${line//:/ } # Change colon delimiter to space
+ line=${line//,/ } # Change comma delimiter to space
+
+ next=0
+ for l in $line; do
+ if [[ $next == 1 ]]; then
+ next=0
+ drs=$(expand $l $drs)
+ elif [[ $l == "include" ]]; then
+ next=1
+ else
+ # glibc's ldconfig silently skips non directories
+ if [[ -d $l ]]; then
+ repeated $l $drs && continue
+ drs+=" $l "
+ fi
+ fi
+ done
+ done < $1
+
+ echo $drs
+}
+
+sanitize() {
+ local drs=$@
+
+ repeated "/lib" $drs || drs="/lib $drs"
+ repeated "/usr/lib" $drs || drs="/usr/lib $drs"
+
+ echo $drs
+}
+
+get_options "$@"
+drs=$(read_ldso_conf "$LDSO_CONF")
+drs=$(sanitize $drs)
+
+LDSO_PATH=$(ls /lib/ld-musl-*.so.1)
+if [[ ! -e $LDSO_PATH ]]; then
+ echo "$LDSO_PATH not found" >&2
+ exit 1
+fi
+
+LDSO_ARCH=$(basename $LDSO_PATH)
+LDSO_NAME=${LDSO_ARCH%.so.1}
+ETC_LDSO_PATH=/etc/${LDSO_NAME}.path
+
+X=$(mktemp --tmpdir=/tmp ${LDSO_NAME}.XXXXXX)
+for d in $drs; do
+ echo $d >> $X
+done
+chmod 644 $X
+mv $X $ETC_LDSO_PATH
diff --git a/sys-libs/musl/files/ldconfig.in b/sys-libs/musl/files/ldconfig.in
new file mode 100644
index 0000000..a292190
--- /dev/null
+++ b/sys-libs/musl/files/ldconfig.in
@@ -0,0 +1,144 @@
+#!/bin/bash -e
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+ROOT="/"
+
+LDSO_CONF="/etc/ld.so.conf"
+if [[ ! -e $LDSO_CONF ]]; then
+ echo "$LDSO_CONF not found" >&2
+ exit 1
+fi
+
+LDSO_CONF_DIR=$(dirname $LDSO_CONF)
+
+VERBOSE=0
+
+UPDATE_LINKS=1
+
+get_options() {
+ while getopts "vnNXf:C:r:p" opt "$@"; do
+ case $opt in
+ v)
+ echo "ldconfig for musl in Gentoo"
+ VERBOSE=1
+ ;;
+ r)
+ ROOT=$OPTARG
+ ;;
+ f)
+ LDSO_CONF=$OPTARG
+ ;;
+ X)
+ UPDATE_LINKS=0
+ ;;
+ \?)
+ echo "Invalid option: -$opt" >&2
+ exit 1
+ ;;
+ n|N|C|p)
+ echo "Unimplemented option: -$opt" >&2
+ exit 1
+ ;;
+ esac
+ done
+
+ if [[ $UPDATE_LINKS == 1 ]]; then
+ echo "Updating links is not implemented."
+ fi
+}
+
+
+repeated() {
+ local l=$1
+ local drs="${@:2}"
+ for m in $drs; do
+ [[ $m == $l ]] && return 0
+ done
+ return 1
+}
+
+expand() {
+ # We are assuming the ld.so.conf's 'include' is not recursive
+ local f line l
+ local glob="$LDSO_CONF_DIR/$1"
+ local drs="${@:2} "
+
+ for f in $glob; do
+ [[ ! -f $f ]] && continue
+ while read line; do
+ line=${line%%#*}
+ line=${line//:/ }
+ line=${line//,/ }
+ for l in $line; do
+ #We must add this whether or not the directory exists
+ repeated $l $drs && continue
+ drs+=" $l "
+ done
+ done < $f
+ done
+
+ echo $drs
+}
+
+read_ldso_conf() {
+ local drs=" "
+
+ while read line; do
+ # Sanitize the line - see ldconfig(8) for delimiters
+ # Note: bash read turns tabs into spaces and read already
+ # delimits on newlines with the default $IFS
+ line=${line%%#*} # Remove comments
+ line=${line//:/ } # Change colon delimiter to space
+ line=${line//,/ } # Change comma delimiter to space
+
+ next=0
+ for l in $line; do
+ if [[ $next == 1 ]]; then
+ next=0
+ drs=$(expand $l $drs)
+ elif [[ $l == "include" ]]; then
+ next=1
+ else
+ # glibc's ldconfig silently skips non directories
+ if [[ -d $l ]]; then
+ repeated $l $drs && continue
+ drs+=" $l "
+ fi
+ fi
+ done
+ done < $1
+
+ echo $drs
+}
+
+sanitize() {
+ local drs=$@
+
+ repeated "/lib" $drs || drs="/lib $drs"
+ repeated "/usr/lib" $drs || drs="/usr/lib $drs"
+
+ echo $drs
+}
+
+get_options "$@"
+drs=$(read_ldso_conf "$LDSO_CONF")
+drs=$(sanitize $drs)
+
+ARCH=@@ARCH@@
+LDSO_PATH="/lib/ld-musl-${ARCH}.so.1"
+if [[ ! -e $LDSO_PATH ]]; then
+ echo "$LDSO_PATH not found" >&2
+ exit 1
+fi
+
+LDSO_ARCH=$(basename $LDSO_PATH)
+LDSO_NAME=${LDSO_ARCH%.so.1}
+ETC_LDSO_PATH=/etc/${LDSO_NAME}.path
+
+X=$(mktemp --tmpdir=/tmp ${LDSO_NAME}.XXXXXX)
+for d in $drs; do
+ echo $d >> $X
+done
+chmod 644 $X
+mv $X $ETC_LDSO_PATH
diff --git a/sys-libs/musl/files/musl-1.1.15-pthread_setname_np.patch b/sys-libs/musl/files/musl-1.1.15-pthread_setname_np.patch
new file mode 100644
index 0000000..e7b2401
--- /dev/null
+++ b/sys-libs/musl/files/musl-1.1.15-pthread_setname_np.patch
@@ -0,0 +1,64 @@
+
+
+the thread name is displayed by gdb's "info threads".
+---
+v1->v2: add _GNU_SOURCE, and "UL" to prctl arguments
+
+I hope that there are no programs for which this function is
+performance critical...
+
+Thanks for the review so far!
+---
+ include/pthread.h | 1 +
+ src/thread/pthread_setname_np.c | 26 ++++++++++++++++++++++++++
+ 2 files changed, 27 insertions(+)
+ create mode 100644 src/thread/pthread_setname_np.c
+
+diff --git a/include/pthread.h b/include/pthread.h
+index 3d2e0c4..94ef919 100644
+--- a/include/pthread.h
++++ b/include/pthread.h
+@@ -214,6 +214,7 @@ struct cpu_set_t;
+ int pthread_getaffinity_np(pthread_t, size_t, struct cpu_set_t *);
+ int pthread_setaffinity_np(pthread_t, size_t, const struct cpu_set_t *);
+ int pthread_getattr_np(pthread_t, pthread_attr_t *);
++int pthread_setname_np(pthread_t, const char *);
+ int pthread_tryjoin_np(pthread_t, void **);
+ int pthread_timedjoin_np(pthread_t, void **, const struct timespec *);
+ #endif
+diff --git a/src/thread/pthread_setname_np.c b/src/thread/pthread_setname_np.c
+new file mode 100644
+index 0000000..82d35e1
+--- /dev/null
++++ b/src/thread/pthread_setname_np.c
+@@ -0,0 +1,26 @@
++#define _GNU_SOURCE
++#include <fcntl.h>
++#include <string.h>
++#include <unistd.h>
++#include <sys/prctl.h>
++
++#include "pthread_impl.h"
++
++int pthread_setname_np(pthread_t thread, const char *name)
++{
++ int fd, cs, status = 0;
++ char f[sizeof "/proc/self/task//comm" + 3*sizeof(int)];
++ size_t len;
++
++ if ((len = strnlen(name, 16)) > 15) return ERANGE;
++
++ if (thread == pthread_self())
++ return prctl(PR_SET_NAME, (unsigned long)name, 0UL, 0UL, 0UL) ? errno : 0;
++
++ snprintf(f, sizeof f, "/proc/self/task/%d/comm", thread->tid);
++ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
++ if ((fd = open(f, O_WRONLY)) < 0 || write(fd, name, len) < 0) status = errno;
++ if (fd >= 0) close(fd);
++ pthread_setcancelstate(cs, 0);
++ return status;
++}
+--
+2.7.3
+
+
diff --git a/sys-libs/musl/metadata.xml b/sys-libs/musl/metadata.xml
new file mode 100644
index 0000000..cd4b91b
--- /dev/null
+++ b/sys-libs/musl/metadata.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person">
+ <email>blueness@gentoo.org</email>
+ <name>Anthony G. Basile</name>
+ </maintainer>
+ <maintainer type="person">
+ <email>lu_zero@gentoo.org</email>
+ </maintainer>
+<maintainer type="project">
+ <email>toolchain@gentoo.org</email>
+ <name>Gentoo Toolchain Project</name>
+ </maintainer>
+</pkgmetadata>
diff --git a/sys-libs/musl/musl-1.1.15-r1.ebuild b/sys-libs/musl/musl-1.1.15-r1.ebuild
new file mode 100644
index 0000000..f53c814
--- /dev/null
+++ b/sys-libs/musl/musl-1.1.15-r1.ebuild
@@ -0,0 +1,147 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=6
+
+inherit eutils flag-o-matic multilib toolchain-funcs
+if [[ ${PV} == "9999" ]] ; then
+ EGIT_REPO_URI="git://git.musl-libc.org/musl"
+ inherit git-r3
+ SRC_URI="
+ http://dev.gentoo.org/~blueness/musl-misc/getconf.c
+ http://dev.gentoo.org/~blueness/musl-misc/getent.c
+ http://dev.gentoo.org/~blueness/musl-misc/iconv.c"
+ KEYWORDS=""
+else
+ SRC_URI="http://www.musl-libc.org/releases/${P}.tar.gz
+ http://dev.gentoo.org/~blueness/musl-misc/getconf.c
+ http://dev.gentoo.org/~blueness/musl-misc/getent.c
+ http://dev.gentoo.org/~blueness/musl-misc/iconv.c"
+ KEYWORDS="-* ~amd64 ~arm ~arm64 ~mips ~ppc ~sh ~x86"
+fi
+
+export CBUILD=${CBUILD:-${CHOST}}
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+
+DESCRIPTION="Light, fast and simple C library focused on standards-conformance and safety"
+HOMEPAGE="http://www.musl-libc.org/"
+LICENSE="MIT LGPL-2 GPL-2"
+SLOT="0"
+IUSE="crosscompile_opts_headers-only"
+
+RDEPEND="!sys-apps/getent"
+
+PATCHES=(
+ "${FILESDIR}"/${P}-pthread_setname_np.patch
+)
+
+QA_SONAME="/usr/lib/libc.so"
+QA_DT_NEEDED="/usr/lib/libc.so"
+
+is_crosscompile() {
+ [[ ${CHOST} != ${CTARGET} ]]
+}
+
+just_headers() {
+ use crosscompile_opts_headers-only && is_crosscompile
+}
+
+musl_endian() {
+ # XXX: this wont work for bi-endian, but we dont have any
+ touch "${T}"/endian.s || die
+ $(tc-getAS ${CTARGET}) "${T}"/endian.s -o "${T}"/endian.o
+ case $(file "${T}"/endian.o) in
+ *" MSB "*) echo "";;
+ *" LSB "*) echo "el";;
+ *) echo "nfc";; # We shouldn't be here
+ esac
+}
+
+pkg_setup() {
+ if [ ${CTARGET} == ${CHOST} ] ; then
+ case ${CHOST} in
+ *-musl*) ;;
+ *) die "Use sys-devel/crossdev to build a musl toolchain" ;;
+ esac
+ fi
+}
+
+src_configure() {
+ tc-getCC ${CTARGET}
+ just_headers && export CC=true
+
+ local sysroot
+ is_crosscompile && sysroot=/usr/${CTARGET}
+ ./configure \
+ --target=${CTARGET} \
+ --prefix=${sysroot}/usr \
+ --syslibdir=${sysroot}/lib \
+ --disable-gcc-wrapper
+}
+
+src_compile() {
+ emake obj/include/bits/alltypes.h
+ just_headers && return 0
+
+ emake
+ $(tc-getCC) ${CFLAGS} "${DISTDIR}"/getconf.c -o "${T}"/getconf
+ $(tc-getCC) ${CFLAGS} "${DISTDIR}"/getent.c -o "${T}"/getent
+ $(tc-getCC) ${CFLAGS} "${DISTDIR}"/iconv.c -o "${T}"/iconv
+}
+
+src_install() {
+ local target="install"
+ just_headers && target="install-headers"
+ emake DESTDIR="${D}" ${target}
+ just_headers && return 0
+
+ # musl provides ldd via a sym link to its ld.so
+ local sysroot
+ is_crosscompile && sysroot=/usr/${CTARGET}
+ local ldso=$(basename "${D}"${sysroot}/lib/ld-musl-*)
+ dosym ${sysroot}/lib/${ldso} ${sysroot}/usr/bin/ldd
+
+ if [[ ${CATEGORY} != cross-* ]] ; then
+ # TODO: We may be able to simplify this code by obtianing the arch name with
+ # /usr/lib/libc.so 2>&1 | sed -n 's/^.*(\(.*\))$/\1/;1p'
+ local target=$(tc-arch) arch
+ local endian=$(musl_endian)
+ case ${target} in
+ amd64) arch="x86_64";;
+ arm) arch="armhf";; # We only have hardfloat right now
+ arm64) arch="aarch64";;
+ mips) arch="mips${endian}";;
+ ppc) arch="powerpc";;
+ sh) arch="sh";; # fdpic?
+ x86) arch="i386";;
+ esac
+ cp "${FILESDIR}"/ldconfig.in "${T}" || die
+ sed -e "s|@@ARCH@@|${arch}|" "${T}"/ldconfig.in > "${T}"/ldconfig || die
+ into /
+ dosbin "${T}"/ldconfig
+ into /usr
+ dobin "${T}"/getconf
+ doman "${FILESDIR}"/getent.1
+ dobin "${T}"/getent
+ doman "${FILESDIR}"/getconf.1
+ dobin "${T}"/iconv
+ echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00musl || die
+ doenvd "${T}"/00musl || die
+ fi
+}
+
+pkg_postinst() {
+ is_crosscompile && return 0
+
+ [ "${ROOT}" != "/" ] && return 0
+
+ ldconfig
+ # reload init ...
+ /sbin/telinit U 2>/dev/null
+}