Other Changes:
* Vladimir Oleynik -- Fixed tr to support 'tr a-z A-Z' syntax,
many ash corrections, and others optimizations, and cleanups.
+ * Matt Kraai -- Added BB_FEATURE_DEVFS to enable devfs device names.
-Not Yet Released
// Support for TELNET to pass TERM type to remote host. Adds 384 bytes.
#define BB_FEATURE_TELNET_TTYPE
//
+// Support for devfs.
+//#define BB_FEATURE_DEVFS
+//
// End of Features List
//
//
show_usage();
}
- fd = open("/dev/tty0", O_RDWR);
+ fd = open(CURRENT_VC, O_RDWR);
if (fd < 0) {
- perror_msg("Error opening /dev/tty0");
+ perror_msg("Error opening " CURRENT_VC);
return EXIT_FAILURE;
}
show_usage();
}
- fd = open("/dev/tty", O_RDWR);
+ fd = open(CURRENT_VC, O_RDWR);
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 (argc != 1)
show_usage();
- fd = open("/dev/tty0", O_RDWR);
+ fd = open(CURRENT_VC, O_RDWR);
if (fd < 0)
- perror_msg_and_die("Error opening /dev/tty0");
+ perror_msg_and_die("Error opening " CURRENT_VC);
loadnewfont(fd);
return EXIT_SUCCESS;
if (argc != 1)
show_usage();
- fd = open("/dev/tty0", O_RDWR);
+ fd = open(CURRENT_VC, O_RDWR);
if (fd < 0)
- perror_msg_and_die("Error opening /dev/tty0");
+ perror_msg_and_die("Error opening " CURRENT_VC);
read(0, buff, 7);
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
show_usage();
}
- fd = open("/dev/tty0", O_RDWR);
+ fd = open(CURRENT_VC, O_RDWR);
if (fd < 0) {
- perror_msg("Error opening /dev/tty0");
+ perror_msg("Error opening " CURRENT_VC);
return EXIT_FAILURE;
}
extern const char * const unknown;
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
-#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 LOGIN_SHELL "-" SHELL /* Default login shell */
#define INITTAB "/etc/inittab" /* inittab file location */
static initAction *initActionList = NULL;
-static char *secondConsole = VT_SECONDARY;
-static char *thirdConsole = VT_THIRD;
-static char *fourthConsole = VT_FOURTH;
-static char *log = VT_LOG;
+static char *secondConsole = VC_2;
+static char *thirdConsole = VC_3;
+static char *fourthConsole = VC_4;
+static char *log = VC_5;
static int kernelVersion = 0;
static char termType[32] = "TERM=linux";
static char console[32] = _PATH_CONSOLE;
else if ((s = getenv("console")) != NULL) {
/* remap tty[ab] to /dev/ttyS[01] */
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)
- safe_strncpy(console, SERIAL_CON1, sizeof(console));
+ safe_strncpy(console, SC_1, sizeof(console));
}
#endif
else {
/* 2.2 kernels: identify the real console backend and try to use it */
if (ioctl(0, TIOCGSERIAL, &sr) == 0) {
/* 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) {
/* this is linux virtual tty */
- snprintf(console, sizeof(console) - 1, "/dev/tty%d",
- vt.v_active);
+ snprintf(console, sizeof(console) - 1, VC_FORMAT, vt.v_active);
} else {
safe_strncpy(console, _PATH_CONSOLE, sizeof(console));
tried_devcons++;
/* Can't open selected console -- try vt1 */
if (!tried_vtprimary) {
tried_vtprimary++;
- safe_strncpy(console, VT_PRIMARY, sizeof(console));
+ safe_strncpy(console, VC_1, sizeof(console));
continue;
}
break;
#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 LOGIN_SHELL "-" SHELL /* Default login shell */
#define INITTAB "/etc/inittab" /* inittab file location */
static initAction *initActionList = NULL;
-static char *secondConsole = VT_SECONDARY;
-static char *thirdConsole = VT_THIRD;
-static char *fourthConsole = VT_FOURTH;
-static char *log = VT_LOG;
+static char *secondConsole = VC_2;
+static char *thirdConsole = VC_3;
+static char *fourthConsole = VC_4;
+static char *log = VC_5;
static int kernelVersion = 0;
static char termType[32] = "TERM=linux";
static char console[32] = _PATH_CONSOLE;
else if ((s = getenv("console")) != NULL) {
/* remap tty[ab] to /dev/ttyS[01] */
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)
- safe_strncpy(console, SERIAL_CON1, sizeof(console));
+ safe_strncpy(console, SC_1, sizeof(console));
}
#endif
else {
/* 2.2 kernels: identify the real console backend and try to use it */
if (ioctl(0, TIOCGSERIAL, &sr) == 0) {
/* 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) {
/* this is linux virtual tty */
- snprintf(console, sizeof(console) - 1, "/dev/tty%d",
- vt.v_active);
+ snprintf(console, sizeof(console) - 1, VC_FORMAT, vt.v_active);
} else {
safe_strncpy(console, _PATH_CONSOLE, sizeof(console));
tried_devcons++;
/* Can't open selected console -- try vt1 */
if (!tried_vtprimary) {
tried_vtprimary++;
- safe_strncpy(console, VT_PRIMARY, sizeof(console));
+ safe_strncpy(console, VC_1, sizeof(console));
continue;
}
break;
return fd;
}
- fd = open_a_console("/dev/tty");
+ fd = open_a_console(CURRENT_TTY);
if (fd >= 0)
return fd;
- fd = open_a_console("/dev/tty0");
+ fd = open_a_console(CURRENT_VC);
if (fd >= 0)
return fd;
- fd = open_a_console("/dev/console");
+ fd = open_a_console(CONSOLE_DEV);
if (fd >= 0)
return fd;
if (is_a_console(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 */
}
extern const char * const unknown;
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__ */
show_usage();
}
- fd = open("/dev/tty", O_RDWR);
+ fd = open(CURRENT_VC, O_RDWR);
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 (argc != 1)
show_usage();
- fd = open("/dev/tty0", O_RDWR);
+ fd = open(CURRENT_VC, O_RDWR);
if (fd < 0)
- perror_msg_and_die("Error opening /dev/tty0");
+ perror_msg_and_die("Error opening " CURRENT_VC);
loadnewfont(fd);
return EXIT_SUCCESS;
if (argc != 1)
show_usage();
- fd = open("/dev/tty0", O_RDWR);
+ fd = open(CURRENT_VC, O_RDWR);
if (fd < 0)
- perror_msg_and_die("Error opening /dev/tty0");
+ perror_msg_and_die("Error opening " CURRENT_VC);
read(0, buff, 7);
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
/* not use inputing from terminal if usage: more > outfile */
if(isatty(fileno(stdout))) {
- cin = fopen("/dev/tty", "r");
+ cin = fopen(CURRENT_TTY, "r");
if (!cin)
- cin = xfopen("/dev/console", "r");
+ cin = xfopen(CONSOLE_DEV, "r");
please_display_more_prompt = 0;
#ifdef BB_FEATURE_USE_TERMIOS
getTermSettings(fileno(cin), &initial_settings);
/* not use inputing from terminal if usage: more > outfile */
if(isatty(fileno(stdout))) {
- cin = fopen("/dev/tty", "r");
+ cin = fopen(CURRENT_TTY, "r");
if (!cin)
- cin = xfopen("/dev/console", "r");
+ cin = xfopen(CONSOLE_DEV, "r");
please_display_more_prompt = 0;
#ifdef BB_FEATURE_USE_TERMIOS
getTermSettings(fileno(cin), &initial_settings);