Example #1
0
static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
)
{
	generic_fillattr(dentry->d_inode, stat);
	stat->nlink = proc_root.nlink + nr_processes();
	return 0;
}
Example #2
0
int proc_fill_super(struct super_block *s, void *data, int silent)
{
	struct inode * root_inode;

	s->s_flags |= MS_NODIRATIME;
	s->s_blocksize = 1024;
	s->s_blocksize_bits = 10;
	s->s_magic = PROC_SUPER_MAGIC;
	s->s_op = &proc_sops;
	s->s_time_gran = 1;
	
	root_inode = proc_get_inode(s, PROC_ROOT_INO, &proc_root);
	if (!root_inode)
		goto out_no_root;
	/*
	 * Fixup the root inode's nlink value
	 */
	root_inode->i_nlink += nr_processes();
	root_inode->i_uid = 0;
	root_inode->i_gid = 0;
	s->s_root = d_alloc_root(root_inode);
	if (!s->s_root)
		goto out_no_root;
	return 0;

out_no_root:
	printk("proc_read_super: get root inode failed\n");
	iput(root_inode);
	return -ENOMEM;
}
/*
 * Prints the number of processes to the kernel log.
 */
int print_nr_procs(void)
{
	unsigned int procs;
	procs = 0;

	procs = nr_processes();
	printk(KERN_INFO "There are currently %d processes running.\n", procs);

	return 0;
}
Example #4
0
static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
)
{
	struct ve_struct *ve = get_exec_env();

	generic_fillattr(dentry->d_inode, stat);
	stat->nlink = glob_proc_root.nlink;
	if (ve_is_super(ve))
		stat->nlink += nr_processes();
#ifdef CONFIG_VE
	else
		/* thread count. not really processes count */
		stat->nlink += ve->pcounter;
	/* the same logic as in the proc_getattr */
	stat->nlink += ve->proc_root->nlink - 2;
#endif
	return 0;
}