android_external_toybox/lib/toyflags.h
Rob Landley 60dd7c8a79 Add TOYFLAG_MAYFORK and annotate a couple commands.
A TOYFLAG_NOFORK command must run in the context of toysh, but a MAYFORK
can either run standalone or run in the toysh process. MAYFORK means it
cleans up after itself: no leaked resources (malloc, mmap, filehandles, etc),
even in error_exit() paths that would longjmp() back to the shell. It also
doesn't discard anything we need to retain (don't close stdout, change
toys.optargs[] so we can't free it, etc)...
2019-08-04 16:17:37 -05:00

43 lines
1.4 KiB
C

/* Flags values for the third argument of NEWTOY()
*
* Included from both main.c (runs in toys.h context) and scripts/install.c
* (which may build on crazy things like macosx when cross compiling).
*/
// Flags describing command behavior.
// Where to install (toybox --long outputs absolute paths to commands)
// If no location bits set, command not listed in "toybox" command's output.
#define TOYFLAG_USR (1<<0)
#define TOYFLAG_BIN (1<<1)
#define TOYFLAG_SBIN (1<<2)
#define TOYMASK_LOCATION ((1<<4)-1)
// This is a shell built-in function, running in the same process context.
#define TOYFLAG_NOFORK (1<<4)
#define TOYFLAG_MAYFORK (1<<5)
// Start command with a umask of 0 (saves old umask in this.old_umask)
#define TOYFLAG_UMASK (1<<6)
// This command runs as root.
#define TOYFLAG_STAYROOT (1<<7) // Don't drop suid root before running cmd_main
#define TOYFLAG_NEEDROOT (1<<8) // Refuse to run if real uid != 0
#define TOYFLAG_ROOTONLY (TOYFLAG_STAYROOT|TOYFLAG_NEEDROOT)
// Call setlocale to listen to environment variables.
// This invalidates sprintf("%.*s", size, string) as a valid length constraint.
#define TOYFLAG_LOCALE (1<<9)
// Suppress default --help processing
#define TOYFLAG_NOHELP (1<<10)
// Error code to return if argument parsing fails (default 1)
#define TOYFLAG_ARGFAIL(x) (x<<24)
#if CFG_TOYBOX_PEDANTIC_ARGS
#define NO_ARGS ">0"
#else
#define NO_ARGS 0
#endif