aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
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>
2011-06-03[klibc] [EXPAND] Free IFS state in evalbackcmdHerbert Xu1-0/+1
On Sun, Nov 07, 2010 at 04:04:20PM -0600, Jonathan Nieder wrote: > > Herbert Xu wrote: > > > commit f42e443bb511ed3224f09b4fcf0772438ebdbbfa > > Author: Herbert Xu <herbert@gondor.apana.org.au> > > Date: Wed Sep 8 20:07:26 2010 +0800 > > > > [EXPAND] Fix ifsfirst/ifslastp leak > > Another puzzle bisecting to f42e443bb. This one comes from the > grub-mkconfig script: > > $ sh -c 'datadir=/usr/share; pkgdatadir=${datadir}/`cat`' 2>&1 | cat -A > cat: M-^\^M^F^HM-4^M^F^HM-(^M^F^H: No such file or directory$ > cat: M-(^M^F^H: No such file or directory$ > > Still reproducible with 016b529. I'll try to find time to look into > it, but thought you might like to know nevertheless. This is the symptom of another leak. In this case evalbackcmd occurs in the middle of an expansion (as it should) but the forked child never clears the previous IFS state. This patch adds the missing ifsfree call. This wasn't as much of a problem as the previously discovered leaks since all it means is that the child gets to carry around the parent's expansion state and the child is usually short-lived. 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] [SIGNAL] Mark status as volatile in exitshellMaciej Żenczykowski1-1/+1
trap.c: In function 'exitshell': trap.c:354: warning: variable 'status' might be clobbered by 'longjmp' or 'vfork' Signed-off-by: Maciej Żenczykowski <zenczykowski@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] Stop documenting EXSHELLPROCJonathan Nieder2-11/+1
At some point between ash 0.3.5-11.0.1 and ash 0.3.8-37, Debian ash stopped using the EXSHELLPROC exception to handle shell scripts without a magic number. Remove all remaining references to it to avoid confusion. 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] Use EXEXIT in place of EXEXECJonathan Nieder3-3/+2
The intended semantics of EXEXEC are identical to EXEXIT, so simplify by using EXEXIT directly. Functional change: in edge cases (exec within a trap handler), this causes the exit status from exec not to be clobbered. For example, without this patch: $ sh -c 'trap "exec nonexistent" EXIT'; echo $? exec: 1: nonexistent: not found 0 And with it: $ sh -c 'trap "exec nonexistent" EXIT'; echo $? exec: 1: nonexistent: not found 127 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] [INPUT] Use exit status 127 when the script to run does notGerrit Pape1-1/+3
exist This commit makes dash exit with return code 127 instead of 2 if started as non-interactive shell with a non-existent command_file specified as argument (or a directory), as documented in http://www.opengroup.org/onlinepubs/009695399/utilities/sh.html#tag_04_128_14 The wrong exit code was reported by Clint Adams and Jari Aalto through http://bugs.debian.org/548743 http://bugs.debian.org/548687 Signed-off-by: Gerrit Pape <pape@smarden.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [ERROR] Allow the originator of EXERROR to set the exitHerbert Xu3-4/+6
status Some errors have exit status values specified by POSIX and it is therefore desirable to be able to set the exit status at the EXERROR source rather than in main.c. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [EVAL] Fixed trap/return regression due to SKIPEVAL removalHerbert Xu3-9/+12
On Wed, Aug 11, 2010 at 08:06:16AM +0000, Guido Berhoerster wrote: > > with the latest git version of dash trap actions are not > evaluated in the context of a function. > > The following script demonstrates the bug: > ----8<---- > read_timeout () { > saved_traps="$(trap)" > trap 'printf "timed out\n"; eval "${saved_traps}"; return' TERM > ( sleep $1; kill -TERM $$ ) >/dev/null 2>&1 & > timer_pid=$! > read $2 > kill $timer_pid 2>/dev/null > } > > read_timeout 5 value > printf "read \"%s\"\n" "${value:=default}" > > ---->8---- > The return statement in the trap inside the read_timeout function > does not return from the function but rather exits the script. > > With dash 0.5.5.1 it works as expected. This bug was caused by the SKIPEVAL removal. When the SKIPEVAL hack was added to improve set -e support in traps, dotrap was changed to return whether set -e was detected. After the removal of SKIPEVAL, set -e is now handled through exraise. However, dotrap still returned a value which is now incorrectly used to trigger an exraise. This patch removes the vestigial link between dotrap and exraise. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [EXPAND] Fix ifsfirst/ifslastp leak in casematchHerbert Xu1-0/+1
The commit f42e443bb511ed3224f09b4fcf0772438ebdbbfa [EXPAND] Fix ifsfirst/ifslastp leak revealed yet another ifsfirst/ifslastp leak in casematch. Previously it was hidden because ifsfirst/ifslastp was cleared unconditionally on entry (which caused the leakage of those entries). Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [BUILTIN] Fix EXEXEC status clobberingHerbert Xu1-1/+1
evalcommand always clobbers the exit status in case of an EXEXEC which means that exec always fails with exit status 2 regardless of what it actually returns. This patch adds the missing check for EXEXEC so that the correct exit status is preserved. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [BUILTIN] Fix trailing field bug in read(1)Herbert Xu1-8/+14
The new read(1) code fails to handle the last variable correctly if it happens to be terminated by IFS characters. Those characters are included in the last variable but they should not be. This patch fixes this. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [EXPAND] Fix ifsfirst/ifslastp leakHerbert Xu3-12/+21
As it stands expandarg may return with a non-NULL ifslastp which then confuses any subsequent ifsbreakup user that doesn't clear it directly. What's worse, if we get interrupted before we hit ifsfree in expandarg we will leak memory. This patch fixes this by always calling ifsfree in expandarg thus ensuring that ifslastp is always NULL on the normal path. It also adds an ifsfree call to the RESET path to ensure that memory isn't leaked. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [JOBS] Debug compile fixmaximilian attems1-2/+1
No point in tracing a no longer undeclared "ps->cmd", fixes: jobs.c: In function \u2018commandtext\u2019: jobs.c:1192: error: \u2018ps\u2019 undeclared (first use in this function) jobs.c:1192: error: (Each undeclared identifier is reported only once jobs.c:1192: error: for each function it appears in.) 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>
2011-06-03[klibc] [VAR] Fix varinit ordering that broke fcJilles Tjoelker1-1/+2
Git commit 0df96793ef6aa103df228d7dfe56099b7d721a15 "[SHELL] Add preliminary LINENO support" added the LINENO variable in the middle of other initialized variables, causing some macros for TERM and HISTSIZE to break (both of these are only used if libedit support is compiled in, which is not the case by default). The breakage is the same as can be seen by setting HISTSIZE=0. Also add a comment warning about this. Reported-by: Wez Furlong <kingwez@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [EVAL] Check exit for eval NSUBSHELLGerrit Pape1-1/+1
Example: $ dash -c 'set -e; (false); echo here' here With this commit, dash exits 1 before echo. The bug was reported by Stefan Fritsch through http://bugs.debian.org/514863 Signed-off-by: Gerrit Pape <pape@smarden.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [EVAL] Removed dead code for eval NPIPEHerbert Xu1-6/+0
The notyet code is identical to the current code. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [VAR] Fix loss of variables when hash collidesHerbert Xu2-14/+18
Brian Koropoff reported that the new var patches broke the following script: #!/bin/dash GDM_LANG="bar" OPTION="foo" unset GDM_LANG # OPTION has mysteriously become unset echo "$OPTION" He correctly diagnosed this as a result of removing all variables in the hash chain preceding the one that should be removed in setvareq. He also provided a patch to fix this. This patch is based on his but without keeping the original vpp. As a result, we now store new variables at the end of the hash chain instead of the beginning. To make this work, setvareq/setvar now returns the vp pointer modified. In case they're used to unset a variable the pointer returned is undefined. This is because mklocal needs it and used to get it by assuming that the new variable always appear at the beginning of the chain. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [EVAL] Don't clear eflag in evalbackcmdGerrit Pape1-1/+0
According to http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_12 "A subshell environment shall be created as a duplicate of the shell environment, except that signal traps set by that shell environment shall be set to the default values." Currently the eflag is cleared when forking a subshell, e.g. $ dash -c 'set -e ; z=$(false;echo foo) ; echo $z' foo With this commit the eflag is preserved for subshells, and dash exits 1 before echo. The problem was reported by Vincent Lefevre through http://bugs.debian.org/514863 Signed-off-by: Gerrit Pape <pape@smarden.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [BUILTIN] Continue after EINTR in read(1) with no pendingHerbert Xu1-2/+11
signals The recent introduction of SIGCHLD trapping broke read(1) as each SIGCHLD may cause read(1) to return prematurely. Now if we did have a trap for SIGCHLD read(1) should actually do this. However, returning when SIGCHLD isn't trapped is wrong. This patch fixes this by checking for EINTR and pendingsigs in read(1). 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] [JOBS] Fix wait regression where it does not wait for allHerbert Xu3-3/+12
jobs The sigsuspend patch broke wait by making it return after just one job has completed. This is because we rely on pendingsigs to signal work and never clear it until waitcmd finishes. This patch adds a separate gotsigchld for this purpose so we can clear it before we start waiting. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> [ fixup trap.c merge -maks ] Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [EXPAND] Fix corruption of redirections with byte 0x81Jilles Tjoelker1-2/+0
In other ash variants, a partial implementation of ksh-like cmd >file* adds and removes CTLESC bytes ('\x81') in redirection filenames, preserving 8-bit transparency. Long ago, dash removed the code to add the CTLESC bytes, but not the code to remove them, causing corruption of filenames containing CTLESC. This commit removes the code to remove the CTLESC bytes. The CTLESC byte occurs frequently in UTF-8 encoded non-Latin text. This bug has been reported various times to Ubuntu and Debian (e.g. Launchpad Ubuntu #422298). This patch is the same as the one submitted by Alexander Korolkov in Ubuntu #422298. Signed-off-by: Jilles Tjoelker <jilles@stack.nl> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [EVAL] Force fork if any trap is set, not just on EXITJilles Tjoelker3-8/+22
In some cases the shell executes a subshell or an external command in the current process. This is not done if a trap on EXIT has been set, so that that trap can execute after the subshell or external command has finished. Extend that check to all traps. (A trap is "set" if a non-empty command string has been attached to it.) Improve encapsulation by exporting an accessor function for this and making the trap array static again. This is much like FreeBSD SVN r194127, enhanced to apply to subshells also (see FreeBSD SVN r194774). Example: dash -c '{ trap "echo moo" TERM; sleep 3; }& sleep 1; kill $!;wait' This should print "moo" after 3 seconds. Example: dash -c '{ trap "echo moo" TERM; (sleep 3) }& sleep 1; kill $!;wait' The same. Example: dash -c '{ trap "echo moo" TERM; sleep 3; :; }& sleep 1; kill $!;wait' This works correctly even without this patch. Signed-off-by: Jilles Tjoelker <jilles@stack.nl> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> [ trivial trap.h merge fixup -maks ] Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [REDIR] Fix popredir on abnormal exit from built-inHerbert Xu3-13/+40
Just like the poplocalvar problem recently fixed, redirections can also be leaked in case of an abnormal exit. This patch fixes it using the same method as poplocalvar, by storing the previous redirection state and restoring to that point. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [REDIR] Move null redirect checks into callerHerbert Xu2-15/+5
The null redirect checks were added as an optimisation to avoid unnecessary memory allocations. However, we could avoid this completely by simply making the caller avoid making a redirection unless it is not null. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [VAR] Do not poplocalvars prematurely on regular utilitiesHerbert Xu2-4/+6
The recent cmdenviron removal broke regular utilities by calling poplocalvars too early. This patch fixes that by postponing the poplocalvars for regular utilities until they have completed. In order to ensure that local still works, it is now a special built-in. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [VAR] Fix poplocalvar on abnormal exit from functionHerbert Xu3-6/+18
The new localvar code broke the abnormal exit from functions and built-ins by not restoring the original localvar state. This patch fixes this by storing the previous localvar state so that we always unwind correctly in case of an abnormal exit. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [VAR] Replace cmdenviron with localvarsHerbert Xu4-42/+40
This patch replaces the cmdenviron mechanism for temporary command variables with the localvars mechanism used by functions. This reduces code size, and more importantly, makes the variable assignment take effect immediately as required by POSIX. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [VAR] Move unsetvar functionality into setvareqHerbert Xu2-38/+18
This patch moves the unsetvar code into setvareq so that we can no have a pathological case of an unset variable hanging around unless it has a bit pinning it like VEXPORT. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [VAR] Fix poplocalvar leakHerbert Xu1-5/+3
When a variable is marked as local, we set VSTRFIXED on its vp recored. However, poplocalvar never clears this flag for variables that were unset to begin with. Thus if you ever made an unset variable local, it would get the VSTRFIXED bit and stick around forever. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [VAR] Add localvars nestingHerbert Xu3-11/+47
This patch adds localvars nesting infrastructure so we can reuse the localvars mechanism for command evaluation. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-06-03[klibc] [EVAL] Fix command -- crashGerrit Pape1-1/+2
parse_command_args() returning a **argv pointer with *argv == 0 makes dash segfault in find_command(). To reproduce run dash -c 'command --' With this commit, parse_command_args() returns 0 if *argv is null after parsing --, and so fixes the subsequent segfault. Reported by Jonny through http://bugs.debian.org/579543 Signed-off-by: Gerrit Pape <pape@smarden.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2011-05-19[klibc] ppc64: Fix build failure with stricter asMatthias Klose1-8/+9
Landed in Ubuntu klibc version 1.5.20-1ubuntu3. Signed-off-by: maximilian attems <max@stro.at>
2011-05-19[klibc] arm: use conditional assignments for CPU_{ARCH,TUNE}Konstantinos Margaritis1-2/+2
This allows building klibc for the new upcoming Debian port armhf. It uses -mfloat-abi=hard by default This was already asked for by Ubuntu arm porter Loïc Minier. Cc: Loïc Minier <lool@dooz.org> Signed-off-by: maximilian attems <max@stro.at>
2011-05-18[klibc] 1.5.22 released, next version is 1.5.23maximilian attems1-1/+1
2011-05-18[klibc] arm: no usage of ARM_VALID_IMM() anymoreklibc-1.5.22maximilian attems1-20/+0
Since bd56c54ae409a2c36d23e61d4075e2d1ffcd1a23 aka klibc 1.4.1 the usage of that macro is gone, so just get rid of it. Signed-off-by: maximilian attems <max@stro.at>
2011-05-18[klibc] arm: use bx on thumb2 (v3)maximilian attems5-7/+29
Use klibc way to define a system dependent preprocessor definition: disabled by default and enabled for newer arm. Based on a patch by vorlon that got tested on his beagleboard, should be functional equivalent. Tested on an arm Debian porter box for the _KLIBC_ARM_USE_BX == 0 case. Fixes: https://bugs.launchpad.net/ubuntu/+source/klibc/+bug/527720 Cc: Steve Langasek <steve.langasek@canonical.com> Cc: Kirill A. Shutemov <kirill@shutemov.name> Cc: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Dave Martin <dave.martin@linaro.org> Signed-off-by: maximilian attems <max@stro.at>
2011-05-10[klibc] ipconfig: comment new escape functionmaximilian attems1-0/+5
Document it's logic for the reader. Signed-off-by: maximilian attems <max@stro.at>
2011-05-10[klibc] ipconfig: Escape DHCP options written to /tmp/net-$DEVCICE.confUlrich Dangel1-16/+39
DHCP options like domain-name or hostname are written to /tmp/net-$DEVICE.conf which is typically later used by other scripts to determine the network configuration. This is done by sourcing the /tmp/net-$DEVICE.conf file to get all defined variables. This patch escapes the DHCP options written to /tmp/net-$DEVICE.conf to prevent arbitrary code execution. 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-04-14[klibc] arm: Fix build failure with latest binutils Loïc Minier1-1/+1
klibc fails to build with recent binutils as "as" became stricter: http://sourceware.org/bugzilla/show_bug.cgi?id=12519 binutils 20110225 and later would break klibc's builds as follows: TYPE unsigned int: size 4, sign 0 TYPE unsigned long: size 4, sign 0 TYPE void *: size 4, sign 0 gcc -Wp,-MD,usr/klibc/syscalls/._exit.o.d -D__ASSEMBLY__ -nostdinc -iwithprefix include -I/build/buildd/klibc-1.5.20/usr/include/arch/arm -Iusr/include/arch/arm -I/build/buildd/klibc-1.5.20/usr/include/bits32 -Iusr/include/bits32 -I/build/buildd/klibc-1.5.20/usr/klibc/../include -Iusr/klibc/../include -I/build/buildd/klibc-1.5.20/usr/include -Iusr/include -I/build/buildd/klibc-1.5.20/linux/include -Ilinux/include -I/build/buildd/klibc-1.5.20/linux/arch/arm/include -Ilinux/arch/arm/include -D__KLIBC__=1 -D__KLIBC_MINOR__=5 -D_BITSIZE=32 -fno-stack-protector -fwrapv -fno-exceptions -mabi=aapcs-linux -mno-thumb-interwork -Os -march=armv4 -mtune=strongarm -W -Wall -Wno-sign-compare -Wno-unused-parameter -D__ASSEMBLY__ -nostdinc -iwithprefix include -I/build/buildd/klibc-1.5.20/usr/include/arch/arm -Iusr/include/arch/arm -I/build/buildd/klibc-1.5.20/usr/include/bits32 -Iusr/include/bits32 -I/build/buildd/klibc-1.5.20/usr/klibc/../include -Iusr/klibc/../include -I/build/buildd/klibc-1.5.20/usr/include -Iusr/include -I/build/buildd/klibc-1.5.20/linux/include -Ilinux/include -I/build/buildd/klibc-1.5.20/linux/arch/arm/include -Ilinux/arch/arm/include -D__KLIBC__=1 -D__KLIBC_MINOR__=5 -D_BITSIZE=32 -fno-stack-protector -fwrapv -fno-exceptions -mabi=aapcs-linux -mno-thumb-interwork -Os -march=armv4 -mtune=strongarm -W -Wall -Wno-sign-compare -Wno-unused-parameter -D__ASSEMBLY__ -nostdinc -iwithprefix include -I/build/buildd/klibc-1.5.20/usr/include/arch/arm -Iusr/include/arch/arm -I/build/buildd/klibc-1.5.20/usr/include/bits32 -Iusr/include/bits32 -I/build/buildd/klibc-1.5.20/usr/klibc/../include -Iusr/klibc/../include -I/build/buildd/klibc-1.5.20/usr/include -Iusr/include -I/build/buildd/klibc-1.5.20/linux/include -Ilinux/include -I/build/buildd/klibc-1.5.20/linux/arch/arm/include -Ilinux/arch/arm/include -D__KLIBC__=1 -D__KLIBC_MINOR__=5 -D_BITSIZE=32 -fno-stack-protector -fwrapv -fno-exceptions -mabi=aapcs-linux -mno-thumb-interwork -Os -march=armv4 -mtune=strongarm -W -Wall -Wno-sign-compare -Wno-unused-parameter -c -o usr/klibc/syscalls/_exit.o usr/klibc/syscalls/_exit.S usr/klibc/syscalls/_exit.S:1:0: warning: target CPU does not support THUMB instructions usr/klibc/syscalls/_exit.S: Assembler messages: usr/klibc/syscalls/_exit.S:29: Error: .size expression does not evaluate to a constant make[5]: *** [usr/klibc/syscalls/_exit.o] Error 1 sample Ubuntu build log: http://launchpadlibrarian.net/66527153/buildlog_ubuntu-natty-armel.klibc_1.5.20-1ubuntu3_FAILEDTOBUILD.txt.gz I've fixed this in Ubuntu with the attached patch, but didn't find where to upstream it; since you're a klibc upstream developer and since it probably already affects Debian, I figured it was probably best to send it here :-) Fixes http://bugs.debian.org/618616 Reviewed-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: maximilian attems <max@stro.at>
2011-03-29[klibc] Makefile: Remove .config directory dependencyGreg Thelen1-1/+1
Previously klibc $(objtree)/.config depended on the kernel output directory. This would cause 'defconfig has changed, please remove or edit .config' build errors if $(KLIBCKERNELOBJ) directory was modified. This directory dependency is a false dependency that does not indicate that the target, $(objtree)/.config, needs to be regenerated. Signed-off-by: Greg Thelen <gthelen@google.com> Signed-off-by: maximilian attems <max@stro.at>
2011-03-29[klibc] klcc support the gcc parameter --paramMike Pagano1-0/+3
This patch adds support to klcc for the --param parameter. Signed-off-by: Mike Pagano <mpagano@gentoo.org> Signed-off-by: maximilian attems <max@stro.at>
2011-03-29[klibc] ipconfig: Ignore configured devices in process_recieve_event.Ulrich Dangel1-0/+2
It may happen that process_receive_event is called with already configured devices resulting in multiple prints of the device configuration. This patch changes the behaviour of process_receive_event and ignores already configured devices. Signed-off-by: Ulrich Dangel <uli@spamt.net> Signed-off-by: maximilian attems <max@stro.at>
2011-03-29[klibc] ipconfig: Remove packet_peek and adjusted packet_rcv as well as ↵Ulrich Dangel3-48/+20
process_receive_event. packet_peek is not really necessary as it does basically nothing besides testing if a packet is availabe. This is already done in packet_recv. Adjusted do_pkt_recv to only use process_receive_event. packet_recv was modified to only receive and use packets from the specified interface. process_receive_event was adjusted to handle discared/ignored packages from the corresponding recv functions. As packet_recv could return 0 for ignored packets process_receive_event handled them as processed/handled packets resulting in an endless loop if new (non valid dhcp/bootp) packets were received. As a side effect ignored packets are now shown automatically in the debug output. Signed-off-by: Ulrich Dangel <uli@spamt.net> Signed-off-by: maximilian attems <max@stro.at>
2011-03-29[klibc] ipconfig: Only peek and discard packets from specified device.Ulrich Dangel5-22/+20
This patch fixes a bug on systems with multiple connected network devices. As packet_peek uses all devices to receive data instead of a specific device. As the return value was never reset it was possible that packets from other devices were returned by packet_peek. That means that the ifindex did not match any ifindex of the specified devices the packet was never removed and packets for the correct device were never processed. This patch enhance packet_peek and packet_discard to only work on packages for the specified device instead of all packets. Signed-off-by: Ulrich Dangel <uli@spamt.net> Signed-off-by: maximilian attems <max@stro.at>
2011-03-29Revert "[klibc] Use <stdarg.h> features in open() and openat()"maximilian attems4-24/+8
Issue for i386 and m68k (corrupting stack) that needs to be fixed for them. This reverts commit 0b40b7a7f71a773b606369e71fff8a6fbe22dbdf.
2011-01-30[klibc] Very minor various typo fixesGilles Espinasse3-3/+3
Signed-off-by: Gilles Espinasse <g.esp@free.fr> Signed-off-by: maximilian attems <max@stro.at>
2011-01-30[klibc] Use <stdarg.h> features in open() and openat()Mikael Pettersson4-8/+24
Looking in klibc-1.5.21 I see that the published prototype for open() is: __extern int open(const char *, int, ...); This looks fine, but the actual definition (which deliberately doesn't see the above prototype) is: int open(const char *pathname, int flags, mode_t mode) { ... } This is invalid C, and very sloppy programming. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47533 Signed-off-by: Mikael Pettersson <mikpe@it.uu.se> Signed-off-by: Thorsten Glaser <tg@mirbsd.de> Signed-off-by: maximilian attems <max@stro.at>
2011-01-26[klibc] Cleanup useless empty lines at file endingmaximilian attems3-3/+0
Overseen in applying the make 3.82 patch bfd4f2fcdfc43d34895de1872768c6301846d81a, so nuke them all. No functional change. Signed-off-by: maximilian attems <max@stro.at>
2011-01-26[klibc] Cleanup various trailing whitespacesmaximilian attems7-16/+14
They crept in with time, verified no functional change: ls -l usr/klibc/klibc-*.so -rwxr-xr-x 2 maks maks 71960 Jan 26 10:31 usr/klibc/klibc-r1_A6R6EwMsdze5h5xz93JiNuoM.so Signed-off-by: maximilian attems <max@stro.at>
2011-01-25[klibc] 1.5.21 released, next version is 1.5.22maximilian attems1-1/+1
2011-01-25[klibc] Kbuild: Avoid infinite loop during build with make 3.82klibc-1.5.21Erik Johansson2-0/+6
Remove FORCE from the list used by if_changed and friends. Otherwise the target will always be considered out of date when built with make 3.82. >From GNU make 3.82 NEWS file: * 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 $?). Tested-by: Erwan Velu <erwanaliasr1@gmail.com> Tested-by: crocket <crockabiscuit@gmail.com> Signed-off-by: maximilian attems <max@stro.at>
2011-01-21[klibc] i386: disable the use of rt signal system calls for nowH. Peter Anvin1-2/+2
For now, disable the use of rt signal system calls, even though that means we can only access 32 signals on i386. <asm/signal.h> still defines things in libc system space, in particular it defines sigset_t, which means that as long as we include <asm/signal.h> we are stuck using the 32-signal system calls. The rt system calls DO NOT support 32 signals. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-11-20[klibc] lib: cleanup unused includesmaximilian attems6-6/+0
Some stdarg.h, errno.h and sys/ioctl.h for the good mix. Signed-off-by: maximilian attems <max@stro.at>
2010-11-20[klibc] tests: cleanup unused includesmaximilian attems4-4/+0
Several unused errno.h and a stdarg.h. Signed-off-by: maximilian attems <max@stro.at>
2010-11-20[klibc] kinit: cleanup unused includesmaximilian attems9-10/+0
Found some unused ctype.h, alloca.h and errno.h. Signed-off-by: maximilian attems <max@stro.at>
2010-11-20[klibc] utils: cleanup unused includesmaximilian attems5-7/+1
several errno.h for no good reasons. cleanup losesetup which is not using getopt_long, thus doesn't need getopt.h included. Move stdarg.h include up in losesetup to more proper place. Signed-off-by: maximilian attems <max@stro.at>
2010-11-20[klibc] cat cleanup ugly ifdeferymaximilian attems1-21/+1
no point in carrying those ifdefs along, just cleanup the code that seems either BSD specific or can't work on klibc. Signed-off-by: maximilian attems <max@stro.at>
2010-11-14[klibc] nfsmounf: start_dummy_portmap() close fd on error pathmaximilian attems1-0/+2
fix ressource leakage. Signed-off-by: maximilian attems <max@stro.at>
2010-11-14[klibc] cpio: remove useless if before freemaximilian attems1-4/+2
Signed-off-by: maximilian attems <max@stro.at>
2010-11-10[klibc] ipconfig: parse_device nuke unused variable imaximilian attems1-2/+2
gets assigned a value without any further usage. Signed-off-by: maximilian attems <max@stro.at>
2010-11-10[klibc] utils: mknod massagemaximilian attems1-1/+3
Show usage instead of segfaulting when no args are passed. 0d844078 added typec and assigned value without actually using it. As variable is properly named just use it in coressponding switch. Signed-off-by: maximilian attems <max@stro.at>
2010-11-10[klibc] utils: dd close fds on error pathesmaximilian attems1-2/+9
fix several ressource leakages. Signed-off-by: maximilian attems <max@stro.at>
2010-11-10[klibc] utils: losesetup close fdmaximilian attems1-0/+1
fix ressource leakage. Signed-off-by: maximilian attems <max@stro.at>
2010-11-10[klibc] kinit: ramdisk_load() fix leakage on error pathmaximilian attems1-0/+2
close respective file descriptor and stream. Signed-off-by: maximilian attems <max@stro.at>
2010-11-10[klibc] tests: fcntl close fdmaximilian attems1-0/+1
fix ressource leak of fd. Signed-off-by: maximilian attems <max@stro.at>
2010-10-30[klibc] fix typo in __static_inline macro definitionsMaciej Żenczykowski1-1/+1
Commit 57c0820992c7b735c7d6283e451b6dac49bf8b05 introduced and obvious typo - fix it. Signed-off-by: Maciej Żenczykowski <maze@google.com> Signed-off-by: maximilian attems <max@stro.at>
2010-10-30[klibc] kbuild: enable reproducible buildsMaciej Żenczykowski2-6/+11
This adds a new setting: KBUILD_REPRODUCIBLE If it is non-empty, ar and ranlib will be called in such a way that timestamps do not affect the build output. This allows one to get perfectly reproducible builds. Signed-off-by: Maciej Żenczykowski <maze@google.com> Signed-off-by: maximilian attems <max@stro.at>
2010-10-20[klibc] kbuild: fix a compile warningmaximilian attems1-2/+3
scripts/basic/fixdep.c: In function ‘traps’: scripts/basic/fixdep.c:368: warning: dereferencing type-punned pointer will break strict-aliasing rules scripts/basic/fixdep.c:370: warning: dereferencing type-punned pointer will break strict-aliasing rules Fix similar to linux-2.6 d067aa741589a9783cc43315119e0f431b4e382c commit. Reported-by: Maciej Żenczykowski <maze@google.com> Signed-off-by: maximilian attems <max@stro.at>
2010-10-05[klibc] Macros to handle inlines when compiling in c99 modeH. Peter Anvin3-15/+38
Use some macros to tell gcc that we're using gnu89-style inlines even if the compiler is in c99/gnu99 mode. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-10-04[klibc] runinitlib: remove unused variableH. Peter Anvin1-1/+1
Remove the unused variable ist in run_init(). Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-10-04[klibc] sys/socket.h: include <sys/types.h>H. Peter Anvin1-0/+1
Include <sys/types.h> in <sys/socket.h>; it prevents <linux/types.h> from unwantedly getting pulled in -- at least in current kernels that is a warning and not a failure, but it's still ugly. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-08-28[klibc] 1.5.20 released, next version is 1.5.21maximilian attems1-1/+1
2010-08-25[klibc] run-init: get rid of over paranoid test for /initklibc-1.5.20maximilian attems1-4/+0
switch_root in util-linux hasn't it either. cc0c0262 added the checks, but probably didn't have the following application in mind. In fact it can break chainloading of bigger initramfs out of small one: "I boot via pxe, kernel + very small ramfs this ramfs start an application that grabs a bigger ramfs and store it locally I did the following: creating a tmpfs, uncpio the ramfs and try to run-init on it, but my miniramfs doesn't have a /init as I specified rdinit=/sbin/init." So for now just get rid of that check. Reported-by: Erwan Velu <erwan.velu@zodiacaerospace.com> Signed-off-by: maximilian attems <max@stro.at>
2010-08-25[klibc] ipconfig: non zero exit on timeoutErwan Velu1-5/+6
I was scripting in klibc and wanted to make an action when the dhcp client failed at grabing an IP after the defined timeout. I found that klibc always exit 0 which isn't that convenient . Belows patch fixes the issue. [ small coding style changes - maks] Signed-off-by: maximilian attems <max@stro.at>
2010-08-25[klibc] ipconfig fix dns domainMichael Prokop1-1/+1
I'm trying to boot a KVM over the net with a FAI created nfsroot. The boot procedure fails with an error message that instructs me to file this bug. In /live.log I see the following error message: /init: /tmp/net-eth0.conf: line 9: int-domain2.priv: not found http://bugs.debian.org/594208 Belows trivial patch addresses this issue. Signed-off-by: Michael Prokop <mika@debian.org> Tested-by: Reinhard Tartler <siretart@tauware.de> Signed-off-by: maximilian attems <max@stro.at>
2010-08-25[klibc] ipconfig: differentiate between error and non-DHCP/BOOTP traffic in ↵Julien BLACHE3-5/+6
packet_recv() Commit 4efbcf90f60e27febe883ef052454d8cfded5c15 badly broke ipconfig by turning packet_recv() into an all-or-nothing function. Before this commit, packet_recv() did distinguish between a DHCP/BOOTP packet that's of interest, random UDP packets we don't care about and errors. After the patch, either a packet is a DHCP/BOOTP packet or packet_recv() exits with an error. This breaks ipconfig on big, noisy LANs where random UDP traffic can arrive before the DHCP reply and throw the device into DEVST_ERROR state. This fixes http://bugs.debian.org/552554 Tested-by: Michael Prokop <mika@debian.org> Signed-off-by: maximilian attems <max@stro.at>
2010-08-25[klibc] ipconfig: fix infinite loopJulien BLACHE1-0/+3
The first switch() statement in process_receive_event() did not handle the DEVST_ERROR state, causing the timeout to be endlessly increased by 10 seconds at each iteration in the second switch() statement. The second switch() statement is only here to catch state changes caused by the first one, so DEVST_ERROR must be caught by the first one to ignore the device until the timeout expires. Tested-by: Michael Prokop <mika@debian.org> Signed-off-by: maximilian attems <max@stro.at>
2010-08-10[klibc] 1.5.19 released, next version is 1.5.20H. Peter Anvin1-1/+1
2010-07-07[klibc] x86_64: MMCONFIG cleanup vestige from pre x86 mergeklibc-1.5.19maximilian attems1-3/+0
this assignment is useless these days, so just get rid of it. Reported-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: maximilian attems <max@stro.at>
2010-07-07[klibc] fix build on native i386Sam Ravnborg1-0/+3
When trying to build klibc on a native i386 box it failed to include asm/posix_types.h This was tracked down to a wrong include path. For x86_64 it was correct. Fix it for i386. This should fix the build problem reported Phil Howard. "FYI basically same patch was done and tested in OpenEmbedded on 2010-07-01" - Andrea Adami <andrea.adami@gmail.com> 6f08923d3024f108b6262258c913573fb6ea78e6 fixed allmost all other unified archs. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Cc: Phil Howard <kunnskaperen@gmail.com> Signed-off-by: maximilian attems <max@stro.at>
2010-07-07[klibc] valgrind: netdev_sif_addr fix unitialized valgrind errormaximilian attems1-0/+1
memset struct sockaddr_in sin and thus get a clean valgrind ipconfig run. Fixes: ==15636== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0) ==15636== ==15636== 1 errors in context 1 of 3: ==15636== Syscall param ioctl(SIOCSIF*ADDR) points to uninitialised byte(s) ==15636== at 0x403EB1: __syscall_common (in /home/maks/src/klibc-latest/usr/kinit/ipconfig/static/ipconfig.g) ==15636== by 0x401859: netdev_setaddress (in /home/maks/src/klibc-latest/usr/kinit/ipconfig/static/ipconfig.g) ==15636== by 0x30687464: ??? ==15636== Address 0x7fefffb02 is on thread 1's stack ==15636== ==15636== ==15636== 1 errors in context 2 of 3: ==15636== Syscall param ioctl(SIOCSIF*ADDR) points to uninitialised byte(s) ==15636== at 0x403EB1: __syscall_common (in /home/maks/src/klibc-latest/usr/kinit/ipconfig/static/ipconfig.g) ==15636== by 0x40180D: netdev_setaddress (in /home/maks/src/klibc-latest/usr/kinit/ipconfig/static/ipconfig.g) ==15636== by 0x30687464: ??? ==15636== Address 0x7fefffb02 is on thread 1's stack ==15636== ==15636== ==15636== 1 errors in context 3 of 3: ==15636== Syscall param ioctl(SIOCSIF*ADDR) points to uninitialised byte(s) ==15636== at 0x403EB1: __syscall_common (in /home/maks/src/klibc-latest/usr/kinit/ipconfig/static/ipconfig.g) ==15636== by 0x4017C8: netdev_setaddress (in /home/maks/src/klibc-latest/usr/kinit/ipconfig/static/ipconfig.g) ==15636== by 0x30687464: ??? ==15636== Address 0x7fefffb02 is on thread 1's stack ==15636== ==15636== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0) Signed-off-by: maximilian attems <max@stro.at>
2010-07-07[klibc] ipconfig: packet_send() fix uninitialized valgrind errorsmaximilian attems1-9/+10
Be conversvative and don't use C99 features, just memset the sll struct. The relevant sll entries are assigned later down the road. Rewrite struct msghdr msg assignments to not mix declarations and assignements. Fixes this valgrind errors: ==3319== ==3319== 1 errors in context 3 of 4: ==3319== Syscall param ioctl(SIOCSIF*ADDR) points to uninitialised byte(s) ==3319== at 0x403BE1: __syscall_common (in /home/maks/src/klibc-latest/usr/kinit/ipconfig/static/ipconfig.g) ==3319== by 0x401724: netdev_setaddress (in /home/maks/src/klibc-latest/usr/kinit/ipconfig/static/ipconfig.g) ==3319== by 0x30687464: ??? ==3319== Address 0x7fefffb02 is on thread 1's stack ==3319== ==3319== ==3319== 2 errors in context 4 of 4: ==3319== Syscall param ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ points to uninitialised byte(s) ==3319== at 0x403BE1: __syscall_common (in /home/maks/src/klibc-latest/usr/kinit/ipconfig/static/ipconfig.g) ==3319== by 0x401B90: packet_send (in /home/maks/src/klibc-latest/usr/kinit/ipconfig/static/ipconfig.g) ==3319== by 0x7FEFFFA0F: ??? ==3319== by 0x13: ??? ==3319== by 0x6060DF: ??? (in /home/maks/src/klibc-latest/usr/kinit/ipconfig/static/ipconfig.g) ==3319== by 0x5: ??? ==3319== Address 0x7fefffa22 is on thread 1's stack Signed-off-by: maximilian attems <max@stro.at>
2010-07-07[klibc] Add ancillary data structures and macros to sys/socket.hMike Waychison1-0/+80
It turns out that all the CMSG_* structures and macros are hidden behind __KERNEL__ in current kernel.org kernels. Expose these macros in sys/socket.h for the time being to make them available. Signed-off-by: Mike Waychison <mikew@google.com> Signed-off-by: maximilian attems <max@stro.at>
2010-07-07[klibc] CFLAGS: enable -fwrapvMike Waychison1-1/+2
Enable -fwrapv in klibc's build as there may be places that assume that signed integers can overflow. Signed-off-by: Mike Waychison <mikew@google.com> [ I noticed no new warning on klibc build with gcc 4.4. ] Signed-off-by: maximilian attems <max@stro.at>
2010-07-07[klibc] fstype: btrfs size endianness fixBenjamin Cama1-1/+1
Tested OK on both little endian (amd64) and big endian (powerpc). Signed-off-by: Benjamin Cama <benoar@free.fr> Signed-off-by: maximilian attems <max@stro.at>
2010-07-07[klibc] sh4: syscalls fixesAurelien Jarno4-9/+44
Using the patch from bug #574834 klibc now builds, but does not work. It assumes that the kernel returns the result of the syscalls in register r3, while it behaves like a normal call, with the results in register r0. Also the pipe syscall needs a special handling as on some other architectures, the structure passed in argument is not filled, instead the two fd are returned in r0 and r1. The patch below fixes the problem. It has been tested by creating an initrd with initramfs and booting the system with it. Closes: #578076 Signed-off-by: maximilian attems <max@stro.at>
2010-07-07[klibc] fstype: list the includes in alphabetic ordermaximilian attems1-8/+8
currently there is no order. Signed-off-by: maximilian attems <max@stro.at>
2010-07-07[klibc] bootp_packet.h minor stylistic fixmaximilian attems1-1/+1
Signed-off-by: maximilian attems <max@stro.at>
2010-07-07[klibc] resume: silence warning on resume trymaximilian attems1-1/+1
We most propably didn't hibernate in the first place. s/fprintf/dprintf/ Signed-off-by: maximilian attems <max@stro.at>
2010-06-20[klibc] add getrusage()Thorsten Glaser2-0/+3
we define rusage, but had no way to see this stats. it may allow compiling mksh against klibc. Signed-off-by: maximilian attems <max@stro.at>
2010-04-22[klibc] 1.5.18 released, next version is 1.5.19H. Peter Anvin1-1/+1
2010-04-21pull faccessat() system callklibc-1.5.18maximilian attems2-2/+0
3-arg faccessat is unfortunately an incomplete implementation. It does not match user-space needs, for example due to wrong answer when egid != gid. dash started to detect klibc faccessat() syscall wrapper. Signed-off-by: maximilian attems <max@stro.at> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-04-21[klibc] dash update sync commitmaximilian attems1-1/+1
we merged in 0.5.6, plus minor fixes since. Signed-off-by: maximilian attems <max@stro.at>
2010-04-21[klibc] [JOBS] Fix for job control off warningH. Peter Anvin1-1/+1
There seems to be a problem with the new version of dash with job control off. I can't tell if it is just a warning or is a manifest bug. usr/dash/trap.c: In function `exitshell': usr/dash/trap.c:376: warning: suggest braces around empty body in an `if' statement Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2010-04-21[klibc] [BUILTIN] Use faccessat if availableHerbert Xu2-0/+25
Eric Blake suggested that we should use faccessat so that ACLs and other corner cases are handled correctly. This patch does exactly that. Note that faccessat doesn't handle ACLs when euid != uid, as this case is currently implemented by glibc instead of the kernel, using code similar to the existing dash test. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> [ config.h undef HAVE_FACCESSAT ] Signed-off-by: maximilian attems <max@stro.at>
2010-04-16Release 0.5.6.Herbert Xu1-3/+3
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2010-04-16[klibc] [BUILTIN] Make trap signal name/number errors non-fatal.Herbert Xu1-2/+4
On Wed, Feb 24, 2010 at 10:23:34AM +0000, Peter Kjellerstedt wrote: > > there seems to be a problem with the trap implementation in dash > (tested with 0.5.4 and 0.5.5.1). If I specify a signal which is not > supported, the shell unconditionally aborts. E.g., I had expected > the following to print foo (like bash and zsh do): > > # dash -c 'trap "echo trap executed" UNKNOWNSIGNAL || echo "foo"' > trap: 1: UNKNOWNSIGNAL: bad trap > > This means I cannot write a construct like the following to take > advantage of the ERR signal which is present in some shells: > > trap "echo ERR trap executed" ERR 2>/dev/null || : > > I also checked the POSIX documentation, and quoting from > http://www.opengroup.org/onlinepubs/009695399/utilities/trap.html > (exit status): "For both interactive and non-interactive shells, > invalid signal names [XSI] [Option Start] or numbers [Option End] > shall not be considered a syntax error and do not cause the shell > to abort." This patch replaces sh_error with a outfmt + return 1 in trapcmd so that these errors are no longer fatal. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2010-04-02[klibc] dash: cd fix getpwdmaximilian attems1-3/+4
On review of klibc dash changes: "Hmm, this breaks the non-glibc case. You're now returning a pointer to a string on the stack which is illegal." Herbert Xu Use upstream dash way. Signed-off-by: maximilian attems <max@stro.at> Cc: Herbert Xu <herbert@gondor.apana.org.au>
2010-03-28[klibc] fstype: btrfs supportmaximilian attems2-0/+71
Butter on bread seems useless for good french cheese. Although there are many nice usage cases for butter. This fs seems to be fancy and lately lots of users were asking for support: mkfs.btrfs /dev/dualvg0/testb WARNING! - Btrfs Btrfs v0.19 IS EXPERIMENTAL WARNING! - see http://btrfs.wiki.kernel.org before using fs created label (null) on /dev/dualvg0/testb nodesize 4096 leafsize 4096 sectorsize 4096 size 920.00MB ~/src/klibc-latest$ ./usr/kinit/fstype/static/fstype /dev/mapper/dualvg0-testb FSTYPE=btrfs FSSIZE=964689920 Signed-off-by: maximilian attems <max@stro.at>
2010-03-23[klibc] fstype: recognise ext4 without journalColin Watson1-8/+0
ext4 no longer requires a journal, fix shipped by Ubuntu for some time. Compare: http://git.kernel.org/?p=fs/ext2/e2fsprogs.git;a=commitdiff;h=a90f5391dda78f7bc4a8196a78355584ace0adf5 Signed-off-by: Colin Watson <cjwatson@ubuntu.com> Acked-by: "Theodore Ts'o" <tytso@mit.edu> Signed-off-by: maximilian attems <max@stro.at>
2010-03-23[klibc] kinit: use dprintf on DEBUGmaximilian attems9-49/+47
as bonus this cleanes up also some whitespace violations in old DEBUG usage. Signed-off-by: maximilian attems <max@stro.at>
2010-03-23[klibc] nfsmount: use dprintf on DEBUGmaximilian attems5-21/+12
same switch as ipconfig. nuke unused include of ipconfig.h in nfsroot.c Signed-off-by: maximilian attems <max@stro.at>
2010-03-23[klibc] ipconfig: use dprintf on DEBUGmaximilian attems5-45/+38
compile the relevant printfs if DEBUG is defined at compile time or nothing if not. dprintf uses simply printf as definition, no need to badly invent a new marcro. nuke comment related to old gcc. the line ending story of those printf needs to be fixed another time. Put some dprintf back in, that went missing in latest fixes. Signed-off-by: maximilian attems <max@stro.at>
2010-03-22[klibc] ipconfig: Use memcpy to avoid strict aliasing warnings.Mike Waychison1-10/+17
Newer compilers will complain about strict aliasing when casting struct sockaddr to sockaddr_in. Even though these are legitimate type casts, changing them to use memcpy is easy enough and silences the warnings. Signed-off-by: Mike Waychison <mikew@google.com> Signed-off-by: maximilian attems <max@stro.at>
2010-03-22[klibc] README update arch statusmaximilian attems1-2/+3
s390 known working in debian ia64 is built staticaly as shared segfault av32 is not yet seen Signed-off-by: maximilian attems <max@stro.at>
2010-03-22[klibc] sh4 build fixNobuhiro Iwamatsu1-1/+1
make[2]: Entering directory `/build/buildd-klibc_1.5.17-3-sh4-O7e0CP/klibc-1.5.17' scripts/Makefile.clean:17: /build/buildd-klibc_1.5.17-3-sh4-O7e0CP/klibc-1.5.17/usr/klibc/arch/sha/Makefile: No such file or directory Debian sh porters sent this patch to fix the issue. Signed-off-by: maximilian attems <max@stro.at>
2010-03-22[klibc] add testcase for future arch socket foomaximilian attems2-0/+20
the test wouldn't be enough to catch sparc64 trickery, but it triggers easily on sparc32 already. Signed-off-by: maximilian attems <max@stro.at>
2010-03-22[klibc] gitignore fixup for test dirmaximilian attems1-0/+1
git needs to track c sourcefiles. Signed-off-by: maximilian attems <max@stro.at>
2010-03-22[klibc] dash update config.hmaximilian attems1-7/+85
this is latest git dash configured with klcc against klibc 1.5.17. Signed-off-by: maximilian attems <max@stro.at>
2010-03-22[klibc] document klibc dash sync proceduremaximilian attems2-7/+25
there might be easier ways, but this one worked out. As bonus rename README.klibc to README.dash. Signed-off-by: maximilian attems <max@stro.at>
2010-03-22[klibc] [ARITH] Fix logical or result valueJilles Tjoelker1-1/+1
Another change I'm making to the arith code is making || return 0 or 1 only, matching C, POSIX and other shells. Apart from the compliance issue, it is also bad to expose implementation details like the exact meaning of 'noeval' to scripts such that they may come to depend on them. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2010-03-22[klibc] [REDIR] Do not truncate file for FROMTO redirectionHerbert Xu1-1/+1
On Tue, Jun 23, 2009 at 10:06:30AM +0000, Nikola Vladov wrote: > May be this is a bug: > > echo XX > uu > cat <> uu > > dash truncates file uu. The open flag O_TRUNC must be removed. > I'm not 100% shure what POSIX say about: program <> file Indeed, this is a bug we inherited from NetBSD. This patch removes the O_TRUNC flag for FROMTO. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2010-03-22[klibc] [ARITH] Fix binary operator parsingHerbert Xu1-10/+20
Jilles Tjoelker reported that binary operator parsing doesn't respect operator precedence correctly in the case where a lower- precedence operator is followed by a higher-precedence operator, and then by a lower-precedence operator. This patch fixes this by stopping when we encounter a binary oeprator with a precedence lower than one that we have already encountered. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2010-03-22[klibc] [BUILTIN] Fix off-by-one recordregion in readcmdHerbert Xu1-1/+1
Alexey Gladkov <gladkov.alexey@gmail.com> wrote: > > I found another example: > > $ tr -d '[:print:]' < /etc/passwd |tr -d '\t\n' |wc -c > 0 > > $ dash -c 'while read o p; do printf "[%s] [%s]\n" "$o" "$p"; done < > /etc/passwd' |tr -d '[:print:]' |tr -d '[:space:]' |wc -c > 61 > > bug is not fixed yet :( This bug is caused by an off-by-one error in the recordregion call in readcmd. It included the terminating NUL in the region which causes ifsbreakup to include the string after it for scanning. Setting the correct length fixes the problem. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2010-03-22[klibc] [PARSER] Fix syntax array sizeJim Meyering1-3/+3
On Mon, Sep 28, 2009 at 11:00:05AM +0200, Jim Meyering wrote: > A DEL (0177, dec 127) byte in a here-document would cause dash to > access uninitialized memory at the end of one of the syntax.c tables, > since those tables are sized to accommodate a maximum index of > BASESYNTAX + 126. Make the generated tables one byte larger. > printf ':<<\\E\n\200y\nE'|./dash > * src/mksyntax.c (filltable): Use 258, not 257 as the size, > so that BASESYNTAX(=130) + 127 is a valid index. > (print): Likewise. > Don't emit explicit array dimension in declaration. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2010-03-22[klibc] [CD] Lookup PWD after going through CDPATHHerbert Xu1-10/+11
On Tue, Jul 14, 2009 at 09:39:03PM +0000, Eric Blake wrote: > For the cd command, POSIX 2008 requires that after all pathnames in CDPATH > have been tested and failed in step 5, then step 6 interprets the directory > argument relative to PWD. In other words, this demonstrates a bug: > > $ dash -c 'cd /tmp; mkdir -p foo; CDPATH=oops; cd foo; echo $?; pwd' > cd: 1: can't cd to foo > 2 > /tmp > > while bash gets it correct: > > $ bash -c 'cd /tmp; mkdir -p foo; CDPATH=oops; cd foo; echo $?; pwd' > 0 > /tmp/foo This patch fixes the problem. Reported-by: Eric Blake <ebb9@byu.net> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2010-03-22[klibc] [BUILTIN] Avoid compiler warnings on isdigitEric Blake1-1/+1
Pass correct type to ctype macro. Signed-off-by: Eric Blake <ebb9@byu.net> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2010-03-22[klibc] [BUILTIN] Add another missing LC_COLLATE to mkbuiltinsMatthew Burgess1-1/+1
On Sat, Aug 15, 2009 at 06:07:16PM +0000, Matthew Burgess wrote: > > My system has Coreutils-7.4 compiled with the i18n patch from > http://cvs.fedoraproject.org/viewvc/devel/coreutils/coreutils-i18n.patch. > > Using this to compile dash, when in an en_GB.UTF-8 locale, I get the following error: > > if gcc -DHAVE_CONFIG_H -I. -I. -I.. -include ../config.h -DBSD=1 -DSHELL -DIFS_BROKEN -Wall -g -O2 -MT eval.o -MD -MP -MF ".deps/eval.Tpo" -c -o eval.o eval.c; \ > then mv -f ".deps/eval.Tpo" ".deps/eval.Po"; else rm -f ".deps/eval.Tpo"; exit 1; fi > eval.c: In function ‘evalcommand’: > eval.c:810: error: ‘EXECCMD’ undeclared (first use in this function) > eval.c:810: error: (Each undeclared identifier is reported only once > eval.c:810: error: for each function it appears in.) > eval.c:812: error: ‘COMMANDCMD’ undeclared (first use in this function) > make[3]: *** [eval.o] Error 1 > > This is because the src/mkbuiltins script ends up generating an incomplete > src/builtins.h file. This, in turn, is caused by 'sort -u -k 3,3' not > working correctly. > > The attached patch fixes/works around things by setting LC_CTYPE=C, thus > overriding the build environment (in a similar manner to the earlier call to > 'sort' in that same script). I've changed it to use LC_COLLATE. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2010-03-22[klibc] [BUILTIN] Fix NUL termination in readcmdHerbert Xu1-1/+1
Commit 55c46b7286f5d9f2d8291158203e2b61d2494420 ([BUILTIN] Honor tab as IFS whitespace when splitting fields in readcmd) introduced a bug where sometimes garbage would follow the last field preceding the end-of-line. This was caused by an off-by-one error in the string length calculation. This patch fixes the bug. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2010-03-22[klibc] [EVAL] Revert SKIPEVAL into EXEXITHerbert Xu3-16/+5
Now that eval handles EV_TESTED correctly, we can remove the SKIPEVAL hack and simply use EXEXIT for set -e. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2010-03-22[klibc] [EVAL] Pass EV_TESTED into evalcmdHerbert Xu5-16/+23
This patch fixes the case where the eval command is used with set -e and as part of a construct that should not cause the shell to abort, e.g., as part of the condition of an if statement. This is achieved by propagating the EV_TESTED flag into the evalstring function through evalcmd. As this alters the prototype of evalcmd it is now invoked explicitly by evalbltin. The built-in infrastructure has been changed to accomodate this special case. In order to ensure that the EXIT trap is properly executed this patch clears evalskip in exitshell. This wasn't needed before because of the broken way evalstring worked where it always clears evalskip when called by minusc. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>
2010-03-22[klibc] [SHELL] Add preliminary LINENO supportRocky Bernstein4-6/+18
Looks like in contrast to what the dash.1 manual page says, expansion of PS{1,2,4} does work. Here is a little patch to set LINENO. The ways in that it is less than ideal mirror the ways that the line number error reporting is also less than ideal. For example if you run this: ( x=$((1/0)) # Just to add another line # And another ) # error reports this line The error reported will be the closing parenthesis even though I think most people would prefer the error to be the one where x was set. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: maximilian attems <max@stro.at>