mirror of
https://github.com/troglobit/finit.git
synced 2026-11-06 15:51:03 +00:00
tty: export tty_exists() to rest of finit (for plugins)
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
4bb67bc06f
commit
3d1b95aa7a
2 files changed
+5
-4
No files matched your search
@@ -221,20 +221,20 @@ int tty_parse_args(char *cmd, struct tty *tty)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tty_exist(char *dev)
|
int tty_exists(char *dev)
|
||||||
{
|
{
|
||||||
int fd, result;
|
int fd, result;
|
||||||
struct termios c;
|
struct termios c;
|
||||||
|
|
||||||
fd = open(dev, O_RDWR);
|
fd = open(dev, O_RDWR);
|
||||||
if (-1 == fd)
|
if (-1 == fd)
|
||||||
return 1;
|
return 0;
|
||||||
|
|
||||||
/* XXX: Add check for errno == EIO? */
|
/* XXX: Add check for errno == EIO? */
|
||||||
result = tcgetattr(fd, &c);
|
result = tcgetattr(fd, &c);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
return result;
|
return result == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tty_exec(svc_t *tty)
|
int tty_exec(svc_t *tty)
|
||||||
@@ -261,7 +261,7 @@ int tty_exec(svc_t *tty)
|
|||||||
return EX_CONFIG;
|
return EX_CONFIG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tty_exist(dev)) {
|
if (!tty_exists(dev)) {
|
||||||
_d("%s: Not a valid TTY: %s", dev, strerror(errno));
|
_d("%s: Not a valid TTY: %s", dev, strerror(errno));
|
||||||
return EX_OSFILE;
|
return EX_OSFILE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ char *tty_atcon (void);
|
|||||||
|
|
||||||
int tty_parse_args (char *cmdline, struct tty *tty);
|
int tty_parse_args (char *cmdline, struct tty *tty);
|
||||||
|
|
||||||
|
int tty_exists (char *dev);
|
||||||
int tty_exec (svc_t *tty);
|
int tty_exec (svc_t *tty);
|
||||||
int tty_fallback (char *file);
|
int tty_fallback (char *file);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user