summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
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