aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2013-02-14[klibc] fopencookie: Add an implementation of fopencookie()fopencookieH. Peter Anvin10-18/+59
fopencookie() is a glibc extension which allows the stdio framework to be used with a user-defined backend. The entire implementation is 172 bytes long on x86-64. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
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>
2011-12-17Merge branch 'master' into stdiostdiomaximilian attems8-25/+31
2011-12-15[klibc] Makefile: drop -2.6 suffix to linux source pathesmaximilian attems1-2/+2
No longer relevant these days of 3.X linux. Signed-off-by: maximilian attems <max@stro.at>
2011-12-04[klibc] vsscanf: remove unused variablesGreg Thelen1-7/+0
Removed unused local variable from vsscanf(). Signed-off-by: Greg Thelen <gthelen@google.com> "POSIX is quite explicit that the unsigned formats still accept signed input, and since klibc requires that signed and unsigned integer types are the same the only reason to track it would be to handle numeric overflow." -hpa Acked-by: "H. Peter Anvin" <hpa@zytor.com> Signed-off-by: maximilian attems <max@stro.at>
2011-12-04[klibc] ipconfig: check poll() return valueGreg Thelen1-1/+1
Check the poll() return value for error before inspecting its output. Signed-off-by: Greg Thelen <gthelen@google.com> Signed-off-by: maximilian attems <max@stro.at>
2011-12-04[klibc] include: [sys/types.h] -> linux/types.h and __aligned_u64Maciej Żenczykowski1-0/+4
When building klibc 1.5.25 against linux/master (ie. post 3.1) I'm seeing: klibc/generated/include/linux/if_packet.h:176: error: expected specifier-qualifier-list before '__aligned_u64' which seems to come from upstream commits: 0d4691ce112be025019999df5f2a5e00c03f03c2 remotes/linux/master~90^2~408 (origin) 96c131842aab45b5d139d0bcb417796819f5ee92 remotes/linux/master~90^2~169 (change from aligned_u64 to __aligned_u64) and collides with klibc/usr/include/sys/types.h /* Keeps linux/types.h from getting included elsewhere */ #define _LINUX_TYPES_H not defining __aligned_u64 like the kernel's include/linux/types.h does. Signed-off-by: maximilian attems <max@stro.at>
2011-12-04[klibc] kbuild: add static to prototypesmaximilian attems1-14/+13
Warnings found via gcc -Wmissing-prototypes. Signed-off-by: Trevor Keith <tsrk@tsrk.net> Acked-by: WANG Cong <xiyou.wangcong@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Sam Ravnborg <sam@ravnborg.org> [ ported 4356f4890792a678936c93c9196e8f7742e04535 to klibc + minor whitespaces ] Signed-off-by: maximilian attems <max@stro.at>
2011-12-04[klibc] include: [limits.h] define OPEN_MAXmaximilian attems1-0/+2
Usage seen in util-linux. Defined according to POSIX:2001 min. Signed-off-by: maximilian attems <max@stro.at>
2011-11-22Merge branch 'master' into stdioH. Peter Anvin1-1/+3
2011-09-05[klibc] include: [sys/file.h] define flock(2) theremaximilian attems2-1/+9
SUSv3 is silent on that definition, but seen several userspace software that expects flock to be defined in that file and complain that it is missing in klibc. Current declaration is in unistd.h. Signed-off-by: maximilian attems <max@stro.at>
2011-09-03[klibc] fflush: add missing parenthesismaximilian attems1-1/+1
Noticed by current cppcheck, all other stdio code is clean. Signed-off-by: maximilian attems <max@stro.at>
2011-09-03[klibc] include: [stdio.h] Add fileno() declarationmaximilian attems1-1/+3
Function is around since longer. Signed-off-by: maximilian attems <max@stro.at>
2011-09-03[klibc] include: [stdio.h] Add getc_unlockedmaximilian attems1-0/+2
module-init-tools uses it. Trivial as klibc has no threading. Signed-off-by: maximilian attems <max@stro.at>
2011-09-01[klibc] include: [sys/stat.h] add mkfifo declarationmaximilian attems1-1/+3
Function was around since longer. Seen while trying to configure against lvm2. Signed-off-by: maximilian attems <max@stro.at>
2011-08-31[klibc] Next version is 2.0maximilian attems1-1/+1
The stdio branch merge warrants major version bump.
2011-08-31[klibc] stdio: fix ferror()maximilian attems3-7/+8
Thanks to the stdio branch merge the error indicator of the stream can be tested against. Signed-off-by: maximilian attems <max@stro.at>
2011-08-31[klibc] stdio: Add feof()maximilian attems3-1/+8
Initial implementation. Signed-off-by: maximilian attems <max@stro.at>
2011-08-31[klibc] f{open,read,write}: Retire the older sourcesmaximilian attems3-105/+0
__create_file is no longer around. They are no longer referenced in Kbuild and thus not built. Signed-off-by: maximilian attems <max@stro.at>
2011-08-31Merge remote-tracking branch 'origin/stdio' into maks/stdiomaximilian attems16-46/+479
Fix up minor conflicts in: usr/include/stdio.h usr/klibc/Kbuild
2011-08-30[klibc] include: [mntent.h] Add MNTTYPE_SWAP definitionmaximilian attems1-0/+2
It is used by util-linux mount code: mount.c:1004:30: error: ‘MNTTYPE_SWAP’ undeclared (first use in this function) .. Signed-off-by: maximilian attems <max@stro.at>
2011-08-30[klibc] include: [sched.h] misssing pid_t definitionmaximilian attems1-0/+1
Add sys/types.h include to fix: /usr/lib/klibc/include/sched.h:20:40: error: expected ‘)’ before ‘int’ /usr/lib/klibc/include/sched.h:21:39: error: expected ‘)’ before ‘unsigned’ /usr/lib/klibc/include/sched.h:22:39: error: expected ‘)’ before ‘unsigned’ /usr/lib/klibc/include/sched.h:35:1: error: unknown type name ‘pid_t’ Signed-off-by: maximilian attems <max@stro.at>
2011-08-30[klibc] include: [sched.h] fix POSIX conformancemaximilian attems1-1/+1
The linux code likes to name it SCHED_NORMAL, userland knows it under SCHED_OTHER. Use later definition as specified in POSIX:2001. Signed-off-by: maximilian attems <max@stro.at>
2011-08-29[klibc] include: [sys/socket.h] Fix bind and connect attributesmaximilian attems2-4/+4
Noticed while compiling some util-linux stuff: gen_uuid.c:507:21: warning: passing argument 2 of 'connect' discards 'const' qualifier from pointer target type [enabled by default] /usr/lib/klibc/include/sys/socket.h:248:14: note: expected 'struct sockaddr *' but argument is of type 'const struct sockaddr *' Signed-off-by: maximilian attems <max@stro.at>
2011-08-23[klibc] 1.5.25 released, next version is 1.5.26maximilian attems1-1/+1
2011-08-22[klibc] kinit: Add drop_capabilities support.klibc-1.5.25Mike Waychison4-0/+233
This patch adds the ability to kinit to allow the dropping of POSIX capabilities. kinit is modified by this change, such that it understands the new kernel command line "drop_capabilities=" that specifies a comma separated list of capability names that should be dropped before switching over to the next init in the boot strap (typically on the root disk). Dropping of capabilities happens in three parts. We explicitly drop the capability from init's inherited masks. We also drop the capability from the bounding set using PR_CAPBSET_DROP so that later setuid execs are bounded. Lastly, we drop the capabilities from the bset and inherited masks exposed at /proc/sys/kernel/usermodehelper if available (introduced in Linux v3.0.0). In all paths, we treat errors as fatal, as we do not want to continue to boot if there was a problem dropping capabilities. We fail because the new drop_capabilities= option on the command line mandates enforcement of a security policy, and we should err on the side of caution if we ever fail to satisfy the administrator's intention. Signed-off-by: Mike Waychison <mikew@google.com> Reviewed-by: "Andrew G. Morgan" <agm@google.com> Reviewed-by: "H. Peter Anvin" <hpa@zytor.com> Signed-off-by: maximilian attems <max@stro.at>
2011-08-17[klibc] test: Fix comment on top of sig-nodefermaximilian attems1-1/+1
Fix naming. Signed-off-by: maximilian attems <max@stro.at>
2011-08-16[klibc] test: Add signal nodeferMatt Fleming2-0/+56
Uncovered a bug in avr32 signal handling, might come handy in testing other archs signal. Signed-off-by: Matt Fleming <matt@console-pimps.org> Signed-off-by: maximilian attems <max@stro.at>
2011-08-08[klibc] include: [sys/ioctl.h] needs linux/sockios.hmaximilian attems1-0/+3
The defines of SIOCGIFCONF and SIOCSIFFLAGS are well hidden in linux-2.6 under #ifdef __KERNEL__ sections for example in linux/socket.h Fixes these in kexec-tools against klibc: | kexec/ifdown.c:46:16: error: 'SIOCGIFCONF' undeclared (first use in this function) | kexec/ifdown.c:46:16: note: each undeclared identifier is reported only once for each function it appears in | kexec/ifdown.c:65:18: error: 'SIOCSIFFLAGS' undeclared (first use in this function) Reported-by: Andrea Adami <andrea.adami@gmail.com> Suggested-by: KUMAAN <9maaan@gmail.com> Cc: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: maximilian attems <max@stro.at>
2011-08-08[klibc] Fix fstatat() family syscallsmaximilian attems1-1/+1
The XXX is right, it was wrong. :D Keep the XXX, as I'm unsure about the proper newfstatat() semantics. Signed-off-by: maximilian attems <max@stro.at>
2011-08-07[klibc] kinit minor checkpatch cleanupmaximilian attems5-25/+21
Just various small coding style fixes. Size shows that kinit didn't change as expected. Signed-off-by: maximilian attems <max@stro.at>
2011-08-07[klibc] klcc: Enhance param parsing Mike Pagano1-3/+11
Later versions of gcc include an option in the form of --param=name=value. This patch adds support for this. Signed-off-by: Mike Pagano <mpagano@gentoo.org> Signed-off-by: maximilian attems <max@stro.at>
2011-08-04[klibc] fstype: fix possible null deref in check_for_modules()maximilian attems1-5/+5
Make check_for_modules() more readable, just allways call continue on NULL return. That way the possible null dereference in strlen is no longer possible. This doesn't yet make it unsuck, but is a small step. Seen fixed too in blkid there with patch adding ko.gz support. Cc: Karel Zak <kzak@redhat.com> Signed-off-by: maximilian attems <max@stro.at>
2011-08-03[klibc] Add alphasort() support.Mike Waychison3-1/+15
Add support for alphasort() as defined in POSIX.1-2008. Signed-off-by: Mike Waychison <mikew@google.com> Reviewed-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: maximilian attems <max@stro.at>
2011-08-03[klibc] Add scandir() support.Mike Waychison3-1/+77
Add support for scandir() as defined in POSIX.1-2008. Signed-off-by: Mike Waychison <mikew@google.com> Reviewed-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: maximilian attems <max@stro.at>
2011-08-03[klibc] include: [capability.h] kill names in argumentsmaximilian attems1-2/+2
It breaks macros. Acked-by: Mike Waychison <mikew@google.com> Signed-off-by: maximilian attems <max@stro.at>
2011-08-02[klibc] include: [socket.h] add missing definitionsmaximilian attems1-0/+2
udev asks for SOCK_CLOEXEC and SOCK_NONBLOCK. Signed-off-by: maximilian attems <max@stro.at>
2011-07-30[klibs] syscalls: Add capset and capgetMike Waychison3-0/+17
Add the capset and capget system calls to klibc so that userland can invoke them. Signed-off-by: Mike Waychison <mikew@google.com> Signed-off-by: maximilian attems <max@stro.at>
2011-07-27[klibc] 1.5.24 released, next version is 1.5.25maximilian attems1-1/+1
2011-07-27[klibc] add support for kexec_load()klibc-1.5.24maximilian attems1-0/+1
With some hacks kexec-tools can compile against klibc. On the klibc side only this addition is missing. The patch has been carried in OpenEmbedded klibc for some time. Signed-off-by: Thomas Kunze <thommycheck@gmx.de> Signed-off-by: Yuri Bushmelev <jay4mail@gmail.com> Signed-off-by: Andrea Adami <andrea.adami@gmail.com> Signed-off-by: maximilian attems <max@stro.at>
2011-07-26[klibc] header: Fix missing <sys/socket.h> includemaximilian attems2-0/+2
Found by autotools while configuring util-linux with ./configure --without-ncurses CC=klcc against klibc-1.5.23 version. It would complain: configure: WARNING: net/if.h: present but cannot be compiled configure: WARNING: net/if.h: check for missing prerequisite headers? configure: WARNING: sys/un.h: present but cannot be compiled configure: WARNING: sys/un.h: check for missing prerequisite headers? This where the only two and it both cases sa_family_t def seemed missing. Reviewed-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: maximilian attems <max@stro.at>
2011-07-26[klibc] Kbuild: fix parallel make install errorTim Harder1-1/+1
This patch fixes a parallel make install error. Signed-off-by: Tim Harder <radhermit@gentoo.org> Signed-off-by: maximilian attems <max@stro.at>
2011-07-14[klibc] losetup, minips: nuke double included headersmaximilian attems2-2/+0
Signed-off-by: maximilian attems <max@stro.at>
2011-07-13[klibc] unlinkat: Add missing third flag argumentmaximilian attems2-2/+2
unlinkat(2) features a third arg with a flag, allowing to a nuke a dir with it, fix it. Signed-off-by: maximilian attems <max@stro.at>
2011-07-10[klibc] gzip: Cleanup unused variablemaximilian attems1-2/+0
The variable is not used in our gzip copy. In the gzip code it is used to strip of .exe of progname, which makes no sense in a unixish environment. Cleans up build with recent gcc 4.6 of: usr/gzip/gzip.c: In function ‘main’: usr/gzip/gzip.c:231:9: warning: variable ‘proglen’ set but not used [-Wunused-but-set-variable] Signed-off-by: maximilian attems <max@stro.at>
2011-07-08[klibc] kinit: checkpatch cleanupmaximilian attems4-13/+16
fix: ERROR: do not use assignment in if condition .. WARNING: line over 80 characters .. WARNING: labels should not be indented .. ERROR: space required after that ',' (ctx:VxV) .. Signed-off-by: maximilian attems <max@stro.at>
2011-07-08[klibc] nfsmount: various checkpatch fixesmaximilian attems4-42/+35
fix: ERROR: "foo * bar" should be "foo *bar" ERROR: do not use assignment in if condition .. ERROR: space required before that '!' (ctx:VxW) ERROR: space prohibited after that '!' (ctx:VxW) WARNING: suspect code indent for conditional statements (16, 18) WARNING: braces {} are not necessary for single statement blocks .. WARNING: braces {} are not necessary for any arm of this statement .. WARNING: labels should not be indented .. Signed-off-by: maximilian attems <max@stro.at>
2011-07-08[klibc] fstype: minor checkpatch fixesmaximilian attems1-7/+13
ERROR: do not use assignment in if condition .. WARNING: line over 80 characters ERROR: space prohibited after that '-' (ctx:WxW) Signed-off-by: maximilian attems <max@stro.at>
2011-07-08[klibc] ipconfig: reduce checkpatch noisemaximilian attems3-25/+23
fix for better codingstyle: ERROR: "foo * bar" should be "foo *bar" .. ERROR: switch and case should be at the same indent WARNING: braces {} are not necessary for single statement blocks WARNING: labels should not be indented .. WARNING: braces {} are not necessary for any arm of this statement .. ERROR: do not use assignment in if condition ERROR: space prohibited after that '&' (ctx:WxW) Signed-off-by: maximilian attems <max@stro.at>
2011-07-07[klibc] tests: checkpatch fixletsmaximilian attems4-7/+6
fix: WARNING: braces {} are not necessary for single statement blocks ERROR: do not use assignment in if condition WARNING: braces {} are not necessary for any arm of this statement WARNING: static char array declaration should probably be static const char Signed-off-by: maximilian attems <max@stro.at>
2011-07-07[klibc] ls: fix various checkpatch complaintsmaximilian attems1-25/+48
fix several of these: WARNING: line over 80 characters .. ERROR: do not use assignment in if condition .. ERROR: else should follow close brace '}' .. ERROR: switch and case should be at the same indent ERROR: trailing statements should be on next line .. ERROR: space required after that ',' (ctx:VxV) .. ERROR: code indent should use tabs where possible .. Signed-off-by: maximilian attems <max@stro.at>
2011-07-07[klibc] mount: whitespace policymaximilian attems1-2/+2
fix: WARNING: space prohibited between function name and open parenthesis '(' Signed-off-by: maximilian attems <max@stro.at>
2011-07-07[klibc] readklink: remove unneeded bracesmaximilian attems1-2/+1
fixes: WARNING: braces {} are not necessary for single statement blocks Signed-off-by: maximilian attems <max@stro.at>
2011-07-07[klibc] sleep: have argument on next linemaximilian attems1-1/+2
fixes: ERROR: trailing statements should be on next line Signed-off-by: maximilian attems <max@stro.at>
2011-07-06[klibc] ipconfig: Don't try to guess the nameserverUlrich Dangel1-5/+0
klibcs ipconfig tries to guess the nameserver if no nameserver is provided. This may happen due to misconfigured dhcp or the use of the ip= parameter. This patch removes the guessing from ipconfig as it is not possible for any other script to determine if the provided nameserver is valid or a guessed one. If the old behavior is really needed this could be easily implemented in an external script. Analysis shows that ip_nameserver is unused outside of ipconfig, nor any sign of gethostbyname() or such. mount.c doesn't do dns resolving, so I'd guess your patch is a welcome fix. I haven't seen this guessing in linux >= 2.0. Closes: #594638 Signed-off-by: Ulrich Dangel <uli@spamt.net> Reviewed-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: maximilian attems <max@stro.at>
2011-07-06[klibc] fstpye: no need for braces around return valuesmaximilian attems1-7/+7
Signed-off-by: maximilian attems <max@stro.at>
2011-07-05[klibc] losetup: use stdout and return 0 for -hKarel Zak1-12/+17
ported to klibc losetup version from util-linux 108591d2b7860ca0b8d27d114bed1e504a31fa72, also add -h option. -maks Reported-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com> Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: maximilian attems <max@stro.at>
2011-06-28[klibc] cpio: directly include fnmatchmaximilian attems1-2/+0
Useless ifdeffery seen on previous cleanup. Signed-off-by: maximilian attems <max@stro.at>
2011-06-28[klibc] cpio: cleanup O_BINARY usage.maximilian attems1-8/+2
No point of using it on a unixish OS. Signed-off-by: maximilian attems <max@stro.at>
2011-06-25[klibc] syscalls: Add sched_setaffinity, sched_getaffinity syscallsMike Waychison2-0/+4
Add the sched_getaffinity and sched_setaffinity system calls. Google-Bug-Id: 4725830 Signed-off-by: Mike Waychison <mikew@google.com> Signed-off-by: maximilian attems <max@stro.at>
2011-06-25[klibc] ipconfig: do_pkt_recv() refix ret initialisationmaximilian attems1-1/+1
fix: usr/kinit/ipconfig/main.c: In function ‘ipconfig_main’: usr/kinit/ipconfig/main.c:350:7: warning: ‘ret’ may be used uninitialized in this function [-Wuninitialized] usr/kinit/ipconfig/main.c:346:6: note: ‘ret’ was declared here I think the initialisation change in 6df362216a2e5beb4f29feafeabc630034a76914 was unintentional. Acked-by: Ulrich Dangel <uli@spamt.net> Signed-off-by: maximilian attems <max@stro.at>
2011-06-25[klibc] strndup(): Do not corrupt the memory poolRomain Izard1-1/+1
The allocated string may be shorter than the requested length. Always use the shortest length to write the terminating zero Signed-off-by: Romain Izard <romain.izard.pro@gmail.com> Reviewed-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: maximilian attems <max@stro.at>
2011-06-25[klibc] strndup(): Fix out of bounds read accessRomain Izard1-3/+2
The use of strlen to get the length of the source string can lead to undetermined memory access if the source string is not finished with a zero. Use strnlen to prevent this. Signed-off-by: Romain Izard <romain.izard.pro@gmail.com> Reviewed-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: maximilian attems <max@stro.at>
2011-06-14[klibc] 1.5.23 released, next version is 1.5.24maximilian attems1-1/+1
2011-06-14[klibc] strndup(): Fix possible null pointer dereferenceklibc-1.5.23maximilian attems1-2/+4
Directly return NULL if malloc failed. Reviewed-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: maximilian attems <max@stro.at>
2011-06-12[klibc] utils add minimal mvmaximilian attems2-1/+72
mv is needed these days in initramfs. One needs to move all the data of initramfs /run to the real rootfs. This minimal mv utiliy originates from the existing ln. Signed-off-by: maximilian attems <max@stro.at>
2011-06-10[klibc] nfsmount: free rem_name on errorsmaximilian attems1-1/+5
Missing unwrap on error path.. Signed-off-by: maximilian attems <max@stro.at>
2011-06-09[klibc] limits.h define LLONG_MIN, LLONG_MAX and ULLONG_MAXmaximilian attems1-3/+3
Fix existing definitions according POSIX spec. Noticed while compiling latest kexecboot against klibc: util.c:237:34: error: ‘ULLONG_MAX’ undeclared (first use in this function) Reviewed-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] dash merge updatemaximilian attems2-8/+37
add latest config.h. Also update sync README with newer git features. Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [PARSER] Fix clobbering of checkkwdHerbert Xu1-2/+3
On Sun, Nov 07, 2010 at 02:21:21AM +0000, Jonathan Nieder wrote: > > Just ran into some strange behavior: > > $ cat test.sh > #!/bin/sh > echo hello >greeting > cat <<EOF && > $(cat greeting) > EOF > { > echo $? > cat greeting > } >/dev/null > > > $ sh test.sh > hello > test.sh: 7: {: not found > 127 > hello > test.sh: 10: Syntax error: "}" unexpected > > bash, mksh, pdksh, and ksh93 all print hello as expected. The problem > is reproducible with all versions of dash in the git repo. This is caused by the clobbering of checkkwd due to readtoken recursion while parsing a here document. This patch fixes it by saving the original value of checkkwd. Reported-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [DEBUG] Use va_copy when reusing a va_listJonathan Nieder1-1/+4
When tracing (with the DEBUG compile-time option set to 1 or 2), exverror calls TRACEV to print its arguments before passing them on. So the arguments are consumed by the time exvwarning looks for them, resulting in a segfault: $ sh -c '"' sh: Syntax error: Unterminated quoted string $ sh -o debug -c '"' sh: Segmentation fault (core dumped) Make a copy with va_copy to avoid this. 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>
2011-06-03[klibc] [EXPAND] Free IFS state after here document expansionJonathan Nieder1-2/+5
Here's another bug bisecting to f42e443bb ([EXPAND] Fix ifsfirst/ifslastp leak, 2010-09-08). It was found with the following test case, based on the configure script for Tracker: dash -x -c ' <<-_ACEOF $@ _ACEOF exec ' - abcdefgh + + exec �a exec: 1: : Permission denied The missing ifsfree call is in expandarg when it returns to openhere during here document expansion. Reported-by: Aurelien Jarno <aurel32@debian.org> 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>
2011-06-03[klibc] [SHELL] Improve LINENO supportHarald van Dijk12-44/+80
This patch improves LINENO support by storing line numbers in the parse tree, for commands as well as for function definitions. It makes LINENO behaves properly when calling functions, and has the added benefit of improved line numbers in error messages when the last-parsed command is not the last-executed one. It removes the earlier LINENO support, and instead sets LINENO from evaltree when a command is executed 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>
2011-06-03[klibc] [EVAL] Let funcnode refer to a function definition, not itsHarald van Dijk3-5/+5
first command It is not unrelated: I changed the meaning of struct funcnode's field n to refer to the function definition, rather than the list of the function's commands, because I needed to refer to the function definition node from evalfun, which only gets passed a funcnode. But it is something that could be applied independently (without being useful by itself), so I've attached it as a separate patch for easier review. 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>
2011-06-03[klibc] [SHELL] Port to SolarisBrian Koropoff18-13/+60
- Solaris lacks paths.h and the various _PATH_* #defines. Check for them in configure.ac and fall back on the usual suspects when they are missing. - Older Solaris lacks isblank(), and versions that have it use a macro. Check for the declaration in configure.ac and fall back on a naive version when missing. - Older Solaris does not support %jd (intmax_t) in format strings, but it does support the PRIdMAX macro from inttypes.h. Do a configure check for PRIdMAX and use it in the code. If it doesn't exist, define it to "lld" when sizeof(long long) equals sizeof(intmax_t) as this is more likely to work on older systems. Otherwise, use "jd" and hope for the best. - Older Solaris lacks stdint.h, but inttypes.h provides the same types and works on all platforms I've tried dash on, so just use it instead. - Older Solaris doesn't like it when vsnprintf() is passed a NULL buffer (in violation of the POSIX spec, of course). Pass a 1-byte dummy buffer instead. - Solaris lacks tempfile and mktemp programs. Fall back on a "good-enough" custom function in mkbuiltins. Signed-off-by: Brian Koropoff <bkoropoff@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> [ minor merge fixup -maks ] Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [BUILTIN] Fix backslash handling in read(1)Herbert Xu4-13/+28
The new read(1) implementation incorrectly assumes that ifsbreakup ignores characters escaped by CTLESC. As such it fails to handle backslashes except for escaping newlines. This patch makes it use recordregion for every part that isn't escaped by a backslash. Reported-by: Jilles Tjoelker <jilles@stack.nl> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> [ merge fixups -maks ] Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [BUILTIN] Dotcmd should exit with zero when doing nothingJonathan Nieder1-3/+4
Tim Allen wrote: > The POSIX specification for the dot command[1] states: > > EXIT STATUS > Returns the value of the last command executed, or a zero exit > status if no command is executed. > > If an empty file is sourced, then "no command is executed" I agree. Looking through "git log --patch src/main.c", though, I find v0.5.3~42 (Do not clobber exit status in dotcmd., 2005-03-03), which appears to have been meant to take care of the following case: $ cat printstatus.sh echo $? $ false $ . ./printstatus.sh 1 I wonder if the following on top might help (imitating evalcmd)? 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>
2011-06-03[klibc] [BUILTIN] Fix CTLESC clobbering by read(1)Herbert Xu1-1/+1
The changeset 55c46b7286f5d9f2d8291158203e2b61d2494420 [BUILTIN] Honor tab as IFS whitespace when splitting fields in readcmd uses CTLESC to prevent field splitting in read(1). However, it did not escape CTLESC itself in the input stream. This patch adds the necessary CTLESC characters so that CTLESC isn't corrupted. Reported-by: Alexey Gladkov <gladkov.alexey@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [SHELL] Port to AIXBrian Koropoff2-1/+3
- AIX lacks a WCOREDUMP macro. It's just used to append "(core dumped)" to the crash message, so #ifdef around it. - For some reason, the nl program on AIX defaults to not printing line numbers ("-b n"), even though the spec says it should default to "-b t". Explicitly pass "-b a" for good measure in mkbuiltins. Signed-off-by: Brian Koropoff <bkoropoff@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [EXPAND] Do not split the result of tilde expansionJilles Tjoelker1-3/+0
A tilde expansion generates a valid pathname. Splitting it using IFS either leaves it unchanged or changes it to something unintended. This fixes FreeBSD sh test expansion/tilde1.0 and does not change the outcome of the other tests. This fixes Debian bug #601096. Example: IFS=m HOME=/tmp; printf "%s\n" ~ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [REDIR] Replace GPL noclobberopen code with the FreeBSDJilles Tjoelker1-62/+15
version Replace noclobberopen() from bash with the FreeBSD code for noclobber opens. This also reduces code size by eliminating an unnecessary check. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>