mirror of
https://github.com/troglobit/finit.git
synced 2026-10-12 10:12:32 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
821a6853fe | ||
|
|
dbdf8ccc72 | ||
|
|
b2f143e623 | ||
|
|
2ffafc3d03 | ||
|
|
3158733ced | ||
|
|
1aa6358611 | ||
|
|
ce998373e5 | ||
|
|
d0b6457f01 | ||
|
|
349593d41b | ||
|
|
b8daa9c869 | ||
|
|
f21b0a2580 | ||
|
|
4e18bc3724 | ||
|
|
90c8c73470 | ||
|
|
c8e7b34b4c | ||
|
|
6ff7f2e52b | ||
|
|
b6bf00ed06 | ||
|
|
136dfeb41a | ||
|
|
7867db7b23 | ||
|
|
75d755afad | ||
|
|
01509376cc | ||
|
|
c55afaadb3 | ||
|
|
ccd49f2024 | ||
|
|
0fdf97653f | ||
|
|
9d164ac312 | ||
|
|
5acd2cd441 | ||
|
|
1f7eab37a0 | ||
|
|
d87fb47cf3 | ||
|
|
7caf633259 | ||
|
|
ba6470f5a6 | ||
|
|
fa23155593 | ||
|
|
996cb2ec1e | ||
|
|
4e3d6ec976 | ||
|
|
0857a0846f | ||
|
|
a3ad99798e | ||
|
|
c79b823f17 | ||
|
|
71ce4b98e9 | ||
|
|
9908a6e680 | ||
|
|
f94a76ed17 | ||
|
|
6fc2a6b108 | ||
|
|
a52c932085 | ||
|
|
2e7952645a | ||
|
|
494f182b13 | ||
|
|
5ad9ff48c5 | ||
|
|
b5e2af21a6 | ||
|
|
eb5445628f | ||
|
|
89854a579f | ||
|
|
1c88ae1f61 | ||
|
|
f972ff4d30 | ||
|
|
904c12d06a | ||
|
|
a85b0cf481 | ||
|
|
286711237d | ||
|
|
434ec4c533 | ||
|
|
6371f82fea | ||
|
|
b2233a6f4b | ||
|
|
6c807c3a95 | ||
|
|
e4f675fa1a | ||
|
|
880b5f8a92 | ||
|
|
c8f171556b | ||
|
|
2a9bfa7fd7 | ||
|
|
98624a3d21 | ||
|
|
6565cc67ee | ||
|
|
08d0dc6ee9 | ||
|
|
6e2ea43e97 | ||
|
|
2679c1b1c5 | ||
|
|
d05900368f | ||
|
|
a1de36c163 | ||
|
|
8206803762 | ||
|
|
fb8c341168 | ||
|
|
7137573534 |
@@ -1,5 +1,22 @@
|
|||||||
|
O.4 (20080516)
|
||||||
|
- default username for finit-alt configurable in Makefile
|
||||||
|
- create loopback device node in finit-alt (for squashfs)
|
||||||
|
- add option to use built-in run-parts instead of /bin/run-parts
|
||||||
|
- ignore signal instead of setting to an empty handler (Metalshark)
|
||||||
|
- handle pam_console permissions in finit-alt for Mandriva
|
||||||
|
- add services.sh example and nash-hotplug patch for Mandriva
|
||||||
|
- mount /proc/bus/usb in Mandriva
|
||||||
|
- add runtime debug to finit-alt if finit_debug parameter is specified
|
||||||
|
- read configuration from /etc/finit.conf
|
||||||
|
- run getty with openvt on the virtual terminal
|
||||||
|
|
||||||
0.2 ()
|
0.3 (20080223)
|
||||||
|
- Change poweroff method to reboot(RB_POWER_OFF) (Metalshark)
|
||||||
|
- Remove duplicate unionctl() reimplementation error
|
||||||
|
- Fix string termination in path creation
|
||||||
|
- Mount /var/lock and /var/run as tmpfs
|
||||||
|
|
||||||
|
0.2 (20080219)
|
||||||
- replace system("touch") with touch() in finit-mod (Metalshark)
|
- replace system("touch") with touch() in finit-mod (Metalshark)
|
||||||
- disable NO_HCTOSYS by default to match stock Eeepc kernel
|
- disable NO_HCTOSYS by default to match stock Eeepc kernel
|
||||||
- drop system("rm -f") to clean /tmp, its a fresh mounted tmpfs
|
- drop system("rm -f") to clean /tmp, its a fresh mounted tmpfs
|
||||||
|
|||||||
@@ -3,17 +3,18 @@ CFLAGS = -Os -Wall -DVERSION=\"$(VERSION)\" -DWHOAMI=\"`whoami`@`hostname`\"
|
|||||||
LD = gcc
|
LD = gcc
|
||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
LIBS =
|
LIBS =
|
||||||
VERSION = 0.2
|
VERSION = 0.4
|
||||||
PKG = finit-$(VERSION)
|
PKG = finit-$(VERSION)
|
||||||
DFILES = Makefile README finit.c finit-mod.c finit-alt.c helpers.c helpers.h
|
DFILES = Makefile README finit.c finit-mod.c finit-alt.c helpers.c helpers.h \
|
||||||
|
patches/*patch contrib/services.sh*
|
||||||
|
BINS = finit finit-mod finit-mdv
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Configurable parameters
|
#### Configurable parameters
|
||||||
|
|
||||||
# Add -DDEBUG to build with debug messages, also drops to terminal after X
|
# Default user for finit-alt if not "user"
|
||||||
#CFLAGS += -DDEBUG
|
#DEFUSER = fred
|
||||||
|
|
||||||
# Parameters added by Metalshark
|
|
||||||
|
|
||||||
# Use -march=pentium-m to build for Eeepc
|
# Use -march=pentium-m to build for Eeepc
|
||||||
CFLAGS += -march=pentium-m
|
CFLAGS += -march=pentium-m
|
||||||
@@ -21,17 +22,26 @@ CFLAGS += -march=pentium-m
|
|||||||
# Omit the first /sbin/hwclock if CONFIG_RTC_HCTOSYS is enabled in the kernel
|
# Omit the first /sbin/hwclock if CONFIG_RTC_HCTOSYS is enabled in the kernel
|
||||||
#CFLAGS += -DNO_HCTOSYS
|
#CFLAGS += -DNO_HCTOSYS
|
||||||
|
|
||||||
# Append –directisa to /sbin/hwclock lines if the user has disabled
|
# Append -directisa to /sbin/hwclock lines if the user has disabled
|
||||||
# CONFIG_GENRTC and enabled CONFIG_RTC but not enabled CONFIG_HPET_TIMER
|
# CONFIG_GENRTC and enabled CONFIG_RTC but not enabled CONFIG_HPET_TIMER
|
||||||
# and CONFIG_HPET_RTC_IRQ.
|
# and CONFIG_HPET_RTC_IRQ.
|
||||||
#CFLAGS += -DDIRECTISA
|
#CFLAGS += -DDIRECTISA
|
||||||
|
|
||||||
|
# Use built-in run-parts instead of /bin/run-parts
|
||||||
|
CFLAGS += -DBUILTIN_RUNPARTS
|
||||||
|
|
||||||
|
#### End of configurable parameters
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ifneq ($(DEFUSER),)
|
||||||
|
CFLAGS += -DDEFUSER=\"$(DEFUSER)\"
|
||||||
|
endif
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
$(CC) -c $(CFLAGS) -o $*.o $<
|
$(CC) -c $(CFLAGS) -o $*.o $<
|
||||||
|
|
||||||
all: finit finit-mod finit-mdv
|
all: $(BINS)
|
||||||
|
|
||||||
finit: finit.o
|
finit: finit.o
|
||||||
$(LD) $(LDFLAGS) -o $@ $+ $(LIBS)
|
$(LD) $(LDFLAGS) -o $@ $+ $(LIBS)
|
||||||
@@ -49,16 +59,19 @@ finit-mdv.o: finit-alt.c Makefile
|
|||||||
$(CC) -c $(CFLAGS) -DDIST_MDV -o $@ finit-alt.c
|
$(CC) -c $(CFLAGS) -DDIST_MDV -o $@ finit-alt.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o core *~
|
rm -f *.o core *~ $(BINS)
|
||||||
|
|
||||||
finit.o: finit.c Makefile
|
finit.o: finit.c Makefile
|
||||||
|
|
||||||
finit-mod.o: finit-mod.c Makefile
|
finit-mod.o: finit-mod.c Makefile
|
||||||
|
|
||||||
|
helpers.o: helpers.c Makefile
|
||||||
|
|
||||||
dist:
|
dist:
|
||||||
rm -Rf $(PKG)
|
rm -Rf $(PKG)
|
||||||
mkdir $(PKG)
|
mkdir -p $(PKG)/contrib $(PKG)/patches
|
||||||
cp Makefile $(DFILES) $(PKG)
|
for i in $(DFILES); do cp $$i $(PKG)/`dirname $$i`; done
|
||||||
tar cf - $(PKG) | gzip -c > $(PKG).tar.gz
|
tar cf - $(PKG) | gzip -c > $(PKG).tar.gz
|
||||||
rm -Rf $(PKG)
|
rm -Rf $(PKG)
|
||||||
ls -l $(PKG).tar.gz
|
ls -l $(PKG).tar.gz
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,14 @@ Eeepc "fastinit" reimplementations
|
|||||||
|
|
||||||
finit.c is a reimplementation of the Asus Eeepc fastinit program based
|
finit.c is a reimplementation of the Asus Eeepc fastinit program based
|
||||||
on its library calls. It tries to be an accurate re-creation and keeps
|
on its library calls. It tries to be an accurate re-creation and keeps
|
||||||
the original bugs and lack of optimization.
|
the original bugs and unoptimized calls.
|
||||||
|
|
||||||
finit-mod.c is a fixed/improved version of finit.c.
|
finit-mod.c is a fixed/improved version of finit.c intended to be a drop-in
|
||||||
|
replacement for the original Eeepc OS.
|
||||||
|
|
||||||
finit-alt.c is a fixed/improved version of finit.c for alternative Linux
|
finit-alt.c is a fixed/improved version of finit.c for alternative Linux
|
||||||
distributions running on the Eeepc (previously ffinit.c). Currently able
|
distributions running on the Eeepc (previously ffinit.c). It's currently
|
||||||
to boot unmodified Mandriva Linux.
|
able to boot Mandriva Linux 2008.0/2008.1.
|
||||||
|
|
||||||
See Makefile for configurable parameters to better suit your system.
|
See Makefile for configurable parameters to better suit your system.
|
||||||
|
|
||||||
@@ -49,27 +50,19 @@ umount vi
|
|||||||
console fb null ram0 sda1 sda2 sda3 sr0 tty0
|
console fb null ram0 sda1 sda2 sda3 sr0 tty0
|
||||||
|
|
||||||
|
|
||||||
|
Reboot and poweroff
|
||||||
|
-------------------
|
||||||
|
|
||||||
Using finit with alternative systems
|
Stock reboot and poweroff utilities of a modern Linux distribution may not
|
||||||
------------------------------------
|
work correctly with finit. You can replace them with simple scripts that
|
||||||
|
send SIGUSR1 to finit for reboot, SIGUSR2 for poweroff.
|
||||||
|
|
||||||
Currently tested only with Mandriva 2008. Proceed with caution, there are
|
|
||||||
problems related to udev and pam.
|
|
||||||
|
|
||||||
1 - Add init=/sbin/finit-mdv to the kernel boot line
|
Using finit with KDE
|
||||||
|
--------------------
|
||||||
|
|
||||||
2 - Provide a suitable /usr/sbin/services.sh, this is the one I use in my
|
If you use finit to start KDE with auto-login enabled, hal-based device
|
||||||
test system:
|
automounting may not work correctly. That happens because the session
|
||||||
|
is started before the system message bus, so add a "dcop kded mediamanager
|
||||||
mkdir /var/lock/subsys
|
reloadBackends" call in the user AutoStart to restart the client.
|
||||||
chmod 1777 /var/lock/subsys
|
|
||||||
/etc/init.d/network start
|
|
||||||
dhclient eth0
|
|
||||||
/sbin/start_udev&
|
|
||||||
/etc/init.d/portmap start
|
|
||||||
/etc/init.d/nfs-common start
|
|
||||||
|
|
||||||
3 - Provide /etc/hostname if you don't have it already
|
|
||||||
|
|
||||||
4 - Set the pointer device in the X server configuration to /dev/input/mice
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
Mandriva 2008
|
||||||
|
-------------
|
||||||
|
|
||||||
|
1 - Add init=/sbin/finit-mdv to the kernel boot line
|
||||||
|
|
||||||
|
2 - Provide a suitable /usr/sbin/services.sh, this is the one I use in my
|
||||||
|
test system running e17:
|
||||||
|
|
||||||
|
mkdir /var/lock/subsys
|
||||||
|
chmod 1777 /var/lock/subsys
|
||||||
|
/etc/init.d/network start
|
||||||
|
dhclient eth0
|
||||||
|
/sbin/start_udev&
|
||||||
|
/etc/init.d/portmap start
|
||||||
|
/etc/init.d/nfs-common start
|
||||||
|
|
||||||
|
If you use KDE or need more services, see examples in contrib/
|
||||||
|
|
||||||
|
3 - Create /etc/finit.conf with user, module, filesystems to check and
|
||||||
|
hostname parameters. See the included finit.conf for more information.
|
||||||
|
If no user is specified, user "user" will be used as default.
|
||||||
|
|
||||||
|
4 - Set the pointer device in the X server configuration to /dev/input/mice
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Mandriva 2008.1
|
||||||
|
---------------
|
||||||
|
|
||||||
|
If you have a stuck nash-hotplug consuming 100% of CPU after the boot, you
|
||||||
|
may want to patch mkinitrd using patches/mkinitrd-6.0.34-nash-hotplug.patch
|
||||||
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Example /usr/sbin/services.sh that can be used in a Mandriva 2008 system
|
||||||
|
# running KDE
|
||||||
|
|
||||||
|
mkdir /var/lock/subsys
|
||||||
|
chmod 1777 /var/lock/subsys
|
||||||
|
/sbin/start_udev
|
||||||
|
mkdir /var/run/dbus
|
||||||
|
/etc/init.d/messagebus start
|
||||||
|
/etc/init.d/haldaemon start
|
||||||
|
/etc/init.d/alsa start
|
||||||
|
/etc/init.d/sound start
|
||||||
|
/etc/init.d/crond start
|
||||||
|
/etc/init.d/network-up start
|
||||||
|
/etc/init.d/network start
|
||||||
|
#/etc/init.d/sshd start
|
||||||
|
/etc/init.d/syslog start
|
||||||
|
/sbin/pam_console_apply
|
||||||
|
#kbuildsycoca --noincremental
|
||||||
+144
-80
@@ -40,12 +40,8 @@ THE SOFTWARE.
|
|||||||
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifndef DEFUSER
|
||||||
#define debug(x...) do { \
|
#define DEFUSER "user"
|
||||||
printf("finit: %d: ", __LINE__); printf(x); printf("\n"); \
|
|
||||||
} while (0)
|
|
||||||
#else
|
|
||||||
#define debug(x...)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Distribution configuration */
|
/* Distribution configuration */
|
||||||
@@ -53,19 +49,16 @@ THE SOFTWARE.
|
|||||||
#ifdef DIST_MDV /* Mandriva */
|
#ifdef DIST_MDV /* Mandriva */
|
||||||
#define RANDOMSEED "/var/lib/random-seed"
|
#define RANDOMSEED "/var/lib/random-seed"
|
||||||
#define SYSROOT "/sysroot"
|
#define SYSROOT "/sysroot"
|
||||||
#define GETTY "/sbin/mingetty tty3"
|
#define GETTY "/usr/bin/openvt /sbin/mingetty tty2"
|
||||||
#define RUNPARTS "/usr/bin/run-parts --arg=-i"
|
#define RUNPARTS "/usr/bin/run-parts"
|
||||||
#define DEFUSER "user"
|
|
||||||
#define HOMEDEV "/dev/sda6"
|
|
||||||
#define AGPDRV "intel-agp"
|
|
||||||
#define REMOUNT_ROOTFS_RW
|
#define REMOUNT_ROOTFS_RW
|
||||||
#define MAKE_DEVICES
|
#define MAKE_DEVICES
|
||||||
|
#define PAM_CONSOLE
|
||||||
#else /* original Eeepc distribution */
|
#else /* original Eeepc distribution */
|
||||||
#define RANDOMSEED "/var/lib/urandom/random-seed"
|
#define RANDOMSEED "/var/lib/urandom/random-seed"
|
||||||
#define SYSROOT "/mnt"
|
#define SYSROOT "/mnt"
|
||||||
#define GETTY "/sbin/getty 38400 tty3"
|
#define GETTY "/usr/bin/openvt /sbin/getty 38400 tty2"
|
||||||
#define RUNPARTS "/bin/run-parts --arg=-i"
|
#define RUNPARTS "/bin/run-parts"
|
||||||
#define DEFUSER "user"
|
|
||||||
#define TOUCH_ETC_NETWORK_RUN_IFSTATE
|
#define TOUCH_ETC_NETWORK_RUN_IFSTATE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -88,26 +81,50 @@ THE SOFTWARE.
|
|||||||
|
|
||||||
#define touch(x) mknod((x), S_IFREG|0644, 0)
|
#define touch(x) mknod((x), S_IFREG|0644, 0)
|
||||||
#define chardev(x,m,maj,min) mknod((x), S_IFCHR|(m), makedev((maj),(min)))
|
#define chardev(x,m,maj,min) mknod((x), S_IFCHR|(m), makedev((maj),(min)))
|
||||||
|
#define blkdev(x,m,maj,min) mknod((x), S_IFBLK|(m), makedev((maj),(min)))
|
||||||
|
|
||||||
|
#define MATCH_CMD(l,c,x) \
|
||||||
|
((!strncmp((l), (c), strlen((c)))) && ((x) = (l) + strlen((c))))
|
||||||
|
|
||||||
|
#define LINE_SIZE 1024
|
||||||
|
#define CMD_SIZE 256
|
||||||
|
#define USERNAME_SIZE 16
|
||||||
|
#define HOSTNAME_SIZE 32
|
||||||
|
|
||||||
void shutdown(int);
|
void shutdown(int);
|
||||||
void signal_handler(int);
|
void signal_handler(int);
|
||||||
void chld_handler(int);
|
void chld_handler(int);
|
||||||
|
|
||||||
|
static int debug = 0;
|
||||||
|
|
||||||
|
static void build_cmd(char *cmd, char *x, int len)
|
||||||
|
{
|
||||||
|
int l;
|
||||||
|
char *c;
|
||||||
|
|
||||||
|
c = cmd + strlen(cmd);
|
||||||
|
for (; *x && (*x == ' ' || *x == '\t'); x++);
|
||||||
|
for (l = 0; *x && *x != ' ' && *x != '\t' && l < len; l++)
|
||||||
|
*c++ = *x++;
|
||||||
|
*c = 0;
|
||||||
|
if (debug)
|
||||||
|
printf("cmd = %s\n", cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char line[2096];
|
char line[LINE_SIZE];
|
||||||
int fd;
|
int fd;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *d;
|
struct dirent *d;
|
||||||
char filename[1024];
|
|
||||||
struct sigaction sa, act;
|
struct sigaction sa, act;
|
||||||
char hline[1024];
|
|
||||||
char *x;
|
|
||||||
sigset_t nmask, nmask2;
|
sigset_t nmask, nmask2;
|
||||||
|
char username[USERNAME_SIZE] = DEFUSER;
|
||||||
|
char hostname[HOSTNAME_SIZE] = "eviltwin";
|
||||||
|
char cmd[CMD_SIZE];
|
||||||
|
|
||||||
puts("finit-alt " VERSION " (built " __DATE__ " by " WHOAMI ")");
|
puts("finit-alt " VERSION " (built " __DATE__ " by " WHOAMI ")");
|
||||||
|
|
||||||
@@ -120,15 +137,15 @@ int main()
|
|||||||
for (i = 1; i < NSIG; i++)
|
for (i = 1; i < NSIG; i++)
|
||||||
SETSIG(sa, i, SIG_IGN, SA_RESTART);
|
SETSIG(sa, i, SIG_IGN, SA_RESTART);
|
||||||
|
|
||||||
SETSIG(sa, SIGINT, shutdown, 0);
|
SETSIG(sa, SIGINT, shutdown, 0);
|
||||||
SETSIG(sa, SIGPWR, signal_handler, 0);
|
SETSIG(sa, SIGPWR, SIG_IGN, 0);
|
||||||
SETSIG(sa, SIGUSR1, shutdown, 0);
|
SETSIG(sa, SIGUSR1, shutdown, 0);
|
||||||
SETSIG(sa, SIGUSR2, shutdown, 0);
|
SETSIG(sa, SIGUSR2, shutdown, 0);
|
||||||
SETSIG(sa, SIGTERM, signal_handler, 0);
|
SETSIG(sa, SIGTERM, SIG_IGN, 0);
|
||||||
SETSIG(sa, SIGALRM, signal_handler, 0);
|
SETSIG(sa, SIGALRM, SIG_IGN, 0);
|
||||||
SETSIG(sa, SIGHUP, signal_handler, 0);
|
SETSIG(sa, SIGHUP, SIG_IGN, 0);
|
||||||
SETSIG(sa, SIGCONT, signal_handler, SA_RESTART);
|
SETSIG(sa, SIGCONT, SIG_IGN, SA_RESTART);
|
||||||
SETSIG(sa, SIGCHLD, chld_handler, SA_RESTART);
|
SETSIG(sa, SIGCHLD, chld_handler, SA_RESTART);
|
||||||
|
|
||||||
/* Block sigchild while forking */
|
/* Block sigchild while forking */
|
||||||
sigemptyset(&nmask);
|
sigemptyset(&nmask);
|
||||||
@@ -137,18 +154,59 @@ int main()
|
|||||||
|
|
||||||
reboot(RB_DISABLE_CAD);
|
reboot(RB_DISABLE_CAD);
|
||||||
|
|
||||||
mount("proc", "/proc", "proc", 0, NULL);
|
mount("none", "/proc", "proc", 0, NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse kernel parameters
|
* Parse kernel parameters
|
||||||
*/
|
*/
|
||||||
if ((f = fopen("/proc/cmdline", "r")) != NULL) {
|
if ((f = fopen("/proc/cmdline", "r")) != NULL) {
|
||||||
fgets(line, 2095, f);
|
fgets(line, LINE_SIZE, f);
|
||||||
if (strstr(line, "quiet")) {
|
if (strstr(line, "quiet")) {
|
||||||
close(0);
|
close(0);
|
||||||
close(1);
|
close(1);
|
||||||
close(2);
|
close(2);
|
||||||
}
|
}
|
||||||
|
if ((strstr(line, "finit_debug"))) {
|
||||||
|
debug = 1;
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parse configuration file
|
||||||
|
*/
|
||||||
|
if ((f = fopen("/etc/finit.conf", "r")) != NULL) {
|
||||||
|
char *x;
|
||||||
|
while (!feof(f)) {
|
||||||
|
fgets(line, LINE_SIZE, f);
|
||||||
|
chomp(line);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
printf("conf: %s\n", line);
|
||||||
|
|
||||||
|
if (MATCH_CMD(line, "check ", x)) {
|
||||||
|
strcpy(cmd, "/sbin/fsck -C -a ");
|
||||||
|
build_cmd(cmd, x, CMD_SIZE);
|
||||||
|
system(cmd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (MATCH_CMD(line, "user ", x)) {
|
||||||
|
*username = 0;
|
||||||
|
build_cmd(username, x, USERNAME_SIZE);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (MATCH_CMD(line, "host ", x)) {
|
||||||
|
*hostname = 0;
|
||||||
|
build_cmd(hostname, x, HOSTNAME_SIZE);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (MATCH_CMD(line, "module ", x)) {
|
||||||
|
strcpy(cmd, "/sbin/modprobe ");
|
||||||
|
build_cmd(cmd, x, CMD_SIZE);
|
||||||
|
system(cmd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,27 +215,26 @@ int main()
|
|||||||
/*
|
/*
|
||||||
* Mount filesystems
|
* Mount filesystems
|
||||||
*/
|
*/
|
||||||
debug("mount filesystems");
|
|
||||||
|
|
||||||
#ifdef REMOUNT_ROOTFS_RW
|
#ifdef REMOUNT_ROOTFS_RW
|
||||||
system("/bin/mount -n -o remount,rw /");
|
system("/bin/mount -n -o remount,rw /");
|
||||||
#endif
|
#endif
|
||||||
umask(0);
|
umask(0);
|
||||||
|
|
||||||
|
#ifdef MAKE_DEVICES
|
||||||
mkdir("/dev/shm", 0755);
|
mkdir("/dev/shm", 0755);
|
||||||
mkdir("/dev/pts", 0755);
|
mkdir("/dev/pts", 0755);
|
||||||
|
#endif
|
||||||
|
|
||||||
mount("sysfs", "/sys", "sysfs", 0, NULL);
|
mount("none", "/sys", "sysfs", 0, NULL);
|
||||||
mount("devpts", "/dev/pts", "devpts", 0, "gid=5,mode=620");
|
mount("none", "/dev/pts", "devpts", 0, "gid=5,mode=620");
|
||||||
mount("tmpfs", "/dev/shm", "tmpfs", 0, NULL);
|
mount("none", "/dev/shm", "tmpfs", 0, NULL);
|
||||||
mount("tmpfs", "/tmp", "tmpfs", 0, "mode=1777,size=128m");
|
mount("none", "/tmp", "tmpfs", 0, "mode=1777,size=128m");
|
||||||
|
mount("none", "/var/run", "tmpfs", 0, "mode=0755");
|
||||||
|
mount("none", "/var/lock", "tmpfs", 0, "mode=1777");
|
||||||
|
mount("none", "/proc/bus/usb", "usbfs", 0, NULL);
|
||||||
mount(SYSROOT, "/", NULL, MS_MOVE, NULL);
|
mount(SYSROOT, "/", NULL, MS_MOVE, NULL);
|
||||||
|
|
||||||
unlink("/etc/mtab");
|
|
||||||
system("mount -a");
|
|
||||||
|
|
||||||
#ifdef MAKE_DEVICES
|
#ifdef MAKE_DEVICES
|
||||||
debug("make devices");
|
|
||||||
mkdir("/dev/input", 0755);
|
mkdir("/dev/input", 0755);
|
||||||
chardev("/dev/urandom", 0666, 1, 9);
|
chardev("/dev/urandom", 0666, 1, 9);
|
||||||
chardev("/dev/ptmx", 0666, 5, 2);
|
chardev("/dev/ptmx", 0666, 5, 2);
|
||||||
@@ -185,12 +242,16 @@ int main()
|
|||||||
chardev("/dev/mem", 0640, 1, 1);
|
chardev("/dev/mem", 0640, 1, 1);
|
||||||
chmod("/dev/null", 0667);
|
chmod("/dev/null", 0667);
|
||||||
chmod("/dev/mem", 0640);
|
chmod("/dev/mem", 0640);
|
||||||
chardev("/dev/tty", 0666, 5, 0);
|
chardev("/dev/tty0", 0660, 4, 0);
|
||||||
chardev("/dev/input/mice", 0660, 13, 63);
|
chardev("/dev/input/mice", 0660, 13, 63);
|
||||||
chardev("/dev/input/event0", 0660, 13, 64);
|
chardev("/dev/input/event0", 0660, 13, 64);
|
||||||
chardev("/dev/agpgart", 0660, 10, 175);
|
chardev("/dev/agpgart", 0660, 10, 175);
|
||||||
|
blkdev("/dev/loop0", 0600, 7, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
unlink("/etc/mtab");
|
||||||
|
system("mount -a");
|
||||||
|
|
||||||
umask(0022);
|
umask(0022);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -214,9 +275,9 @@ int main()
|
|||||||
while ((d = readdir(dir)) != NULL) {
|
while ((d = readdir(dir)) != NULL) {
|
||||||
if (isalnum(d->d_name[0]))
|
if (isalnum(d->d_name[0]))
|
||||||
continue;
|
continue;
|
||||||
sprintf(filename, "/etc/resolvconf/run/interface/%s",
|
snprintf(line, LINE_SIZE,
|
||||||
d->d_name);
|
"/etc/resolvconf/run/interface/%s", d->d_name);
|
||||||
unlink(filename);
|
unlink(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
@@ -226,7 +287,11 @@ int main()
|
|||||||
touch("/etc/resolvconf/run/enable-updates");
|
touch("/etc/resolvconf/run/enable-updates");
|
||||||
|
|
||||||
chdir("/etc/resolvconf/run/interface");
|
chdir("/etc/resolvconf/run/interface");
|
||||||
system(RUNPARTS " /etc/resolvconf/update.d");
|
#ifdef BUILTIN_RUNPARTS
|
||||||
|
run_parts("/etc/resolvconf/update.d", "-i", NULL);
|
||||||
|
#else
|
||||||
|
system(RUNPARTS " --arg=i /etc/resolvconf/update.d");
|
||||||
|
#endif
|
||||||
chdir("/");
|
chdir("/");
|
||||||
|
|
||||||
#ifdef TOUCH_ETC_NETWORK_RUN_IFSTATE
|
#ifdef TOUCH_ETC_NETWORK_RUN_IFSTATE
|
||||||
@@ -234,14 +299,13 @@ int main()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((f = fopen("/etc/hostname", "r")) != NULL) {
|
if ((f = fopen("/etc/hostname", "r")) != NULL) {
|
||||||
fgets(hline, 1023, f);
|
fgets(hostname, HOSTNAME_SIZE, f);
|
||||||
if ((x = strchr(hline, 0x0a)) != NULL)
|
chomp(hostname);
|
||||||
*x = 0;
|
|
||||||
|
|
||||||
sethostname(hline, strlen(hline));
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sethostname(hostname, strlen(hostname));
|
||||||
|
|
||||||
ifconfig("lo", "127.0.0.1", "255.0.0.0", 1);
|
ifconfig("lo", "127.0.0.1", "255.0.0.0", 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -251,18 +315,31 @@ int main()
|
|||||||
unlink(RANDOMSEED);
|
unlink(RANDOMSEED);
|
||||||
umask(077);
|
umask(077);
|
||||||
copyfile("/dev/urandom", RANDOMSEED, 4096);
|
copyfile("/dev/urandom", RANDOMSEED, 4096);
|
||||||
|
umask(0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Console setup (for X)
|
||||||
|
*/
|
||||||
|
makepath("/var/run/console");
|
||||||
|
snprintf(line, LINE_SIZE, "/var/run/console/%s", username);
|
||||||
|
touch(line);
|
||||||
|
|
||||||
|
#ifdef PAM_CONSOLE
|
||||||
|
if ((fd = open("/var/run/console/console.lock", O_CREAT|O_WRONLY|O_TRUNC, 0644)) >= 0) {
|
||||||
|
write(fd, username, strlen(username));
|
||||||
|
close(fd);
|
||||||
|
system("/sbin/pam_console_apply");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Misc setup
|
* Misc setup
|
||||||
*/
|
*/
|
||||||
unlink("/var/run/.clean");
|
|
||||||
unlink("/var/lock/.clean");
|
|
||||||
umask(0);
|
|
||||||
mkdir("/tmp/.X11-unix", 01777);
|
mkdir("/tmp/.X11-unix", 01777);
|
||||||
mkdir("/tmp/.ICE-unix", 01777);
|
mkdir("/tmp/.ICE-unix", 01777);
|
||||||
umask(022);
|
umask(022);
|
||||||
|
|
||||||
debug("forking");
|
system(GETTY "&");
|
||||||
|
|
||||||
if (!fork()) {
|
if (!fork()) {
|
||||||
/* child process */
|
/* child process */
|
||||||
@@ -273,7 +350,7 @@ int main()
|
|||||||
close(1);
|
close(1);
|
||||||
close(0);
|
close(0);
|
||||||
|
|
||||||
if (open("/dev/tty1", O_RDWR, 0))
|
if (open("/dev/tty1", O_RDWR) != 0)
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
sigemptyset(&act.sa_mask);
|
sigemptyset(&act.sa_mask);
|
||||||
@@ -298,13 +375,18 @@ int main()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (access("/tmp/shutdown", F_OK) < 0) {
|
while (access("/tmp/shutdown", F_OK) < 0) {
|
||||||
debug("start X as " DEFUSER);
|
if (debug) {
|
||||||
#ifdef DEBUG
|
printf("Starting X as %s\n", username);
|
||||||
system("su -c startx -l " DEFUSER);
|
snprintf(line, LINE_SIZE,
|
||||||
system("/bin/sh");
|
"su -c startx -l %s\n", username);
|
||||||
#else
|
system(line);
|
||||||
system("su -c startx -l " DEFUSER " &> /dev/null");
|
system("/bin/sh");
|
||||||
#endif
|
} else {
|
||||||
|
snprintf(line, LINE_SIZE,
|
||||||
|
"su -c startx -l %s\n &> /dev/null",
|
||||||
|
username);
|
||||||
|
system(line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
@@ -312,7 +394,6 @@ int main()
|
|||||||
|
|
||||||
/* parent process */
|
/* parent process */
|
||||||
|
|
||||||
system(GETTY "&");
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
system("/usr/sbin/services.sh &>/dev/null&");
|
system("/usr/sbin/services.sh &>/dev/null&");
|
||||||
|
|
||||||
@@ -328,9 +409,6 @@ int main()
|
|||||||
*/
|
*/
|
||||||
void shutdown(int sig)
|
void shutdown(int sig)
|
||||||
{
|
{
|
||||||
int fd;
|
|
||||||
|
|
||||||
debug("shutdown");
|
|
||||||
touch("/tmp/shutdown");
|
touch("/tmp/shutdown");
|
||||||
|
|
||||||
kill(-1, SIGTERM);
|
kill(-1, SIGTERM);
|
||||||
@@ -341,23 +419,18 @@ void shutdown(int sig)
|
|||||||
|
|
||||||
system("/usr/sbin/alsactl store > /dev/null 2>&1");
|
system("/usr/sbin/alsactl store > /dev/null 2>&1");
|
||||||
system("/sbin/hwclock --systohc --localtime" HWCLOCK_DIRECTISA);
|
system("/sbin/hwclock --systohc --localtime" HWCLOCK_DIRECTISA);
|
||||||
system("/sbin/unionctl.static / --remove / > /dev/null 2>&1");
|
|
||||||
|
|
||||||
kill(-1, SIGKILL);
|
kill(-1, SIGKILL);
|
||||||
|
|
||||||
sync();
|
sync();
|
||||||
sync();
|
sync();
|
||||||
system("/bin/mount -n -o remount,ro /");
|
system("/bin/mount -n -o remount,ro /");
|
||||||
|
|
||||||
system("/sbin/unionctl.static / --remove / > /dev/null 2>&1");
|
system("/sbin/unionctl.static / --remove / > /dev/null 2>&1");
|
||||||
|
|
||||||
if (sig == SIGINT || sig == SIGUSR1)
|
if (sig == SIGINT || sig == SIGUSR1)
|
||||||
reboot(RB_AUTOBOOT);
|
reboot(RB_AUTOBOOT);
|
||||||
|
|
||||||
if ((fd = open("/sys/power/state", O_WRONLY)) >= 0) {
|
reboot(RB_POWER_OFF);
|
||||||
write(fd, "5", 1);
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -374,12 +447,3 @@ void chld_handler(int sig)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We got a signal (PWR TERM ALRM HUP CONT)
|
|
||||||
*/
|
|
||||||
void signal_handler(int sig)
|
|
||||||
{
|
|
||||||
/* do nothing */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
+35
-39
@@ -38,6 +38,13 @@ Changelog from the original Eeepc fastinit:
|
|||||||
- Set loopback interface using direct calls instead of system("ifconfig")
|
- Set loopback interface using direct calls instead of system("ifconfig")
|
||||||
- Copy 4096 data block in C instead of system("cat") or system("dd")
|
- Copy 4096 data block in C instead of system("cat") or system("dd")
|
||||||
- Draw shutdown splash screen using C calls instead of system("echo;cat")
|
- Draw shutdown splash screen using C calls instead of system("echo;cat")
|
||||||
|
- Change poweroff method from writing 5 to /sys/power/state to
|
||||||
|
reboot(RB_POWER_OFF) (by Metalshark)
|
||||||
|
- Mount /var/run and /var/lock as tmpfs
|
||||||
|
- Use SIG_IGN instead of empty signal handler (by Metalshark)
|
||||||
|
- Add built-in run-parts option to be used instead of system("run-parts")
|
||||||
|
- Reuse cmdline buffer as hostname and filename buffers
|
||||||
|
- Open terminal in vt2 using openvt
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -78,9 +85,9 @@ Changelog from the original Eeepc fastinit:
|
|||||||
|
|
||||||
#define touch(x) mknod((x), S_IFREG|0644, 0)
|
#define touch(x) mknod((x), S_IFREG|0644, 0)
|
||||||
|
|
||||||
|
#define LINE_SIZE 1024
|
||||||
|
|
||||||
void shutdown(int);
|
void shutdown(int);
|
||||||
void signal_handler(int);
|
|
||||||
void chld_handler(int);
|
void chld_handler(int);
|
||||||
|
|
||||||
|
|
||||||
@@ -88,13 +95,11 @@ int main()
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char line[2096];
|
char line[LINE_SIZE];
|
||||||
int fd;
|
int fd;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *d;
|
struct dirent *d;
|
||||||
char filename[1024];
|
|
||||||
struct sigaction sa, act;
|
struct sigaction sa, act;
|
||||||
char hline[1024];
|
|
||||||
char *x;
|
char *x;
|
||||||
sigset_t nmask, nmask2;
|
sigset_t nmask, nmask2;
|
||||||
|
|
||||||
@@ -109,15 +114,15 @@ int main()
|
|||||||
for (i = 1; i < NSIG; i++)
|
for (i = 1; i < NSIG; i++)
|
||||||
SETSIG(sa, i, SIG_IGN, SA_RESTART);
|
SETSIG(sa, i, SIG_IGN, SA_RESTART);
|
||||||
|
|
||||||
SETSIG(sa, SIGINT, shutdown, 0);
|
SETSIG(sa, SIGINT, shutdown, 0);
|
||||||
SETSIG(sa, SIGPWR, signal_handler, 0);
|
SETSIG(sa, SIGPWR, SIG_IGN, 0);
|
||||||
SETSIG(sa, SIGUSR1, shutdown, 0);
|
SETSIG(sa, SIGUSR1, shutdown, 0);
|
||||||
SETSIG(sa, SIGUSR2, shutdown, 0);
|
SETSIG(sa, SIGUSR2, shutdown, 0);
|
||||||
SETSIG(sa, SIGTERM, signal_handler, 0);
|
SETSIG(sa, SIGTERM, SIG_IGN, 0);
|
||||||
SETSIG(sa, SIGALRM, signal_handler, 0);
|
SETSIG(sa, SIGALRM, SIG_IGN, 0);
|
||||||
SETSIG(sa, SIGHUP, signal_handler, 0);
|
SETSIG(sa, SIGHUP, SIG_IGN, 0);
|
||||||
SETSIG(sa, SIGCONT, signal_handler, SA_RESTART);
|
SETSIG(sa, SIGCONT, SIG_IGN, SA_RESTART);
|
||||||
SETSIG(sa, SIGCHLD, chld_handler, SA_RESTART);
|
SETSIG(sa, SIGCHLD, chld_handler, SA_RESTART);
|
||||||
|
|
||||||
/* Block sigchild while forking */
|
/* Block sigchild while forking */
|
||||||
sigemptyset(&nmask);
|
sigemptyset(&nmask);
|
||||||
@@ -130,7 +135,7 @@ int main()
|
|||||||
* Parse kernel parameters
|
* Parse kernel parameters
|
||||||
*/
|
*/
|
||||||
if ((f = fopen("/proc/cmdline", "r")) != NULL) {
|
if ((f = fopen("/proc/cmdline", "r")) != NULL) {
|
||||||
fgets(line, 2095, f);
|
fgets(line, LINE_SIZE, f);
|
||||||
if (strstr(line, "quiet")) {
|
if (strstr(line, "quiet")) {
|
||||||
close(0);
|
close(0);
|
||||||
close(1);
|
close(1);
|
||||||
@@ -149,6 +154,8 @@ int main()
|
|||||||
mount("devpts", "/dev/pts", "devpts", 0, "gid=5,mode=620");
|
mount("devpts", "/dev/pts", "devpts", 0, "gid=5,mode=620");
|
||||||
mount("tmpfs", "/dev/shm", "tmpfs", 0, NULL);
|
mount("tmpfs", "/dev/shm", "tmpfs", 0, NULL);
|
||||||
mount("tmpfs", "/tmp", "tmpfs", 0, "mode=1777,size=128m");
|
mount("tmpfs", "/tmp", "tmpfs", 0, "mode=1777,size=128m");
|
||||||
|
mount("tmpfs", "/var/run", "tmpfs", 0, "mode=0755");
|
||||||
|
mount("tmpfs", "/var/lock", "tmpfs", 0, "mode=1777");
|
||||||
mount("/mnt", "/", NULL, MS_MOVE, NULL);
|
mount("/mnt", "/", NULL, MS_MOVE, NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -172,9 +179,9 @@ int main()
|
|||||||
while ((d = readdir(dir)) != NULL) {
|
while ((d = readdir(dir)) != NULL) {
|
||||||
if (isalnum(d->d_name[0]))
|
if (isalnum(d->d_name[0]))
|
||||||
continue;
|
continue;
|
||||||
sprintf(filename, "/etc/resolvconf/run/interface/%s",
|
snprintf(line, LINE_SIZE,
|
||||||
d->d_name);
|
"/etc/resolvconf/run/interface/%s", d->d_name);
|
||||||
unlink(filename);
|
unlink(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
@@ -184,17 +191,21 @@ int main()
|
|||||||
touch("/etc/resolvconf/run/enable-updates");
|
touch("/etc/resolvconf/run/enable-updates");
|
||||||
|
|
||||||
chdir("/etc/resolvconf/run/interface");
|
chdir("/etc/resolvconf/run/interface");
|
||||||
|
#ifdef BUILTIN_RUNPARTS
|
||||||
|
run_parts("/etc/resolvconf/update.d", "-i", NULL);
|
||||||
|
#else
|
||||||
system("/bin/run-parts --arg=-i /etc/resolvconf/update.d");
|
system("/bin/run-parts --arg=-i /etc/resolvconf/update.d");
|
||||||
|
#endif
|
||||||
chdir("/");
|
chdir("/");
|
||||||
|
|
||||||
touch("/etc/network/run/ifstate");
|
touch("/etc/network/run/ifstate");
|
||||||
|
|
||||||
if ((f = fopen("/etc/hostname", "r")) != NULL) {
|
if ((f = fopen("/etc/hostname", "r")) != NULL) {
|
||||||
fgets(hline, 1023, f);
|
fgets(line, LINE_SIZE, f);
|
||||||
if ((x = strchr(hline, 0x0a)) != NULL)
|
if ((x = strchr(line, 0x0a)) != NULL)
|
||||||
*x = 0;
|
*x = 0;
|
||||||
|
|
||||||
sethostname(hline, strlen(hline));
|
sethostname(line, strlen(line));
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -219,6 +230,8 @@ int main()
|
|||||||
mkdir("/tmp/.ICE-unix", 01777);
|
mkdir("/tmp/.ICE-unix", 01777);
|
||||||
umask(022);
|
umask(022);
|
||||||
|
|
||||||
|
system("/usr/bin/openvt /sbin/getty 38400 tty2&");
|
||||||
|
|
||||||
if (!fork()) {
|
if (!fork()) {
|
||||||
/* child process */
|
/* child process */
|
||||||
|
|
||||||
@@ -228,7 +241,7 @@ int main()
|
|||||||
close(1);
|
close(1);
|
||||||
close(0);
|
close(0);
|
||||||
|
|
||||||
if (open("/dev/tty1", O_RDWR, 0))
|
if (open("/dev/tty1", O_RDWR) != 0)
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
sigemptyset(&act.sa_mask);
|
sigemptyset(&act.sa_mask);
|
||||||
@@ -255,7 +268,6 @@ int main()
|
|||||||
|
|
||||||
/* parent process */
|
/* parent process */
|
||||||
|
|
||||||
system("/sbin/getty 38400 tty3&");
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
system("/usr/sbin/services.sh &>/dev/null&");
|
system("/usr/sbin/services.sh &>/dev/null&");
|
||||||
|
|
||||||
@@ -271,8 +283,6 @@ int main()
|
|||||||
*/
|
*/
|
||||||
void shutdown(int sig)
|
void shutdown(int sig)
|
||||||
{
|
{
|
||||||
int fd;
|
|
||||||
|
|
||||||
touch("/tmp/shutdown");
|
touch("/tmp/shutdown");
|
||||||
|
|
||||||
kill(-1, SIGTERM);
|
kill(-1, SIGTERM);
|
||||||
@@ -283,23 +293,18 @@ void shutdown(int sig)
|
|||||||
|
|
||||||
system("/usr/sbin/alsactl store > /dev/null 2>&1");
|
system("/usr/sbin/alsactl store > /dev/null 2>&1");
|
||||||
system("/sbin/hwclock --systohc --localtime" HWCLOCK_DIRECTISA);
|
system("/sbin/hwclock --systohc --localtime" HWCLOCK_DIRECTISA);
|
||||||
system("/sbin/unionctl.static / --remove / > /dev/null 2>&1");
|
|
||||||
|
|
||||||
kill(-1, SIGKILL);
|
kill(-1, SIGKILL);
|
||||||
|
|
||||||
sync();
|
sync();
|
||||||
sync();
|
sync();
|
||||||
system("/bin/mount -n -o remount,ro /");
|
system("/bin/mount -n -o remount,ro /");
|
||||||
|
|
||||||
system("/sbin/unionctl.static / --remove / > /dev/null 2>&1");
|
system("/sbin/unionctl.static / --remove / > /dev/null 2>&1");
|
||||||
|
|
||||||
if (sig == SIGINT || sig == SIGUSR1)
|
if (sig == SIGINT || sig == SIGUSR1)
|
||||||
reboot(RB_AUTOBOOT);
|
reboot(RB_AUTOBOOT);
|
||||||
|
|
||||||
if ((fd = open("/sys/power/state", O_WRONLY)) >= 0) {
|
reboot(RB_POWER_OFF);
|
||||||
write(fd, "5", 1);
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -316,12 +321,3 @@ void chld_handler(int sig)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We got a signal (PWR TERM ALRM HUP CONT)
|
|
||||||
*/
|
|
||||||
void signal_handler(int sig)
|
|
||||||
{
|
|
||||||
/* do nothing */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -240,14 +240,12 @@ void shutdown(int sig)
|
|||||||
|
|
||||||
system("/usr/sbin/alsactl store > /dev/null 2>&1");
|
system("/usr/sbin/alsactl store > /dev/null 2>&1");
|
||||||
system("/sbin/hwclock --systohc --localtime");
|
system("/sbin/hwclock --systohc --localtime");
|
||||||
system("/sbin/unionctl.static / --remove / > /dev/null 2>&1");
|
|
||||||
|
|
||||||
kill(-1, SIGKILL);
|
kill(-1, SIGKILL);
|
||||||
|
|
||||||
sync();
|
sync();
|
||||||
sync();
|
sync();
|
||||||
system("/bin/mount -n -o remount,ro /");
|
system("/bin/mount -n -o remount,ro /");
|
||||||
|
|
||||||
system("/sbin/unionctl.static / --remove / > /dev/null 2>&1");
|
system("/sbin/unionctl.static / --remove / > /dev/null 2>&1");
|
||||||
|
|
||||||
if (sig == SIGINT || sig == SIGUSR1)
|
if (sig == SIGINT || sig == SIGUSR1)
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
user fred
|
||||||
|
module intel-agp
|
||||||
|
module p4-clockmod
|
||||||
|
check /dev/sda3
|
||||||
|
host eviltwin
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -10,6 +11,12 @@
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
#ifdef BUILTIN_RUNPARTS
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -25,6 +32,7 @@ int makepath(char *p)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
do { *x++ = *p++; } while (*p && *p != '/');
|
do { *x++ = *p++; } while (*p && *p != '/');
|
||||||
|
*x = 0;
|
||||||
ret = mkdir(path, 0777);
|
ret = mkdir(path, 0777);
|
||||||
} while (*p && (*p != '/' || *(p + 1))); /* ignore trailing slash */
|
} while (*p && (*p != '/' || *(p + 1))); /* ignore trailing slash */
|
||||||
|
|
||||||
@@ -89,3 +97,76 @@ void copyfile(char *src, char *dst, int size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILTIN_RUNPARTS
|
||||||
|
|
||||||
|
#define NUM_SCRIPTS 128 /* ought to be enough for anyone */
|
||||||
|
#define NUM_ARGS 16
|
||||||
|
|
||||||
|
static int cmp(const void *s1, const void *s2)
|
||||||
|
{
|
||||||
|
return strcmp(*(char **)s1, *(char **)s2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int run_parts(char *dir, ...)
|
||||||
|
{
|
||||||
|
DIR *d;
|
||||||
|
struct dirent *e;
|
||||||
|
struct stat st;
|
||||||
|
char *ent[NUM_SCRIPTS];
|
||||||
|
int i, num = 0, argnum = 1;
|
||||||
|
char *args[NUM_ARGS];
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
if (chdir(dir))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if ((d = opendir(dir)) == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
va_start(ap, dir);
|
||||||
|
while (argnum < NUM_ARGS && (args[argnum++] = va_arg(ap, char *)));
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
while ((e = readdir(d))) {
|
||||||
|
if (e->d_type == DT_REG && stat(e->d_name, &st) == 0) {
|
||||||
|
if (st.st_mode & S_IXUSR) {
|
||||||
|
ent[num++] = strdup(e->d_name);
|
||||||
|
if (num >= NUM_SCRIPTS)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir(d);
|
||||||
|
|
||||||
|
if (num == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
qsort(ent, num, sizeof(char *), cmp);
|
||||||
|
|
||||||
|
for (i = 0; i < num; i++) {
|
||||||
|
args[0] = ent[i];
|
||||||
|
if (!fork()) {
|
||||||
|
execv(ent[i], args);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
wait(NULL);
|
||||||
|
free(ent[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Other convenience functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
void chomp(char *s)
|
||||||
|
{
|
||||||
|
char *x;
|
||||||
|
|
||||||
|
if ((x = strchr((s), 0x0a)) != NULL)
|
||||||
|
*x = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -4,5 +4,10 @@
|
|||||||
int makepath (char *);
|
int makepath (char *);
|
||||||
void ifconfig (char *, char *, char *, int);
|
void ifconfig (char *, char *, char *, int);
|
||||||
void copyfile (char *, char *, int);
|
void copyfile (char *, char *, int);
|
||||||
|
void chomp (char *);
|
||||||
|
|
||||||
|
#ifdef BUILTIN_RUNPARTS
|
||||||
|
int run_parts (char *, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
Prevent nash-hotplug to keep running after boot using 100% of cpu
|
||||||
|
|
||||||
|
diff -rud mkinitrd-6.0.34-orig/nash/hotplug.c mkinitrd-6.0.34/nash/hotplug.c
|
||||||
|
--- mkinitrd-6.0.34-orig/nash/hotplug.c 2008-03-06 21:20:34.000000000 -0300
|
||||||
|
+++ mkinitrd-6.0.34/nash/hotplug.c 2008-03-12 18:48:46.000000000 -0300
|
||||||
|
@@ -547,7 +547,7 @@
|
||||||
|
nashLogger(nc, NASH_ERROR, "parent exited without telling us\n");
|
||||||
|
close(nc->hp_childfd);
|
||||||
|
nc->hp_childfd = -1;
|
||||||
|
- break;
|
||||||
|
+ exit(1);
|
||||||
|
}
|
||||||
|
count += rc;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user