commit 289a3d93e511931b16db534ceab1d32653b9dddd
parent 7d2394b33fd0442019c1d005cc01d737770bdf7c
Author: sanjiyan <sanjiyan>
Date: Fri, 22 Mar 2002 21:21:52 +0000
add write_proc
"make install" now installs hard-reboot and write_proc in /sbin
Diffstat:
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/CHANGES b/CHANGES
@@ -4,6 +4,7 @@
add hard-reboot from Tommi Virtanen. He also asked me to include an
explicit license statement and sent a patch to make debian packaging
easier (deb files can't include FIFOs).
+ Olaf: add write_proc.
0.8:
call waitpid repeatedly until it returns "no children".
diff --git a/Makefile b/Makefile
@@ -1,4 +1,4 @@
-all: minit msvc pidfilehack hard-reboot
+all: minit msvc pidfilehack hard-reboot write_proc
#CFLAGS=-pipe -march=i386 -fomit-frame-pointer -Os -I../dietlibc/include
DIET=diet
@@ -31,8 +31,12 @@ pidfilehack: pidfilehack.c
hard-reboot: hard-reboot.c
$(DIET) $(CROSS)$(CC) $(CFLAGS) -o $@ $^
+write_proc: write_proc.c
+ $(DIET) $(CROSS)$(CC) $(CFLAGS) -o $@ $^
+
install-files:
install minit pidfilehack $(DESTDIR)/sbin
+ install write_proc hard-reboot $(DESTDIR)/sbin
install msvc $(DESTDIR)/bin
test -d $(DESTDIR)/etc/minit || mkdir $(DESTDIR)/etc/minit
diff --git a/write_proc.c b/write_proc.c
@@ -0,0 +1,17 @@
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+
+#define USAGE "write_proc <value> <path_to_proc_file>\n"
+
+int main(int argc,char*argv[]) {
+ int fd;
+ if (argc!=3) goto usage;
+ if ((fd=open(argv[2],O_WRONLY))==-1) goto usage;
+ write(fd,argv[1],strlen(argv[1]));
+ close(fd);
+ return 0;
+usage:
+ write(2,USAGE,strlen(USAGE));
+ return 1;
+}