Age | Commit message (Collapse) | Author | Files | Lines |
|
Since the UAPI/KAPI header split in Linux 3.7, we have needed
KLIBCKERNELSRC to point to the installed UAPI headers. Invoking
"make headers_install" in this directory doesn't work.
The previously proposed fix was to invoke make in the parent
directory. But since we require the headers to be installed
already, we can copy the install tree instead. Make sure to
dereference any symbolic links while doing this.
Reported-by: Thomas Meyer <thomas@m3y3r.de>
Reported-by: Luis R. Rodriguez <mcgrof@kernel.org>
Link: https://www.zytor.com/pipermail/klibc/2019-January/004033.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
Since the UAPI/KAPI header split in Linux 3.7, we have needed
KLIBCKERNELSRC to point to the installed UAPI headers. The "sample
invocation" has been updated to reflect this but the rest of the help
text has not.
Link: https://www.zytor.com/pipermail/klibc/2019-January/004032.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
Since the UAPI/KAPI header split in Linux 3.7, we have needed
KLIBCKERNELSRC to point to the installed UAPI headers. This makes
KLIBCKERNELOBJ and the extra header directories based on it completely
redundant.
Link: https://www.zytor.com/pipermail/klibc/2019-January/004031.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
The error message for a missing $(KLIBCKERNELSRC) won't appear
unless it's specified as a target or something depends on it.
Make the klcc and klibc targets depend on it.
Link: https://www.zytor.com/pipermail/klibc/2019-January/004030.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
We link all executables as non-relocatable, so it makes no sense to
generate PIE code. In addition, PIE code on i386 requires a working
GOT which we don't generate.
Link: https://www.zytor.com/pipermail/klibc/2019-January/004028.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
Building klibc for i386 with binutils 2.31 adds an extra
.note.gnu.property section to klibc.so, the address of which is not
affected by the -Ttext option. Loading a klibc executable then
fails with the following kernel log message:
9409 (sh.shared): Uhuuh, elf segment at 0000000000600000 requested but the memory is mapped already
I don't exactly see why this is happening, but it is triggered by the
new section and the collision can be avoided by passing -Ttext-segment
instead of -Ttext, similarly to x86_64.
Link: https://www.zytor.com/pipermail/klibc/2019-January/004027.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
Building klibc for x86_64 with binutils 2.31 adds an extra
.note.gnu.property section to klibc.so, the address of which is not
affected by the -Ttext option. Loading a klibc executable then
fails with the following kernel log message:
9409 (sh.shared): Uhuuh, elf segment at 0000000000200000 requested but the memory is mapped already
I don't exactly see why this is happening, but it is triggered by the
new section and the collision can be avoided by passing -Ttext-segment
instead of -Ttext. A similar change was applied to MIPS recently.
Link: https://www.zytor.com/pipermail/klibc/2019-January/004024.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
Some distributions default to PIE for their compilers, which on sparc is passed
on to the assembler. Since the behaviour of %hi/%lo changes under PIC to become
GOT offsets, the current assembly files need adapting to not try to use a GOT
offset as an absolute address.
References: https://bugs.debian.org/885852
Link: https://www.zytor.com/pipermail/klibc/2018-July/004001.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
The top-level "distclean" and "mrproper" targets delete zero-size
files in the source, perhaps assumed to be stamp files. This is fine
for actual source direcgtories, but disastrous for a quilt status
directory.
For each patch, quilt stores the previous versions of the modified
files in a subdirectory of .pc. If the patch creates a file, this
file will be empty. Removing it effectively removes the file creation
from the patch.
The .git directory is already excluded from the clean rules for
a similar reason, so do the same for .pc.
Link: https://www.zytor.com/pipermail/klibc/2018-July/003999.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
Building klibc with binutils 2.30 results in the following layout
for klibc.so:
Idx Name Size VMA LMA File off Algn
0 .text 0000d1ff 0000000000200200 0000000000200200 00000200 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .rodata 000031af 0000000000300000 0000000000300000 00100000 2**5
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .data.rel.ro 00000990 0000000000403660 0000000000403660 00103660 2**5
CONTENTS, ALLOC, LOAD, DATA
3 .data 00000140 0000000000404000 0000000000404000 00104000 2**5
CONTENTS, ALLOC, LOAD, DATA
4 .bss 000042f8 0000000000404140 0000000000404140 00104140 2**5
ALLOC
The .text and .rodata sections have each been padded to the specified
maximum page size of 1 MB, causing the following sections to overlap
the executable.
This causes all klibc executables to crash immediately.
Since there's no architectural page size betwen 4 KB and 2MB, set
max-page-size to 4 KB.
Link: https://www.zytor.com/pipermail/klibc/2018-July/003998.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
RISC-V is pretty boring. I've cribbed most of this from the MIPS and
AArch64 ports.
I ran into difficulty with initialisation of the gp,register, which I
think has to be process-global - the psABI says that signal handlers
can rely on it, and they could come from any module. This means that
klibc.so and the executable using it need to agree on a single value.
Currently they don't, and this causes gp-relative addressing to go
wrong.
gp-relative addressing is introduced by "relaxation" in the linker,
so I've disabled that for now.
Link: https://www.zytor.com/pipermail/klibc/2018-July/003997.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
New architectures only define the renameat2() system call, which was
added in Linux 3.15. Define rename() and renameat() as wrappers for
it if necessary.
Link: https://www.zytor.com/pipermail/klibc/2018-July/003996.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
make-3.81 excludes PHONY dependencies from $?, make 3.82+ includes them.
This leads to always rebuilding klibc targets that depend on .PHONY
dependencies. From the make 3.82 release notes
https://lists.gnu.org/archive/html/info-gnu/2010-07/msg00023.html:
* WARNING: Backward-incompatibility!
The '$?' variable now contains all prerequisites that caused the target to
be considered out of date, even if they do not exist (previously only
existing targets were provided in $?).
Linux fixed this with commit 4f1933620f57 ("kbuild: change kbuild to not
rely on incorrect GNU make behavior").
Similar to Linux, klibc if_changed already excludes $(PHONY) from $?
when determining if a target is up-to-date. Klibc also has a $(PHONY)
list of phony targets. But klibc does not add many .PHONY targets to
$(PHONY).
Changes in this patch:
- add previously defined .PHONY targets to PHONY, so existing if_changed
filtering applies to them as well
- declare $(PHONY) targets as .PHONY
Signed-off-by: Greg Thelen <gthelen@google.com>
Link: https://www.zytor.com/pipermail/klibc/2018-June/003995.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
gcc 7.3.0 complains:
```
usr/utils/mount_main.c: In function ‘print_mount’:
usr/utils/mount_main.c:46:46: warning: comparison between pointer and zero character constant [-Wpointer-compare]
if (mnt->mnt_type != NULL && mnt->mnt_type != '\0')
^~
usr/utils/mount_main.c:46:32: note: did you mean to dereference the pointer?
if (mnt->mnt_type != NULL && mnt->mnt_type != '\0')
^
usr/utils/mount_main.c:48:46: warning: comparison between pointer and zero character constant [-Wpointer-compare]
if (mnt->mnt_opts != NULL && mnt->mnt_opts != '\0')
^~
usr/utils/mount_main.c:48:32: note: did you mean to dereference the pointer?
if (mnt->mnt_opts != NULL && mnt->mnt_opts != '\0')
^
```
Link: https://www.zytor.com/pipermail/klibc/2018-June/003994.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
Implement classless static routes support as specified in RFC3442.
Bug-Debian: https://bugs.debian.org/884716
Bug-Ubuntu: https://launchpad.net/bugs/1526956
Signed-off-by: Benjamin Drung <benjamin.drung@profitbricks.com>
Link: https://salsa.debian.org/kernel-team/klibc/merge_requests/2
Link: https://www.zytor.com/pipermail/klibc/2018-June/003993.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
This field is not needed. Probably it was copied straight from the
32-bit mips __jmp_buf.
Signed-off-by: James Cowgill <james.cowgill@mips.com>
Link: https://www.zytor.com/pipermail/klibc/2018-March/003984.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
Don't bother saving any floating point registers in setjmp or restoring
them in longjmp. This causes issues when compiling for the FPXX ABI, and
is unnessesary as klibc does not support floating point code.
Additionally, remove the unused parts of __jmp_buf.
Signed-off-by: James Cowgill <james.cowgill@mips.com>
Link: https://www.zytor.com/pipermail/klibc/2018-March/003983.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
Various simplifications and adjustments to the MIPS crt0 files:
- Use NESTED(__start, 0, ra) - this has no effect on the code, but is
arguably more correct since we have no real stack frame.
- Don't allocate extra stack space. We need none on 64-bit, and only 16
bytes on 32-bit.
- Align the stack pointer in the (unlikely) event it is misaligned.
- Don't load the gp register - it is useless in non-PIC code.
- Use jal in 64-bit code.
- Crash if __libc_start returns (teq should causes a trap exception).
Signed-off-by: James Cowgill <james.cowgill@mips.com>
Link: https://www.zytor.com/pipermail/klibc/2018-March/003982.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
Most architectures use the -Ttext option to move the klibc shared
library out of the way of the normal load address. Unfortunately MIPS
has some extra sections which are positioned before the .text section
and are therefore not repositioned by the -Ttext option.
Fix this by using the -Ttext-segment option. Instead of changing the
address of the .text section, this option changes the .text segment
which happens to include all the special MIPS sections. After this we
can drop the linker script which we no longer need.
Signed-off-by: James Cowgill <james.cowgill@mips.com>
Link: https://www.zytor.com/pipermail/klibc/2018-March/003981.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
By default, the MIPS toolchain compiles all code as PIC. Since klibc
links everything at static addresses, we don't need PIC code so use
-mno-abicalls to disable it. To fix subsequent link errors, use
-Ttext-segment to adjust the base address of klibc to a more sensible
location.
This fixes a bug in the shared library form of klibc where programs
would segfault in the syscall handler because we tried to store into the
"errno" variable without setting up the gp register. This is only required
under the PIC ABI.
Signed-off-by: James Cowgill <james.cowgill@mips.com>
Link: https://www.zytor.com/pipermail/klibc/2018-March/003985.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
Use $(kecho) to remove 'GEN klcc/klibc.config' log message from
'make --silent' output.
Signed-off-by: Greg Thelen <gthelen@google.com>
Link: https://www.zytor.com/pipermail/klibc/2018-February/003979.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
Signed-off-by: Greg Thelen <gthelen@google.com>
Link: https://www.zytor.com/pipermail/klibc/2018-February/003978.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
Fix compilation warnings:
$KLIBC/usr/klibc/asprintf.c: In function 'asprintf':
$KLIBC/usr/klibc/asprintf.c:14:8: warning: unused variable 'p' [-Wunused-variable]
char *p;
$KLIBC/usr/klibc/asprintf.c:13:6: warning: unused variable 'bytes' [-Wunused-variable]
int bytes;
$KLIBC/usr/utils/readlink.c: In function 'main':
$KLIBC/usr/utils/readlink.c:20:6: warning: unused variable 'i' [-Wunused-variable]
int i;
Signed-off-by: Greg Thelen <gthelen@google.com>
Link: https://www.zytor.com/pipermail/klibc/2018-February/003977.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
Include sys/types.h to avoid compilation warnings:
In file included from $LINUX/usr/include/linux/byteorder/little_endian.h:12:0,
from $LINUX/usr/include/asm/byteorder.h:5,
from $KLIBC/usr/klibc/../include/klibc/endian.h:11,
from $KLIBC/usr/klibc/../include/endian.h:8,
from $KLIBC/usr/klibc/pread.c:7:
$LINUX/usr/include/linux/types.h:22:0: warning: "__bitwise" redefined
In file included from $KLIBC/usr/klibc/../include/klibc/endian.h:10:0,
from $KLIBC/usr/klibc/../include/endian.h:8,
from $KLIBC/usr/klibc/pread.c:7:
$KLIBC/usr/klibc/../include/klibc/compiler.h:144:0: note: this is the location of the previous definition
In file included from $LINUX/usr/include/linux/byteorder/little_endian.h:12:0,
from $LINUX/usr/include/asm/byteorder.h:5,
from $KLIBC/usr/klibc/../include/klibc/endian.h:11,
from $KLIBC/usr/klibc/../include/endian.h:8,
from $KLIBC/usr/klibc/pwrite.c:7:
$LINUX/usr/include/linux/types.h:22:0: warning: "__bitwise" redefined
In file included from $KLIBC/usr/klibc/../include/klibc/endian.h:10:0,
from $KLIBC/usr/klibc/../include/endian.h:8,
from $KLIBC/usr/klibc/pwrite.c:7:
$KLIBC/usr/klibc/../include/klibc/compiler.h:144:0: note: this is the location of the previous definition
Signed-off-by: Greg Thelen <gthelen>google.com>
Link: https://www.zytor.com/pipermail/klibc/2018-February/003976.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
We need to do this, since our devices are probably not configured yet and
there may be more than one device we're trying to do DHCP on on the same
network. Otherwise, things might be dropped.
Patch is originally from here:
https://bugs.launchpad.net/ubuntu/+source/klibc/+bug/1327412/comments/5
... but the reporter "patpat" has not provided contact information, and
this is independently verifiable by looking at RFC 2131, section 4.1,
page 24.
References: https://bugs.debian.org/733988
References: https://bugs.launchpad.net/bugs/1327412
Link: https://www.zytor.com/pipermail/klibc/2017-December/003974.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
initramfs-tools wants to validate the real init program before running
it, as there is no way out once it has exec'd run-init. This is
complicated by the increasing use of symlinks for /sbin/init and for
/sbin itself. We can't simply resolve them with 'readlink -f' because
any absolute symlinks will be resolved using the wrong root. Add a
dry-run mode (-n option) to run-init that goes as far as possible to
validate that the given init is executable.
References: https://bugs.debian.org/810965
Link: https://www.zytor.com/pipermail/klibc/2017-December/003973.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
The standard mount option nowadays to specify NFS version is "nfsvers", as
documented in nfs(5) on modern Linux systems. Up to now, nfsmount only
supported the old "v2" or "v3" boolean options.
Extend option parsing to support both "nfsvers=X" and "vers=X", with X
being equal to either 2 or 3 (nfsmount does not support NFSv4 at present).
If both the new option "nfsvers=X" and old option "vX" are passed, the
version specified by "nfsvers" takes precedence.
Tested with initramfs-tools on Debian stretch, it can now successfully
mount the root on NFS using nfsmount, with the following kernel command
line:
root=/dev/nfs nfsroot=server:path,nfsvers=3
Without this patch, such a command line would cause Debian's initrd to
loop with the following error message:
Begin: Retrying nfs mount ... nfsmount: bad option 'nfsvers'
Signed-off-by: Baptiste Jonglez <baptiste.jonglez@imag.fr>
Link: https://www.zytor.com/pipermail/klibc/2017-September/003959.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
Add support to the reboot command so an argument for the 4th parameter
of the syscall can be passed around. This can be useful in, say, devices
that follow Android partitions conventions, so we can do things like
rebootinig to the kernel in recovery partition with "reboot recovery".
References: https://bugs.launchpad.net/ubuntu/+source/klibc/+bug/1692494
Link: https://www.zytor.com/pipermail/klibc/2017-May/003957.html
Link: https://bugs.debian.org/863761
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
When configuring multiple interfaces, the existing logic in
ipconfig can fail if DHCP replies are received out of the expected order,
or if one or more interfaces never receive replies.
The current ipconfig logic uses a single packet socket to handle
all incoming DHCP replies. If, for example, the host has two interfaces,
A and B, and only B will be sent a DHCP reply, the order of events goes
something like this:
ipconfig sends DHCP on A
ipconfig sends DHCP on B
system receives DHCP response to B
ipconfig attempts to receive DHCP reply for A; the available packet does
not match A's XID, et al, and is discarded.
This will repeat until ipconfig times out and gives up.
The failure can come and go with different kernel versions, as the
kernel version affects the order in which the devices appear. In the
above example, if interface B is first, then the sequence will work.
The solution is to use a packet socket per interface. This avoids
the need to queue packets being read for the "wrong" interface or other
schemes to peek incoming packets.
Signed-off-by: Jay Vosburgh <jay.vosburgh@canonical.com>
Link: https://www.zytor.com/pipermail/klibc/2017-February/003945.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
Fix typo in comment, no code change.
Reported-by: Gilles Espinasse <g.esp@free.fr>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
If we are doing a large write, flush the buffer preemptively, so we
don't end up double-buffering a sequence of BUFSIZ writes simply
because we started out with something in the buffer.
This doesn't increase the number of system calls, since we will always
need to do two system calls in this case.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
Since we have vasprintf() anyway, save about a hundred bytes (on
x86-64) by making asprintf() a typical stdarg wrapper function.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
Since namespace pollution is not a major concern in klibc, add
<fcntl.h> to support the inline of posix_grantpt().
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
This function is so trivial that there is no reason to not make it an
inline.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
Correct the filename in the header.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
The kernel now (since 2.6.23) allows O_CLOEXEC to be passed directly
to open(), so there is no reason to have open_cloexec() anymore.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
Add support for the accept4() system call.
Some architectures now have accept4() but not accept(), so introduce a
standard fallback. However, since accept() is a socketcall, we have
to do some special hacks.
While we are at it, handle conditional socketcall stubs based on
their existence <linux/net.h>, analogous to <asm/unistd.h>.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
We no longer generate assembly stubs for socketcalls on any
architecture, so <linux/net.h> is perfectly usable as is.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
getpt() has long since been obsolete; instead use
posix_openpt(O_RDWR|O_NOCTTY).
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
If the gzip utilities are built without support for compression,
they will always attempt to carry out decompression even if the
command name and options don't imply that. Instead they should
fail with an explicit error in this case.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
LC_COLLATE can be overriden by LC_ALL, so set LC_ALL instead when
running sort.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
Currently we ensure the installed headers are readable by everyone,
but write permissions will depend on the current umask. Turn off the
group and other writable bits to ensure consistent results.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
This is needed to support mounting non-root filesystems in
initramfs-tools.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
This is needed to support mounting non-root filesystems in
initramfs-tools.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
This is needed as the basis for the readlink -f option.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
On ppc64 the struct stat defined by klibc matches the kernel one.
However it contains implicit padding before the st_rdev field due to the
64-bit alignement. For internal reasons, klibc defines st_rdev as a pair
of 32-bit values (using the __stdev64 macro). They only need to be
32-bit aligned and as a consequence st->st_rdev is incorrectly defined.
The solution is to add an explicit padding in the structure. This fixes
the resume binary on ppc64 BE and LE, and probably other things.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Link: http://lkml.kernel.org/r/20160106004416.GG28542@decadent.org.uk
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
On the hppa arch (32bit userspace and 32 or 64bit kernel), the fstype
program fails to detect the filesystem. The reason for this failure
is, that fstype calls the pread() syscall, which has on some
architectures with 32bit userspace a different calling syntax. I
noticed this bug on hppa, but I assume s390 (32bit) and others might
run into similiar issues.
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
Update usr/include/arch/mips/archfcntl.h from kernel headers:
- Add definitions of O_PATH, O_TMPFILE
- Update value of O_SYNC to include __O_SYNC
- Add definitions of F_{SET,GET}OWN_EX, F_GETOWNER_UIDS,
F_OFD_{GETLK,SETLK,SETLKW}, F_OWNER_{TID,PID,PGRP}
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
This fixes a segmentation fault in the system call's error handling path with
dynamically-linked binaries on PowerPC64 little endian. The system call stub
wasn't loading up r2 with the appropriate TOC value in its global entry point.
The r2 setup code comes from the FUNC_START macro in gcc [1] and an equivalent
one can also be found in the LOCALENTRY macro in glibc [2].
On the ELFv2 ABI (see [1]):
- The global entry point is expected to load up r2 with the appropriate TOC
value for this function.
- The local entry point expects r2 to be set up to the current TOC.
The problem happened with dynamically-linked binaries because:
- the system call is an indirect call (via global entry point) from the binary
to the shared library, landing in the syscall stub (which didn't load up r2
with the TOC of the shared library)
- its branch to __syscall_error is a direct call (via local entry point) within
the shared library, landing in the function (which expects r2 to be set up to
that TOC)
- when the function attempts to store errno (in an address relative to the TOC),
that address incorrectly pointed to a read-only segment -- segmentation fault.
The problem didn't happen with statically-linked binaries because the TOC value
wasn't different on that case.
Thanks and credits to Alan Modra and Ulrich Weigand, for helping with this and
pointing out the solution.
[1] https://gcc.gnu.org/ml/gcc-patches/2013-11/msg01141.html
[2] https://www.sourceware.org/ml/libc-alpha/2013-11/msg00315.html
Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
In README.klibc:
- Clarify the new kernel header creation process
- Change mips64 to Working
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
As of kernel 4.3, i386 now has direct system calls for sockets, so
drop the special handling for i386 socketcall. If built on older
kernels, it will still generate socketcall stubs although they will be
less efficient.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
__arch_libcinit() is only ever used as part of __libc_init(), so we
might as well make it an inline function.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
Description: Adding mips64 specific chagnes.
Modeled on mips 32 and adapted for 64 bit ABI.
- MCONFIG: using existing klibc.ld scrpit
- crt0.S: adapted gp initialization
- setjmp.S: do not save floating-point state
|
|
Description: Add mips64 support, using existing mips32 code.
- using mips32 assembler source files: pipe.S vfork.S syscall.S
- sysstub.ph: copied over from klibc/arch/mips
|
|
Description: Added header files for mips64.
Modeled on mips 32 header files and adapted for 64 bit ABI.
- archsetjmp.h: do not save floating-point state
- asm.h: Symbolic register names for 64 bit ABI
|
|
|
|
While all “real” ttys may support TIOCGPGRP, /dev/console doesn’t;
using TCGETS here allows Linux booted with init=/bin/mksh-static
to have working interactive command line (PS1, editing, etc).
[ hpa: TCGETS matches glibc, so go with it ]
Reported-by: Dominik George <d.george@tarent.de>
Signed-off-by: Thorsten Glaser <t.glaser@tarent.de>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
Disable the use of SSE registers. This reduces the size of the code
because it means the varadic functions don't need to marshall
parameters in the SSE registers. Since klibc doesn't support floating
point, this is a significant size win.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
We know how long the output is, so we might as well call _fwrite()
directly, with the explicit termination set to \n instead of \0.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
Handle multiple links as parguments passed to readlink().
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
- Allow PATH_MAX bytes, not just a hard-coded 128 bytes
- Just allocate the buffer on the stack, no need for malloc()
- Use puts() rather than printf()
Reported-by: Rafi Rubin <rafi@seas.upenn.edu>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
In line buffered mode, we need to split the write at the final '\n'
(which usually, but not always, is the last character in the string.)
Use memrchr() instead of open-coding it.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
This enum is not used anywhere.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
Move out architecture-specific initialization code (currently only for
i386) into the arch/ directory and define a configuration variable
_KLIBC_HAS_ARCHINIT to indicate its presence.
For consistency, change __init_stdio() to __libc_init_stdio().
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
__extern is defined in <klibc/extern.h>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
|
|
Use the system call entry point in the vdso for system calls on i386.
The vdso can provide either int $0x80, sysenter or syscall depending
on the CPU.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
Convert the ELF auxiliary vector into an array. Define getauxval() as
an inline accessor to that array.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
|
|
We were using CONFIG_KLIB_ZIP in a couple of places where we
meant to use CONFIG_KLIBC_ZIP. I also added the option to
the defconfig.
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
gcc picked up a couple of suspicious memset lengths which turned
out to be real bugs.
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
If available, use -mcmodel=small. klibc is small enough that we
should never hit the limits of the small memory model.
This produces better code, for example:
000000000f003890 <.strcasecmp>:
f003890: 3c a2 ff fe addis r5,r2,-2
...
f003898: 38 c5 23 58 addi r6,r5,9048
...
f0038ac: 7d 46 50 ae lbzx r10,r6,r10
vs:
000000000f0037c4 <.strcasecmp>:
f0037c4: e8 c2 81 48 ld r6,-32440(r2)
f0037dc: 7d 46 50 ae lbzx r10,r6,r10
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
Add PowerPC 64bit little endian support.
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
Fix whitespace style problems in poll.c and select.c.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
Use actual struct timespec fields in struct stat, and use the proper
__stdev64 macro for the dev_t fields.
Also fix bizarre formatting.
Cc: Neil Williams <codehelp@debian.org>
Cc: Anil Singhar <anil.singhar@linaro.org>
Cc: Steve Capper <steve.capper@linaro.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
<klibc/asmmacros.h> is a file specific to arm32; the file is empty on
arm64 so we can just drop it.
Cc: Neil Williams <codehelp@debian.org>
Cc: Anil Singhar <anil.singhar@linaro.org>
Cc: Steve Capper <steve.capper@linaro.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
Based on work by Neil Williams (codehelp@debian.org) and Anil Singhar
(anil.singhar@linaro.org), this patch adds arm64 support.
Originally-by: Neil Williams <codehelp@debian.org>
Originally-by: Anil Singhar <anil.singhar@linaro.org>
Signed-off-by: Steve Capper <steve.capper@linaro.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
arm64 uses generic syscalls, and does not include the "noat",
"noflags", and "deprecated" syscalls.
This patch adds substitution functions for system calls not available
on arm64.
Originally-by: Neil Williams <codehelp@debian.org>
Originally-by: Anil Singhar <anil.singhar@linaro.org>
Signed-off-by: Steve Capper <steve.capper@linaro.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
mknodat and mkdirat contain a spurious repeated parameter, linkat
is missing the final int flags parameter, symlinkat has the first
two parameters transposed, and fchmodat is missing the flags
parameter and is declared in the wrong header.
Also declarations are missing for utimensat and fchownat.
This patch fixes up these syscall declarations.
Originally-by: Neil Williams <codehelp@debian.org>
Originally-by: Anil Singhar <anil.singhar@linaro.org>
Signed-off-by: Steve Capper <steve.capper@linaro.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
It seems this file was still conveying the old way to build klibc
and hence confusing the users, simplify and reword build instructions.
Signed-off-by: maximilian attems <max@stro.at>
|
|
Drop the double tests that klibc doesn't care about
and that where hence failing in the first place.
Check the returned integer values too.
Fixes Bug: https://bugs.gentoo.org/show_bug.cgi?id=464908
Reported-by: Mike Pagano <mpagano@gentoo.org>
Signed-off-by: maximilian attems <max@stro.at>
|
|
|
|
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>
|