summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai2001-07-23 14:52:08 +0000
committerMatt Kraai2001-07-23 14:52:08 +0000
commit439e3df65300100e4b63580141eaa238c30431d5 (patch)
treef74320f9994faf4d68826c95cb8d043e35d3a685
parent0139ca92ff4b960e904d18bc0254499e163e2545 (diff)
downloadbusybox-439e3df65300100e4b63580141eaa238c30431d5.zip
busybox-439e3df65300100e4b63580141eaa238c30431d5.tar.gz
Add support for devfs device names.
-rw-r--r--Changelog1
-rw-r--r--Config.h3
-rw-r--r--console-tools/dumpkmap.c4
-rw-r--r--console-tools/loadacm.c4
-rw-r--r--console-tools/loadfont.c4
-rw-r--r--console-tools/loadkmap.c4
-rw-r--r--dumpkmap.c4
-rw-r--r--include/libbb.h28
-rw-r--r--init.c26
-rw-r--r--init/init.c26
-rw-r--r--libbb/get_console.c8
-rw-r--r--libbb/libbb.h28
-rw-r--r--loadacm.c4
-rw-r--r--loadfont.c4
-rw-r--r--loadkmap.c4
-rw-r--r--more.c4
-rw-r--r--util-linux/more.c4
17 files changed, 102 insertions, 58 deletions
diff --git a/Changelog b/Changelog
index eadff4d..76a5e4b 100644
--- a/Changelog
+++ b/Changelog
@@ -9,6 +9,7 @@
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
diff --git a/Config.h b/Config.h
index d40a959..da62cbf 100644
--- a/Config.h
+++ b/Config.h
@@ -407,6 +407,9 @@
// 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
//
//
diff --git a/console-tools/dumpkmap.c b/console-tools/dumpkmap.c
index 0da0186..22652a5 100644
--- a/console-tools/dumpkmap.c
+++ b/console-tools/dumpkmap.c
@@ -51,9 +51,9 @@ int dumpkmap_main(int argc, char **argv)
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;
}
diff --git a/console-tools/loadacm.c b/console-tools/loadacm.c
index 5dbf03e..3fb4e76 100644
--- a/console-tools/loadacm.c
+++ b/console-tools/loadacm.c
@@ -37,9 +37,9 @@ int loadacm_main(int argc, char **argv)
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)) {
diff --git a/console-tools/loadfont.c b/console-tools/loadfont.c
index 1a724ca..d665001 100644
--- a/console-tools/loadfont.c
+++ b/console-tools/loadfont.c
@@ -46,9 +46,9 @@ extern int loadfont_main(int argc, char **argv)
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;
diff --git a/console-tools/loadkmap.c b/console-tools/loadkmap.c
index dcb5c1c..4f217d6 100644
--- a/console-tools/loadkmap.c
+++ b/console-tools/loadkmap.c
@@ -53,9 +53,9 @@ int loadkmap_main(int argc, char **argv)
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))
diff --git a/dumpkmap.c b/dumpkmap.c
index 0da0186..22652a5 100644
--- a/dumpkmap.c
+++ b/dumpkmap.c
@@ -51,9 +51,9 @@ int dumpkmap_main(int argc, char **argv)
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;
}
diff --git a/include/libbb.h b/include/libbb.h
index c167e10..3cf932d 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -288,4 +288,32 @@ extern const char * const name_longer_than_foo;
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__ */
diff --git a/init.c b/init.c
index ec144ea..f397b7e 100644
--- a/init.c
+++ b/init.c
@@ -117,13 +117,6 @@ static const int RB_AUTOBOOT = 0x01234567;
#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 */
@@ -176,10 +169,10 @@ struct initActionTag {
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;
@@ -341,20 +334,19 @@ static void console_init()
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++;
@@ -371,7 +363,7 @@ static void console_init()
/* 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;
diff --git a/init/init.c b/init/init.c
index ec144ea..f397b7e 100644
--- a/init/init.c
+++ b/init/init.c
@@ -117,13 +117,6 @@ static const int RB_AUTOBOOT = 0x01234567;
#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 */
@@ -176,10 +169,10 @@ struct initActionTag {
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;
@@ -341,20 +334,19 @@ static void console_init()
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++;
@@ -371,7 +363,7 @@ static void console_init()
/* 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;
diff --git a/libbb/get_console.c b/libbb/get_console.c
index 4be9adc..3b36a59 100644
--- a/libbb/get_console.c
+++ b/libbb/get_console.c
@@ -98,15 +98,15 @@ int get_console_fd(char *tty_name)
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;
@@ -114,7 +114,7 @@ int get_console_fd(char *tty_name)
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 */
}
diff --git a/libbb/libbb.h b/libbb/libbb.h
index c167e10..3cf932d 100644
--- a/libbb/libbb.h
+++ b/libbb/libbb.h
@@ -288,4 +288,32 @@ extern const char * const name_longer_than_foo;
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__ */
diff --git a/loadacm.c b/loadacm.c
index 5dbf03e..3fb4e76 100644
--- a/loadacm.c
+++ b/loadacm.c
@@ -37,9 +37,9 @@ int loadacm_main(int argc, char **argv)
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)) {
diff --git a/loadfont.c b/loadfont.c
index 1a724ca..d665001 100644
--- a/loadfont.c
+++ b/loadfont.c
@@ -46,9 +46,9 @@ extern int loadfont_main(int argc, char **argv)
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;
diff --git a/loadkmap.c b/loadkmap.c
index dcb5c1c..4f217d6 100644
--- a/loadkmap.c
+++ b/loadkmap.c
@@ -53,9 +53,9 @@ int loadkmap_main(int argc, char **argv)
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))
diff --git a/more.c b/more.c
index 6cdec72..780cddf 100644
--- a/more.c
+++ b/more.c
@@ -79,9 +79,9 @@ extern int more_main(int argc, char **argv)
/* 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);
diff --git a/util-linux/more.c b/util-linux/more.c
index 6cdec72..780cddf 100644
--- a/util-linux/more.c
+++ b/util-linux/more.c
@@ -79,9 +79,9 @@ extern int more_main(int argc, char **argv)
/* 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);