aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--event.d/serial11
-rw-r--r--initscripts.spec12
-rwxr-xr-xrc.d/init.d/network2
-rwxr-xr-xrc.d/rc7
-rw-r--r--src/Makefile3
-rw-r--r--src/console_check.c154
-rw-r--r--udev/rules.d/10-console.rules8
8 files changed, 195 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index d96f4d37..f7558bf7 100644
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,7 @@ install:
cp -af rc.d/init.d $(ROOT)/etc/rc.d/
install -m755 sysconfig/init sysconfig/netconsole sysconfig/readonly-root $(ROOT)/etc/sysconfig/
cp -af sysconfig/network-scripts $(ROOT)/etc/sysconfig/
- cp -af ppp udev NetworkManager $(ROOT)/etc
+ cp -af ppp udev NetworkManager event.d $(ROOT)/etc
mkdir -p $(ROOT)/etc/ppp/peers
chmod 755 $(ROOT)/etc/rc.d/* $(ROOT)/etc/rc.d/init.d/*
chmod 755 $(ROOT)/etc/ppp/peers
@@ -53,6 +53,7 @@ install:
chmod 755 $(ROOT)/etc/sysconfig/network-scripts/init*
chmod 755 $(ROOT)/etc/sysconfig/network-scripts/net.hotplug
chmod 755 $(ROOT)/etc/NetworkManager/dispatcher.d/00-netreport
+ chmod 644 $(ROOT)/etc/event.d/*
mkdir -p $(ROOT)/etc/sysconfig/modules
mkdir -p $(ROOT)/etc/sysconfig/networking/devices
mkdir -p $(ROOT)/etc/sysconfig/networking/profiles/default
diff --git a/event.d/serial b/event.d/serial
new file mode 100644
index 00000000..6c29af04
--- /dev/null
+++ b/event.d/serial
@@ -0,0 +1,11 @@
+
+start on fedora.serial-console-available *
+stop on runlevel [016]
+
+instance
+exec /sbin/agetty /dev/$1 $2 vt100-nav
+post-stop script
+ if [ "$UPSTART_EVENT" != "${UPSTART_EVENT##fedora.serial-console-available}" ]; then
+ initctl emit --no-wait fedora.serial-console-available $1 $2
+ fi
+end script
diff --git a/initscripts.spec b/initscripts.spec
index d2b70a8d..e3496c91 100644
--- a/initscripts.spec
+++ b/initscripts.spec
@@ -1,6 +1,6 @@
Summary: The inittab file and the /etc/init.d scripts
Name: initscripts
-Version: 8.64
+Version: 8.65
# ppp-watch is GPLv2+, everything else is GPLv2
License: GPLv2 and GPLv2+
Group: System Environment/Base
@@ -156,6 +156,7 @@ rm -rf $RPM_BUILD_ROOT
%dir /etc/rwtab.d
/etc/statetab
%dir /etc/statetab.d
+%config(noreplace) /etc/event.d/*
/etc/udev/rules.d/*
%config /etc/X11/prefdm
%config(noreplace) /etc/inittab
@@ -188,6 +189,7 @@ rm -rf $RPM_BUILD_ROOT
/sbin/initlog
/lib/udev/rename_device
/lib/udev/console_init
+/lib/udev/console_check
%ifarch s390 s390x
/lib/udev/ccw_init
%endif
@@ -214,6 +216,14 @@ rm -rf $RPM_BUILD_ROOT
%ghost %attr(0664,root,utmp) /var/run/utmp
%changelog
+* Mon Mar 10 2008 Bill Nottingham <notting@redhat.com> - 8.65-1
+- Add a serial console udev/upstart handler (#434764, indirectly)
+- Add some upstart notification for sysv scripts (modified from <cjdahlin@ncsu.edu>, #431231)
+- Handle _rnetdev correctly (#435358, <pjones@redhat.com>)
+- various minor speedups (<arjan@infradead.org>)
+- translation updates: el, fr
+- disable network by default, in favor of NetworkManager
+
* Tue Feb 26 2008 Bill Nottingham <notting@redhat.com> - 8.64-1
- Add a console_init udev helper to do console initialization
- add /sbin/pidof requirement (#434863)
diff --git a/rc.d/init.d/network b/rc.d/init.d/network
index 78370f9e..b1b15592 100755
--- a/rc.d/init.d/network
+++ b/rc.d/init.d/network
@@ -2,7 +2,7 @@
#
# network Bring up/down networking
#
-# chkconfig: 2345 10 90
+# chkconfig: - 10 90
# description: Activates/Deactivates all network interfaces configured to \
# start at boot time.
#
diff --git a/rc.d/rc b/rc.d/rc
index 7f44b447..316751a4 100755
--- a/rc.d/rc
+++ b/rc.d/rc
@@ -37,7 +37,8 @@ do_confirm="no"
if [ -f /var/run/confirm ]; then
do_confirm="yes"
fi
-
+UPSTART=
+[ -x /sbin/initctl ] && UPSTART=yes
# See if we want to be in user confirmation mode
if [ "$previous" = "N" ]; then
if [ "$do_confirm" = "yes" ]; then
@@ -70,7 +71,9 @@ for i in /etc/rc$runlevel.d/K* ; do
check_runlevel "$i" || continue
# Bring the subsystem down.
+ [ -n "$UPSTART" ] && initctl emit --quiet "stopping $subsys"
$i stop
+ [ -n "$UPSTART" ] && initctl emit --quiet "stopped $subsys"
done
# Now run the START scripts.
@@ -97,11 +100,13 @@ for i in /etc/rc$runlevel.d/S* ; do
update_boot_stage "$subsys"
# Bring the subsystem up.
+ [ -n "$UPSTART" ] && initctl emit --quiet "starting $subsys"
if [ "$subsys" = "halt" -o "$subsys" = "reboot" ]; then
export LC_ALL=C
exec $i start
fi
$i start
+ [ -n "$UPSTART" ] && initctl emit --quiet "started $subsys"
done
[ "$do_confirm" = "yes" ] && rm -f /var/run/confirm
if [ "$GRAPHICAL" = "yes" ]; then
diff --git a/src/Makefile b/src/Makefile
index 5c23a8fe..887e2373 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -2,7 +2,7 @@ CFLAGS+=$(RPM_OPT_FLAGS) -Wall -D_GNU_SOURCE
PROGS=usernetctl doexec netreport testd usleep ipcalc initlog \
fstab-decode getkey ppp-watch consoletype genhostid rename_device \
- console_init
+ console_init console_check
PPPWATCH_OBJS=ppp-watch.o shvar.o
CONSOLE_INIT_OBJS=console_init.o shvar.o
INITLOG_OBJS=initlog.o process.o
@@ -30,6 +30,7 @@ install:
install -m 755 consoletype $(ROOT)/sbin/consoletype
install -m 755 rename_device $(ROOT)/lib/udev/rename_device
install -m 755 console_init $(ROOT)/lib/udev/console_init
+ install -m 755 console_check $(ROOT)/lib/udev/console_check
install -m 755 ccw_init $(ROOT)/lib/udev/ccw_init
install -m 644 initlog.1 $(ROOT)$(mandir)/man1
install -m 644 genhostid.1 $(ROOT)$(mandir)/man1
diff --git a/src/console_check.c b/src/console_check.c
new file mode 100644
index 00000000..243e9be5
--- /dev/null
+++ b/src/console_check.c
@@ -0,0 +1,154 @@
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <termios.h>
+#include <unistd.h>
+
+#include <sys/ioctl.h>
+
+#include <linux/serial.h>
+
+struct speeds
+{
+ speed_t speed;
+ unsigned long value;
+};
+
+struct speeds speed_map[] =
+{
+ {B50, 50},
+ {B75, 75},
+ {B110, 110},
+ {B134, 134},
+ {B150, 150},
+ {B200, 200},
+ {B300, 300},
+ {B600, 600},
+ {B1200, 1200},
+ {B1800, 1800},
+ {B2400, 2400},
+ {B4800, 4800},
+ {B9600, 9600},
+ {B19200, 19200},
+ {B38400, 38400},
+#ifdef B57600
+ {B57600, 57600},
+#endif
+#ifdef B115200
+ {B115200, 115200},
+#endif
+#ifdef B230400
+ {B230400, 230400},
+#endif
+#ifdef B460800
+ {B460800, 460800},
+#endif
+ {0, 0}
+};
+
+int termcmp(struct termios *a, struct termios *b) {
+ if (a->c_iflag != b->c_iflag || a->c_oflag != b->c_oflag ||
+ a->c_cflag != b->c_cflag || a->c_lflag != b->c_lflag ||
+ a->c_ispeed != b->c_ispeed || a->c_ospeed != b->c_ospeed)
+ return 1;
+ return memcmp(a->c_cc, b->c_cc, sizeof(a->c_cc));
+}
+
+int get_serial_speed(int fd) {
+ struct termios mode;
+
+ if (!tcgetattr(fd, &mode)) {
+ int i;
+ speed_t speed;
+
+ speed = cfgetospeed(&mode);
+ for (i = 0; speed_map[i].value != 0; i++)
+ if (speed_map[i].speed == speed)
+ return speed_map[i].value;
+ }
+ return 0;
+}
+
+int compare_termios_to_console(char *dev, int *speed) {
+ struct termios cmode, mode;
+ int fd, cfd;
+
+ cfd = open ("/dev/console", O_RDONLY);
+ tcgetattr(cfd, &cmode);
+ close(cfd);
+
+ fd = open(dev, O_RDONLY);
+ tcgetattr(fd, &mode);
+
+ if (!termcmp(&cmode, &mode)) {
+ *speed = get_serial_speed(fd);
+ close(fd);
+ return 1;
+ }
+ close(fd);
+ return 0;
+}
+
+char *check_serial_console(int *speed) {
+ int fd;
+ char *ret = NULL, *device;
+ char twelve = 12;
+ struct serial_struct si, si2;
+
+ fd = open("/dev/console", O_RDWR);
+ if (ioctl (fd, TIOCLINUX, &twelve) >= 0)
+ goto out;
+
+ if (ioctl(fd, TIOCGSERIAL, &si) < 0)
+ goto out;
+ close(fd);
+
+ asprintf(&device, "ttyS%d", si.line);
+ fd = open(device, O_RDWR|O_NONBLOCK);
+ if (fd == -1)
+ goto out;
+
+ if (ioctl(fd, TIOCGSERIAL, &si2) < 0)
+ goto out;
+
+ if (memcmp(&si,&si2, sizeof(si)))
+ goto out;
+
+ *speed = get_serial_speed(fd);
+ ret = device;
+out:
+ close(fd);
+ return ret;
+}
+
+int emit_console_event(char *dev, int speed) {
+ char *args[] = { "initctl", "emit", "--no-wait", "fedora.serial-console-available", NULL, NULL, NULL };
+
+ args[4] = dev;
+ if (speed)
+ asprintf(&args[5],"%d",speed);
+ execv("/sbin/initctl", args);
+ return 1;
+}
+
+int main(int argc, char **argv) {
+ char *device;
+ int speed;
+
+ if (argc < 2) {
+ printf("usage: console_check <device>\n");
+ exit(1);
+ }
+ chdir("/dev");
+ device = argv[1];
+ if (!strcmp(device, "console")) {
+ device = check_serial_console(&speed);
+ if (device)
+ return emit_console_event(device, speed);
+ } else if (compare_termios_to_console(device, &speed)) {
+ return emit_console_event(device, speed);
+ }
+ return 0;
+}
diff --git a/udev/rules.d/10-console.rules b/udev/rules.d/10-console.rules
index da0cfe0d..6e8c4587 100644
--- a/udev/rules.d/10-console.rules
+++ b/udev/rules.d/10-console.rules
@@ -1 +1,9 @@
+# Console initialization - keyboard, font, etc.
KERNEL=="tty0", RUN+="/lib/udev/console_init %k"
+
+# Check and set up serial and serial-like consoles if necessary
+KERNEL=="console", RUN+="/lib/udev/console_check %k"
+KERNEL=="ttySG*", RUN+="/lib/udev/console_check %k"
+KERNEL=="xvc*", RUN+="/lib/udev/console_check %k"
+KERNEL=="hvsi*", RUN+="/lib/udev/console_check %k"
+KERNEL=="hvc*", RUN+="/lib/udev/console_check %k"