tty: export tty_exists() to rest of finit (for plugins)

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2021-04-15 08:43:32 +02:00
parent 4bb67bc06f
commit 3d1b95aa7a
2 changed files with 5 additions and 4 deletions
+4 -4
View File
@@ -221,20 +221,20 @@ int tty_parse_args(char *cmd, struct tty *tty)
return 0;
}
static int tty_exist(char *dev)
int tty_exists(char *dev)
{
int fd, result;
struct termios c;
fd = open(dev, O_RDWR);
if (-1 == fd)
return 1;
return 0;
/* XXX: Add check for errno == EIO? */
result = tcgetattr(fd, &c);
close(fd);
return result;
return result == 0;
}
int tty_exec(svc_t *tty)
@@ -261,7 +261,7 @@ int tty_exec(svc_t *tty)
return EX_CONFIG;
}
if (tty_exist(dev)) {
if (!tty_exists(dev)) {
_d("%s: Not a valid TTY: %s", dev, strerror(errno));
return EX_OSFILE;
}
+1
View File
@@ -49,6 +49,7 @@ char *tty_atcon (void);
int tty_parse_args (char *cmdline, struct tty *tty);
int tty_exists (char *dev);
int tty_exec (svc_t *tty);
int tty_fallback (char *file);