aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2019-01-07[klibc] Kbuild.install: Copy UAPI headers instead of reinstalling themHEADmasterBen Hutchings1-1/+1
Since the UAPI/KAPI header split in Linux 3.7, we have needed KLIBCKERNELSRC to point to the installed UAPI headers. Invoking "make headers_install" in this directory doesn't work. The previously proposed fix was to invoke make in the parent directory. But since we require the headers to be installed already, we can copy the install tree instead. Make sure to dereference any symbolic links while doing this. Reported-by: Thomas Meyer <thomas@m3y3r.de> Reported-by: Luis R. Rodriguez <mcgrof@kernel.org> Link: https://www.zytor.com/pipermail/klibc/2019-January/004033.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-07[klibc] Makefile: Update help text for KLIBCKERNELSRCBen Hutchings1-5/+5
Since the UAPI/KAPI header split in Linux 3.7, we have needed KLIBCKERNELSRC to point to the installed UAPI headers. The "sample invocation" has been updated to reflect this but the rest of the help text has not. Link: https://www.zytor.com/pipermail/klibc/2019-January/004032.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-07[klibc] Kbuild: Remove KLIBCKERNELOBJ variableBen Hutchings7-21/+3
Since the UAPI/KAPI header split in Linux 3.7, we have needed KLIBCKERNELSRC to point to the installed UAPI headers. This makes KLIBCKERNELOBJ and the extra header directories based on it completely redundant. Link: https://www.zytor.com/pipermail/klibc/2019-January/004031.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-07[klibc] Makefile: Add dependencies on $(KLIBCKERNELSRC)Ben Hutchings1-2/+2
The error message for a missing $(KLIBCKERNELSRC) won't appear unless it's specified as a target or something depends on it. Make the klcc and klibc targets depend on it. Link: https://www.zytor.com/pipermail/klibc/2019-January/004030.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-06[klibc] Disable PIEBen Hutchings1-1/+2
We link all executables as non-relocatable, so it makes no sense to generate PIE code. In addition, PIE code on i386 requires a working GOT which we don't generate. Link: https://www.zytor.com/pipermail/klibc/2019-January/004028.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-06[klibc] i386: Use -Ttext-segment to avoid address collisionBen Hutchings1-1/+1
Building klibc for i386 with binutils 2.31 adds an extra .note.gnu.property section to klibc.so, the address of which is not affected by the -Ttext option. Loading a klibc executable then fails with the following kernel log message: 9409 (sh.shared): Uhuuh, elf segment at 0000000000600000 requested but the memory is mapped already I don't exactly see why this is happening, but it is triggered by the new section and the collision can be avoided by passing -Ttext-segment instead of -Ttext, similarly to x86_64. Link: https://www.zytor.com/pipermail/klibc/2019-January/004027.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-05[klibc] x86_64: Use -Ttext-segment to avoid address collisionfor-hpaBen Hutchings1-1/+1
Building klibc for x86_64 with binutils 2.31 adds an extra .note.gnu.property section to klibc.so, the address of which is not affected by the -Ttext option. Loading a klibc executable then fails with the following kernel log message: 9409 (sh.shared): Uhuuh, elf segment at 0000000000200000 requested but the memory is mapped already I don't exactly see why this is happening, but it is triggered by the new section and the collision can be avoided by passing -Ttext-segment instead of -Ttext. A similar change was applied to MIPS recently. Link: https://www.zytor.com/pipermail/klibc/2019-January/004024.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] Fix sparc assembly when compiled as PICJames Clarke9-14/+37
Some distributions default to PIE for their compilers, which on sparc is passed on to the assembler. Since the behaviour of %hi/%lo changes under PIC to become GOT offsets, the current assembly files need adapting to not try to use a GOT offset as an absolute address. References: https://bugs.debian.org/885852 Link: https://www.zytor.com/pipermail/klibc/2018-July/004001.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] Never clean files in quilt status directoryBen Hutchings1-1/+1
The top-level "distclean" and "mrproper" targets delete zero-size files in the source, perhaps assumed to be stamp files. This is fine for actual source direcgtories, but disastrous for a quilt status directory. For each patch, quilt stores the previous versions of the modified files in a subdirectory of .pc. If the patch creates a file, this file will be empty. Removing it effectively removes the file creation from the patch. The .git directory is already excluded from the clean rules for a similar reason, so do the same for .pc. Link: https://www.zytor.com/pipermail/klibc/2018-July/003999.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] x86_64: Reduce ld max-page-size option againBen Hutchings1-3/+5
Building klibc with binutils 2.30 results in the following layout for klibc.so: Idx Name Size VMA LMA File off Algn 0 .text 0000d1ff 0000000000200200 0000000000200200 00000200 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE 1 .rodata 000031af 0000000000300000 0000000000300000 00100000 2**5 CONTENTS, ALLOC, LOAD, READONLY, DATA 2 .data.rel.ro 00000990 0000000000403660 0000000000403660 00103660 2**5 CONTENTS, ALLOC, LOAD, DATA 3 .data 00000140 0000000000404000 0000000000404000 00104000 2**5 CONTENTS, ALLOC, LOAD, DATA 4 .bss 000042f8 0000000000404140 0000000000404140 00104140 2**5 ALLOC The .text and .rodata sections have each been padded to the specified maximum page size of 1 MB, causing the following sections to overlap the executable. This causes all klibc executables to crash immediately. Since there's no architectural page size betwen 4 KB and 2MB, set max-page-size to 4 KB. Link: https://www.zytor.com/pipermail/klibc/2018-July/003998.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] Add RISC-V (RV64) portBen Hutchings12-1/+252
RISC-V is pretty boring. I've cribbed most of this from the MIPS and AArch64 ports. I ran into difficulty with initialisation of the gp,register, which I think has to be process-global - the psABI says that signal handlers can rely on it, and they could come from any module. This means that klibc.so and the executable using it need to agree on a single value. Currently they don't, and this causes gp-relative addressing to go wrong. gp-relative addressing is introduced by "relaxation" in the linker, so I've disabled that for now. Link: https://www.zytor.com/pipermail/klibc/2018-July/003997.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] rename, renameat: Use renameat2() system callBen Hutchings4-2/+16
New architectures only define the renameat2() system call, which was added in Linux 3.15. Define rename() and renameat() as wrappers for it if necessary. Link: https://www.zytor.com/pipermail/klibc/2018-July/003996.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] add more PHONY targets to $(PHONY)Greg Thelen3-7/+19
make-3.81 excludes PHONY dependencies from $?, make 3.82+ includes them. This leads to always rebuilding klibc targets that depend on .PHONY dependencies. From the make 3.82 release notes https://lists.gnu.org/archive/html/info-gnu/2010-07/msg00023.html: * WARNING: Backward-incompatibility! The '$?' variable now contains all prerequisites that caused the target to be considered out of date, even if they do not exist (previously only existing targets were provided in $?). Linux fixed this with commit 4f1933620f57 ("kbuild: change kbuild to not rely on incorrect GNU make behavior"). Similar to Linux, klibc if_changed already excludes $(PHONY) from $? when determining if a target is up-to-date. Klibc also has a $(PHONY) list of phony targets. But klibc does not add many .PHONY targets to $(PHONY). Changes in this patch: - add previously defined .PHONY targets to PHONY, so existing if_changed filtering applies to them as well - declare $(PHONY) targets as .PHONY Signed-off-by: Greg Thelen <gthelen@google.com> Link: https://www.zytor.com/pipermail/klibc/2018-June/003995.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] mount_main: Fix empty string checkBenjamin Drung1-2/+2
gcc 7.3.0 complains: ``` usr/utils/mount_main.c: In function ‘print_mount’: usr/utils/mount_main.c:46:46: warning: comparison between pointer and zero character constant [-Wpointer-compare] if (mnt->mnt_type != NULL && mnt->mnt_type != '\0') ^~ usr/utils/mount_main.c:46:32: note: did you mean to dereference the pointer? if (mnt->mnt_type != NULL && mnt->mnt_type != '\0') ^ usr/utils/mount_main.c:48:46: warning: comparison between pointer and zero character constant [-Wpointer-compare] if (mnt->mnt_opts != NULL && mnt->mnt_opts != '\0') ^~ usr/utils/mount_main.c:48:32: note: did you mean to dereference the pointer? if (mnt->mnt_opts != NULL && mnt->mnt_opts != '\0') ^ ``` Link: https://www.zytor.com/pipermail/klibc/2018-June/003994.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] ipconfig: Implement classless static routesBenjamin Drung5-25/+212
Implement classless static routes support as specified in RFC3442. Bug-Debian: https://bugs.debian.org/884716 Bug-Ubuntu: https://launchpad.net/bugs/1526956 Signed-off-by: Benjamin Drung <benjamin.drung@profitbricks.com> Link: https://salsa.debian.org/kernel-team/klibc/merge_requests/2 Link: https://www.zytor.com/pipermail/klibc/2018-June/003993.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] mips64: remove __unused from __jmp_bufJames Cowgill1-1/+0
This field is not needed. Probably it was copied straight from the 32-bit mips __jmp_buf. Signed-off-by: James Cowgill <james.cowgill@mips.com> Link: https://www.zytor.com/pipermail/klibc/2018-March/003984.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] mips: don't save floating point registers in setjmp / longjmpJames Cowgill2-44/+0
Don't bother saving any floating point registers in setjmp or restoring them in longjmp. This causes issues when compiling for the FPXX ABI, and is unnessesary as klibc does not support floating point code. Additionally, remove the unused parts of __jmp_buf. Signed-off-by: James Cowgill <james.cowgill@mips.com> Link: https://www.zytor.com/pipermail/klibc/2018-March/003983.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] mips/mips64: simplify crt0 codeJames Cowgill2-23/+10
Various simplifications and adjustments to the MIPS crt0 files: - Use NESTED(__start, 0, ra) - this has no effect on the code, but is arguably more correct since we have no real stack frame. - Don't allocate extra stack space. We need none on 64-bit, and only 16 bytes on 32-bit. - Align the stack pointer in the (unlikely) event it is misaligned. - Don't load the gp register - it is useless in non-PIC code. - Use jal in 64-bit code. - Crash if __libc_start returns (teq should causes a trap exception). Signed-off-by: James Cowgill <james.cowgill@mips.com> Link: https://www.zytor.com/pipermail/klibc/2018-March/003982.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] mips: use -Ttext-segment when linking shared libraryJames Cowgill2-215/+6
Most architectures use the -Ttext option to move the klibc shared library out of the way of the normal load address. Unfortunately MIPS has some extra sections which are positioned before the .text section and are therefore not repositioned by the -Ttext option. Fix this by using the -Ttext-segment option. Instead of changing the address of the .text section, this option changes the .text segment which happens to include all the special MIPS sections. After this we can drop the linker script which we no longer need. Signed-off-by: James Cowgill <james.cowgill@mips.com> Link: https://www.zytor.com/pipermail/klibc/2018-March/003981.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] mips64: compile with -mno-abicallsJames Cowgill1-1/+11
By default, the MIPS toolchain compiles all code as PIC. Since klibc links everything at static addresses, we don't need PIC code so use -mno-abicalls to disable it. To fix subsequent link errors, use -Ttext-segment to adjust the base address of klibc to a more sensible location. This fixes a bug in the shared library form of klibc where programs would segfault in the syscall handler because we tried to store into the "errno" variable without setting up the gp register. This is only required under the PIC ABI. Signed-off-by: James Cowgill <james.cowgill@mips.com> Link: https://www.zytor.com/pipermail/klibc/2018-March/003985.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] remove some 'make -s' build spewGreg Thelen1-1/+1
Use $(kecho) to remove 'GEN klcc/klibc.config' log message from 'make --silent' output. Signed-off-by: Greg Thelen <gthelen@google.com> Link: https://www.zytor.com/pipermail/klibc/2018-February/003979.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] use more consistent quotingGreg Thelen1-1/+1
Signed-off-by: Greg Thelen <gthelen@google.com> Link: https://www.zytor.com/pipermail/klibc/2018-February/003978.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] remove unused variablesGreg Thelen2-3/+0
Fix compilation warnings: $KLIBC/usr/klibc/asprintf.c: In function 'asprintf': $KLIBC/usr/klibc/asprintf.c:14:8: warning: unused variable 'p' [-Wunused-variable] char *p; $KLIBC/usr/klibc/asprintf.c:13:6: warning: unused variable 'bytes' [-Wunused-variable] int bytes; $KLIBC/usr/utils/readlink.c: In function 'main': $KLIBC/usr/utils/readlink.c:20:6: warning: unused variable 'i' [-Wunused-variable] int i; Signed-off-by: Greg Thelen <gthelen@google.com> Link: https://www.zytor.com/pipermail/klibc/2018-February/003977.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] include sys/types.h in more placesGreg Thelen2-0/+2
Include sys/types.h to avoid compilation warnings: In file included from $LINUX/usr/include/linux/byteorder/little_endian.h:12:0, from $LINUX/usr/include/asm/byteorder.h:5, from $KLIBC/usr/klibc/../include/klibc/endian.h:11, from $KLIBC/usr/klibc/../include/endian.h:8, from $KLIBC/usr/klibc/pread.c:7: $LINUX/usr/include/linux/types.h:22:0: warning: "__bitwise" redefined In file included from $KLIBC/usr/klibc/../include/klibc/endian.h:10:0, from $KLIBC/usr/klibc/../include/endian.h:8, from $KLIBC/usr/klibc/pread.c:7: $KLIBC/usr/klibc/../include/klibc/compiler.h:144:0: note: this is the location of the previous definition In file included from $LINUX/usr/include/linux/byteorder/little_endian.h:12:0, from $LINUX/usr/include/asm/byteorder.h:5, from $KLIBC/usr/klibc/../include/klibc/endian.h:11, from $KLIBC/usr/klibc/../include/endian.h:8, from $KLIBC/usr/klibc/pwrite.c:7: $LINUX/usr/include/linux/types.h:22:0: warning: "__bitwise" redefined In file included from $KLIBC/usr/klibc/../include/klibc/endian.h:10:0, from $KLIBC/usr/klibc/../include/endian.h:8, from $KLIBC/usr/klibc/pwrite.c:7: $KLIBC/usr/klibc/../include/klibc/compiler.h:144:0: note: this is the location of the previous definition Signed-off-by: Greg Thelen <gthelen>google.com> Link: https://www.zytor.com/pipermail/klibc/2018-February/003976.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] ipconfig: Set broadcast when sending DHCPREQUEST and DHCPDISCOVERMathieu Trudel-Lapierre1-1/+7
We need to do this, since our devices are probably not configured yet and there may be more than one device we're trying to do DHCP on on the same network. Otherwise, things might be dropped. Patch is originally from here: https://bugs.launchpad.net/ubuntu/+source/klibc/+bug/1327412/comments/5 ... but the reporter "patpat" has not provided contact information, and this is independently verifiable by looking at RFC 2131, section 4.1, page 24. References: https://bugs.debian.org/733988 References: https://bugs.launchpad.net/bugs/1327412 Link: https://www.zytor.com/pipermail/klibc/2017-December/003974.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] run-init: Add dry-run modeBen Hutchings4-29/+57
initramfs-tools wants to validate the real init program before running it, as there is no way out once it has exec'd run-init. This is complicated by the increasing use of symlinks for /sbin/init and for /sbin itself. We can't simply resolve them with 'readlink -f' because any absolute symlinks will be resolved using the wrong root. Add a dry-run mode (-n option) to run-init that goes as far as possible to validate that the given init is executable. References: https://bugs.debian.org/810965 Link: https://www.zytor.com/pipermail/klibc/2017-December/003973.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] nfsmount: support nfsvers= and vers= optionsBaptiste Jonglez1-0/+19
The standard mount option nowadays to specify NFS version is "nfsvers", as documented in nfs(5) on modern Linux systems. Up to now, nfsmount only supported the old "v2" or "v3" boolean options. Extend option parsing to support both "nfsvers=X" and "vers=X", with X being equal to either 2 or 3 (nfsmount does not support NFSv4 at present). If both the new option "nfsvers=X" and old option "vX" are passed, the version specified by "nfsvers" takes precedence. Tested with initramfs-tools on Debian stretch, it can now successfully mount the root on NFS using nfsmount, with the following kernel command line: root=/dev/nfs nfsroot=server:path,nfsvers=3 Without this patch, such a command line would cause Debian's initrd to loop with the following error message: Begin: Retrying nfs mount ... nfsmount: bad option 'nfsvers' Signed-off-by: Baptiste Jonglez <baptiste.jonglez@imag.fr> Link: https://www.zytor.com/pipermail/klibc/2017-September/003959.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] Add support for reboot syscall argumentAlfonso Sanchez-beato3-19/+25
Add support to the reboot command so an argument for the 4th parameter of the syscall can be passed around. This can be useful in, say, devices that follow Android partitions conventions, so we can do things like rebootinig to the kernel in recovery partition with "reboot recovery". References: https://bugs.launchpad.net/ubuntu/+source/klibc/+bug/1692494 Link: https://www.zytor.com/pipermail/klibc/2017-May/003957.html Link: https://bugs.debian.org/863761 Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-01-02[klibc] ipconfig: handle multiple interfaces correctlyJay Vosburgh4-40/+58
When configuring multiple interfaces, the existing logic in ipconfig can fail if DHCP replies are received out of the expected order, or if one or more interfaces never receive replies. The current ipconfig logic uses a single packet socket to handle all incoming DHCP replies. If, for example, the host has two interfaces, A and B, and only B will be sent a DHCP reply, the order of events goes something like this: ipconfig sends DHCP on A ipconfig sends DHCP on B system receives DHCP response to B ipconfig attempts to receive DHCP reply for A; the available packet does not match A's XID, et al, and is discarded. This will repeat until ipconfig times out and gives up. The failure can come and go with different kernel versions, as the kernel version affects the order in which the devices appear. In the above example, if interface B is first, then the sequence will work. The solution is to use a packet socket per interface. This avoids the need to queue packets being read for the "wrong" interface or other schemes to peek incoming packets. Signed-off-by: Jay Vosburgh <jay.vosburgh@canonical.com> Link: https://www.zytor.com/pipermail/klibc/2017-February/003945.html Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2016-02-01[klibc] fwrite: fix typo in commentH. Peter Anvin1-1/+1
Fix typo in comment, no code change. Reported-by: Gilles Espinasse <g.esp@free.fr> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-02-01[klibc] fwrite: flush before a large write to allow better bypassH. Peter Anvin1-4/+5
If we are doing a large write, flush the buffer preemptively, so we don't end up double-buffering a sequence of BUFSIZ writes simply because we started out with something in the buffer. This doesn't increase the number of system calls, since we will always need to do two system calls in this case. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-02-01[klibc] Make asprintf() a simple wrapper around vasprintf()H. Peter Anvin1-11/+2
Since we have vasprintf() anyway, save about a hundred bytes (on x86-64) by making asprintf() a typical stdarg wrapper function. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-02-01[klibc] stdlib.h: include <fcntl.h> for inline of posix_grantpt()H. Peter Anvin1-0/+1
Since namespace pollution is not a major concern in klibc, add <fcntl.h> to support the inline of posix_grantpt(). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-01-26[klibc] Make posix_openpt() an inlineH. Peter Anvin3-16/+9
This function is so trivial that there is no reason to not make it an inline. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-01-26[klibc] accept.c: fix file headerH. Peter Anvin1-1/+1
Correct the filename in the header. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-01-15[klibc] Remove open_cloexec()H. Peter Anvin5-23/+4
The kernel now (since 2.6.23) allows O_CLOEXEC to be passed directly to open(), so there is no reason to have open_cloexec() anymore. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-01-05[klibc] Add accept4(), handle fallback from accept() to accept4()H. Peter Anvin5-3/+32
Add support for the accept4() system call. Some architectures now have accept4() but not accept(), so introduce a standard fallback. However, since accept() is a socketcall, we have to do some special hacks. While we are at it, handle conditional socketcall stubs based on their existence <linux/net.h>, analogous to <asm/unistd.h>. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-01-05[klibc] Remove sys/socketcalls.hH. Peter Anvin2-29/+0
We no longer generate assembly stubs for socketcalls on any architecture, so <linux/net.h> is perfectly usable as is. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-01-05[klibc] Remove obsolete getpt() functionH. Peter Anvin3-18/+1
getpt() has long since been obsolete; instead use posix_openpt(O_RDWR|O_NOCTTY). Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-01-05[klibc] gzip: Fix silent fallback to decompressionBen Hutchings1-13/+16
If the gzip utilities are built without support for compression, they will always attempt to carry out decompression even if the command name and options don't imply that. Instead they should fail with an explicit error in this case. Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-01-05[klibc] dash: mkbuiltins: Fix sort order harderBen Hutchings1-1/+1
LC_COLLATE can be overriden by LC_ALL, so set LC_ALL instead when running sort. Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-01-05[klibc] Install headers with consistent modeBen Hutchings1-1/+1
Currently we ensure the installed headers are readable by everyone, but write permissions will depend on the current umask. Turn off the group and other writable bits to ensure consistent results. Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-01-05[klibc] mount: Implement -o defaultsBen Hutchings1-2/+7
This is needed to support mounting non-root filesystems in initramfs-tools. Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-01-05[klibc] readlink: Add -f optionBen Hutchings1-4/+25
This is needed to support mounting non-root filesystems in initramfs-tools. Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-01-05[klibc] Implement realpath()Ben Hutchings3-1/+52
This is needed as the basis for the readlink -f option. Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-01-05[klibc] ppc64: fix struct statAurelien Jarno1-0/+1
On ppc64 the struct stat defined by klibc matches the kernel one. However it contains implicit padding before the st_rdev field due to the 64-bit alignement. For internal reasons, klibc defines st_rdev as a pair of 32-bit values (using the __stdev64 macro). They only need to be 32-bit aligned and as a consequence st->st_rdev is incorrectly defined. The solution is to add an explicit padding in the structure. This fixes the resume binary on ppc64 BE and LE, and probably other things. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Link: http://lkml.kernel.org/r/20160106004416.GG28542@decadent.org.uk Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-01-05[klibc] Add pread and pwrite 32bit syscall wrappers for pariscHelge Deller5-2/+69
On the hppa arch (32bit userspace and 32 or 64bit kernel), the fstype program fails to detect the filesystem. The reason for this failure is, that fstype calls the pread() syscall, which has on some architectures with 32bit userspace a different calling syntax. I noticed this bug on hppa, but I assume s390 (32bit) and others might run into similiar issues. Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-01-05[klibc] MIPS: Update archfcntl.hBen Hutchings1-1/+21
Update usr/include/arch/mips/archfcntl.h from kernel headers: - Add definitions of O_PATH, O_TMPFILE - Update value of O_SYNC to include __O_SYNC - Add definitions of F_{SET,GET}OWN_EX, F_GETOWNER_UIDS, F_OFD_{GETLK,SETLK,SETLKW}, F_OWNER_{TID,PID,PGRP} Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-01-05[klibc] ppc64: ELFv2: Load TOC value in system call stubMauricio Faria de Oliveira1-0/+3
This fixes a segmentation fault in the system call's error handling path with dynamically-linked binaries on PowerPC64 little endian. The system call stub wasn't loading up r2 with the appropriate TOC value in its global entry point. The r2 setup code comes from the FUNC_START macro in gcc [1] and an equivalent one can also be found in the LOCALENTRY macro in glibc [2]. On the ELFv2 ABI (see [1]): - The global entry point is expected to load up r2 with the appropriate TOC value for this function. - The local entry point expects r2 to be set up to the current TOC. The problem happened with dynamically-linked binaries because: - the system call is an indirect call (via global entry point) from the binary to the shared library, landing in the syscall stub (which didn't load up r2 with the TOC of the shared library) - its branch to __syscall_error is a direct call (via local entry point) within the shared library, landing in the function (which expects r2 to be set up to that TOC) - when the function attempts to store errno (in an address relative to the TOC), that address incorrectly pointed to a read-only segment -- segmentation fault. The problem didn't happen with statically-linked binaries because the TOC value wasn't different on that case. Thanks and credits to Alan Modra and Ulrich Weigand, for helping with this and pointing out the solution. [1] https://gcc.gnu.org/ml/gcc-patches/2013-11/msg01141.html [2] https://www.sourceware.org/ml/libc-alpha/2013-11/msg00315.html Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com> Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-01-05[klibc] Update README.klibcH. Peter Anvin1-2/+5
In README.klibc: - Clarify the new kernel header creation process - Change mips64 to Working Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-01-05[klibc] i386: remove special handling of socketcallH. Peter Anvin3-89/+17
As of kernel 4.3, i386 now has direct system calls for sockets, so drop the special handling for i386 socketcall. If built on older kernels, it will still generate socketcall stubs although they will be less efficient. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2015-11-05[klibc] Inline __arch_libcinit()H. Peter Anvin6-6/+22
__arch_libcinit() is only ever used as part of __libc_init(), so we might as well make it an inline function. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2015-03-05add-mips64-support-arch-mips64-specificDejan Latinovic3-0/+83
Description: Adding mips64 specific chagnes. Modeled on mips 32 and adapted for 64 bit ABI. - MCONFIG: using existing klibc.ld scrpit - crt0.S: adapted gp initialization - setjmp.S: do not save floating-point state
2015-03-05add-mips64-support-arch-mips32Dejan Latinovic2-0/+40
Description: Add mips64 support, using existing mips32 code. - using mips32 assembler source files: pipe.S vfork.S syscall.S - sysstub.ph: copied over from klibc/arch/mips
2015-03-05add-mips64-support-headersDejan Latinovic4-1/+114
Description: Added header files for mips64. Modeled on mips 32 header files and adapted for 64 bit ABI. - archsetjmp.h: do not save floating-point state - asm.h: Symbolic register names for 64 bit ABI
2014-07-09[klibc] 2.0.4 released, next version is 2.0.5H. Peter Anvin1-1/+1
2014-07-09[klibc] isatty(): use TCGETS instead of TIOCGPGRP, like dietlibc doesklibc-2.0.4Thorsten Glaser1-2/+3
While all “real” ttys may support TIOCGPGRP, /dev/console doesn’t; using TCGETS here allows Linux booted with init=/bin/mksh-static to have working interactive command line (PS1, editing, etc). [ hpa: TCGETS matches glibc, so go with it ] Reported-by: Dominik George <d.george@tarent.de> Signed-off-by: Thorsten Glaser <t.glaser@tarent.de> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2014-04-15[klibc] x86-64: disable the use of SSEH. Peter Anvin1-4/+4
Disable the use of SSE registers. This reduces the size of the code because it means the varadic functions don't need to marshall parameters in the SSE registers. Since klibc doesn't support floating point, this is a significant size win. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2014-04-15readlink: Reduce size by calling _fwrite() instead of puts()H. Peter Anvin1-2/+2
We know how long the output is, so we might as well call _fwrite() directly, with the explicit termination set to \n instead of \0. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2014-04-15readlink: Handle multiple input argumentsH. Peter Anvin1-11/+14
Handle multiple links as parguments passed to readlink(). Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2014-04-15readlink: Better buffer handlingH. Peter Anvin1-10/+8
- Allow PATH_MAX bytes, not just a hard-coded 128 bytes - Just allocate the buffer on the stack, no need for malloc() - Use puts() rather than printf() Reported-by: Rafi Rubin <rafi@seas.upenn.edu> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2014-04-09[klibc] fwrite: use memrchr() to find the final '\n' in _IOLBF modeH. Peter Anvin1-9/+4
In line buffered mode, we need to split the write at the final '\n' (which usually, but not always, is the last character in the string.) Use memrchr() instead of open-coding it. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2014-04-09[klibc] Remove obsolete enum _IO_file_flagsH. Peter Anvin1-9/+0
This enum is not used anywhere. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2014-04-09[klibc] Move architecture-specific initialization to arch/H. Peter Anvin6-14/+41
Move out architecture-specific initialization code (currently only for i386) into the arch/ directory and define a configuration variable _KLIBC_HAS_ARCHINIT to indicate its presence. For consistency, change __init_stdio() to __libc_init_stdio(). Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2014-04-09[klibc] <sys/auxv.h>: add missing dependency <klibc/extern.h>H. Peter Anvin1-0/+1
__extern is defined in <klibc/extern.h> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2014-01-24[klibc] i386: use the vdso for system calls on i386H. Peter Anvin4-4/+30
Use the system call entry point in the vdso for system calls on i386. The vdso can provide either int $0x80, sysenter or syscall depending on the CPU. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2014-01-24auxv: convert auxiliary vector into an array; define getauxval()H. Peter Anvin3-13/+30
Convert the ELF auxiliary vector into an array. Define getauxval() as an inline accessor to that array. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-12-03[klibc] 2.0.3 released, next version is 2.0.4H. Peter Anvin1-1/+1
2013-12-03[klibc] gzip: Fix typo CONFIG_KLIB_ZIP -> CONFIG_KLIBC_ZIPklibc-2.0.3Anton Blanchard2-2/+3
We were using CONFIG_KLIB_ZIP in a couple of places where we meant to use CONFIG_KLIBC_ZIP. I also added the option to the defconfig. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-12-03[klibc] nfsmount: memset uses sizeof pointer as lengthAnton Blanchard1-2/+2
gcc picked up a couple of suspicious memset lengths which turned out to be real bugs. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-12-03[klibc] ppc64: build with -mcmodel=smallAnton Blanchard1-0/+1
If available, use -mcmodel=small. klibc is small enough that we should never hit the limits of the small memory model. This produces better code, for example: 000000000f003890 <.strcasecmp>: f003890: 3c a2 ff fe addis r5,r2,-2 ... f003898: 38 c5 23 58 addi r6,r5,9048 ... f0038ac: 7d 46 50 ae lbzx r10,r6,r10 vs: 000000000f0037c4 <.strcasecmp>: f0037c4: e8 c2 81 48 ld r6,-32440(r2) f0037dc: 7d 46 50 ae lbzx r10,r6,r10 Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-12-03[klibc] ppc64: Add ppc64le supportAnton Blanchard5-43/+87
Add PowerPC 64bit little endian support. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-11[klibc] poll, select: fix style problemsH. Peter Anvin2-3/+3
Fix whitespace style problems in poll.c and select.c. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-11[klibc] arm64: Fix struct statH. Peter Anvin1-21/+20
Use actual struct timespec fields in struct stat, and use the proper __stdev64 macro for the dev_t fields. Also fix bizarre formatting. Cc: Neil Williams <codehelp@debian.org> Cc: Anil Singhar <anil.singhar@linaro.org> Cc: Steve Capper <steve.capper@linaro.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-11[klibc] arm64: remove useless <klibc/asmmacros.h> fileH. Peter Anvin4-15/+0
<klibc/asmmacros.h> is a file specific to arm32; the file is empty on arm64 so we can just drop it. Cc: Neil Williams <codehelp@debian.org> Cc: Anil Singhar <anil.singhar@linaro.org> Cc: Steve Capper <steve.capper@linaro.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-11[klibc] arm64: Add arm64 supportSteve Capper15-2/+277
Based on work by Neil Williams (codehelp@debian.org) and Anil Singhar (anil.singhar@linaro.org), this patch adds arm64 support. Originally-by: Neil Williams <codehelp@debian.org> Originally-by: Anil Singhar <anil.singhar@linaro.org> Signed-off-by: Steve Capper <steve.capper@linaro.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-11[klibc] syscalls: Add syscalls needed by arm64Steve Capper22-21/+323
arm64 uses generic syscalls, and does not include the "noat", "noflags", and "deprecated" syscalls. This patch adds substitution functions for system calls not available on arm64. Originally-by: Neil Williams <codehelp@debian.org> Originally-by: Anil Singhar <anil.singhar@linaro.org> Signed-off-by: Steve Capper <steve.capper@linaro.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-11-11[klibc] syscalls: Fixup some of the -at syscall declarationsSteve Capper3-9/+11
mknodat and mkdirat contain a spurious repeated parameter, linkat is missing the final int flags parameter, symlinkat has the first two parameters transposed, and fchmodat is missing the flags parameter and is declared in the wrong header. Also declarations are missing for utimensat and fchownat. This patch fixes up these syscall declarations. Originally-by: Neil Williams <codehelp@debian.org> Originally-by: Anil Singhar <anil.singhar@linaro.org> Signed-off-by: Steve Capper <steve.capper@linaro.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2013-08-21README.klibc: update build informationmaximilian attems1-10/+7
It seems this file was still conveying the old way to build klibc and hence confusing the users, simplify and reword build instructions. Signed-off-by: maximilian attems <max@stro.at>
2013-08-21tests: Fix sscanf integer testsmaximilian attems1-17/+14
Drop the double tests that klibc doesn't care about and that where hence failing in the first place. Check the returned integer values too. Fixes Bug: https://bugs.gentoo.org/show_bug.cgi?id=464908 Reported-by: Mike Pagano <mpagano@gentoo.org> Signed-off-by: maximilian attems <max@stro.at>
2012-10-05[klibc] 2.0.2 released, next version is 2.0.3H. Peter Anvin1-1/+1
2012-10-03[klibc] [PATCH] fix ARM longjmp with zero 'val'.klibc-2.0.2Bill Pringlemeir1-4/+3
We need to set the condition codes on the ARM. The previous version was using a left over condition code from the caller. Also, use conditional execution to eliminate branch and reduce size. Signed-off-by: Bill Pringlemeir <bpringle@sympatico.ca> Signed-off-by: maximilian attems <max@stro.at>
2012-10-01[klibc] dash: resync with latest gitmaximilian attems1-1/+1
Signed-off-by: maximilian attems <max@stro.at>
2012-10-01[klibc] [BUILTIN] Add support for ulimit -rChristoph Mathys1-0/+3
I recently found myself in need to have dash support 'ulimit -r' to set maximum realtime priority. Attached is a patch that adds the parameter to the builtin ulimit command and updates the manpage. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2012-10-01[klibc] Avoid overflow for very long variable nameJim Meyering1-1/+1
Otherwise, this: $ perl -le 'print "v"x(2**31+1) ."=1"' | dash provokes integer overflow: (gdb) bt #0 doformat (dest=0x61d580, f=0x416a08 "%s: %d: %s: ", ap=0x7fffffffd308) at output.c:310 #1 0x00000000004128c1 in outfmt (file=0x61d580, fmt=0x416a08 "%s: %d: %s: ") at output.c:257 #2 0x000000000040382e in exvwarning2 (msg=0x417339 "Out of space", ap=0x7fffffffd468) at error.c:125 #3 0x000000000040387e in exverror (cond=1, msg=0x417339 "Out of space", ap=0x7fffffffd468) at error.c:156 #4 0x0000000000403938 in sh_error (msg=0x417339 "Out of space") at error.c:172 #5 0x000000000040c970 in ckmalloc (nbytes=18446744071562067984) at memalloc.c:57 #6 0x000000000040ca78 in stalloc (nbytes=18446744071562067972) at memalloc.c:132 #7 0x000000000040ece9 in grabstackblock (len=18446744071562067972) at memalloc.h:67 #8 0x00000000004106b5 in readtoken1 (firstc=118, syntax=0x419522 "", eofmark=0x0, striptabs=0) at parser.c:1040 #9 0x00000000004101a4 in xxreadtoken () at parser.c:826 #10 0x000000000040fe1d in readtoken () at parser.c:697 #11 0x000000000040edcc in parsecmd (interact=0) at parser.c:145 #12 0x000000000040c679 in cmdloop (top=1) at main.c:224 #13 0x000000000040c603 in main (argc=2, argv=0x7fffffffd9f8) at main.c:178 #8 0x00000000004106b5 in readtoken1 (firstc=118, syntax=0x419522 "", eofmark=0x0, striptabs=0) at parser.c:1040 1040 grabstackblock(len); (gdb) p len $30 = -2147483644 Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2012-10-01[klibc] include: [sys/time.h] fix for Linux 3.5.1Colin Watson1-0/+3
From 3.5.1, <linux/time.h> does not even define FD_ZERO etc. With Linux 3.5.1, 'make test' fails with: usr/klibc/tests/select.c: In function ‘main’: usr/klibc/tests/select.c:31:14: error: ‘FD_SETSIZE’ undeclared (first use in this function) usr/klibc/tests/select.c:31:14: note: each undeclared identifier is reported only once for each function it appears in This is due to Linux commit 8ded2bbc1845e19c771eb55209aab166ef011243. Handle it by making sure that FD_SETSIZE is defined. Signed-off-by: Colin Watson <cjwatson@ubuntu.com> Signed-off-by: maximilian attems <max@stro.at>
2012-10-01[klibc] arm: remove unused variable Thorsten Glaser1-1/+0
MCONFIG containing a no longer recognised gcc flag. Signed-off-by: Thorsten Glaser <tg@mirbsd.org> Signed-off-by: maximilian attems <max@stro.at>
2012-10-01[klibc] arm: unbreak armhf shared binaries (those with thumb)Thorsten Glaser1-1/+1
The linker command was wrong. Signed-off-by: Thorsten Glaser <tg@mirbsd.org> Signed-off-by: maximilian attems <max@stro.at>
2012-10-01[klibc] arm: fix trashing of callee-saved registers in thumb setjmp()Thorsten Glaser1-0/+3
fixes http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=634890 (although dynamically-linked binaries seem to have another bug) Signed-off-by: Thorsten Glaser <tg@mirbsd.org> Signed-off-by: maximilian attems <max@stro.at>
2012-07-03[klibc] kbuild: Fix permissions of headersmaximilian attems1-0/+1
Small build fix carried in Debian, triggered by paranoid umask. Cc: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: maximilian attems <max@stro.at>
2012-07-02[klibc] dash: sync with latest gitmaximilian attems2-7/+8
Gains us compile and runtime fixes including newer dash >= 0.5.7. For now disable faccessat() as we yet miss AT_EACCESS definition. Signed-off-by: maximilian attems <max@stro.at>
2012-07-02[klibc] [VAR] Sanitise environment variable names on entryHerbert Xu1-1/+2
On Tue, Feb 14, 2012 at 10:48:48AM +0000, harald@redhat.com wrote: > > "export -p" prints all environment variables, without checking if the > environment variable is a valid dash variable name. > > IMHO, the only valid usecase for "export -p" is to eval the output. > > $ eval $(export -p); echo OK > OK > > Without this patch the following test does error out with: > > test.py: > import os > os.environ["test-test"]="test" > os.environ["test_test"]="test" > os.execv("./dash", [ './dash', '-c', 'eval $(export -p); echo OK' ]) > > $ python test.py > ./dash: 1: export: test-test: bad variable name > > Of course the results can be more evil, if the environment variable > name is crafted, that it injects valid shell code. This patch fixes the issue by sanitising all environment variable names upon entry into the shell. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2012-07-02[klibc] [SHELL] Allow building without LINEO supportDavid S. Miller2-0/+10
Simply specify --disable-lineno to configure. Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2012-07-02[klibc] [ARITH] Avoid imaxdiv when only one of the results is wantedHarald van Dijk1-9/+0
dash rather pointlessly calls imaxdiv, only to discard one of its results. The call was already made conditional a while back because some systems don't have imaxdiv, but the generated code for the version with imaxdiv and the one with / and % is identical (with GCC 4.6.1 or ICC 12.0.2, with -O0, -O2 or -Os), so it could just as well go entirely to clean up the code a little bit. Signed-off-by: Harald van Dijk <harald@gigawatt.nl> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2012-07-02[klibc] [SHELL] Fix klibc DEBUG compilationmaximilian attems1-0/+6
dash didn't compile in DEBUG mode against klibc for all long time. Now it only fails at link stage for not having setlinebuf(3) and freopen(3). Fixes: usr/dash/show.o: In function `opentrace': show.c:(.text+0x36): undefined reference to `freopen' show.c:(.text+0x86): undefined reference to `setlinebuf' Skip setlinebuf and use fclose/fopen inside __KLIBC__ Compile tested with debug in klibc and against glibc in dash repo. Signed-off-by: maximilian attems <max@stro.at> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2012-07-02[klibc] [BUILTIN] Merge SKIPFUNC/SKIPFILE and only clear SKIPFUNC when ↵Herbert Xu3-3/+2
leaving dotcmd Currently upon leaving a dotcmd the evalskip state is reset so if a continue/break statement is used within a dot script it would have no effect outside of the dot script. This is inconsistent with other shells. This patch is based on one by Jilles Tjoelker and only clears SKIPFUNC when leaving a dot script. As a result continue/break will remain in effect. It also merges SKIPFUNC/SKIPFILE as they have no practical difference. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2012-07-02[klibc] [EVAL] Avoid using undefined handlerJim Meyering1-2/+2
* src/eval.c (evalbltin, evalfun): Set savehandler before calling setjmp with the possible "goto *done", where savehandler is used. Otherwise, clang warns that "Assigned value is garbage or undefined" at the point where "savehandler" is used on the RHS. Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2012-07-02[klibc] [MEMALLOC] Avoid clang warning about dead store to "size"Jim Meyering1-1/+1
* src/memalloc.c (makestrspace): Remove dead store. Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2012-07-02[klibc] [MEMALLOC] Avoid gcc warning: variable 'oldstackp' set but not usedJim Meyering1-3/+1
* src/memalloc.c (growstackblock): Remove declaration and set of set-but-not-used variable. Also remove a stray space-before-TAB. Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2012-07-02[klibc] [BUILTIN] Eliminate unnecessary promotion in echocmdHerbert Xu1-1/+1
The patch to make outc into an inline function created an unnecessary promotion in echocmd due to its use of char vs. the int used by outc. This patch changes echocmd to use int instead. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2012-07-02[klibc] [OUTPUT] Make outc an inline functionJonathan Nieder1-2/+13
As "gcc -pedantic" warns, ISO C forbids conditional expressions with only one void side. So the (needslow ? slowpath() : fastpath) code for outc in the !USE_GLIBC_STDIO case might not be portable. More importantly, it's hard to read. Rip it out and replace it with an inline function which should generate the same code. Reported-by: Szabolcs Nagy <nsz@port70.net> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2012-07-02[klibc] [EVAL] Remove unused EV_BACKCMD flagJonathan Nieder1-45/+19
The original ash defered forking commands in backquotes so builtins could be run in the same context as the shell. This behavior was controlled using the EV_BACKCMD to evaltree. Unfortunately, as Matthias Scheler noticed in 1999 (NetBSD PR/7814), the result was counterintuitive; for example, echo "`cd /`" would change the cwd. So ash 0.3.5 left out that optimization. The EV_BACKCMD codepath stayed around, unused. Some time between ash 0.3.5-11 and ash 0.3.8-37, Debian ash omitted the EV_BACKCMD pathway by guarding it with #ifdef notyet. In dash 0.5.1 and later, the commented code is no more. Let's finish the job and remove the last vestiges. If someone wants to work on omitting the fork in backcmd, the remaining hints are not going to be very helpful, anyway. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2012-07-01[klibc] arm/setjmp.S: fix longjmpSteve McIntyre1-1/+3
There's a real bug in the ARM assembly version of longjmp in usr/klibc/arch/arm/setjmp.S: it will always pass back its first argument as a return value, even if it's 0 (see the man page for more details). Oddly, the Thumb implementation in the same file *is* correct! Signed-off-by: Steve McIntyre <steve@einval.com> Signed-off-by: maximilian attems <max@stro.at>
2012-06-29[klibc] inlcude: [mips*/klibc/archstat.h] get rid of nlink_tmaximilian attems2-2/+6
_u32 in all cases, mirrors dcc62b6b38334075271eaffb1dc42cd47ceb5692 in linux. Signed-off-by: maximilian attems <max@stro.at>
2012-06-29[klibc] include: [ppc64/klibc/archstat.h] get rid of nlink_t usemaximilian attems1-1/+1
It is a unsigned long on ppc64, see 0fd7bee1e9b68fd271ad87c3e705facd1ca38055 in linux. Signed-off-by: maximilian attems <max@stro.at>
2012-06-29[klibc] include: [sys/types.h] bury __kernel_nlink_tmaximilian attems1-1/+0
We don't use it anywhere and it is gone on linux side with bb8ac181a5cf50458a0d83b4460790badc9fdc16 for 3.5-rc1. Fixes compiling against latest linux. Signed-off-by: maximilian attems <max@stro.at>
2012-06-28[klibc] 2.0.1 released, next version is 2.0.2H. Peter Anvin1-1/+1
2012-06-28[klibc] Fix gethostname()/getdomainname()klibc-2.0.1Maciej Żenczykowski2-2/+2
uname(2) returns (like all syscalls) 0 on success. Signed-off-by: Maciej Żenczykowski <maze@google.com> Signed-off-by: maximilian attems <max@stro.at>
2012-06-28[klibc] nfsmount: Fix wrong NFS umount pathBenjamin Cama1-2/+2
Hi, When mounting a NFS share and an error occurs for some reason, the NFS share is not unmounted correctly: the local path is used instead of the remote path in the umount_v[23]() call. This patch fixes this. I found this while debugging some problems mounting the root file system on NFS in a test system; I saw this in the logs (/mnt/duplicated is the legitimate remote path): Jun 21 21:52:35 pangolin-test rpc.mountd[11155]: authenticated mount request from 192.168.42.2:984 for /mnt/duplicated (/mnt/duplicated) Jun 21 21:52:35 pangolin-test rpc.mountd[11155]: refused unmount request from 192.168.42.2 for /root (/): no export ent ry I didn't understand why the hell it was trying to umount /root. You can look at google for this and you'll find a lot of people wondering what this is. I think that the big issue with this is that _a lot_ of problems appearing _after_ not unmounting correctly the share the first time are caused by this: I used to get mounting errors with “Stale NFS file handle” that would never go away (NFS is so much a PITA for this statefull behavior). You'll find a lot of people on the net trying to reboot their NFS server and the like, in hope this errors goes away. It was also quite misleading that the mount point for the root FS in the initramfs is called /root. Anyway, a lot of these problems go away with this patch. BTW, this bug is more than 9 years old, since the inception of nfsmount! Signed-off-by: Benjamin Cama <benjamin.cama@telecom-bretagne.eu> Signed-off-by: maximilian attems <max@stro.at>
2012-05-30[klibc] 2.0 released, next version is 2.0.1H. Peter Anvin1-1/+1
2012-05-29[klibc] include: [limits.h] define MB_LEN_MAXklibc-2.0maximilian attems1-0/+3
Susv3 tells it shall be defined, encountered in util-linux. Signed-off-by: maximilian attems <max@stro.at>
2012-05-29[klibc] alpha: fix signal handler setup on DEC AlphaThorsten Glaser3-2/+8
We need a five-argument rt_sigaction syscall form with a hidden argument but that can be NULL as the kernel sets it up for us better than we can (easily) do, at speed cost. Signed-off-by: Thorsten Glaser <tg@mirbsd.org> [ Mark alpha as working. -maks ] Signed-off-by: maximilian attems <max@stro.at>
2012-05-29[klibc] capabilities: Use fflush() instead of fseek()maximilian attems1-2/+2
It shouldn't use stream I/O against a control device at all in do_usermodehelper_file(), as noted by hpa. Stylistically rewind seems cleaner, but fflush() has error checking. Reported-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: maximilian attems <max@stro.at>
2012-05-27[klibc] kinit: Fix capabilities alternate read/write io without flushmaximilian attems1-0/+3
Just fseek back to the start. Signed-off-by: maximilian attems <max@stro.at>
2012-05-25[klibc] README update arch statusmaximilian attems1-5/+4
alpha, sh4 known broken. parisc status is unknown. ppc64 working. Do kick m68knommu from arch list.
2012-05-24[klibc] sys/sysmacros.h: define major, minor, and makedev as macrosH. Peter Anvin1-6/+10
There seems to exist programs in the field that assume major(), minor() and makedev() are argument-taking macros, resulting in monstrosities like: int major, minor; major = major(st.st_rdev); minor = minor(st.st_rdev); Although such code really should clean their house, in the interest of minimizing porting friction define major, minor and makedev as macros. While we are at it, clean up the type handling in the pure macro versions. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-24[klibc] sys/sysmacros.h: use __static_inlineH. Peter Anvin1-6/+5
In sys/sysmacros.h use __static_inline to deal with the various forms of inline functions. Also remove #ifndef around #include <sys/types.h>; that is just clutter. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-23[klibc] Add faccessat() system callmaximilian attems2-0/+2
Similar to access, but acts relative to a directory. Used in util-linux. Signed-off-by: maximilian attems <max@stro.at>
2012-05-23[klibc] include: [limits.h] define SSIZE_MAXmaximilian attems1-0/+2
Used in kexec-tools and lvm2. Signed-off-by: maximilian attems <max@stro.at>
2012-05-22[klibc] include: [stdio.h] add clearerr() prototypemaximilian attems1-0/+1
Seen on kmod compiling: /usr/lib/klibc/include/stdio.h:130:22: warning: no previous prototype for 'clearerr' [-Wmissing-prototypes] Signed-off-by: maximilian attems <max@stro.at>
2012-05-22[klibc] klcc.1: document -nostdincmaximilian attems1-0/+3
Needed it to have a chance making efilinux compile, due to a funny exit() redefinition. Signed-off-by: maximilian attems <max@stro.at>
2012-05-22[klibc] include: [sys/elfcommon.h] define STN_UNDEFmaximilian attems1-0/+3
Noticed while trying to compile kexec against klibc. Signed-off-by: maximilian attems <max@stro.at>
2012-05-22[klibc] include: [sys/socket.h] define SOMAXCONNmaximilian attems1-0/+3
It is part of POSIX, noticed while trying to build util-linux stuff. Signed-off-by: maximilian attems <max@stro.at>
2012-05-22[klibc] ipconfig: Use /run/ directory for script filemaximilian attems1-1/+2
This could be made to be an optional switch, but for security reason /run is just as good, due to unprivileged users not beeing allowed to write there. http://www.zytor.com/pipermail/klibc/2011-May/002912.html Reported-by: Dan Rosenberg <dan.j.rosenberg@gmail.com> Signed-off-by: maximilian attems <max@stro.at>
2012-05-22[klibc] ipconfig: Append padding if DHCP packet length < 300 octetsKUMAAN2-1/+20
This patch appends padding to DHCP packet for its length to be 300 octets, if its length is shorter than 300 octets. dhclient in ISC DHCP 4.1.1-P1 also does so. Some bad DHCP servers ignore short DHCP packet which dhclient doesn't send. Signed-off-by: KUMAAN <9maaan@gmail.com> Acked-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: maximilian attems <max@stro.at>
2012-05-22[klibc] ipconfig: Write $DOMAINSEARCH as domain-searchKUMAAN5-3/+253
This patch requests domain-search option to DHCP servers, and parses domain-search option value in DHCP ACK packet when ipconfig uses DHCP. This patch writes $DOMAINSEARCH as the value to /tmp/net-$DEVICE.conf file. > ipconfig: ignores dhcp options > http://bugs.debian.org/627166 This Debian Bug report requests the option value. The format of $DOMAINSEARCH is domain name list which is separated with ' '. For example, $DOMAINSEARCH is either 'foo1.bar. foo2.bar.', 'foo.', or ''. Signed-off-by: KUMAAN <9maaan@gmail.com> Acked-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: maximilian attems <max@stro.at>
2012-05-22[klibc] tests: Add simple sscanf checkmaximilian attems2-0/+40
klibc currently fails on the double numbers. The int part is done well. Signed-off-by: maximilian attems <max@stro.at>
2012-05-21[klibc] Move SEEK_ constants to a common header fileH. Peter Anvin4-4/+17
POSIX states that the SEEK_ constants should be defined by stdio.h, unistd.h, and fcntl.h. The easiest way to do that without having to worry about duplicate definitions is to move them to their own header file with header guards and #include it in the other files. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-21[klibc] Add pipe2() system callH. Peter Anvin2-0/+2
pipe2() is like pipe() except we can set the O_CLOEXEC flag via a second argument. Unlike pipe(), noone seems to have seemed fit to create a completely ad hoc calling convention for pipe2(), so we can just define it in one simple place. Thank goodness. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-21[klibc] Add dup3() system callH. Peter Anvin2-0/+2
The dup3() system call allows a file descriptor to be duped with the O_CLOEXEC flag set. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-21[klibc] Add trivial lseek testH. Peter Anvin2-0/+16
Add a trivial lseek test which should at least make it possible to catch parameter marshalling errors when converting to llseek. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-21[klibc] lseek: give gcc a little optimization hintH. Peter Anvin1-2/+3
It looks like gcc generates some epicly confused code for splitting the two halves of the offset argument to lseek() at least on i386. Copy it into an unsigned long long before breaking it apart seems to help. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-21[klibc] Rename llseek.c to lseek.cH. Peter Anvin2-2/+2
The file llseek.c actually implements lseek() on 32-bit platforms (on 64-bit platforms, lseek() is a plain system call.) Rename the file accordingly. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-21[klibc] SYSCALLS.def: add openat() on 64-bit platformsH. Peter Anvin1-0/+1
We had __openat() as a system call on 32 bits, wrappered in openat.c; however, the unwrappered system call used on 64-bit platforms was missing from SYSCALLS.def. Reported-by: Maximilan Attems <max@stro.at> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-21[klibc] klcc: pass down -vmaximilian attems1-1/+1
Do pass down -v for the gcc version. Signed-off-by: maximilian attems <max@stro.at>
2012-05-19[klibc] ipconfig: A bit more robust bootp/dhcp option parsingKUMAAN2-9/+28
Be a bit more strict about our BOOTP/DHCP option parsing to avoid segmentation faults. Signed-off-by: KUMAAN <9maaan@gmail.com> Acked-by: H. Peter Anvin <hpa@linux.intel.com> Signed-off-by: maximilian attems <max@stro.at>
2012-05-19[klibc] ipconfig: Write $PROTO as configuration protocolKUMAAN2-4/+28
This patch writes $PROTO as what protocol ipconfig used to configure $DEVICE to /tmp/net-$DEVICE.conf file. For example, $PROTO is either 'boop', 'dhcp', or 'none'. Later, other scripts which source the file can known the protocol clearly. Signed-off-by: KUMAAN <9maaan@gmail.com> Acked-by: H. Peter Anvin <hpa@linux.intel.com> Signed-off-by: maximilian attems <max@stro.at>
2012-05-19[klibc] ipconfig: Write $DHCPLEASETIME as dhcp-lease-timeKUMAAN3-0/+7
This patch parses dhcp-lease-time option value in DHCP ACK packet when ipconfig uses DHCP. This patch writes $DHCPLEASETIME as the value to /tmp/net-$DEVICE.conf file. > ipconfig: ignores dhcp options > http://bugs.debian.org/627166 This Debian Bug report requests the option value. For example, $DHCPLEASETIME is equal to '3600' which means 3600 seconds. If $PROTO is not equal to 'dhcp', $DHCPLEASETIME should be ignored. Signed-off-by: KUMAAN <9maaan@gmail.com> Acked-by: H. Peter Anvin <hpa@linux.intel.com> Signed-off-by: maximilian attems <max@stro.at>
2012-05-19[klibc] ipconfig: Write $UPTIME as uptimeKUMAAN2-0/+13
This patch stores uptime value of sysinfo when ipconfig configured $DEVICE, and writes $UPTIME as the value to /tmp/net-$DEVICE.conf file. For example, $UPTIME is equal to '1' which means one second. Later, other scripts which source the file can calculate the time when ipconfig configured a $DEVICE . Since the clock of uptime is not adjusted until reboot, it is useful, while system clock may be adjusted by some programs like ntpdate or hwclock before other scripts source the file. Signed-off-by: KUMAAN <9maaan@gmail.com> Acked-by: H. Peter Anvin <hpa@linux.intel.com> [ minor style fix ] Signed-off-by: maximilian attems <max@stro.at>
2012-05-18[klibc] sh4: switch to RT signalsThorsten Glaser1-1/+2
tested on sumotsu.debian.net (Debian non-DSA porterbox) note: this unbreaks the build and fixes a regression, but any klibc executable (static or shared) still throws SIGILL on sh4 Signed-off-by: Thorsten Glaser <tg@mirbsd.org> Signed-off-by: maximilian attems <max@stro.at>
2012-05-18[klibc] Makefile: help document V=2 switchmaximilian attems1-0/+1
New feature thanks to kbuild sync. Signed-off-by: maximilian attems <max@stro.at>
2012-05-18[klibc] arm: use rt signalsmaximilian attems1-0/+3
Fixes arm* breakage. Tested-by: Thorsten Glaser <tg@mirbsd.org> Signed-off-by: maximilian attems <max@stro.at>
2012-05-18[klibc] sigsuspend: unbreak s390xThorsten Glaser1-1/+1
s390 does *not* work with RT syscalls, and s390x is distinguished from s390 even if they share the same arch include directory tested both on zelenka.debian.org Signed-off-by: Thorsten Glaser <tg@mirbsd.org> Signed-off-by: maximilian attems <max@stro.at>
2012-05-18[klibc] unbreak powerpc buildsThorsten Glaser2-2/+2
a) sigset_t is larger than 32 bit, so switch to RT signals b) fix mispelt port Signed-off-by: Thorsten Glaser <tg@mirbsd.org> Signed-off-by: maximilian attems <max@stro.at>
2012-05-18[klibc] mips: define O_CLOEXECmaximilian attems1-0/+1
Fixes: usr/klibc/stdio/fopen.c: In function '__parse_open_mode': usr/klibc/stdio/fopen.c:28:14: error: 'O_CLOEXEC' undeclared (first use in this function) Reported-by: Thorsten Glaser <tg@mirbsd.org> Signed-off-by: maximilian attems <max@stro.at>
2012-05-17[klibc] kbuild: sync with kernel 3.4-rc7Sam Ravnborg2-55/+180
Update Kbuild.include and fixup Kbuild.klibc. This fixes a bug where all files are rebuild each time we invoke make. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-17[klibc] fwrite: fix the implementation of _IONBFH. Peter Anvin1-2/+2
The _IONBF implementation was a duplicate of _IOFBF, which is obviously incorrect. Actually make sure we flush after each write. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-17[klibc] Use RT signal system calls on MIPSH. Peter Anvin2-0/+6
The old signal system calls seem rather messed up on MIPS, but the headers should be clean for the RT signals, so just use those. Reported-by: Thorsten Glaser <tg@mirbsd.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-15[klibc] stdio: don't force stdin and stdout to line bufferedH. Peter Anvin1-4/+0
Don't force stdin and stdout to be line buffered, instead let them be line- or fully buffered depending on the I/O type. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-15klibc: fseek: use >= 0 to test for lseek() successH. Peter Anvin1-1/+1
On Linux, at least, lseek() will never return a negative value on success; on some architectures comparing against zero is smaller. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-15[klibc] fseek: remove redundant clearing of obytesH. Peter Anvin1-1/+0
We have already called __fflush() and gotten success, so obytes must be zero. That is also why we don't need to adjust the where argument for obytes in the SEEK_CUR case. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-15[klibc] stdio: don't cache the file pointerH. Peter Anvin7-22/+10
Caching the file pointer is incorrect for append streams, and if we have to make system calls for append streams we might as well not bother maintaining the file pointer at all... the biggest win came from the fact the ftell() could be inlined. A fully optimized libc can maintain the cached pointer for non-append streams, but for klibc, don't bother maintaining the file pointer at all, and just let the kernel worry about that. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-15[klibc] Define fseeko and ftello as macrosH. Peter Anvin1-0/+2
We ignore the "long" requirement for fseek/ftell and really have fseeko/ftello as the only implementation, but #define those names so properly written software will do the right thing. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-15[klibc] Change stdio prefix from _io_ to _IO_H. Peter Anvin13-37/+37
_io_ isn't actually implementation namespace, so use _IO_ instead. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-15[klibc] Don't set the file pointer to -1 if unseekableH. Peter Anvin1-1/+3
For unseekable files, don't set the file pointer to -1. Although it is arguably meaningless anyway, there might be problems with having the stdio file pointer be negative. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-15[klibc] run-init: add drop_capabilities supportKees Cook7-14/+39
Building on the work in ff0a614bd724f6c4c6a5014a9955dc1bc028f336, this moves the capability code down into the run-init library, so that run-init can use it as well, via the new "-d" flag. Signed-off-by: Kees Cook <kees@outflux.net> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-15[klibc] kinit: Parse mount command options properly.Curt Wohlgemuth1-28/+164
Mount options sent via "kinit_mount=" command line args, or an embedded fstab file, were not parsed properly to turn option strings into mount flags where possible. Stole and modified code from usr/utils/mount_opts.c to handle this. Tested: Tested using a variety of command line and fstab mounts and options. Signed-off-by: Curt Wohlgemuth <curtw@google.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-15[klibc] kinit: Create block device for mount commands if needed.Curt Wohlgemuth1-2/+28
For mount commands coming from the "kinit_mount=" option or from an embedded /etc/fstab, try to create the block device before we issue the mount() command. Tested: Tested with a variety of mount commands (cmdline + fstab), using both block devices and 9p mounts. Signed-off-by: Curt Wohlgemuth <curtw@google.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-15[klibc] kinit: Add ability to mount filesystems via /etc/fstab or cmdlineCurt Wohlgemuth1-2/+127
This patch adds the ability to mount filesystems via an embedded fstab or via the kernel command line. When using the kernel command-line, the following format is required: 'kinit_mount=<fs_dev>;<fs_dir>;<fs_type>;<fs_opts>' Multiple mount options can be specified; they are evaluated in the order they appear in the command-line. Mount directories ('fs_dir') sent in will have '/root' prepended to them before the actual mount(2) call is made. Tested: Sent mount commands via kinit_mount= command line; also used an embedded /etc/fstab file. Signed-off-by: San Mehat <san@google.com> Signed-off-by: Curt Wohlgemuth <curtw@google.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-15[klibc] nfsmount: clean up dummypmap compiler warningGreg Thelen1-7/+14
Without this patch gcc 4.6 warns: KLIBCCC usr/kinit/nfsmount/dummypmap.o usr/kinit/nfsmount/dummypmap.c: In function 'dummy_portmap': usr/kinit/nfsmount/dummypmap.c:191:13: warning: array subscript is below array bounds [-Warray-bounds] [ hpa: removed incorrect packed attribute and enum abuse ] Signed-off-by: Greg Thelen <gthelen@google.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-15[klibc] Add fdopendir(), fix dirfd()H. Peter Anvin2-9/+22
Add fdopendir() by splitting opendir() into two components. Note that the fdopendir() implementation doesn't actually check the validity of the file descriptor; we just let readdir() return an error if someone passed us garbage. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-15[klibc] readdir(): use _KLIBC_BUFSIZ to size the dirent bufferH. Peter Anvin1-1/+2
If _KLIBC_BUFSIZ is good enough for stdio it should be good enough for readdir() too... Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-15[klibc] fflush: only flush output streams for fflush(NULL)H. Peter Anvin1-3/+6
If we call fflush(NULL), only flush output streams; in particular, don't flush input streams... Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-15[klibc] Fix help target for headers_install pathmaximilian attems1-1/+1
Along the lines of the README update. Signed-off-by: maximilian attems <max@stro.at>
2012-05-15[klibc] Fold fopen and fdopenH. Peter Anvin6-118/+93
Fold common features of fopen() and fdopen(). In particular, POSIX doesn't actually require that fdopen() modifies the flags on the file descriptor, so *don't* -- this is klibc, after all. With that, we can then remove __fxopen() and __parse_open_mode() and fold them into fdopen() and fopen() respectively. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-15[klibc] If we need mmap2(), it doesn't matter if NO_MMUH. Peter Anvin1-1/+1
Just because we are NO_MMU doesn't mean we might not need to use mmap2(). It makes it less likely, but if that is the situation then the archconfig.h should have something like: Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-15[klibc] Handle legacy sigsuspend() correctlyH. Peter Anvin2-1/+29
Legacy sigsuspend() doesn't look anything like the user space prototype. There are two variants, and make sure we use the right one. This ignores type differences which do not matter. Originally-by: Thorsten Glaser <tg@mirbsd.org> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-15[klibc] Kbuild: build subdirectories firstH. Peter Anvin1-10/+10
Make sure subdirectories are listed first in the build list. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-15[klibc] Fix m68k supportThorsten Glaser9-22/+92
- fix syscall API and vfork - support 6-argument syscalls - add open/openat special handling for non-regparm arches Signed-off-by: Thorsten Glaser <tg@mirbsd.org> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-15[klibc] Use GCC definitions for size_t, ssize_t, ptrdiff_tThorsten Glaser4-48/+27
Fall back to (unsigned) long if klibc userspace applications are compiled with something that is not GCC or close enough to also define its __SIZE_TYPE__ and __PTRDIFF_TYPE__ macros. Change the definition of ssize_t to be decoupled from ptrdiff_t and be derived from __SIZE_TYPE__ instead, dropping the unsigned. Signed-off-by: Thorsten Glaser <tg@mirbsd.org> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-15[klibc] Fix missing prototypes for ctype inline functionsThorsten Glaser1-0/+17
Add missing prototypes. Signed-off-by: Thorsten Glaser <tg@mirbsd.org> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-15[klibc] Align <sys/types.h> with the kernel headersThorsten Glaser1-10/+11
Align __le64 (and other) type definitions with the kernel linux-libc-dev headers. Signed-off-by: Thorsten Glaser <tg@mirbsd.org> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-14[klibc] Update the documentation about how to get headersH. Peter Anvin1-7/+6
We now rely on "make headers_install", so document that fact. It is actually a simpler procedure in many ways. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-12[klibc] f*open: support the glibc 'x' flagH. Peter Anvin1-3/+6
Support the glibc 'x' extension for exclusively opening a file (O_EXCL). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-12[klibc] fgetc: shave off a few bytesH. Peter Anvin1-5/+3
Restructure fgetc() so that gcc produces slightly smaller code. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-12[klibc] isatty: allow errno to be setH. Peter Anvin1-7/+2
The specification for isatty() *does* specify that errno is set if the file descriptor is not a terminal. Since we also have to propagate errors on real errors (e.g. EBADF) this makes the implementation really simple... Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-12[klibc] stdio: fix the handling of the eof and error flags on fseekH. Peter Anvin2-1/+4
For fseek, a successful seek clears the eof flag; a failed seek sets the error flag. This means we don't need to clear the eof flag in rewind(). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-12[klibc] Fix the zapping of unused input on output operationH. Peter Anvin2-10/+10
It is not supposed to happen, but if we are to discard any buffered input on output operations, at least do it correctly. This is functionally equivalent to fseek(..., 0, SEEK_CUR); so implement it that way. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-12[klibc] Optimize fgetc() to read the buffer directlyH. Peter Anvin3-22/+25
If there is data in the buffer, optimize fgetc() to pull from the buffer directly. Continue to use _fread() to get data out of an empty buffer. This also speeds up fgets() since it calls fgetc(). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-12[klibc] fgets: remove obsolete commentH. Peter Anvin1-4/+0
Remove obsolete comment about fgets() being super slow. We have buffered I/O now. Note that fgets() certainly could be made faster by getting data directly from the buffer rather than calling getc(). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-12[klibc] fgets: shave a few bytes offH. Peter Anvin1-2/+2
Shave a few bytes off the fgets() implementation. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-12[klibc] Add rewind() functionH. Peter Anvin3-1/+9
Add rewind() function - basically fseek + clearerr. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-12[klibc] f[d]open: don't bother setting input bufferH. Peter Anvin1-1/+0
The current code relies on ->data to be set and valid only if ->ibytes contains a nonzero value, so don't bother setting the ->data pointer in other cases. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-12[klibc] fseek: report error on fflush() failureH. Peter Anvin1-3/+3
fseek(): if flushing output fails, report an error rather than proceeding with the seek. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-12[klibc] fflush: discard input dataH. Peter Anvin1-2/+3
Match the Linux semantics which is to discard any unused input data on fflush(). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-10[klibc] Make byte counters in stdio unsignedH. Peter Anvin1-3/+3
Make the byte counters in the stdio private structure unsigned; this ends up saving a few bytes. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-10[klibc] Fix confusion between _IONBF and _IOFBFH. Peter Anvin2-3/+3
_IONBF and _IOFBF were swapped in several places. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-10[klibc] Restructure the FILE object to allow simple inlinesH. Peter Anvin18-161/+247
Restructure the FILE object so that functions which are simple accessors for the FILE object contents can get it from there, without unnecessarily exposing the internals. Furthermore, allocate the buffer and the file object in the same allocation; no need to have extra mallocs() for no reason. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-10[klibc] Add zalloc() functionH. Peter Anvin3-8/+19
Although not standard, the zalloc() function is so useful and common that we might as well include it. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-10[klibc] Move _IO_file_flags from stdio.h to stdioint.hH. Peter Anvin2-9/+9
Nothing outside the stdio directory uses these flags anymore. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-08[klibc] Make __parse_open_mode handle "e" for O_CLOEXECH. Peter Anvin1-11/+14
glibc now supports an "e" for O_CLOEXEC; this makes sense so follow suit. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-08[klibc] Remove unused fputc implementationH. Peter Anvin2-25/+0
Remove unused "native" fputc implementation, intended to not require the whole fwrite machinery. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-08[klibc] Remove stdio internals from <stdio.h>H. Peter Anvin7-28/+33
Remove the internals of the FILE structure from <stdio.h>. This means removing the handful of inlines we already had there and replacing them with out-of-line functions. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-08[klibc] Change OPEN_MAX to 256H. Peter Anvin1-1/+1
256 is a much more reasonable value for OPEN_MAX on Linux. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-08[klibc] Bypass stdio buffering for large I/OH. Peter Anvin2-43/+95
If the I/O size is too large to fit in the buffer, bypass the buffering and go directly to the system call. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-08[klibc] Replace the stdio offset with a stdio data pointerH. Peter Anvin5-15/+10
There are almost no places where the offset is the useful piece, so replace the offset with a data pointer. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-05-08[klibc] Simple stdio testH. Peter Anvin2-0/+71
Very simple test for basic stdio functionality. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-03-29[klibc] ia64: Replace pipe.c with pipe.SLuck, Tony2-41/+29
There is a concern that use of macros inside "C" versions of system call stubs could have licensing consequences. Remove any doubt by re-writing the stub in assember. [ hpa: specifically, the origin of this particular file is a bit murky so avoid any and all concerns by just replacing it; all other IA64 system calls are already in pure assembly. ] Signed-off-by: Tony Luck <tony.luck@intel.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-03-29[klibc] ia64: remove obsolete <klibc/archsys.h>H. Peter Anvin3-221/+3
Remove last vestigial users of <klibc/archsys.h> and remove the header file itself. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-02-23[klibc] s390x: klcc searches for include in the wrong pathAurelien Jarno2-1/+2
s390 and s390x are sharing the same include files, in /usr/lib/klibc/include/arch/s390. However klcc seatches for the s390x includes in /usr/lib/klibc/include/arch/s390x, which doesn't exist. The patch below fixes the issue by using the ARCHDIR variable instead of the ARCH one in klcc. It's one possible fix, another possible fix would be to use a symlink, or to split s390 and s390x in two different architectures as anyway they don't share so much code. Signed-off-by: maximilian attems <max@stro.at>