old trash removed

This commit is contained in:
Sergey Bolshakov 2004-11-30 18:12:23 +00:00
parent 25f4ab2cc3
commit 2e6d5b5b61
2 changed files with 5 additions and 100 deletions

89
init.c
View File

@ -105,14 +105,11 @@ void print_str_init(int fd, char * string)
*/
void doklog()
{
fd_set readset, unixs;
int in, out, i;
int log;
int s;
int sock = -1;
struct sockaddr_un sockaddr;
char buf[1024];
int readfd;
/* open kernel message logger */
in = open("/proc/kmsg", O_RDONLY,0);
@ -143,96 +140,20 @@ void doklog()
perror("can't open /dev/tty4");
print_warning("couldn't open tty for syslog -- still using /tmp/syslog\n");
}
/* now open the syslog socket */
// ############# LINUX 2.4 /dev/log IS BUGGED! --> apparently the syslogs can't reach me, and it's full up after a while
// sockaddr.sun_family = AF_UNIX;
// strncpy(sockaddr.sun_path, "/dev/log", UNIX_PATH_MAX);
// sock = socket(AF_UNIX, SOCK_STREAM, 0);
// if (sock < 0) {
// printf("error creating socket: %d\n", errno);
// sleep(5);
// }
//
// print_str_init(log, "] got socket\n");
// if (bind(sock, (struct sockaddr *) &sockaddr, sizeof(sockaddr.sun_family) + strlen(sockaddr.sun_path))) {
// print_str_init(log, "] bind error: ");
// print_int_init(log, errno);
// print_str_init(log, "\n");
// sleep(// }
//
// print_str_init(log, "] bound socket\n");
// chmod("/dev/log", 0666);
// if (listen(sock, 5)) {
// print_str_init(log, "] listen error: ");
// print_int_init(log, errno);
// print_str_init(log, "\n");
// sleep(5);
// }
/* disable on-console syslog output */
syslog(8, NULL, 1);
print_str_init(log, "] kernel/system logger ok\n");
FD_ZERO(&unixs);
while (1) {
memcpy(&readset, &unixs, sizeof(unixs));
if (sock >= 0)
FD_SET(sock, &readset);
FD_SET(in, &readset);
i = select(20, &readset, NULL, NULL, NULL);
if (i <= 0)
continue;
/* has /proc/kmsg things to tell us? */
if (FD_ISSET(in, &readset)) {
i = read(in, buf, sizeof(buf));
if (i > 0) {
if (out >= 0)
write(out, buf, i);
write(log, buf, i);
}
}
/* examine some fd's in the hope to find some syslog outputs from programs */
for (readfd = 0; readfd < 20; ++readfd) {
if (FD_ISSET(readfd, &readset) && FD_ISSET(readfd, &unixs)) {
i = read(readfd, buf, sizeof(buf));
if (i > 0) {
/* grep out the output of RPM telling that it installed/removed some packages */
if (!strstr(buf, "mdk installed") && !strstr(buf, "mdk removed")) {
if (out >= 0)
write(out, buf, i);
write(log, buf, i);
}
} else if (i == 0) {
/* socket closed */
close(readfd);
FD_CLR(readfd, &unixs);
}
}
}
/* the socket has moved, new stuff to do */
if (sock >= 0 && FD_ISSET(sock, &readset)) {
s = sizeof(sockaddr);
readfd = accept(sock, (struct sockaddr *) &sockaddr, &s);
if (readfd < 0) {
char * msg_error = "] error in accept\n";
if (out >= 0)
write(out, msg_error, strlen(msg_error));
write(log, msg_error, strlen(msg_error));
close(sock);
sock = -1;
}
else
FD_SET(readfd, &unixs);
i = read(in, buf, sizeof(buf));
if (i > 0) {
if (out >= 0)
write(out, buf, i);
write(log, buf, i);
}
}
}
#define LOOP_CLR_FD 0x4C01
void del_loop(char *device)

View File

@ -415,24 +415,8 @@ int main(int argc, char **argv, char **env)
if (ret != RETURN_OK)
fatal_error("could not select an installation method");
#if 0
if (!IS_RAMDISK) {
if (symlink(IMAGE_LOCATION LIVE_LOCATION, STAGE2_LOCATION) != 0) {
perror("symlink");
printf("symlink from " IMAGE_LOCATION LIVE_LOCATION " to " STAGE2_LOCATION " failed");
fatal_error(strerror(errno));
}
}
#endif
if (interactive_pid != 0)
kill(interactive_pid, 9);
#if 0
if (IS_RESCUE || IS_LIVE)
return 66;
if (IS_TESTING)
return 0;
#endif
return 0; /* shut up compiler (we can't get here anyway!) */
}