1 --- linux-2.4.1/include/linux/proc_fs_i.h Sat Apr 8 06:38:00 2000
2 +++ linux-akpm/include/linux/proc_fs_i.h Fri Feb 2 01:50:40 2001
4 struct proc_inode_info {
5 struct task_struct *task;
9 int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **);
10 int (*proc_read)(struct task_struct *task, char *page);
11 + int (*proc_write)(struct task_struct *task, char *page, size_t nbytes);
15 --- linux-2.4.1/include/linux/capability.h Sun Oct 15 01:27:46 2000
16 +++ linux-akpm/include/linux/capability.h Fri Feb 2 01:55:00 2001
18 /* Allow enabling/disabling tagged queuing on SCSI controllers and sending
19 arbitrary SCSI commands */
20 /* Allow setting encryption key on loopback filesystem */
21 +/* Allow bonding of tasks to CPUs */
23 #define CAP_SYS_ADMIN 21
25 --- linux-2.4.1/fs/proc/base.c Tue Nov 21 20:11:21 2000
26 +++ linux-akpm/fs/proc/base.c Fri Feb 2 02:41:51 2001
28 int proc_pid_status(struct task_struct*,char*);
29 int proc_pid_statm(struct task_struct*,char*);
30 int proc_pid_cpu(struct task_struct*,char*);
31 +int proc_pid_cpus_allowed_read(struct task_struct *task, char * buffer);
32 +int proc_pid_cpus_allowed_write(struct task_struct *task, char * buffer, size_t nbytes);
34 static int proc_fd_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt)
40 +static ssize_t proc_info_write(struct file * file, const char * buf,
41 + size_t count, loff_t *ppos)
43 + struct inode * inode = file->f_dentry->d_inode;
46 + struct task_struct *task = inode->u.proc_i.task;
49 + if (inode->u.proc_i.op.proc_write == NULL)
51 + if (count > PAGE_SIZE - 1)
55 + if (!(page = __get_free_page(GFP_KERNEL)))
59 + if (copy_from_user((char *)page, buf, count))
62 + ((char *)page)[count] = '\0';
63 + ret = inode->u.proc_i.op.proc_write(task, (char*)page, count);
75 static struct file_operations proc_info_file_operations = {
77 + write: proc_info_write,
80 #define MAY_PTRACE(p) \
85 + PROC_PID_CPUS_ALLOWED,
86 PROC_PID_FD_DIR = 0x8000, /* 0x8000-0xffff */
90 E(PROC_PID_STAT, "stat", S_IFREG|S_IRUGO),
91 E(PROC_PID_STATM, "statm", S_IFREG|S_IRUGO),
93 - E(PROC_PID_CPU, "cpu", S_IFREG|S_IRUGO),
94 + E(PROC_PID_CPU, "cpu", S_IFREG|S_IRUGO),
95 + E(PROC_PID_CPUS_ALLOWED, "cpus_allowed", S_IFREG|S_IRUGO|S_IWUSR),
97 E(PROC_PID_MAPS, "maps", S_IFREG|S_IRUGO),
98 E(PROC_PID_MEM, "mem", S_IFREG|S_IRUSR|S_IWUSR),
101 inode->i_fop = &proc_info_file_operations;
102 inode->u.proc_i.op.proc_read = proc_pid_cpu;
104 + case PROC_PID_CPUS_ALLOWED:
105 + inode->i_fop = &proc_info_file_operations;
106 + inode->u.proc_i.op.proc_read = proc_pid_cpus_allowed_read;
107 + inode->u.proc_i.op.proc_write = proc_pid_cpus_allowed_write;
111 --- linux-2.4.1/fs/proc/array.c Tue Nov 21 20:11:21 2000
112 +++ linux-akpm/fs/proc/array.c Fri Feb 2 02:05:39 2001
114 * Al Viro & Jeff Garzik : moved most of the thing into base.c and
115 * : proc_misc.c. The rest may eventually go into
118 + * Andrew Morton : cpus_allowed
121 #include <linux/config.h>
123 task->per_cpu_stime[cpu_logical_map(i)]);
128 +int proc_pid_cpus_allowed_read(struct task_struct *task, char * buffer)
132 + len = sprintf(buffer, "%08lx\n", task->cpus_allowed);
137 + * FIXME: cpu_online_map should be used, but not all archs have it.
140 +int proc_pid_cpus_allowed_write(struct task_struct *task, char * buffer, size_t nbytes)
142 + unsigned long new_mask;
145 + unsigned long flags;
148 + if (!capable(CAP_SYS_ADMIN))
151 + new_mask = simple_strtoul(buffer, &endp, 16);
152 + ret = endp - buffer;
154 + spin_lock_irqsave(&runqueue_lock, flags); /* token effort to not be racy */
155 + if ((((1 << smp_num_cpus) - 1) & new_mask) == 0)
158 + task->cpus_allowed = new_mask;
159 + spin_unlock_irqrestore(&runqueue_lock, flags);