This commit is contained in:
Mark 2020-07-07 21:27:15 +03:00
parent eeae3fb19d
commit 5e745434fc
3 changed files with 42 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
kernel-hdr
build
progs/rsh
progs/rc

3
etc/inittab Normal file
View File

@ -0,0 +1,3 @@
# Runlevels: 1
l0:1:once:/bin/login

38
progs/base/bin/ucat.c Normal file
View File

@ -0,0 +1,38 @@
#include <sys/socket.h>
#include <string.h>
#include <ygg/un.h>
#include <unistd.h>
#include <stdio.h>
int main(int argc, char **argv) {
struct sockaddr_un un;
ssize_t rd;
int fd;
char buf[1024];
if (argc != 2) {
fprintf(stderr, "usage: %s SOCKET\n", argv[0]);
return -1;
}
un.sun_family = AF_UNIX;
strcpy(un.sun_path, argv[1]);
if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
perror("socket()");
return -1;
}
if (connect(fd, (struct sockaddr *) &un, sizeof(un)) != 0) {
perror("connect()");
return -1;
}
while ((rd = recv(fd, buf, sizeof(buf), 0)) > 0) {
write(STDOUT_FILENO, buf, rd);
}
close(fd);
return 0;
}