Skip to content

Commit 003426b

Browse files
authored
Merge pull request #288 from djs55/osquery
tty: write filename in a file, don't symlink to /dev
2 parents 461b3f9 + 4aad16e commit 003426b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/lib/uart_emul.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -758,14 +758,16 @@ uart_set_backend(struct uart_softc *sc, const char *backend, const char *devname
758758

759759
if (linkname) {
760760
if ((unlink(linkname) == -1) && (errno != ENOENT)) {
761-
perror("unlinking autopty symlink");
761+
perror("unlinking autopty file");
762762
goto err;
763763
}
764-
if (symlink(ptyname, linkname) == -1){
765-
perror("creating autopty symlink");
764+
int namefd = open(linkname, O_CREAT | O_WRONLY);
765+
if (namefd == -1) {
766+
perror("creating autopty file");
766767
goto err;
767768
}
768-
fprintf(stdout, "%s linked to %s\n", devname, linkname);
769+
(void) write(namefd, ptyname, strlen(ptyname));
770+
(void) close(namefd);
769771
}
770772

771773
sc->tty.fd = ptyfd;

0 commit comments

Comments
 (0)