diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-11-02 19:07:27 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-11-02 19:07:27 -0400 |
commit | 092f4c56c1927e4b61a41ee8055005f1cb437009 (patch) | |
tree | 616ceb54b7671ccc13922ae9e002b8b972f6e09e /fs/proc | |
parent | 80c2861672bbf000f6af838656959ee937e4ee4d (diff) | |
parent | c1e2ee2dc436574880758b3836fc96935b774c32 (diff) |
Merge branch 'akpm' (Andrew's incoming - part two)
Says Andrew:
"60 patches. That's good enough for -rc1 I guess. I have quite a lot
of detritus to be rechecked, work through maintainers, etc.
- most of the remains of MM
- rtc
- various misc
- cgroups
- memcg
- cpusets
- procfs
- ipc
- rapidio
- sysctl
- pps
- w1
- drivers/misc
- aio"
* akpm: (60 commits)
memcg: replace ss->id_lock with a rwlock
aio: allocate kiocbs in batches
drivers/misc/vmw_balloon.c: fix typo in code comment
drivers/misc/vmw_balloon.c: determine page allocation flag can_sleep outside loop
w1: disable irqs in critical section
drivers/w1/w1_int.c: multiple masters used same init_name
drivers/power/ds2780_battery.c: fix deadlock upon insertion and removal
drivers/power/ds2780_battery.c: add a nolock function to w1 interface
drivers/power/ds2780_battery.c: create central point for calling w1 interface
w1: ds2760 and ds2780, use ida for id and ida_simple_get() to get it
pps gpio client: add missing dependency
pps: new client driver using GPIO
pps: default echo function
include/linux/dma-mapping.h: add dma_zalloc_coherent()
sysctl: make CONFIG_SYSCTL_SYSCALL default to n
sysctl: add support for poll()
RapidIO: documentation update
drivers/net/rionet.c: fix ethernet address macros for LE platforms
RapidIO: fix potential null deref in rio_setup_device()
RapidIO: add mport driver for Tsi721 bridge
...
Diffstat (limited to 'fs/proc')
-rw-r--r-- | fs/proc/base.c | 146 | ||||
-rw-r--r-- | fs/proc/proc_sysctl.c | 46 |
2 files changed, 149 insertions, 43 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 851ba3dcdc29..2db1bd3173b2 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -1652,12 +1652,46 @@ out: | |||
1652 | return error; | 1652 | return error; |
1653 | } | 1653 | } |
1654 | 1654 | ||
1655 | static int proc_pid_fd_link_getattr(struct vfsmount *mnt, struct dentry *dentry, | ||
1656 | struct kstat *stat) | ||
1657 | { | ||
1658 | struct inode *inode = dentry->d_inode; | ||
1659 | struct task_struct *task = get_proc_task(inode); | ||
1660 | int rc; | ||
1661 | |||
1662 | if (task == NULL) | ||
1663 | return -ESRCH; | ||
1664 | |||
1665 | rc = -EACCES; | ||
1666 | if (lock_trace(task)) | ||
1667 | goto out_task; | ||
1668 | |||
1669 | generic_fillattr(inode, stat); | ||
1670 | unlock_trace(task); | ||
1671 | rc = 0; | ||
1672 | out_task: | ||
1673 | put_task_struct(task); | ||
1674 | return rc; | ||
1675 | } | ||
1676 | |||
1655 | static const struct inode_operations proc_pid_link_inode_operations = { | 1677 | static const struct inode_operations proc_pid_link_inode_operations = { |
1656 | .readlink = proc_pid_readlink, | 1678 | .readlink = proc_pid_readlink, |
1657 | .follow_link = proc_pid_follow_link, | 1679 | .follow_link = proc_pid_follow_link, |
1658 | .setattr = proc_setattr, | 1680 | .setattr = proc_setattr, |
1659 | }; | 1681 | }; |
1660 | 1682 | ||
1683 | static const struct inode_operations proc_fdinfo_link_inode_operations = { | ||
1684 | .setattr = proc_setattr, | ||
1685 | .getattr = proc_pid_fd_link_getattr, | ||
1686 | }; | ||
1687 | |||
1688 | static const struct inode_operations proc_fd_link_inode_operations = { | ||
1689 | .readlink = proc_pid_readlink, | ||
1690 | .follow_link = proc_pid_follow_link, | ||
1691 | .setattr = proc_setattr, | ||
1692 | .getattr = proc_pid_fd_link_getattr, | ||
1693 | }; | ||
1694 | |||
1661 | 1695 | ||
1662 | /* building an inode */ | 1696 | /* building an inode */ |
1663 | 1697 | ||
@@ -1889,49 +1923,61 @@ out: | |||
1889 | 1923 | ||
1890 | static int proc_fd_info(struct inode *inode, struct path *path, char *info) | 1924 | static int proc_fd_info(struct inode *inode, struct path *path, char *info) |
1891 | { | 1925 | { |
1892 | struct task_struct *task = get_proc_task(inode); | 1926 | struct task_struct *task; |
1893 | struct files_struct *files = NULL; | 1927 | struct files_struct *files; |
1894 | struct file *file; | 1928 | struct file *file; |
1895 | int fd = proc_fd(inode); | 1929 | int fd = proc_fd(inode); |
1930 | int rc; | ||
1896 | 1931 | ||
1897 | if (task) { | 1932 | task = get_proc_task(inode); |
1898 | files = get_files_struct(task); | 1933 | if (!task) |
1899 | put_task_struct(task); | 1934 | return -ENOENT; |
1900 | } | 1935 | |
1901 | if (files) { | 1936 | rc = -EACCES; |
1902 | /* | 1937 | if (lock_trace(task)) |
1903 | * We are not taking a ref to the file structure, so we must | 1938 | goto out_task; |
1904 | * hold ->file_lock. | 1939 | |
1905 | */ | 1940 | rc = -ENOENT; |
1906 | spin_lock(&files->file_lock); | 1941 | files = get_files_struct(task); |
1907 | file = fcheck_files(files, fd); | 1942 | if (files == NULL) |
1908 | if (file) { | 1943 | goto out_unlock; |
1909 | unsigned int f_flags; | 1944 | |
1910 | struct fdtable *fdt; | 1945 | /* |
1911 | 1946 | * We are not taking a ref to the file structure, so we must | |
1912 | fdt = files_fdtable(files); | 1947 | * hold ->file_lock. |
1913 | f_flags = file->f_flags & ~O_CLOEXEC; | 1948 | */ |
1914 | if (FD_ISSET(fd, fdt->close_on_exec)) | 1949 | spin_lock(&files->file_lock); |
1915 | f_flags |= O_CLOEXEC; | 1950 | file = fcheck_files(files, fd); |
1916 | 1951 | if (file) { | |
1917 | if (path) { | 1952 | unsigned int f_flags; |
1918 | *path = file->f_path; | 1953 | struct fdtable *fdt; |
1919 | path_get(&file->f_path); | 1954 | |
1920 | } | 1955 | fdt = files_fdtable(files); |
1921 | if (info) | 1956 | f_flags = file->f_flags & ~O_CLOEXEC; |
1922 | snprintf(info, PROC_FDINFO_MAX, | 1957 | if (FD_ISSET(fd, fdt->close_on_exec)) |
1923 | "pos:\t%lli\n" | 1958 | f_flags |= O_CLOEXEC; |
1924 | "flags:\t0%o\n", | 1959 | |
1925 | (long long) file->f_pos, | 1960 | if (path) { |
1926 | f_flags); | 1961 | *path = file->f_path; |
1927 | spin_unlock(&files->file_lock); | 1962 | path_get(&file->f_path); |
1928 | put_files_struct(files); | ||
1929 | return 0; | ||
1930 | } | 1963 | } |
1931 | spin_unlock(&files->file_lock); | 1964 | if (info) |
1932 | put_files_struct(files); | 1965 | snprintf(info, PROC_FDINFO_MAX, |
1933 | } | 1966 | "pos:\t%lli\n" |
1934 | return -ENOENT; | 1967 | "flags:\t0%o\n", |
1968 | (long long) file->f_pos, | ||
1969 | f_flags); | ||
1970 | rc = 0; | ||
1971 | } else | ||
1972 | rc = -ENOENT; | ||
1973 | spin_unlock(&files->file_lock); | ||
1974 | put_files_struct(files); | ||
1975 | |||
1976 | out_unlock: | ||
1977 | unlock_trace(task); | ||
1978 | out_task: | ||
1979 | put_task_struct(task); | ||
1980 | return rc; | ||
1935 | } | 1981 | } |
1936 | 1982 | ||
1937 | static int proc_fd_link(struct inode *inode, struct path *path) | 1983 | static int proc_fd_link(struct inode *inode, struct path *path) |
@@ -2026,7 +2072,7 @@ static struct dentry *proc_fd_instantiate(struct inode *dir, | |||
2026 | spin_unlock(&files->file_lock); | 2072 | spin_unlock(&files->file_lock); |
2027 | put_files_struct(files); | 2073 | put_files_struct(files); |
2028 | 2074 | ||
2029 | inode->i_op = &proc_pid_link_inode_operations; | 2075 | inode->i_op = &proc_fd_link_inode_operations; |
2030 | inode->i_size = 64; | 2076 | inode->i_size = 64; |
2031 | ei->op.proc_get_link = proc_fd_link; | 2077 | ei->op.proc_get_link = proc_fd_link; |
2032 | d_set_d_op(dentry, &tid_fd_dentry_operations); | 2078 | d_set_d_op(dentry, &tid_fd_dentry_operations); |
@@ -2058,7 +2104,12 @@ static struct dentry *proc_lookupfd_common(struct inode *dir, | |||
2058 | if (fd == ~0U) | 2104 | if (fd == ~0U) |
2059 | goto out; | 2105 | goto out; |
2060 | 2106 | ||
2107 | result = ERR_PTR(-EACCES); | ||
2108 | if (lock_trace(task)) | ||
2109 | goto out; | ||
2110 | |||
2061 | result = instantiate(dir, dentry, task, &fd); | 2111 | result = instantiate(dir, dentry, task, &fd); |
2112 | unlock_trace(task); | ||
2062 | out: | 2113 | out: |
2063 | put_task_struct(task); | 2114 | put_task_struct(task); |
2064 | out_no_task: | 2115 | out_no_task: |
@@ -2078,23 +2129,28 @@ static int proc_readfd_common(struct file * filp, void * dirent, | |||
2078 | retval = -ENOENT; | 2129 | retval = -ENOENT; |
2079 | if (!p) | 2130 | if (!p) |
2080 | goto out_no_task; | 2131 | goto out_no_task; |
2132 | |||
2133 | retval = -EACCES; | ||
2134 | if (lock_trace(p)) | ||
2135 | goto out; | ||
2136 | |||
2081 | retval = 0; | 2137 | retval = 0; |
2082 | 2138 | ||
2083 | fd = filp->f_pos; | 2139 | fd = filp->f_pos; |
2084 | switch (fd) { | 2140 | switch (fd) { |
2085 | case 0: | 2141 | case 0: |
2086 | if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0) | 2142 | if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0) |
2087 | goto out; | 2143 | goto out_unlock; |
2088 | filp->f_pos++; | 2144 | filp->f_pos++; |
2089 | case 1: | 2145 | case 1: |
2090 | ino = parent_ino(dentry); | 2146 | ino = parent_ino(dentry); |
2091 | if (filldir(dirent, "..", 2, 1, ino, DT_DIR) < 0) | 2147 | if (filldir(dirent, "..", 2, 1, ino, DT_DIR) < 0) |
2092 | goto out; | 2148 | goto out_unlock; |
2093 | filp->f_pos++; | 2149 | filp->f_pos++; |
2094 | default: | 2150 | default: |
2095 | files = get_files_struct(p); | 2151 | files = get_files_struct(p); |
2096 | if (!files) | 2152 | if (!files) |
2097 | goto out; | 2153 | goto out_unlock; |
2098 | rcu_read_lock(); | 2154 | rcu_read_lock(); |
2099 | for (fd = filp->f_pos-2; | 2155 | for (fd = filp->f_pos-2; |
2100 | fd < files_fdtable(files)->max_fds; | 2156 | fd < files_fdtable(files)->max_fds; |
@@ -2118,6 +2174,9 @@ static int proc_readfd_common(struct file * filp, void * dirent, | |||
2118 | rcu_read_unlock(); | 2174 | rcu_read_unlock(); |
2119 | put_files_struct(files); | 2175 | put_files_struct(files); |
2120 | } | 2176 | } |
2177 | |||
2178 | out_unlock: | ||
2179 | unlock_trace(p); | ||
2121 | out: | 2180 | out: |
2122 | put_task_struct(p); | 2181 | put_task_struct(p); |
2123 | out_no_task: | 2182 | out_no_task: |
@@ -2195,6 +2254,7 @@ static struct dentry *proc_fdinfo_instantiate(struct inode *dir, | |||
2195 | ei->fd = fd; | 2254 | ei->fd = fd; |
2196 | inode->i_mode = S_IFREG | S_IRUSR; | 2255 | inode->i_mode = S_IFREG | S_IRUSR; |
2197 | inode->i_fop = &proc_fdinfo_file_operations; | 2256 | inode->i_fop = &proc_fdinfo_file_operations; |
2257 | inode->i_op = &proc_fdinfo_link_inode_operations; | ||
2198 | d_set_d_op(dentry, &tid_fd_dentry_operations); | 2258 | d_set_d_op(dentry, &tid_fd_dentry_operations); |
2199 | d_add(dentry, inode); | 2259 | d_add(dentry, inode); |
2200 | /* Close the race of the process dying before we return the dentry */ | 2260 | /* Close the race of the process dying before we return the dentry */ |
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index b44113279e30..a6b62173d4c3 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c | |||
@@ -3,6 +3,7 @@ | |||
3 | */ | 3 | */ |
4 | #include <linux/init.h> | 4 | #include <linux/init.h> |
5 | #include <linux/sysctl.h> | 5 | #include <linux/sysctl.h> |
6 | #include <linux/poll.h> | ||
6 | #include <linux/proc_fs.h> | 7 | #include <linux/proc_fs.h> |
7 | #include <linux/security.h> | 8 | #include <linux/security.h> |
8 | #include <linux/namei.h> | 9 | #include <linux/namei.h> |
@@ -14,6 +15,15 @@ static const struct inode_operations proc_sys_inode_operations; | |||
14 | static const struct file_operations proc_sys_dir_file_operations; | 15 | static const struct file_operations proc_sys_dir_file_operations; |
15 | static const struct inode_operations proc_sys_dir_operations; | 16 | static const struct inode_operations proc_sys_dir_operations; |
16 | 17 | ||
18 | void proc_sys_poll_notify(struct ctl_table_poll *poll) | ||
19 | { | ||
20 | if (!poll) | ||
21 | return; | ||
22 | |||
23 | atomic_inc(&poll->event); | ||
24 | wake_up_interruptible(&poll->wait); | ||
25 | } | ||
26 | |||
17 | static struct inode *proc_sys_make_inode(struct super_block *sb, | 27 | static struct inode *proc_sys_make_inode(struct super_block *sb, |
18 | struct ctl_table_header *head, struct ctl_table *table) | 28 | struct ctl_table_header *head, struct ctl_table *table) |
19 | { | 29 | { |
@@ -176,6 +186,39 @@ static ssize_t proc_sys_write(struct file *filp, const char __user *buf, | |||
176 | return proc_sys_call_handler(filp, (void __user *)buf, count, ppos, 1); | 186 | return proc_sys_call_handler(filp, (void __user *)buf, count, ppos, 1); |
177 | } | 187 | } |
178 | 188 | ||
189 | static int proc_sys_open(struct inode *inode, struct file *filp) | ||
190 | { | ||
191 | struct ctl_table *table = PROC_I(inode)->sysctl_entry; | ||
192 | |||
193 | if (table->poll) | ||
194 | filp->private_data = proc_sys_poll_event(table->poll); | ||
195 | |||
196 | return 0; | ||
197 | } | ||
198 | |||
199 | static unsigned int proc_sys_poll(struct file *filp, poll_table *wait) | ||
200 | { | ||
201 | struct inode *inode = filp->f_path.dentry->d_inode; | ||
202 | struct ctl_table *table = PROC_I(inode)->sysctl_entry; | ||
203 | unsigned long event = (unsigned long)filp->private_data; | ||
204 | unsigned int ret = DEFAULT_POLLMASK; | ||
205 | |||
206 | if (!table->proc_handler) | ||
207 | goto out; | ||
208 | |||
209 | if (!table->poll) | ||
210 | goto out; | ||
211 | |||
212 | poll_wait(filp, &table->poll->wait, wait); | ||
213 | |||
214 | if (event != atomic_read(&table->poll->event)) { | ||
215 | filp->private_data = proc_sys_poll_event(table->poll); | ||
216 | ret = POLLIN | POLLRDNORM | POLLERR | POLLPRI; | ||
217 | } | ||
218 | |||
219 | out: | ||
220 | return ret; | ||
221 | } | ||
179 | 222 | ||
180 | static int proc_sys_fill_cache(struct file *filp, void *dirent, | 223 | static int proc_sys_fill_cache(struct file *filp, void *dirent, |
181 | filldir_t filldir, | 224 | filldir_t filldir, |
@@ -364,12 +407,15 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct | |||
364 | } | 407 | } |
365 | 408 | ||
366 | static const struct file_operations proc_sys_file_operations = { | 409 | static const struct file_operations proc_sys_file_operations = { |
410 | .open = proc_sys_open, | ||
411 | .poll = proc_sys_poll, | ||
367 | .read = proc_sys_read, | 412 | .read = proc_sys_read, |
368 | .write = proc_sys_write, | 413 | .write = proc_sys_write, |
369 | .llseek = default_llseek, | 414 | .llseek = default_llseek, |
370 | }; | 415 | }; |
371 | 416 | ||
372 | static const struct file_operations proc_sys_dir_file_operations = { | 417 | static const struct file_operations proc_sys_dir_file_operations = { |
418 | .read = generic_read_dir, | ||
373 | .readdir = proc_sys_readdir, | 419 | .readdir = proc_sys_readdir, |
374 | .llseek = generic_file_llseek, | 420 | .llseek = generic_file_llseek, |
375 | }; | 421 | }; |