FILEUTILS_PRESERVE_SECURITY_CONTEXT = 1 << 15, /* -c */
#endif
FILEUTILS_RMDEST = 1 << (16 - !ENABLE_SELINUX), /* --remove-destination */
+ /* bit 17 skipped for "cp --parents" */
+ FILEUTILS_REFLINK = 1 << (18 - !ENABLE_SELINUX), /* cp --reflink=auto */
+ FILEUTILS_REFLINK_ALWAYS = 1 << (19 - !ENABLE_SELINUX), /* cp --reflink[=always] */
/*
* Hole. cp may have some bits set here,
* they should not affect remove_file()/copy_file()
DIR *warn_opendir(const char *path) FAST_FUNC;
char *xmalloc_realpath(const char *path) FAST_FUNC RETURNS_MALLOC;
+char *xmalloc_realpath_coreutils(const char *path) FAST_FUNC RETURNS_MALLOC;
char *xmalloc_readlink(const char *path) FAST_FUNC RETURNS_MALLOC;
char *xmalloc_readlink_or_warn(const char *path) FAST_FUNC RETURNS_MALLOC;
/* !RETURNS_MALLOC: it's a realloc-like function */
int sigaction_set(int sig, const struct sigaction *act) FAST_FUNC;
/* SIG_BLOCK/SIG_UNBLOCK all signals: */
int sigprocmask_allsigs(int how) FAST_FUNC;
+/* Return old set in the same set: */
+int sigprocmask2(int how, sigset_t *set) FAST_FUNC;
/* Standard handler which just records signo */
extern smallint bb_got_signal;
void record_signo(int signo); /* not FAST_FUNC! */
int bb_getsockname(int sockfd, void *addr, socklen_t addrlen) FAST_FUNC;
/* NB: returns port in host byte order */
unsigned bb_lookup_port(const char *port, const char *protocol, unsigned default_port) FAST_FUNC;
+#if ENABLE_FEATURE_ETC_SERVICES
+# define bb_lookup_std_port(portstr, protocol, portnum) bb_lookup_port(portstr, protocol, portnum)
+#else
+# define bb_lookup_std_port(portstr, protocol, portnum) (portnum)
+#endif
typedef struct len_and_sockaddr {
socklen_t len;
union {
// + inet_common.c has additional IPv4-only stuff
+struct tls_aes {
+ uint32_t key[60];
+ unsigned rounds;
+};
#define TLS_MAX_MAC_SIZE 32
#define TLS_MAX_KEY_SIZE 32
+#define TLS_MAX_IV_SIZE 4
struct tls_handshake_data; /* opaque */
typedef struct tls_state {
+ unsigned flags;
+
int ofd;
int ifd;
unsigned min_encrypted_len_on_read;
uint16_t cipher_id;
- uint8_t encrypt_on_write;
unsigned MAC_size;
unsigned key_size;
+ unsigned IV_size;
uint8_t *outbuf;
int outbuf_size;
/*uint64_t read_seq64_be;*/
uint64_t write_seq64_be;
+ /*uint8_t *server_write_MAC_key;*/
uint8_t *client_write_key;
uint8_t *server_write_key;
+ uint8_t *client_write_IV;
+ uint8_t *server_write_IV;
uint8_t client_write_MAC_key[TLS_MAX_MAC_SIZE];
uint8_t server_write_MAC_k__[TLS_MAX_MAC_SIZE];
uint8_t client_write_k__[TLS_MAX_KEY_SIZE];
uint8_t server_write_k__[TLS_MAX_KEY_SIZE];
+ uint8_t client_write_I_[TLS_MAX_IV_SIZE];
+ uint8_t server_write_I_[TLS_MAX_IV_SIZE];
+
+ struct tls_aes aes_encrypt;
+ struct tls_aes aes_decrypt;
+ uint8_t H[16]; //used by AES_GCM
} tls_state_t;
static inline tls_state_t *new_tls_state(void)
} uni_stat_t;
/* Returns a string with unprintable chars replaced by '?' or
* SUBST_WCHAR. This function is unicode-aware. */
-const char* FAST_FUNC printable_string(uni_stat_t *stats, const char *str);
+const char* FAST_FUNC printable_string(const char *str);
+const char* FAST_FUNC printable_string2(uni_stat_t *stats, const char *str);
/* Prints unprintable char ch as ^C or M-c to file
* (M-c is used only if ch is ORed with PRINTABLE_META),
* else it is printed as-is (except for ch = 0x9b) */
/* Useful for reading port numbers */
uint16_t xatou16(const char *numstr) FAST_FUNC;
+#if ENABLE_FLOAT_DURATION
+typedef double duration_t;
+void sleep_for_duration(duration_t duration) FAST_FUNC;
+#define DURATION_FMT "f"
+#else
+typedef unsigned duration_t;
+#define sleep_for_duration(duration) sleep(duration)
+#define DURATION_FMT "u"
+#endif
+duration_t parse_duration_str(char *str) FAST_FUNC;
/* These parse entries in /etc/passwd and /etc/group. This is desirable
* for BusyBox since we want to avoid using the glibc NSS stuff, which
* to /dev/null if they are not.
*/
enum {
- DAEMON_CHDIR_ROOT = 1,
- DAEMON_DEVNULL_STDIO = 2,
- DAEMON_CLOSE_EXTRA_FDS = 4,
- DAEMON_ONLY_SANITIZE = 8, /* internal use */
- DAEMON_DOUBLE_FORK = 16, /* double fork to avoid controlling tty */
+ DAEMON_CHDIR_ROOT = 1 << 0,
+ DAEMON_DEVNULL_STDIO = 1 << 1,
+ DAEMON_CLOSE_EXTRA_FDS = 1 << 2,
+ DAEMON_ONLY_SANITIZE = 1 << 3, /* internal use */
+ //DAEMON_DOUBLE_FORK = 1 << 4, /* double fork to avoid controlling tty */
};
#if BB_MMU
enum { re_execed = 0 };
/* True only if we created pidfile which is *file*, not /dev/null etc */
extern smallint wrote_pidfile;
void write_pidfile(const char *path) FAST_FUNC;
+void write_pidfile_std_path_and_ext(const char *path) FAST_FUNC;
+void remove_pidfile_std_path_and_ext(const char *path) FAST_FUNC;
#define remove_pidfile(path) do { if (wrote_pidfile) unlink(path); } while (0)
#else
enum { wrote_pidfile = 0 };
+#define write_pidfile_std_path_and_ext(path) ((void)0)
+#define remove_pidfile_std_path_and_ext(path) ((void)0)
#define write_pidfile(path) ((void)0)
#define remove_pidfile(path) ((void)0)
#endif
LOGMODE_BOTH = LOGMODE_SYSLOG + LOGMODE_STDIO,
};
extern const char *msg_eol;
-extern smallint syslog_level;
extern smallint logmode;
extern uint8_t xfunc_error_retval;
extern void (*die_func)(void);
void bb_die_memory_exhausted(void) NORETURN FAST_FUNC;
void bb_logenv_override(void) FAST_FUNC;
+#if ENABLE_FEATURE_SYSLOG_INFO
+void bb_info_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
+void bb_vinfo_msg(const char *s, va_list p) FAST_FUNC;
+#else
+#define bb_info_msg bb_error_msg
+#define bb_vinfo_msg(s,p) bb_verror_msg(s,p,NULL)
+#endif
+
/* We need to export XXX_main from libbusybox
* only if we build "individual" binaries
*/
#define MAIN_EXTERNALLY_VISIBLE
#endif
+/* Embedded script support */
+char *get_script_content(unsigned n) FAST_FUNC;
+int scripted_main(int argc, char** argv) MAIN_EXTERNALLY_VISIBLE;
/* Applets which are useful from another applets */
int bb_cat(char** argv) FAST_FUNC;
+int ash_main(int argc, char** argv)
+#if ENABLE_ASH || ENABLE_SH_IS_ASH || ENABLE_BASH_IS_ASH
+ MAIN_EXTERNALLY_VISIBLE
+#endif
+;
+int hush_main(int argc, char** argv)
+#if ENABLE_HUSH || ENABLE_SH_IS_HUSH || ENABLE_BASH_IS_HUSH
+ MAIN_EXTERNALLY_VISIBLE
+#endif
+;
/* If shell needs them, they exist even if not enabled as applets */
int echo_main(int argc, char** argv) IF_ECHO(MAIN_EXTERNALLY_VISIBLE);
int printf_main(int argc, char **argv) IF_PRINTF(MAIN_EXTERNALLY_VISIBLE);
const char *empty_str;
smallint all, nonempty;
};
-void print_numbered_lines(struct number_state *ns, const char *filename) FAST_FUNC;
+int print_numbered_lines(struct number_state *ns, const char *filename) FAST_FUNC;
/* Networking */
int get_terminal_width(int fd) FAST_FUNC;
int tcsetattr_stdin_TCSANOW(const struct termios *tp) FAST_FUNC;
-#define TERMIOS_CLEAR_ISIG (1 << 0)
-#define TERMIOS_RAW_CRNL (1 << 1)
-#define TERMIOS_RAW_INPUT (1 << 2)
+#define TERMIOS_CLEAR_ISIG (1 << 0)
+#define TERMIOS_RAW_CRNL_INPUT (1 << 1)
+#define TERMIOS_RAW_CRNL_OUTPUT (1 << 2)
+#define TERMIOS_RAW_CRNL (TERMIOS_RAW_CRNL_INPUT|TERMIOS_RAW_CRNL_OUTPUT)
+#define TERMIOS_RAW_INPUT (1 << 3)
int get_termios_and_make_raw(int fd, struct termios *newterm, struct termios *oldterm, int flags) FAST_FUNC;
int set_termios_to_raw(int fd, struct termios *oldterm, int flags) FAST_FUNC;
FOR_SHELL = DO_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION,
};
line_input_t *new_line_input_t(int flags) FAST_FUNC;
-/* So far static: void free_line_input_t(line_input_t *n) FAST_FUNC; */
+void free_line_input_t(line_input_t *n) FAST_FUNC;
/*
* maxsize must be >= 2.
* Returns:
unsigned long stack;
unsigned long smap_pss, smap_swap;
unsigned long smap_size;
- unsigned long smap_start;
+ // For mixed 32/64 userspace, 32-bit pmap still needs
+ // 64-bit field here to correctly show 64-bit processes:
+ unsigned long long smap_start;
+ // (strictly speaking, other fields need to be wider too,
+ // but they are in kbytes, not bytes, and they hold sizes,
+ // not start addresses, sizes tend to be less than 4 terabytes)
char smap_mode[5];
char *smap_name;
};
(p)->curfile = NULL; \
} while (0)
void bb_progress_init(bb_progress_t *p, const char *curfile) FAST_FUNC;
-void bb_progress_update(bb_progress_t *p,
+int bb_progress_update(bb_progress_t *p,
uoff_t beg_range,
uoff_t transferred,
uoff_t totalsize) FAST_FUNC;
# define FB_0 "/dev/fb0"
#endif
+// storage helpers for mk*fs utilities
+char BUG_wrong_field_size(void);
+#define STORE_LE(field, value) \
+do { \
+ if (sizeof(field) == 4) \
+ field = SWAP_LE32((uint32_t)(value)); \
+ else if (sizeof(field) == 2) \
+ field = SWAP_LE16((uint16_t)(value)); \
+ else if (sizeof(field) == 1) \
+ field = (uint8_t)(value); \
+ else \
+ BUG_wrong_field_size(); \
+} while (0)
+
+#define FETCH_LE32(field) \
+ (sizeof(field) == 4 ? SWAP_LE32(field) : BUG_wrong_field_size())
+
#define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0])))
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))