aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linux/linux_util.c
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2008-06-02 08:40:06 +0000
committerEd Schouten <ed@FreeBSD.org>2008-06-02 08:40:06 +0000
commita147e6cadf7e0b040cabd185739a63a7f2f1d36d (patch)
treeb9282f9ca4b45aceee2692d80d77f99280c87ca9 /sys/compat/linux/linux_util.c
parent047b4ae4cf6c321d7dc1c7b962ca57615f252177 (diff)
Push down the major/minor conversion for pts/%u to improve consistency.
In the mpsafetty branch, Linux sshd seems to work properly inside a jail. Some small modifications had to be made to the Linux compatibility layer. The Linux PTY routines always expect the device major number to be 136 or higher. Our code always set the major/minor number pair to 136:0. This makes routines like ttyname() and ptsname() fail, because we'll end up having ambiguous device numbers. The conversion was not performed on all *stat() routines, which meant in some cases the numbers didn't get transformed. By pushing the conversion into linux_driver_get_major_minor(), the transformation will take place on all calls. Approved by: philip (mentor), rdivacky
Notes
Notes: svn path=/head/; revision=179486
Diffstat (limited to 'sys/compat/linux/linux_util.c')
-rw-r--r--sys/compat/linux/linux_util.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/sys/compat/linux/linux_util.c b/sys/compat/linux/linux_util.c
index 76d62885fab2..51a0ec3c947b 100644
--- a/sys/compat/linux/linux_util.c
+++ b/sys/compat/linux/linux_util.c
@@ -130,6 +130,22 @@ linux_driver_get_major_minor(char *node, int *major, int *minor)
if (node == NULL || major == NULL || minor == NULL)
return 1;
+
+ if (strlen(node) > strlen("pts/") &&
+ strncmp(node, "pts/", strlen("pts/")) == 0) {
+ unsigned long devno;
+
+ /*
+ * Linux checks major and minors of the slave device
+ * to make sure it's a pty device, so let's make him
+ * believe it is.
+ */
+ devno = strtoul(node + strlen("pts/"), NULL, 10);
+ *major = 136 + (devno / 256);
+ *minor = devno % 256;
+ return 0;
+ }
+
TAILQ_FOREACH(de, &devices, list) {
if (strcmp(node, de->entry.bsd_device_name) == 0) {
*major = de->entry.linux_major;