diff options
Diffstat (limited to 'fs/proc/task_nommu.c')
| -rw-r--r-- | fs/proc/task_nommu.c | 69 | 
1 files changed, 58 insertions, 11 deletions
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c index 980de547c07..74fe164d1b2 100644 --- a/fs/proc/task_nommu.c +++ b/fs/proc/task_nommu.c @@ -134,9 +134,11 @@ static void pad_len_spaces(struct seq_file *m, int len)  /*   * display a single VMA to a sequenced file   */ -static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma) +static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma, +			  int is_pid)  {  	struct mm_struct *mm = vma->vm_mm; +	struct proc_maps_private *priv = m->private;  	unsigned long ino = 0;  	struct file *file;  	dev_t dev = 0; @@ -168,10 +170,19 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma)  		pad_len_spaces(m, len);  		seq_path(m, &file->f_path, "");  	} else if (mm) { -		if (vma->vm_start <= mm->start_stack && -			vma->vm_end >= mm->start_stack) { +		pid_t tid = vm_is_stack(priv->task, vma, is_pid); + +		if (tid != 0) {  			pad_len_spaces(m, len); -			seq_puts(m, "[stack]"); +			/* +			 * Thread stack in /proc/PID/task/TID/maps or +			 * the main process stack. +			 */ +			if (!is_pid || (vma->vm_start <= mm->start_stack && +			    vma->vm_end >= mm->start_stack)) +				seq_printf(m, "[stack]"); +			else +				seq_printf(m, "[stack:%d]", tid);  		}  	} @@ -182,11 +193,22 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma)  /*   * display mapping lines for a particular process's /proc/pid/maps   */ -static int show_map(struct seq_file *m, void *_p) +static int show_map(struct seq_file *m, void *_p, int is_pid)  {  	struct rb_node *p = _p; -	return nommu_vma_show(m, rb_entry(p, struct vm_area_struct, vm_rb)); +	return nommu_vma_show(m, rb_entry(p, struct vm_area_struct, vm_rb), +			      is_pid); +} + +static int show_pid_map(struct seq_file *m, void *_p) +{ +	return show_map(m, _p, 1); +} + +static int show_tid_map(struct seq_file *m, void *_p) +{ +	return show_map(m, _p, 0);  }  static void *m_start(struct seq_file *m, loff_t *pos) @@ -240,10 +262,18 @@ static const struct seq_operations proc_pid_maps_ops = {  	.start	= m_start,  	.next	= m_next,  	.stop	= m_stop, -	.show	= show_map +	.show	= show_pid_map +}; + +static const struct seq_operations proc_tid_maps_ops = { +	.start	= m_start, +	.next	= m_next, +	.stop	= m_stop, +	.show	= show_tid_map  }; -static int maps_open(struct inode *inode, struct file *file) +static int maps_open(struct inode *inode, struct file *file, +		     const struct seq_operations *ops)  {  	struct proc_maps_private *priv;  	int ret = -ENOMEM; @@ -251,7 +281,7 @@ static int maps_open(struct inode *inode, struct file *file)  	priv = kzalloc(sizeof(*priv), GFP_KERNEL);  	if (priv) {  		priv->pid = proc_pid(inode); -		ret = seq_open(file, &proc_pid_maps_ops); +		ret = seq_open(file, ops);  		if (!ret) {  			struct seq_file *m = file->private_data;  			m->private = priv; @@ -262,8 +292,25 @@ static int maps_open(struct inode *inode, struct file *file)  	return ret;  } -const struct file_operations proc_maps_operations = { -	.open		= maps_open, +static int pid_maps_open(struct inode *inode, struct file *file) +{ +	return maps_open(inode, file, &proc_pid_maps_ops); +} + +static int tid_maps_open(struct inode *inode, struct file *file) +{ +	return maps_open(inode, file, &proc_tid_maps_ops); +} + +const struct file_operations proc_pid_maps_operations = { +	.open		= pid_maps_open, +	.read		= seq_read, +	.llseek		= seq_lseek, +	.release	= seq_release_private, +}; + +const struct file_operations proc_tid_maps_operations = { +	.open		= tid_maps_open,  	.read		= seq_read,  	.llseek		= seq_lseek,  	.release	= seq_release_private,  |