aboutsummaryrefslogtreecommitdiff
path: root/lib/portability.c
AgeCommit message (Collapse)Author
2020-12-18Andy Hu wants mount -tnomsdos,smbfs to work.Rob Landley
2020-06-01Use copy_file_range() when available.Rob Landley
2020-05-28portability.c: fix macOS build.Elliott Hughes
I suspect the rest of the non-POSIX signals might end up like this, but this is the subset that needs to be #ifdef'ed to fix the macOS build.
2020-05-26Instead of ifdef linux or macos, just ifdef the signals.Rob Landley
2020-05-21Check the signal rather than special case a library and a target.Rob Landley
2020-05-21glibc on mips is missing SIGSTKFLTKhem Raj
Do not therefore assume it being available linuxwide Fixes | lib/portability.c:433:3: error: use of undeclared identifier 'SIGSTKFLT' | SIGNIFY(STKFLT), SIGNIFY(POLL), SIGNIFY(PWR), | ^ Signed-off-by: Khem Raj <raj.khem@gmail.com>
2020-05-19xsignal_all_killers() should install the handler given to it, and do someRob Landley
refactoring while I was looking at the codepath.
2020-03-12Fix get_block_device_size() for linuxGreg Kaiser
We were incorrectly passing a pointer to a pointer of an unsigned long long, when we just wanted to pass a pointer to the unsigned long long. This is especially bad on 32-bit systems, where we're then writing a 64-bits into a 32-bit value within ioctl. We fix this to pass a pointer to the unsigned long long. Test: On 32-bit device, no longer see native crash from toybox Bug: http://b/151311535 Signed-off-by: Elliott Hughes <enh@google.com>
2020-03-11Fix Mac build.Elliott Hughes
The recent re-enablement of the BLKGETSIZE64 code broke the Mac build. Use the equivalent <sys/disk.h> ioctl() pair instead.
2019-12-06Squash a warning.Rob Landley
2019-12-06stat: fix filesystem type on macOS.Elliott Hughes
(Also show unknown values on Linux in hex rather than just "unknown".)
2019-11-23Fix dev_minor()/dev_major()/dev_makedev() for Mac.Elliott Hughes
Major/minor device encoding is not portable. No two BSDs agree with each other, and Darwin is different again. Everyone does agree on having major()/minor()/makedev() macros, but they disagree whether they should be in <sys/types.h> (the BSDs including Darwin, and old versions of glibc) or <sys/sysmacros.h> (glibc >= 2.26 and bionic). This fixes `ls -l /dev/zero` and `stat /dev/zero` on Mac.
2019-10-27macOS: implement posix_fallocate().Elliott Hughes
2019-06-11Move sig_to_num and num_to_sig into portability.c.Elliott Hughes
macOS doesn't have real-time signals, and it has a slightly different set of non-portable signals from Linux. With this, the toybox `kill -l` output matches the default macOS kill(1).
2019-06-08macOS: numerous fixes.Elliott Hughes
This patch adds a BSD version of xgetmountlist (for the path == NULL case only), tested on macOS. It also papers over the differences between macOS' and Linux's xattr APIs. For once I think the macOS one is better. The imitation of mknodat I've had to write swings things back in Linux's favor though. BSD calls f_frsize by the name f_iosize instead. (FWIW, it looks like this is meaningless on Linux and actually meaningful on macOS.) I've added one #if to toys/ --- I'm calling pathconf in stat.c to work around the absence of f_namelen, and have left a TODO with an explanation. I'm not sure what the best fix is here, so punting. No-one can agree what f_fsid is, even if they're all basically the same, so work around the `val` versus `__val` issue between macOS and Linux. With this patch, it's now possible to build cp/mv/install and stat for macOS too. (Which completes the set of "toybox commands currently used on Linux as part of the AOSP build" if you ignore stuff that deals with processes, which I doubt we'll ever be able to support for lack of any API.)
2019-06-03tail: fix macOS build.Elliott Hughes
Trivial breakage from the recent refactoring. Also add tail to the default config for macOS. I'm still unconvinced that CONFIG_TAIL_SEEK makes sense in a world where inotify support is always built in, but that's an argument for another day...
2019-05-25Move notify.c into portability.c (collate the #ifdefs), move global variablesRob Landley
into a structure passed as arguments, add x prefix to functions that can fail, add overflow test.
2019-04-21Shouldn't need clearenv() for macosx now we've got xclearenv.Rob Landley
2019-01-08FreeBSD will use the getmntinfo API as with AppleEd Maste
2018-12-07Forgot to check the portability.? changes. (Oops.)Rob Landley
2018-12-04macOS: move getmountlist.c functions into portability.c.Elliott Hughes
I think this was the preferred option for this code that turns out to be very different on Linux vs BSD. I don't yet have a BSD implementation, and I'm not likely to have chance to work on one in the near future, so this just #ifdefs it out for macOS right now. With this (and a suitably minimal .config), toybox builds for macOS out of the box.
2018-11-30macOS: remove unnecessary <stdio.h> workarounds.Elliott Hughes
These were added in macOS 10.7 in 2011-07, so the seven year rule applies...
2018-08-03xgetrandom: use getrandom result if it succeedsPatrick Oppenlander
2018-07-13Fix typo in a macro nameKonst Mayer
2018-07-06Bionic ships newer libc with older kernels, so Android needs to fallback atRob Landley
runtime for ENOSYS.
2018-07-04Add xgetrandom() with probe for new system call (else open/read /dev/{,u}random)Rob Landley
2018-01-01xphung on github said: "config2help currently doesn't work on OS X, itRob Landley
terminates parsing of Config.in at first blank line. This is because getdelim() in portability.c returns -1 whenever the line comprises only a single linefeed character. Fixing this was a trivial change to two lines (see below), and config2help now works on OS X but I haven't regression tested this on any other commands which rely on getdelim()"
2016-05-04Simplify ps android scheduling policy fetch slightly.Rob Landley
2016-04-30Add a ps "PCY" field for Android scheduling policy.Elliott Hughes
2015-07-03Probe for fork() instead of relying on a distro-specific #define.Rob Landley
2015-03-21Patch from David Halls to fix mac/ios portability issue.Rob Landley
2015-01-18Lift the basename/libgen.h shenanigans back out of portability.c and make it ↵Rob Landley
a static inline in portability.h, and prototype dirname() while we're at it.
2014-12-31When you include the posix header libgen.h, glibc #defines basename to some ↵Rob Landley
random other symbol name (because gnu) and this screws up nontrivial macro expansions of NEWTOY(basename), so work around it in portability.h.
2014-12-04Work with buildroot's extensively patched uClibc, and for nommu support move ↵Rob Landley
xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
2014-11-21A patch against your current ToT that builds in AOSP master.Elliott Hughes
2014-11-21Don't include asm/* files directly.Rob Landley
2014-11-19probe for getspnam(), forkpty(), utmpx, replace sethostname()Isaac Dunham
Android is missing all of these; we need to probe for some so we have a config symbol to depend on. sethostname() is easily replaced. We got termios.h via pty.h; now it's not included in configure-step tools, so we need termios.h to generate globals.
2012-11-13Reindent to two spaces per level. Remove vi: directives that haven't worked ↵Rob Landley
right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style. The actual code should be the same afterward, this is just cosmetic refactoring.
2012-03-16Implement Apple and Android versions of getline(), getdelim(), and clearenv().Georgi Chorbadzhiyski