summaryrefslogtreecommitdiff
path: root/lib/portability.h
AgeCommit message (Collapse)AuthorFilesLines
2015-07-11Fix 32-bit bionic toybox build.Elliott Hughes1-2/+10
https://android-review.googlesource.com/159035/
2015-05-18More ls -Z upgrading. Move TOYBOX_SELINUX and TOYBOX_SMACK support fromRob Landley1-21/+4
portability.h to new lib/lsm.h. Update ls.c to use it. Fix "ls . toys" (two directories when one is . or ..), which was filtering out the . as something we shouldn't recurse into even though it was explicitly listed on the command line. For some reason "ls -Z . toys" is still segfaulting though (but "ls -Z ." isn't), need to figure out why...
2015-05-08Move not-curses code into interstingtimes.cRob Landley1-1/+1
2015-05-03Move a prototype to the start of portability.h (suggested by Elliott Hughes)Rob Landley1-0/+3
2015-05-01Portability bits for the recent ls smack changes.Rob Landley1-0/+6
2015-04-17Link against libattr and libsmack.Xavier Roche1-0/+9
2015-04-15Put SELINUX in a a menu, and add config option for SMACK.Rob Landley1-0/+4
2015-03-01Only switch on printf format warnings for error_exit() and friends when ↵Rob Landley1-0/+4
TOYBOX_DEBUG enabled. One again gcc manages to be incompetent about producing warnings. For example, in bzcat we error_exit() with a message that's an error code fed into an array of string constants, and apparently dereferencing an array of string literals doesn't give you a string literal according to -Wformat-security. Not breaking the code to humor the compiler here, the compiler is wrong.
2015-03-01let the compiler check format stringsElliott Hughes1-0/+2
i'll be AFK for a week, so here's the patch i've been using this evening to find other format string mistakes. BSD uses __printflike and takes two arguments instead of hard-coding (1,2), but i figured that as long as you don't need the generality you'd prefer not to have it. and it's easy enough to retrofit if we ever do have a formatting function that takes other arguments.
2015-02-06Alright, the Android guys agree with the musl guys: ↵Rob Landley1-6/+0
faccessat(AT_SYMLINK_NOFOLLOW) is not supported.
2015-01-18Lift the basename/libgen.h shenanigans back out of portability.c and make it ↵Rob Landley1-4/+8
a static inline in portability.h, and prototype dirname() while we're at it.
2015-01-18fix non-glibc basename(3) usageElliott Hughes1-0/+5
I considered a #else on the big #ifdef __GLIBC__ above, but that seemed harder to follow.
2015-01-16Move pty.h back to toys.h (under LSB 4.1 headers).Rob Landley1-3/+0
2015-01-16AOSP master has <pty.h> and builds netcat/nc.Elliott Hughes1-4/+1
2015-01-16id.c #ifdefectomy. (ifdefs belong in headers, not in C code.)Rob Landley1-0/+3
2015-01-16This patch adds a TOYBOX_SELINUX configuration option to control bothElliott Hughes1-0/+4
the SELinux commands (such as chcon) and the SELinux-specific options to regular commands (such as ls -Z). This lets us #include <selinux/selinux.h> in portability.h. I've also fixed chcon to insist on being given the a context argument. This patch also adds -Z to id and fixes id's regular output (-G should be separated by spaces, non-G output should be separated by commas, and you don't want a double comma where the egid is omitted from the list of groups).
2014-12-31When you include the posix header libgen.h, glibc #defines basename to some ↵Rob Landley1-0/+9
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 Landley1-0/+21
xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
2014-11-22As long as Android's going to require fortify, fixup the warnings it generates.Rob Landley1-12/+0
2014-11-21A patch against your current ToT that builds in AOSP master.Elliott Hughes1-3/+0
2014-11-21Patch from Elliott Hughes for Android/bionic build.Rob Landley1-1/+4
2014-11-19Fixups for the android/bionic build probes patch.Rob Landley1-3/+5
The CFG_* symbols are always defined so if() can use them as compile-time constants, so don't if defined() them. Doing USE_BLAH() around variable definitions opens up the same potential for config-dependent build breaks as #ifdefs do, just make the whole command depend on the symbol for now, factor out the utmpx infrastructure later. The PTY probe was always failing because it used NULL without #including the header that defines it. Substitute 0 instead.
2014-11-19probe for getspnam(), forkpty(), utmpx, replace sethostname()Isaac Dunham1-1/+16
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.
2014-10-02Workaround for musl's faccessat bug (the rm -r "error: is a directory" thing).Rob Landley1-0/+6
The Linux man page says I can use AT_SYMLINK_NOFOLLOW. It works in glibc, uclibc, and klibc, but musl returns -EINVAL any time you pass in that flag and the maintainer says that's not a bug and insists the man page and those other libraries all change to match musl's behavior. Toybox uses it to avoid scheduling unnecessary metadata writes for things we're about to delete (have to chmod unreadable directories so we can descend into them to delete their contents, the chmod happens before we descend so the disk I/O has plenty of time to be scheduled) because the extra writes wear out SSD faster. It's just an optimization and I don't really care if it works _well_ (the fchmodat call _also_ takes AT_SYMLINK_NOFOLLOW so that's covered), but musl's behavior uniquely makes the check always error and thus breaks normal "rm -r". Yes this workaround is checking #ifdef __MUSL__ which the library does not supply (because its code is perfect and will thus never need to be worked around). You can CFLAGS=-D__MUSL__ if you don't echo "#define __MUSL__" >> include/features.h when installing the library.
2014-09-20Tweak portability.h for uClibc version in buildroot defconfig.Rob Landley1-0/+2
I've been locally patching uClibc to not violate posix-2008 (you don't need to define a GNU macro to get a posix function), but uClibc is obsolete and moribund (development peaked in 2006, last bugfix release was over 2 years ago), and the largest remaining user (buildroot) doesn't bother to apply such a patch. Since even buildroot is slowly migrating to musl-libc, just do the portability tweak for what the last release of the old thing actually did.
2014-09-06Work around uClibc brain-damage.Rob Landley1-0/+12
2014-08-12Patches to commands for issues reported from static analysis tool.Ashwini Sharma1-0/+4
portability.h.patch - it is for O_CLOEXEC, as compiler complained of it. Makefile.patch - for cleaning generated/*.o files and libopts.dat file [Fixup to uniq.c from Rob.]
2014-07-20Add utf8 support to ls -C.Rob Landley1-0/+5
Use wcwidth() instead of strlen(), and extend the -q substitution to also whiteout nonprintable characters that are nonparseable utf8 snippets.
2014-05-06Use compiler built-in macros to determine if argument parsing can use double ↵Rob Landley1-1/+10
or float for FLOAT arguments. (I.E. whether double fits in a long's memory.) Check in a way that the macros not being defined just gives us the shorter one.
2014-04-15Probes for O_NOFOLLOW that compile and run something aren't compatible with ↵Rob Landley1-2/+5
cross compiling, so just #define it to 0 if it's not in fcntl.h where posix-2008 says.
2014-03-29Group headers by standard (POSIX or LSB) or function (internationalization, ↵Rob Landley1-0/+8
networking). Move headers standards ignore (but which have been there >15 years) to lib/portability.h. Fold xregcomp into lib since it's posix.
2014-01-28Two changes to shut up GCC:Isaac Dunham1-1/+1
* __GLIBC__ was checked unconditionally; this made for a very messy build on musl. * int fd in chvt is always initialized; GCC 3.4 does not recognize this.
2013-12-19Only define MNT_DETACH for old glibc, portability.h included _before_ ↵Rob Landley1-4/+4
sys/mount.h...
2013-12-19Regression test against Ancient Build Environment (Ubuntu 8.04), fixup bit-rot.Rob Landley1-1/+6
2013-03-11Compile time probe to fish O_NOFOLLOW out of linux headers when fcntl ↵0.4.4Rob Landley1-0/+2
doesn't conform to posix-2008.
2013-03-09O_NOFOLLOW is specified by posix-2008 and varies by target, don't try to ↵Rob Landley1-8/+0
supply them for broken headers.
2013-02-24Comment updates and a policy statement about avoiding #define GNU_dammitRob Landley1-11/+23
2013-02-04More support for old (~2008) build environments, move the #ifdef checks for ↵Rob Landley1-19/+32
symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
2013-01-15Work around more random uClibc-specific breakage.Rob Landley1-0/+3
2012-12-01Fix ancient glibc workaround to force fstatat64Rob Landley1-1/+2
2012-11-26The headers of uClibc and older glibc got unhappy with O_DIRECTORY and some ↵Rob Landley1-8/+16
other stuff. Fix it up in portability.h.
2012-11-16More touch cleanup to use generic infrastructure: use getdate() from libc, ↵Rob Landley1-0/+2
use flag macros, option parsing can collect argument strings in global block, use existing perror_* macros.
2012-11-13Older versions of glibc predated posix-2008. They still provide most of what ↵0.4.1Rob Landley1-0/+30
we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
2012-06-16More header fiddling: crypt.h is silly, SUSv4 requires crypt() to be ↵Rob Landley1-8/+5
prototyped in unistd.h. The fact glibc refuses to do so without a wacky #define is a glibc bug, treat it as such.
2012-03-19Remove "feature test macros", replace non-portable fdprintf() with standard ↵Rob Landley1-6/+15
fprintf().
2012-03-16Implement Apple and Android versions of getline(), getdelim(), and clearenv().Georgi Chorbadzhiyski1-1/+7
2012-03-07Consolidate headers.Rob Landley1-2/+7
2010-01-06Shut up even MORE gcc/glibc spurious warnings.Rob Landley1-0/+9
2007-11-15Add noreturn mark to [p]error_exit(), suggested by Charlie Shepherd.Rob Landley1-0/+5
2007-02-13MacOS X has a defective sed with no -r.Rob Landley1-2/+18