Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F109152502
D25588.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D25588.diff
View Options
Index: head/sys/compat/linprocfs/linprocfs.c
===================================================================
--- head/sys/compat/linprocfs/linprocfs.c
+++ head/sys/compat/linprocfs/linprocfs.c
@@ -767,6 +767,32 @@
return (0);
}
+static int
+linprocfs_get_tty_nr(struct proc *p)
+{
+ struct session *sp;
+ const char *ttyname;
+ int error, major, minor, nr;
+
+ PROC_LOCK_ASSERT(p, MA_OWNED);
+ sx_assert(&proctree_lock, SX_LOCKED);
+
+ if ((p->p_flag & P_CONTROLT) == 0)
+ return (-1);
+
+ sp = p->p_pgrp->pg_session;
+ if (sp == NULL)
+ return (-1);
+
+ ttyname = devtoname(sp->s_ttyp->t_dev);
+ error = linux_driver_get_major_minor(ttyname, &major, &minor);
+ if (error != 0)
+ return (-1);
+
+ nr = makedev(major, minor);
+ return (nr);
+}
+
/*
* Filler function for proc/pid/stat
*/
@@ -777,12 +803,14 @@
struct timeval boottime;
char state;
static int ratelimit = 0;
+ int tty_nr;
vm_offset_t startcode, startdata;
getboottime(&boottime);
sx_slock(&proctree_lock);
PROC_LOCK(p);
fill_kinfo_proc(p, &kp);
+ tty_nr = linprocfs_get_tty_nr(p);
sx_sunlock(&proctree_lock);
if (p->p_vmspace) {
startcode = (vm_offset_t)p->p_vmspace->vm_taddr;
@@ -809,10 +837,7 @@
PS_ADD("pgrp", "%d", p->p_pgid);
PS_ADD("session", "%d", p->p_session->s_sid);
PROC_UNLOCK(p);
- if (kp.ki_tdev == NODEV)
- PS_ADD("tty", "%s", "-1");
- else
- PS_ADD("tty", "%ju", (uintmax_t)kp.ki_tdev);
+ PS_ADD("tty", "%d", tty_nr);
PS_ADD("tpgid", "%d", kp.ki_tpgid);
PS_ADD("flags", "%u", 0); /* XXX */
PS_ADD("minflt", "%lu", kp.ki_rusage.ru_minflt);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 2, 12:18 PM (21 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16400843
Default Alt Text
D25588.diff (1 KB)
Attached To
Mode
D25588: Make linprocfs(5) report correct tty number in /proc/<PID>/stat
Attached
Detach File
Event Timeline
Log In to Comment