Add support for devfs device names.
This commit is contained in:
parent
0139ca92ff
commit
439e3df653
@ -9,6 +9,7 @@
|
|||||||
Other Changes:
|
Other Changes:
|
||||||
* Vladimir Oleynik -- Fixed tr to support 'tr a-z A-Z' syntax,
|
* Vladimir Oleynik -- Fixed tr to support 'tr a-z A-Z' syntax,
|
||||||
many ash corrections, and others optimizations, and cleanups.
|
many ash corrections, and others optimizations, and cleanups.
|
||||||
|
* Matt Kraai -- Added BB_FEATURE_DEVFS to enable devfs device names.
|
||||||
|
|
||||||
|
|
||||||
-Not Yet Released
|
-Not Yet Released
|
||||||
|
3
Config.h
3
Config.h
@ -407,6 +407,9 @@
|
|||||||
// Support for TELNET to pass TERM type to remote host. Adds 384 bytes.
|
// Support for TELNET to pass TERM type to remote host. Adds 384 bytes.
|
||||||
#define BB_FEATURE_TELNET_TTYPE
|
#define BB_FEATURE_TELNET_TTYPE
|
||||||
//
|
//
|
||||||
|
// Support for devfs.
|
||||||
|
//#define BB_FEATURE_DEVFS
|
||||||
|
//
|
||||||
// End of Features List
|
// End of Features List
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -51,9 +51,9 @@ int dumpkmap_main(int argc, char **argv)
|
|||||||
show_usage();
|
show_usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = open("/dev/tty0", O_RDWR);
|
fd = open(CURRENT_VC, O_RDWR);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
perror_msg("Error opening /dev/tty0");
|
perror_msg("Error opening " CURRENT_VC);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ int loadacm_main(int argc, char **argv)
|
|||||||
show_usage();
|
show_usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = open("/dev/tty", O_RDWR);
|
fd = open(CURRENT_VC, O_RDWR);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
perror_msg_and_die("Error opening /dev/tty1");
|
perror_msg_and_die("Error opening " CURRENT_VC);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (screen_map_load(fd, stdin)) {
|
if (screen_map_load(fd, stdin)) {
|
||||||
|
@ -46,9 +46,9 @@ extern int loadfont_main(int argc, char **argv)
|
|||||||
if (argc != 1)
|
if (argc != 1)
|
||||||
show_usage();
|
show_usage();
|
||||||
|
|
||||||
fd = open("/dev/tty0", O_RDWR);
|
fd = open(CURRENT_VC, O_RDWR);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
perror_msg_and_die("Error opening /dev/tty0");
|
perror_msg_and_die("Error opening " CURRENT_VC);
|
||||||
loadnewfont(fd);
|
loadnewfont(fd);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
@ -53,9 +53,9 @@ int loadkmap_main(int argc, char **argv)
|
|||||||
if (argc != 1)
|
if (argc != 1)
|
||||||
show_usage();
|
show_usage();
|
||||||
|
|
||||||
fd = open("/dev/tty0", O_RDWR);
|
fd = open(CURRENT_VC, O_RDWR);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
perror_msg_and_die("Error opening /dev/tty0");
|
perror_msg_and_die("Error opening " CURRENT_VC);
|
||||||
|
|
||||||
read(0, buff, 7);
|
read(0, buff, 7);
|
||||||
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
|
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
|
||||||
|
@ -51,9 +51,9 @@ int dumpkmap_main(int argc, char **argv)
|
|||||||
show_usage();
|
show_usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = open("/dev/tty0", O_RDWR);
|
fd = open(CURRENT_VC, O_RDWR);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
perror_msg("Error opening /dev/tty0");
|
perror_msg("Error opening " CURRENT_VC);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,4 +288,32 @@ extern const char * const name_longer_than_foo;
|
|||||||
extern const char * const unknown;
|
extern const char * const unknown;
|
||||||
extern const char * const can_not_create_raw_socket;
|
extern const char * const can_not_create_raw_socket;
|
||||||
|
|
||||||
|
#ifdef BB_FEATURE_DEVFS
|
||||||
|
# define CURRENT_VC "/dev/vc/0"
|
||||||
|
# define VC_1 "/dev/vc/1"
|
||||||
|
# define VC_2 "/dev/vc/2"
|
||||||
|
# define VC_3 "/dev/vc/3"
|
||||||
|
# define VC_4 "/dev/vc/4"
|
||||||
|
# define VC_5 "/dev/vc/5"
|
||||||
|
# define SC_0 "/dev/tts/0"
|
||||||
|
# define SC_1 "/dev/tts/1"
|
||||||
|
# define VC_FORMAT "/dev/vc/%d"
|
||||||
|
# define SC_FORMAT "/dev/tts/%d"
|
||||||
|
#else
|
||||||
|
# define CURRENT_VC "/dev/tty0"
|
||||||
|
# define VC_1 "/dev/tty1"
|
||||||
|
# define VC_2 "/dev/tty2"
|
||||||
|
# define VC_3 "/dev/tty3"
|
||||||
|
# define VC_4 "/dev/tty4"
|
||||||
|
# define VC_5 "/dev/tty5"
|
||||||
|
# define SC_0 "/dev/ttyS0"
|
||||||
|
# define SC_1 "/dev/ttyS1"
|
||||||
|
# define VC_FORMAT "/dev/tty%d"
|
||||||
|
# define SC_FORMAT "/dev/ttyS%d"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The following devices are the same on devfs and non-devfs systems. */
|
||||||
|
#define CURRENT_TTY "/dev/tty"
|
||||||
|
#define CONSOLE_DEV "/dev/console"
|
||||||
|
|
||||||
#endif /* __LIBBB_H__ */
|
#endif /* __LIBBB_H__ */
|
||||||
|
26
init.c
26
init.c
@ -117,13 +117,6 @@ static const int RB_AUTOBOOT = 0x01234567;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define VT_PRIMARY "/dev/tty1" /* Primary virtual console */
|
|
||||||
#define VT_SECONDARY "/dev/tty2" /* Virtual console */
|
|
||||||
#define VT_THIRD "/dev/tty3" /* Virtual console */
|
|
||||||
#define VT_FOURTH "/dev/tty4" /* Virtual console */
|
|
||||||
#define VT_LOG "/dev/tty5" /* Virtual console */
|
|
||||||
#define SERIAL_CON0 "/dev/ttyS0" /* Primary serial console */
|
|
||||||
#define SERIAL_CON1 "/dev/ttyS1" /* Serial console */
|
|
||||||
#define SHELL "/bin/sh" /* Default shell */
|
#define SHELL "/bin/sh" /* Default shell */
|
||||||
#define LOGIN_SHELL "-" SHELL /* Default login shell */
|
#define LOGIN_SHELL "-" SHELL /* Default login shell */
|
||||||
#define INITTAB "/etc/inittab" /* inittab file location */
|
#define INITTAB "/etc/inittab" /* inittab file location */
|
||||||
@ -176,10 +169,10 @@ struct initActionTag {
|
|||||||
static initAction *initActionList = NULL;
|
static initAction *initActionList = NULL;
|
||||||
|
|
||||||
|
|
||||||
static char *secondConsole = VT_SECONDARY;
|
static char *secondConsole = VC_2;
|
||||||
static char *thirdConsole = VT_THIRD;
|
static char *thirdConsole = VC_3;
|
||||||
static char *fourthConsole = VT_FOURTH;
|
static char *fourthConsole = VC_4;
|
||||||
static char *log = VT_LOG;
|
static char *log = VC_5;
|
||||||
static int kernelVersion = 0;
|
static int kernelVersion = 0;
|
||||||
static char termType[32] = "TERM=linux";
|
static char termType[32] = "TERM=linux";
|
||||||
static char console[32] = _PATH_CONSOLE;
|
static char console[32] = _PATH_CONSOLE;
|
||||||
@ -341,20 +334,19 @@ static void console_init()
|
|||||||
else if ((s = getenv("console")) != NULL) {
|
else if ((s = getenv("console")) != NULL) {
|
||||||
/* remap tty[ab] to /dev/ttyS[01] */
|
/* remap tty[ab] to /dev/ttyS[01] */
|
||||||
if (strcmp(s, "ttya") == 0)
|
if (strcmp(s, "ttya") == 0)
|
||||||
safe_strncpy(console, SERIAL_CON0, sizeof(console));
|
safe_strncpy(console, SC_0, sizeof(console));
|
||||||
else if (strcmp(s, "ttyb") == 0)
|
else if (strcmp(s, "ttyb") == 0)
|
||||||
safe_strncpy(console, SERIAL_CON1, sizeof(console));
|
safe_strncpy(console, SC_1, sizeof(console));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
/* 2.2 kernels: identify the real console backend and try to use it */
|
/* 2.2 kernels: identify the real console backend and try to use it */
|
||||||
if (ioctl(0, TIOCGSERIAL, &sr) == 0) {
|
if (ioctl(0, TIOCGSERIAL, &sr) == 0) {
|
||||||
/* this is a serial console */
|
/* this is a serial console */
|
||||||
snprintf(console, sizeof(console) - 1, "/dev/ttyS%d", sr.line);
|
snprintf(console, sizeof(console) - 1, SC_FORMAT, sr.line);
|
||||||
} else if (ioctl(0, VT_GETSTATE, &vt) == 0) {
|
} else if (ioctl(0, VT_GETSTATE, &vt) == 0) {
|
||||||
/* this is linux virtual tty */
|
/* this is linux virtual tty */
|
||||||
snprintf(console, sizeof(console) - 1, "/dev/tty%d",
|
snprintf(console, sizeof(console) - 1, VC_FORMAT, vt.v_active);
|
||||||
vt.v_active);
|
|
||||||
} else {
|
} else {
|
||||||
safe_strncpy(console, _PATH_CONSOLE, sizeof(console));
|
safe_strncpy(console, _PATH_CONSOLE, sizeof(console));
|
||||||
tried_devcons++;
|
tried_devcons++;
|
||||||
@ -371,7 +363,7 @@ static void console_init()
|
|||||||
/* Can't open selected console -- try vt1 */
|
/* Can't open selected console -- try vt1 */
|
||||||
if (!tried_vtprimary) {
|
if (!tried_vtprimary) {
|
||||||
tried_vtprimary++;
|
tried_vtprimary++;
|
||||||
safe_strncpy(console, VT_PRIMARY, sizeof(console));
|
safe_strncpy(console, VC_1, sizeof(console));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
26
init/init.c
26
init/init.c
@ -117,13 +117,6 @@ static const int RB_AUTOBOOT = 0x01234567;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define VT_PRIMARY "/dev/tty1" /* Primary virtual console */
|
|
||||||
#define VT_SECONDARY "/dev/tty2" /* Virtual console */
|
|
||||||
#define VT_THIRD "/dev/tty3" /* Virtual console */
|
|
||||||
#define VT_FOURTH "/dev/tty4" /* Virtual console */
|
|
||||||
#define VT_LOG "/dev/tty5" /* Virtual console */
|
|
||||||
#define SERIAL_CON0 "/dev/ttyS0" /* Primary serial console */
|
|
||||||
#define SERIAL_CON1 "/dev/ttyS1" /* Serial console */
|
|
||||||
#define SHELL "/bin/sh" /* Default shell */
|
#define SHELL "/bin/sh" /* Default shell */
|
||||||
#define LOGIN_SHELL "-" SHELL /* Default login shell */
|
#define LOGIN_SHELL "-" SHELL /* Default login shell */
|
||||||
#define INITTAB "/etc/inittab" /* inittab file location */
|
#define INITTAB "/etc/inittab" /* inittab file location */
|
||||||
@ -176,10 +169,10 @@ struct initActionTag {
|
|||||||
static initAction *initActionList = NULL;
|
static initAction *initActionList = NULL;
|
||||||
|
|
||||||
|
|
||||||
static char *secondConsole = VT_SECONDARY;
|
static char *secondConsole = VC_2;
|
||||||
static char *thirdConsole = VT_THIRD;
|
static char *thirdConsole = VC_3;
|
||||||
static char *fourthConsole = VT_FOURTH;
|
static char *fourthConsole = VC_4;
|
||||||
static char *log = VT_LOG;
|
static char *log = VC_5;
|
||||||
static int kernelVersion = 0;
|
static int kernelVersion = 0;
|
||||||
static char termType[32] = "TERM=linux";
|
static char termType[32] = "TERM=linux";
|
||||||
static char console[32] = _PATH_CONSOLE;
|
static char console[32] = _PATH_CONSOLE;
|
||||||
@ -341,20 +334,19 @@ static void console_init()
|
|||||||
else if ((s = getenv("console")) != NULL) {
|
else if ((s = getenv("console")) != NULL) {
|
||||||
/* remap tty[ab] to /dev/ttyS[01] */
|
/* remap tty[ab] to /dev/ttyS[01] */
|
||||||
if (strcmp(s, "ttya") == 0)
|
if (strcmp(s, "ttya") == 0)
|
||||||
safe_strncpy(console, SERIAL_CON0, sizeof(console));
|
safe_strncpy(console, SC_0, sizeof(console));
|
||||||
else if (strcmp(s, "ttyb") == 0)
|
else if (strcmp(s, "ttyb") == 0)
|
||||||
safe_strncpy(console, SERIAL_CON1, sizeof(console));
|
safe_strncpy(console, SC_1, sizeof(console));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
/* 2.2 kernels: identify the real console backend and try to use it */
|
/* 2.2 kernels: identify the real console backend and try to use it */
|
||||||
if (ioctl(0, TIOCGSERIAL, &sr) == 0) {
|
if (ioctl(0, TIOCGSERIAL, &sr) == 0) {
|
||||||
/* this is a serial console */
|
/* this is a serial console */
|
||||||
snprintf(console, sizeof(console) - 1, "/dev/ttyS%d", sr.line);
|
snprintf(console, sizeof(console) - 1, SC_FORMAT, sr.line);
|
||||||
} else if (ioctl(0, VT_GETSTATE, &vt) == 0) {
|
} else if (ioctl(0, VT_GETSTATE, &vt) == 0) {
|
||||||
/* this is linux virtual tty */
|
/* this is linux virtual tty */
|
||||||
snprintf(console, sizeof(console) - 1, "/dev/tty%d",
|
snprintf(console, sizeof(console) - 1, VC_FORMAT, vt.v_active);
|
||||||
vt.v_active);
|
|
||||||
} else {
|
} else {
|
||||||
safe_strncpy(console, _PATH_CONSOLE, sizeof(console));
|
safe_strncpy(console, _PATH_CONSOLE, sizeof(console));
|
||||||
tried_devcons++;
|
tried_devcons++;
|
||||||
@ -371,7 +363,7 @@ static void console_init()
|
|||||||
/* Can't open selected console -- try vt1 */
|
/* Can't open selected console -- try vt1 */
|
||||||
if (!tried_vtprimary) {
|
if (!tried_vtprimary) {
|
||||||
tried_vtprimary++;
|
tried_vtprimary++;
|
||||||
safe_strncpy(console, VT_PRIMARY, sizeof(console));
|
safe_strncpy(console, VC_1, sizeof(console));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -98,15 +98,15 @@ int get_console_fd(char *tty_name)
|
|||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = open_a_console("/dev/tty");
|
fd = open_a_console(CURRENT_TTY);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
return fd;
|
return fd;
|
||||||
|
|
||||||
fd = open_a_console("/dev/tty0");
|
fd = open_a_console(CURRENT_VC);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
return fd;
|
return fd;
|
||||||
|
|
||||||
fd = open_a_console("/dev/console");
|
fd = open_a_console(CONSOLE_DEV);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
return fd;
|
return fd;
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ int get_console_fd(char *tty_name)
|
|||||||
if (is_a_console(fd))
|
if (is_a_console(fd))
|
||||||
return fd;
|
return fd;
|
||||||
|
|
||||||
error_msg("Couldnt get a file descriptor referring to the console");
|
error_msg("Couldn't get a file descriptor referring to the console");
|
||||||
return -1; /* total failure */
|
return -1; /* total failure */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,4 +288,32 @@ extern const char * const name_longer_than_foo;
|
|||||||
extern const char * const unknown;
|
extern const char * const unknown;
|
||||||
extern const char * const can_not_create_raw_socket;
|
extern const char * const can_not_create_raw_socket;
|
||||||
|
|
||||||
|
#ifdef BB_FEATURE_DEVFS
|
||||||
|
# define CURRENT_VC "/dev/vc/0"
|
||||||
|
# define VC_1 "/dev/vc/1"
|
||||||
|
# define VC_2 "/dev/vc/2"
|
||||||
|
# define VC_3 "/dev/vc/3"
|
||||||
|
# define VC_4 "/dev/vc/4"
|
||||||
|
# define VC_5 "/dev/vc/5"
|
||||||
|
# define SC_0 "/dev/tts/0"
|
||||||
|
# define SC_1 "/dev/tts/1"
|
||||||
|
# define VC_FORMAT "/dev/vc/%d"
|
||||||
|
# define SC_FORMAT "/dev/tts/%d"
|
||||||
|
#else
|
||||||
|
# define CURRENT_VC "/dev/tty0"
|
||||||
|
# define VC_1 "/dev/tty1"
|
||||||
|
# define VC_2 "/dev/tty2"
|
||||||
|
# define VC_3 "/dev/tty3"
|
||||||
|
# define VC_4 "/dev/tty4"
|
||||||
|
# define VC_5 "/dev/tty5"
|
||||||
|
# define SC_0 "/dev/ttyS0"
|
||||||
|
# define SC_1 "/dev/ttyS1"
|
||||||
|
# define VC_FORMAT "/dev/tty%d"
|
||||||
|
# define SC_FORMAT "/dev/ttyS%d"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The following devices are the same on devfs and non-devfs systems. */
|
||||||
|
#define CURRENT_TTY "/dev/tty"
|
||||||
|
#define CONSOLE_DEV "/dev/console"
|
||||||
|
|
||||||
#endif /* __LIBBB_H__ */
|
#endif /* __LIBBB_H__ */
|
||||||
|
@ -37,9 +37,9 @@ int loadacm_main(int argc, char **argv)
|
|||||||
show_usage();
|
show_usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = open("/dev/tty", O_RDWR);
|
fd = open(CURRENT_VC, O_RDWR);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
perror_msg_and_die("Error opening /dev/tty1");
|
perror_msg_and_die("Error opening " CURRENT_VC);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (screen_map_load(fd, stdin)) {
|
if (screen_map_load(fd, stdin)) {
|
||||||
|
@ -46,9 +46,9 @@ extern int loadfont_main(int argc, char **argv)
|
|||||||
if (argc != 1)
|
if (argc != 1)
|
||||||
show_usage();
|
show_usage();
|
||||||
|
|
||||||
fd = open("/dev/tty0", O_RDWR);
|
fd = open(CURRENT_VC, O_RDWR);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
perror_msg_and_die("Error opening /dev/tty0");
|
perror_msg_and_die("Error opening " CURRENT_VC);
|
||||||
loadnewfont(fd);
|
loadnewfont(fd);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
@ -53,9 +53,9 @@ int loadkmap_main(int argc, char **argv)
|
|||||||
if (argc != 1)
|
if (argc != 1)
|
||||||
show_usage();
|
show_usage();
|
||||||
|
|
||||||
fd = open("/dev/tty0", O_RDWR);
|
fd = open(CURRENT_VC, O_RDWR);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
perror_msg_and_die("Error opening /dev/tty0");
|
perror_msg_and_die("Error opening " CURRENT_VC);
|
||||||
|
|
||||||
read(0, buff, 7);
|
read(0, buff, 7);
|
||||||
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
|
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
|
||||||
|
4
more.c
4
more.c
@ -79,9 +79,9 @@ extern int more_main(int argc, char **argv)
|
|||||||
|
|
||||||
/* not use inputing from terminal if usage: more > outfile */
|
/* not use inputing from terminal if usage: more > outfile */
|
||||||
if(isatty(fileno(stdout))) {
|
if(isatty(fileno(stdout))) {
|
||||||
cin = fopen("/dev/tty", "r");
|
cin = fopen(CURRENT_TTY, "r");
|
||||||
if (!cin)
|
if (!cin)
|
||||||
cin = xfopen("/dev/console", "r");
|
cin = xfopen(CONSOLE_DEV, "r");
|
||||||
please_display_more_prompt = 0;
|
please_display_more_prompt = 0;
|
||||||
#ifdef BB_FEATURE_USE_TERMIOS
|
#ifdef BB_FEATURE_USE_TERMIOS
|
||||||
getTermSettings(fileno(cin), &initial_settings);
|
getTermSettings(fileno(cin), &initial_settings);
|
||||||
|
@ -79,9 +79,9 @@ extern int more_main(int argc, char **argv)
|
|||||||
|
|
||||||
/* not use inputing from terminal if usage: more > outfile */
|
/* not use inputing from terminal if usage: more > outfile */
|
||||||
if(isatty(fileno(stdout))) {
|
if(isatty(fileno(stdout))) {
|
||||||
cin = fopen("/dev/tty", "r");
|
cin = fopen(CURRENT_TTY, "r");
|
||||||
if (!cin)
|
if (!cin)
|
||||||
cin = xfopen("/dev/console", "r");
|
cin = xfopen(CONSOLE_DEV, "r");
|
||||||
please_display_more_prompt = 0;
|
please_display_more_prompt = 0;
|
||||||
#ifdef BB_FEATURE_USE_TERMIOS
|
#ifdef BB_FEATURE_USE_TERMIOS
|
||||||
getTermSettings(fileno(cin), &initial_settings);
|
getTermSettings(fileno(cin), &initial_settings);
|
||||||
|
Loading…
Reference in New Issue
Block a user