summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-03-14 02:33:23 +0100
committerLennart Poettering <lennart@poettering.net>2011-03-14 03:12:25 +0100
commit46824d0e6b2aae8f503464368d02c1da992f56f1 (patch)
treed2f8c2e9a379b372f6c6fb4dd8b13d89f6b4d42a /src/util.c
parent3eb4d9a214a09883e50ce557b36c7903406d7ef8 (diff)
util: properly identify pty devices by their major
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/util.c b/src/util.c
index c9366c4a39..ee6217d64c 100644
--- a/src/util.c
+++ b/src/util.c
@@ -2865,7 +2865,7 @@ int getttyname_harder(int fd, char **r) {
if (streq(s, "tty")) {
free(s);
- return get_ctty(r);
+ return get_ctty(r, NULL);
}
*r = s;
@@ -2907,7 +2907,7 @@ int get_ctty_devnr(dev_t *d) {
return 0;
}
-int get_ctty(char **r) {
+int get_ctty(char **r, dev_t *_devnr) {
int k;
char fn[128], *s, *b, *p;
dev_t devnr;
@@ -2925,6 +2925,18 @@ int get_ctty(char **r) {
if (k != -ENOENT)
return k;
+ /* This is an ugly hack */
+ if (major(devnr) == 136) {
+ if (asprintf(&b, "pts/%lu", (unsigned long) minor(devnr)) < 0)
+ return -ENOMEM;
+
+ *r = b;
+ if (_devnr)
+ *_devnr = devnr;
+
+ return 0;
+ }
+
/* Probably something like the ptys which have no
* symlink in /dev/char. Let's return something
* vaguely useful. */
@@ -2933,6 +2945,9 @@ int get_ctty(char **r) {
return -ENOMEM;
*r = b;
+ if (_devnr)
+ *_devnr = devnr;
+
return 0;
}
@@ -2950,6 +2965,9 @@ int get_ctty(char **r) {
return -ENOMEM;
*r = b;
+ if (_devnr)
+ *_devnr = devnr;
+
return 0;
}