Age | Commit message (Collapse) | Author | Files | Lines |
|
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>
|
|
|
|
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>
|
|
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
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>
|
|
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>
|
|
MCONFIG containing a no longer recognised gcc flag.
Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
Signed-off-by: maximilian attems <max@stro.at>
|
|
The linker command was wrong.
Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
Small build fix carried in Debian, triggered by paranoid umask.
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
* 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>
|
|
* 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>
|
|
* 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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
_u32 in all cases, mirrors dcc62b6b38334075271eaffb1dc42cd47ceb5692
in linux.
Signed-off-by: maximilian attems <max@stro.at>
|
|
It is a unsigned long on ppc64, see
0fd7bee1e9b68fd271ad87c3e705facd1ca38055 in linux.
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
|
|
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>
|
|
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>
|
|
|
|
Susv3 tells it shall be defined, encountered in util-linux.
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
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>
|
|
Just fseek back to the start.
Signed-off-by: maximilian attems <max@stro.at>
|
|
alpha, sh4 known broken.
parisc status is unknown.
ppc64 working.
Do kick m68knommu from arch list.
|
|
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>
|
|
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>
|
|
Similar to access, but acts relative to a directory.
Used in util-linux.
Signed-off-by: maximilian attems <max@stro.at>
|
|
Used in kexec-tools and lvm2.
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
Needed it to have a chance making efilinux compile,
due to a funny exit() redefinition.
Signed-off-by: maximilian attems <max@stro.at>
|
|
Noticed while trying to compile kexec against klibc.
Signed-off-by: maximilian attems <max@stro.at>
|
|
It is part of POSIX, noticed while trying to build util-linux stuff.
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
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>
|
|
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>
|
|
klibc currently fails on the double numbers.
The int part is done well.
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Do pass down -v for the gcc version.
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
New feature thanks to kbuild sync.
Signed-off-by: maximilian attems <max@stro.at>
|
|
Fixes arm* breakage.
Tested-by: Thorsten Glaser <tg@mirbsd.org>
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
_io_ isn't actually implementation namespace, so use _IO_ instead.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Along the lines of the README update.
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
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>
|
|
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>
|
|
Make sure subdirectories are listed first in the build list.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
- 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>
|
|
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>
|
|
Add missing prototypes.
Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
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>
|
|
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>
|
|
Support the glibc 'x' extension for exclusively opening a file
(O_EXCL).
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
Restructure fgetc() so that gcc produces slightly smaller code.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Shave a few bytes off the fgets() implementation.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
Add rewind() function - basically fseek + clearerr.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
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>
|
|
fseek(): if flushing output fails, report an error rather than
proceeding with the seek.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
Match the Linux semantics which is to discard any unused input
data on fflush().
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
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>
|
|
_IONBF and _IOFBF were swapped in several places.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
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>
|
|
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>
|
|
Nothing outside the stdio directory uses these flags anymore.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
glibc now supports an "e" for O_CLOEXEC; this makes sense so follow
suit.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
Remove unused "native" fputc implementation, intended to not require
the whole fwrite machinery.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
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>
|
|
256 is a much more reasonable value for OPEN_MAX on Linux.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
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>
|
|
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>
|
|
Very simple test for basic stdio functionality.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
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>
|
|
Remove last vestigial users of <klibc/archsys.h> and remove the header
file itself.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
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>
|
|
|
|
No longer relevant these days of 3.X linux.
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Usage seen in util-linux. Defined according to POSIX:2001 min.
Signed-off-by: maximilian attems <max@stro.at>
|
|
|
|
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>
|
|
Noticed by current cppcheck, all other stdio code is clean.
Signed-off-by: maximilian attems <max@stro.at>
|
|
Function is around since longer.
Signed-off-by: maximilian attems <max@stro.at>
|
|
module-init-tools uses it.
Trivial as klibc has no threading.
Signed-off-by: maximilian attems <max@stro.at>
|
|
Function was around since longer.
Seen while trying to configure against lvm2.
Signed-off-by: maximilian attems <max@stro.at>
|
|
The stdio branch merge warrants major version bump.
|
|
Thanks to the stdio branch merge the error indicator of the stream
can be tested against.
Signed-off-by: maximilian attems <max@stro.at>
|
|
Initial implementation.
Signed-off-by: maximilian attems <max@stro.at>
|
|
__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>
|
|
Fix up minor conflicts in:
usr/include/stdio.h
usr/klibc/Kbuild
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
|
|
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>
|
|
Fix naming.
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
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>
|
|
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>
|
|
Just various small coding style fixes.
Size shows that kinit didn't change as expected.
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
It breaks macros.
Acked-by: Mike Waychison <mikew@google.com>
Signed-off-by: maximilian attems <max@stro.at>
|
|
udev asks for SOCK_CLOEXEC and SOCK_NONBLOCK.
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
|
|
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>
|
|
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>
|
|
This patch fixes a parallel make install error.
Signed-off-by: Tim Harder <radhermit@gentoo.org>
Signed-off-by: maximilian attems <max@stro.at>
|
|
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
fix:
WARNING: space prohibited between function name and open parenthesis '('
Signed-off-by: maximilian attems <max@stro.at>
|
|
fixes:
WARNING: braces {} are not necessary for single statement blocks
Signed-off-by: maximilian attems <max@stro.at>
|
|
fixes:
ERROR: trailing statements should be on next line
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
Useless ifdeffery seen on previous cleanup.
Signed-off-by: maximilian attems <max@stro.at>
|
|
No point of using it on a unixish OS.
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
|
|
Directly return NULL if malloc failed.
Reviewed-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
Missing unwrap on error path..
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
add latest config.h.
Also update sync README with newer git features.
Signed-off-by: maximilian attems <max@stro.at>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
- 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>
|
|
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>
|
|
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>
|
|
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>
|
|
- 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>
|
|
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>
|
|
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>
|