Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Eric Andersen | 2b69c40 | 1999-10-05 22:58:32 +0000 | [diff] [blame] | 2 | /* |
Eric Andersen | c499601 | 1999-10-20 22:08:37 +0000 | [diff] [blame] | 3 | * Busybox main internal header file |
Eric Andersen | 2b69c40 | 1999-10-05 22:58:32 +0000 | [diff] [blame] | 4 | * |
Eric Andersen | 2b69c40 | 1999-10-05 22:58:32 +0000 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | * |
| 20 | * Based in part on code from sash, Copyright (c) 1999 by David I. Bell |
| 21 | * Permission has been granted to redistribute this code under the GPL. |
| 22 | * |
| 23 | */ |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 24 | #ifndef _BB_INTERNAL_H_ |
| 25 | #define _BB_INTERNAL_H_ 1 |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 26 | |
| 27 | #include "busybox.def.h" |
| 28 | |
| 29 | #include <stdlib.h> |
Erik Andersen | 5509af7 | 2000-01-23 18:19:02 +0000 | [diff] [blame] | 30 | #include <stdarg.h> |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 31 | #include <string.h> |
| 32 | #include <unistd.h> |
| 33 | #include <sys/stat.h> |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 34 | //#include <sys/param.h> |
Eric Andersen | 29d2e36 | 1999-11-06 06:07:27 +0000 | [diff] [blame] | 35 | #include <mntent.h> |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 36 | |
| 37 | |
| 38 | /* Some useful definitions */ |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 39 | #define FALSE ((int) 1) |
| 40 | #define TRUE ((int) 0) |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 41 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 42 | /* for mtab.c */ |
| 43 | #define MTAB_GETMOUNTPT '1' |
| 44 | #define MTAB_GETDEVICE '2' |
| 45 | |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 46 | #define BUF_SIZE 8192 |
| 47 | #define EXPAND_ALLOC 1024 |
| 48 | |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 49 | |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 50 | #define isBlank(ch) (((ch) == ' ') || ((ch) == '\t')) |
| 51 | #define isDecimal(ch) (((ch) >= '0') && ((ch) <= '9')) |
| 52 | #define isOctal(ch) (((ch) >= '0') && ((ch) <= '7')) |
| 53 | #define isWildCard(ch) (((ch) == '*') || ((ch) == '?') || ((ch) == '[')) |
| 54 | |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 55 | enum Location { |
| 56 | _BB_DIR_ROOT = 0, |
| 57 | _BB_DIR_BIN, |
| 58 | _BB_DIR_SBIN, |
| 59 | _BB_DIR_USR_BIN, |
| 60 | _BB_DIR_USR_SBIN |
| 61 | }; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 62 | |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 63 | struct Applet { |
| 64 | const char* name; |
| 65 | int (*main)(int argc, char** argv); |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 66 | enum Location location; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 67 | }; |
| 68 | |
Erik Andersen | e272915 | 2000-02-18 21:34:17 +0000 | [diff] [blame] | 69 | extern int basename_main(int argc, char **argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 70 | extern int busybox_main(int argc, char** argv); |
| 71 | extern int block_device_main(int argc, char** argv); |
Eric Andersen | e77ae3a | 1999-10-19 20:03:34 +0000 | [diff] [blame] | 72 | extern int cat_main(int argc, char** argv); |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 73 | extern int cp_mv_main(int argc, char** argv); |
Eric Andersen | 1b61f41 | 1999-10-13 18:56:42 +0000 | [diff] [blame] | 74 | extern int chmod_chown_chgrp_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 75 | extern int chroot_main(int argc, char** argv); |
Erik Andersen | 6f23cec | 1999-12-15 22:14:12 +0000 | [diff] [blame] | 76 | extern int chvt_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 77 | extern int clear_main(int argc, char** argv); |
| 78 | extern int date_main(int argc, char** argv); |
| 79 | extern int dd_main(int argc, char** argv); |
Erik Andersen | fb002d0 | 2000-03-05 08:07:00 +0000 | [diff] [blame] | 80 | extern int dirname_main(int argc, char** argv); |
Erik Andersen | 6f23cec | 1999-12-15 22:14:12 +0000 | [diff] [blame] | 81 | extern int deallocvt_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 82 | extern int df_main(int argc, char** argv); |
| 83 | extern int dmesg_main(int argc, char** argv); |
John Beppu | 7a98606 | 1999-12-09 18:29:29 +0000 | [diff] [blame] | 84 | extern int du_main(int argc, char** argv); |
Eric Andersen | e77ae3a | 1999-10-19 20:03:34 +0000 | [diff] [blame] | 85 | extern int dutmp_main(int argc, char** argv); |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 86 | extern int echo_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 87 | extern int false_main(int argc, char** argv); |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 88 | extern int fbset_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 89 | extern int fdisk_main(int argc, char** argv); |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 90 | extern int fdflush_main(int argc, char **argv); |
Eric Andersen | e494fdd | 1999-10-19 20:23:03 +0000 | [diff] [blame] | 91 | extern int fsck_minix_main(int argc, char **argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 92 | extern int find_main(int argc, char** argv); |
Eric Andersen | abc0f4f | 1999-12-08 23:19:36 +0000 | [diff] [blame] | 93 | extern int free_main(int argc, char** argv); |
Erik Andersen | 6437170 | 2000-03-04 22:23:27 +0000 | [diff] [blame] | 94 | extern int freeramdisk_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 95 | extern int grep_main(int argc, char** argv); |
Erik Andersen | 3163821 | 2000-01-15 22:28:50 +0000 | [diff] [blame] | 96 | extern int gunzip_main (int argc, char** argv); |
| 97 | extern int gzip_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 98 | extern int halt_main(int argc, char** argv); |
John Beppu | 3157b1f | 1999-12-10 07:42:50 +0000 | [diff] [blame] | 99 | extern int head_main(int argc, char** argv); |
Erik Andersen | 3163821 | 2000-01-15 22:28:50 +0000 | [diff] [blame] | 100 | extern int hostid_main(int argc, char** argv); |
Eric Andersen | 485b955 | 1999-12-07 23:14:59 +0000 | [diff] [blame] | 101 | extern int hostname_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 102 | extern int init_main(int argc, char** argv); |
Erik Andersen | 6da0ae8 | 1999-12-17 01:08:27 +0000 | [diff] [blame] | 103 | extern int insmod_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 104 | extern int kill_main(int argc, char** argv); |
| 105 | extern int length_main(int argc, char** argv); |
| 106 | extern int ln_main(int argc, char** argv); |
Erik Andersen | 3163821 | 2000-01-15 22:28:50 +0000 | [diff] [blame] | 107 | extern int loadacm_main(int argc, char** argv); |
Eric Andersen | 3e0fbae | 1999-10-19 06:02:44 +0000 | [diff] [blame] | 108 | extern int loadfont_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 109 | extern int loadkmap_main(int argc, char** argv); |
| 110 | extern int losetup_main(int argc, char** argv); |
Erik Andersen | 3163821 | 2000-01-15 22:28:50 +0000 | [diff] [blame] | 111 | extern int logger_main(int argc, char **argv); |
| 112 | extern int logname_main(int argc, char **argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 113 | extern int ls_main(int argc, char** argv); |
Erik Andersen | 6f23cec | 1999-12-15 22:14:12 +0000 | [diff] [blame] | 114 | extern int lsmod_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 115 | extern int makedevs_main(int argc, char** argv); |
| 116 | extern int math_main(int argc, char** argv); |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 117 | extern int mkdir_main(int argc, char** argv); |
Eric Andersen | 19db07b | 1999-12-11 08:41:28 +0000 | [diff] [blame] | 118 | extern int mkfifo_main(int argc, char **argv); |
| 119 | extern int mkfs_minix_main(int argc, char **argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 120 | extern int mknod_main(int argc, char** argv); |
| 121 | extern int mkswap_main(int argc, char** argv); |
| 122 | extern int mnc_main(int argc, char** argv); |
Erik Andersen | 3163821 | 2000-01-15 22:28:50 +0000 | [diff] [blame] | 123 | extern int more_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 124 | extern int mount_main(int argc, char** argv); |
| 125 | extern int mt_main(int argc, char** argv); |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 126 | extern int nslookup_main(int argc, char **argv); |
Eric Andersen | 485b955 | 1999-12-07 23:14:59 +0000 | [diff] [blame] | 127 | extern int ping_main(int argc, char **argv); |
Eric Andersen | 2cb5507 | 1999-12-10 08:25:07 +0000 | [diff] [blame] | 128 | extern int poweroff_main(int argc, char **argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 129 | extern int printf_main(int argc, char** argv); |
Eric Andersen | ef8b6c7 | 1999-10-20 08:05:35 +0000 | [diff] [blame] | 130 | extern int ps_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 131 | extern int pwd_main(int argc, char** argv); |
| 132 | extern int reboot_main(int argc, char** argv); |
| 133 | extern int rm_main(int argc, char** argv); |
Erik Andersen | 3d7e341 | 1999-12-16 23:04:20 +0000 | [diff] [blame] | 134 | extern int rmdir_main(int argc, char **argv); |
| 135 | extern int rmmod_main(int argc, char** argv); |
Eric Andersen | c1525e8 | 1999-10-29 00:07:31 +0000 | [diff] [blame] | 136 | extern int sed_main(int argc, char** argv); |
Erik Andersen | 3163821 | 2000-01-15 22:28:50 +0000 | [diff] [blame] | 137 | extern int sfdisk_main(int argc, char** argv); |
Erik Andersen | 3522eb1 | 2000-03-12 23:49:18 +0000 | [diff] [blame] | 138 | extern int shell_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 139 | extern int sleep_main(int argc, char** argv); |
John Beppu | 019513a | 1999-12-22 17:57:31 +0000 | [diff] [blame] | 140 | extern int sort_main(int argc, char** argv); |
Eric Andersen | 8759006 | 1999-10-18 21:22:59 +0000 | [diff] [blame] | 141 | extern int swap_on_off_main(int argc, char** argv); |
Eric Andersen | e77ae3a | 1999-10-19 20:03:34 +0000 | [diff] [blame] | 142 | extern int sync_main(int argc, char** argv); |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 143 | extern int syslogd_main(int argc, char **argv); |
Eric Andersen | abc0f4f | 1999-12-08 23:19:36 +0000 | [diff] [blame] | 144 | extern int tail_main(int argc, char** argv); |
Erik Andersen | 3163821 | 2000-01-15 22:28:50 +0000 | [diff] [blame] | 145 | extern int tar_main(int argc, char** argv); |
John Beppu | 059f152 | 1999-12-10 05:27:16 +0000 | [diff] [blame] | 146 | extern int tee_main(int argc, char** argv); |
Erik Andersen | d75af99 | 2000-03-16 08:09:09 +0000 | [diff] [blame] | 147 | extern int test_main(int argc, char** argv); |
Erik Andersen | f7c49ef | 2000-02-22 17:17:45 +0000 | [diff] [blame] | 148 | extern int telnet_main(int argc, char** argv); |
Eric Andersen | 596e546 | 1999-10-07 08:30:23 +0000 | [diff] [blame] | 149 | extern int touch_main(int argc, char** argv); |
Erik Andersen | fb002d0 | 2000-03-05 08:07:00 +0000 | [diff] [blame] | 150 | extern int tr_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 151 | extern int true_main(int argc, char** argv); |
Erik Andersen | 3163821 | 2000-01-15 22:28:50 +0000 | [diff] [blame] | 152 | extern int tput_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 153 | extern int tryopen_main(int argc, char** argv); |
Erik Andersen | 3163821 | 2000-01-15 22:28:50 +0000 | [diff] [blame] | 154 | extern int tty_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 155 | extern int umount_main(int argc, char** argv); |
Erik Andersen | 3163821 | 2000-01-15 22:28:50 +0000 | [diff] [blame] | 156 | extern int uname_main(int argc, char** argv); |
Erik Andersen | 66be5e7 | 2000-03-05 07:52:05 +0000 | [diff] [blame] | 157 | extern int uptime_main(int argc, char** argv); |
John Beppu | abb4772 | 2000-01-06 00:48:21 +0000 | [diff] [blame] | 158 | extern int uniq_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 159 | extern int update_main(int argc, char** argv); |
Erik Andersen | 3163821 | 2000-01-15 22:28:50 +0000 | [diff] [blame] | 160 | extern int wc_main(int argc, char** argv); |
| 161 | extern int whoami_main(int argc, char** argv); |
| 162 | extern int yes_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 163 | |
Eric Andersen | 2b69c40 | 1999-10-05 22:58:32 +0000 | [diff] [blame] | 164 | |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 165 | extern void usage(const char *usage) __attribute__ ((noreturn)); |
Erik Andersen | 1ad302a | 2000-03-24 00:54:46 +0000 | [diff] [blame^] | 166 | extern void errorMsg(const char *s, ...); |
| 167 | extern void fatalError(const char *s, ...) __attribute__ ((noreturn)); |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 168 | |
Eric Andersen | 2b69c40 | 1999-10-05 22:58:32 +0000 | [diff] [blame] | 169 | const char *modeString(int mode); |
| 170 | const char *timeString(time_t timeVal); |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 171 | int isDirectory(const char *name, const int followLinks, struct stat *statBuf); |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 172 | int isDevice(const char *name); |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 173 | |
| 174 | typedef struct ino_dev_hash_bucket_struct { |
| 175 | struct ino_dev_hash_bucket_struct *next; |
| 176 | ino_t ino; |
| 177 | dev_t dev; |
| 178 | char name[1]; |
| 179 | } ino_dev_hashtable_bucket_t; |
| 180 | int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name); |
| 181 | void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name); |
| 182 | void reset_ino_dev_hashtable(void); |
| 183 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 184 | int copyFile(const char *srcName, const char *destName, int setModes, |
| 185 | int followLinks); |
| 186 | char *buildName(const char *dirName, const char *fileName); |
| 187 | int makeString(int argc, const char **argv, char *buf, int bufLen); |
Eric Andersen | 2b69c40 | 1999-10-05 22:58:32 +0000 | [diff] [blame] | 188 | char *getChunk(int size); |
| 189 | char *chunkstrdup(const char *str); |
| 190 | void freeChunks(void); |
| 191 | int fullWrite(int fd, const char *buf, int len); |
| 192 | int fullRead(int fd, char *buf, int len); |
Eric Andersen | 63a0e53 | 1999-10-22 05:12:14 +0000 | [diff] [blame] | 193 | int recursiveAction(const char *fileName, int recurse, int followLinks, int depthFirst, |
Eric Andersen | 9b58718 | 1999-10-17 05:43:39 +0000 | [diff] [blame] | 194 | int (*fileAction) (const char *fileName, struct stat* statbuf), |
| 195 | int (*dirAction) (const char *fileName, struct stat* statbuf)); |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 196 | const char* timeString(time_t timeVal); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 197 | |
Erik Andersen | 06936df | 2000-01-23 02:14:20 +0000 | [diff] [blame] | 198 | extern int createPath (const char *name, int mode); |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 199 | extern int parse_mode( const char* s, mode_t* theMode); |
Eric Andersen | b0e9a70 | 1999-10-18 22:28:26 +0000 | [diff] [blame] | 200 | |
Erik Andersen | 1ad302a | 2000-03-24 00:54:46 +0000 | [diff] [blame^] | 201 | extern int get_kernel_revision(void); |
Eric Andersen | d23f9ba | 1999-10-20 19:18:15 +0000 | [diff] [blame] | 202 | extern uid_t my_getpwnam(char *name); |
| 203 | extern gid_t my_getgrnam(char *name); |
| 204 | extern void my_getpwuid(char* name, uid_t uid); |
| 205 | extern void my_getgrgid(char* group, gid_t gid); |
Eric Andersen | 0460ff2 | 1999-10-25 23:32:44 +0000 | [diff] [blame] | 206 | extern int get_console_fd(char* tty_name); |
Eric Andersen | 29d2e36 | 1999-11-06 06:07:27 +0000 | [diff] [blame] | 207 | extern struct mntent *findMountPoint(const char *name, const char *table); |
Eric Andersen | d0246fb | 1999-11-04 21:18:07 +0000 | [diff] [blame] | 208 | extern void write_mtab(char* blockDevice, char* directory, |
| 209 | char* filesystemType, long flags, char* string_flags); |
| 210 | extern void erase_mtab(const char * name); |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 211 | extern void mtab_read(void); |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 212 | extern char *mtab_first(void **iter); |
| 213 | extern char *mtab_next(void **iter); |
| 214 | extern char *mtab_getinfo(const char *match, const char which); |
Eric Andersen | b186d98 | 1999-12-03 09:19:54 +0000 | [diff] [blame] | 215 | extern int check_wildcard_match(const char* text, const char* pattern); |
Eric Andersen | 1792f8c | 1999-12-09 06:11:36 +0000 | [diff] [blame] | 216 | extern long getNum (const char *cp); |
Erik Andersen | 246cc6d | 2000-03-07 07:41:42 +0000 | [diff] [blame] | 217 | extern pid_t findPidByName( char* pidName); |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 218 | extern void *xmalloc (size_t size); |
Erik Andersen | ec5bd90 | 2000-03-22 07:12:05 +0000 | [diff] [blame] | 219 | extern int find_real_root_device_name(char* name); |
| 220 | |
Erik Andersen | c7c634b | 2000-03-19 05:28:55 +0000 | [diff] [blame] | 221 | #ifdef BB_FEATURE_SH_COMMAND_EDITING |
| 222 | #include <stdio.h> |
| 223 | extern int cmdedit_read_input(char* prompt, int inputFd, int outputFd, char command[BUFSIZ]); |
| 224 | extern void cmdedit_init(void); |
| 225 | #endif |
| 226 | |
Erik Andersen | 31cf8e0 | 2000-02-07 20:31:19 +0000 | [diff] [blame] | 227 | #if defined BB_INIT || defined BB_SYSLOGD |
Erik Andersen | d0480c2 | 2000-02-07 20:35:14 +0000 | [diff] [blame] | 228 | extern int device_open(char *device, int mode); |
Erik Andersen | 31cf8e0 | 2000-02-07 20:31:19 +0000 | [diff] [blame] | 229 | #endif |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 230 | extern void whine_if_fstab_is_missing(); |
Eric Andersen | d0246fb | 1999-11-04 21:18:07 +0000 | [diff] [blame] | 231 | |
Erik Andersen | 5cbdd71 | 2000-01-26 20:06:48 +0000 | [diff] [blame] | 232 | #if defined BB_FEATURE_MOUNT_LOOP |
| 233 | extern int del_loop(const char *device); |
Erik Andersen | de7965c | 2000-01-26 23:49:21 +0000 | [diff] [blame] | 234 | extern int set_loop(const char *device, const char *file, int offset, int *loopro); |
| 235 | extern char *find_unused_loop_device (void); |
Erik Andersen | 5cbdd71 | 2000-01-26 20:06:48 +0000 | [diff] [blame] | 236 | #endif |
| 237 | |
Erik Andersen | 3fe39dc | 2000-01-25 18:13:53 +0000 | [diff] [blame] | 238 | |
Erik Andersen | 5509af7 | 2000-01-23 18:19:02 +0000 | [diff] [blame] | 239 | #if (__GLIBC__ < 2) && (defined BB_SYSLOGD || defined BB_INIT) |
Erik Andersen | 7dc1607 | 2000-01-04 01:10:25 +0000 | [diff] [blame] | 240 | extern int vdprintf(int d, const char *format, va_list ap); |
| 241 | #endif |
Eric Andersen | e674eb7 | 1999-10-19 20:52:57 +0000 | [diff] [blame] | 242 | |
Eric Andersen | a9c95ea | 1999-11-15 17:33:30 +0000 | [diff] [blame] | 243 | #if defined BB_NFSMOUNT |
| 244 | int nfsmount(const char *spec, const char *node, unsigned long *flags, |
| 245 | char **extra_opts, char **mount_opts, int running_bg); |
| 246 | #endif |
Eric Andersen | 29d2e36 | 1999-11-06 06:07:27 +0000 | [diff] [blame] | 247 | |
Eric Andersen | e674eb7 | 1999-10-19 20:52:57 +0000 | [diff] [blame] | 248 | #if defined (BB_FSCK_MINIX) || defined (BB_MKFS_MINIX) |
| 249 | |
| 250 | static inline int bit(char * addr,unsigned int nr) |
| 251 | { |
| 252 | return (addr[nr >> 3] & (1<<(nr & 7))) != 0; |
| 253 | } |
| 254 | |
| 255 | static inline int setbit(char * addr,unsigned int nr) |
| 256 | { |
| 257 | int __res = bit(addr, nr); |
| 258 | addr[nr >> 3] |= (1<<(nr & 7)); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 259 | return __res != 0; |
Eric Andersen | e674eb7 | 1999-10-19 20:52:57 +0000 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | static inline int clrbit(char * addr,unsigned int nr) |
| 263 | { |
| 264 | int __res = bit(addr, nr); |
| 265 | addr[nr >> 3] &= ~(1<<(nr & 7)); |
| 266 | return __res != 0; |
| 267 | } |
| 268 | |
Eric Andersen | aa0765e | 1999-10-22 04:30:20 +0000 | [diff] [blame] | 269 | #endif /* inline bitops junk */ |
Eric Andersen | e674eb7 | 1999-10-19 20:52:57 +0000 | [diff] [blame] | 270 | |
| 271 | |
Erik Andersen | 3163821 | 2000-01-15 22:28:50 +0000 | [diff] [blame] | 272 | #ifndef RB_POWER_OFF |
| 273 | /* Stop system and switch power off if possable. */ |
| 274 | #define RB_POWER_OFF 0x4321fedc |
| 275 | #endif |
| 276 | |
Eric Andersen | aa0765e | 1999-10-22 04:30:20 +0000 | [diff] [blame] | 277 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 278 | #endif /* _BB_INTERNAL_H_ */ |