summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2008-06-02 08:40:06 +0000
committered <ed@FreeBSD.org>2008-06-02 08:40:06 +0000
commitff609f1187e6a6436decf9241cddf833963d9d8d (patch)
treeb9282f9ca4b45aceee2692d80d77f99280c87ca9 /sys/compat
parentb3629efe71087e0465b3d28273f1949b8f4a0088 (diff)
downloadFreeBSD-src-ff609f1187e6a6436decf9241cddf833963d9d8d.zip
FreeBSD-src-ff609f1187e6a6436decf9241cddf833963d9d8d.tar.gz
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
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/linux/linux_stats.c30
-rw-r--r--sys/compat/linux/linux_util.c16
2 files changed, 20 insertions, 26 deletions
diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c
index 670ef22..7c85fb4 100644
--- a/sys/compat/linux/linux_stats.c
+++ b/sys/compat/linux/linux_stats.c
@@ -178,19 +178,8 @@ linux_newstat(struct thread *td, struct linux_newstat_args *args)
#endif
error = kern_stat(td, path, UIO_SYSSPACE, &buf);
- if (!error) {
- if (strlen(path) > strlen("/dev/pts/") &&
- !strncmp(path, "/dev/pts/", strlen("/dev/pts/")) &&
- path[9] >= '0' && path[9] <= '9') {
- /*
- * 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.
- */
- buf.st_rdev = (136 << 8);
- } else
- translate_path_major_minor(td, path, &buf);
- }
+ if (!error)
+ translate_path_major_minor(td, path, &buf);
LFREEPATH(path);
if (error)
return (error);
@@ -528,19 +517,8 @@ linux_stat64(struct thread *td, struct linux_stat64_args *args)
#endif
error = kern_stat(td, filename, UIO_SYSSPACE, &buf);
- if (!error) {
- if (strlen(filename) > strlen("/dev/pts/") &&
- !strncmp(filename, "/dev/pts/", strlen("/dev/pts/")) &&
- filename[9] >= '0' && filename[9] <= '9') {
- /*
- * Linux checks major and minors of the slave device
- * to make sure it's a pty deivce, so let's make him
- * believe it is.
- */
- buf.st_rdev = (136 << 8);
- } else
- translate_path_major_minor(td, filename, &buf);
- }
+ if (!error)
+ translate_path_major_minor(td, filename, &buf);
LFREEPATH(filename);
if (error)
return (error);
diff --git a/sys/compat/linux/linux_util.c b/sys/compat/linux/linux_util.c
index 76d6288..51a0ec3 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;
OpenPOWER on IntegriCloud