diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-02 23:25:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-02 23:25:04 -0400 |
commit | aab174f0df5d72d31caccf281af5f614fa254578 (patch) | |
tree | 2a172c5009c4ac8755e858593154c258ce7709a0 /arch/um | |
parent | ca41cc96b2813221b05af57d0355157924de5a07 (diff) | |
parent | 2bd2c1941f141ad780135ccc1cd08ca71a24f10a (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs update from Al Viro:
- big one - consolidation of descriptor-related logics; almost all of
that is moved to fs/file.c
(BTW, I'm seriously tempted to rename the result to fd.c. As it is,
we have a situation when file_table.c is about handling of struct
file and file.c is about handling of descriptor tables; the reasons
are historical - file_table.c used to be about a static array of
struct file we used to have way back).
A lot of stray ends got cleaned up and converted to saner primitives,
disgusting mess in android/binder.c is still disgusting, but at least
doesn't poke so much in descriptor table guts anymore. A bunch of
relatively minor races got fixed in process, plus an ext4 struct file
leak.
- related thing - fget_light() partially unuglified; see fdget() in
there (and yes, it generates the code as good as we used to have).
- also related - bits of Cyrill's procfs stuff that got entangled into
that work; _not_ all of it, just the initial move to fs/proc/fd.c and
switch of fdinfo to seq_file.
- Alex's fs/coredump.c spiltoff - the same story, had been easier to
take that commit than mess with conflicts. The rest is a separate
pile, this was just a mechanical code movement.
- a few misc patches all over the place. Not all for this cycle,
there'll be more (and quite a few currently sit in akpm's tree)."
Fix up trivial conflicts in the android binder driver, and some fairly
simple conflicts due to two different changes to the sock_alloc_file()
interface ("take descriptor handling from sock_alloc_file() to callers"
vs "net: Providing protocol type via system.sockprotoname xattr of
/proc/PID/fd entries" adding a dentry name to the socket)
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (72 commits)
MAX_LFS_FILESIZE should be a loff_t
compat: fs: Generic compat_sys_sendfile implementation
fs: push rcu_barrier() from deactivate_locked_super() to filesystems
btrfs: reada_extent doesn't need kref for refcount
coredump: move core dump functionality into its own file
coredump: prevent double-free on an error path in core dumper
usb/gadget: fix misannotations
fcntl: fix misannotations
ceph: don't abuse d_delete() on failure exits
hypfs: ->d_parent is never NULL or negative
vfs: delete surplus inode NULL check
switch simple cases of fget_light to fdget
new helpers: fdget()/fdput()
switch o2hb_region_dev_write() to fget_light()
proc_map_files_readdir(): don't bother with grabbing files
make get_file() return its argument
vhost_set_vring(): turn pollstart/pollstop into bool
switch prctl_set_mm_exe_file() to fget_light()
switch xfs_find_handle() to fget_light()
switch xfs_swapext() to fget_light()
...
Diffstat (limited to 'arch/um')
-rw-r--r-- | arch/um/drivers/mconsole_kern.c | 99 |
1 files changed, 21 insertions, 78 deletions
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c index c17de0db6736..9efeb6da48bc 100644 --- a/arch/um/drivers/mconsole_kern.c +++ b/arch/um/drivers/mconsole_kern.c | |||
@@ -21,6 +21,9 @@ | |||
21 | #include <linux/un.h> | 21 | #include <linux/un.h> |
22 | #include <linux/workqueue.h> | 22 | #include <linux/workqueue.h> |
23 | #include <linux/mutex.h> | 23 | #include <linux/mutex.h> |
24 | #include <linux/fs.h> | ||
25 | #include <linux/mount.h> | ||
26 | #include <linux/file.h> | ||
24 | #include <asm/uaccess.h> | 27 | #include <asm/uaccess.h> |
25 | #include <asm/switch_to.h> | 28 | #include <asm/switch_to.h> |
26 | 29 | ||
@@ -118,90 +121,38 @@ void mconsole_log(struct mc_request *req) | |||
118 | mconsole_reply(req, "", 0, 0); | 121 | mconsole_reply(req, "", 0, 0); |
119 | } | 122 | } |
120 | 123 | ||
121 | /* This is a more convoluted version of mconsole_proc, which has some stability | ||
122 | * problems; however, we need it fixed, because it is expected that UML users | ||
123 | * mount HPPFS instead of procfs on /proc. And we want mconsole_proc to still | ||
124 | * show the real procfs content, not the ones from hppfs.*/ | ||
125 | #if 0 | ||
126 | void mconsole_proc(struct mc_request *req) | 124 | void mconsole_proc(struct mc_request *req) |
127 | { | 125 | { |
128 | struct vfsmount *mnt = current->nsproxy->pid_ns->proc_mnt; | 126 | struct vfsmount *mnt = current->nsproxy->pid_ns->proc_mnt; |
129 | struct file *file; | ||
130 | int n; | ||
131 | char *ptr = req->request.data, *buf; | ||
132 | mm_segment_t old_fs = get_fs(); | ||
133 | |||
134 | ptr += strlen("proc"); | ||
135 | ptr = skip_spaces(ptr); | ||
136 | |||
137 | file = file_open_root(mnt->mnt_root, mnt, ptr, O_RDONLY); | ||
138 | if (IS_ERR(file)) { | ||
139 | mconsole_reply(req, "Failed to open file", 1, 0); | ||
140 | goto out; | ||
141 | } | ||
142 | |||
143 | buf = kmalloc(PAGE_SIZE, GFP_KERNEL); | ||
144 | if (buf == NULL) { | ||
145 | mconsole_reply(req, "Failed to allocate buffer", 1, 0); | ||
146 | goto out_fput; | ||
147 | } | ||
148 | |||
149 | if (file->f_op->read) { | ||
150 | do { | ||
151 | loff_t pos; | ||
152 | set_fs(KERNEL_DS); | ||
153 | n = vfs_read(file, buf, PAGE_SIZE - 1, &pos); | ||
154 | file_pos_write(file, pos); | ||
155 | set_fs(old_fs); | ||
156 | if (n >= 0) { | ||
157 | buf[n] = '\0'; | ||
158 | mconsole_reply(req, buf, 0, (n > 0)); | ||
159 | } | ||
160 | else { | ||
161 | mconsole_reply(req, "Read of file failed", | ||
162 | 1, 0); | ||
163 | goto out_free; | ||
164 | } | ||
165 | } while (n > 0); | ||
166 | } | ||
167 | else mconsole_reply(req, "", 0, 0); | ||
168 | |||
169 | out_free: | ||
170 | kfree(buf); | ||
171 | out_fput: | ||
172 | fput(file); | ||
173 | out: ; | ||
174 | } | ||
175 | #endif | ||
176 | |||
177 | void mconsole_proc(struct mc_request *req) | ||
178 | { | ||
179 | char path[64]; | ||
180 | char *buf; | 127 | char *buf; |
181 | int len; | 128 | int len; |
182 | int fd; | 129 | struct file *file; |
183 | int first_chunk = 1; | 130 | int first_chunk = 1; |
184 | char *ptr = req->request.data; | 131 | char *ptr = req->request.data; |
185 | 132 | ||
186 | ptr += strlen("proc"); | 133 | ptr += strlen("proc"); |
187 | ptr = skip_spaces(ptr); | 134 | ptr = skip_spaces(ptr); |
188 | snprintf(path, sizeof(path), "/proc/%s", ptr); | ||
189 | 135 | ||
190 | fd = sys_open(path, 0, 0); | 136 | file = file_open_root(mnt->mnt_root, mnt, ptr, O_RDONLY); |
191 | if (fd < 0) { | 137 | if (IS_ERR(file)) { |
192 | mconsole_reply(req, "Failed to open file", 1, 0); | 138 | mconsole_reply(req, "Failed to open file", 1, 0); |
193 | printk(KERN_ERR "open %s: %d\n",path,fd); | 139 | printk(KERN_ERR "open /proc/%s: %ld\n", ptr, PTR_ERR(file)); |
194 | goto out; | 140 | goto out; |
195 | } | 141 | } |
196 | 142 | ||
197 | buf = kmalloc(PAGE_SIZE, GFP_KERNEL); | 143 | buf = kmalloc(PAGE_SIZE, GFP_KERNEL); |
198 | if (buf == NULL) { | 144 | if (buf == NULL) { |
199 | mconsole_reply(req, "Failed to allocate buffer", 1, 0); | 145 | mconsole_reply(req, "Failed to allocate buffer", 1, 0); |
200 | goto out_close; | 146 | goto out_fput; |
201 | } | 147 | } |
202 | 148 | ||
203 | for (;;) { | 149 | do { |
204 | len = sys_read(fd, buf, PAGE_SIZE-1); | 150 | loff_t pos; |
151 | mm_segment_t old_fs = get_fs(); | ||
152 | set_fs(KERNEL_DS); | ||
153 | len = vfs_read(file, buf, PAGE_SIZE - 1, &pos); | ||
154 | set_fs(old_fs); | ||
155 | file->f_pos = pos; | ||
205 | if (len < 0) { | 156 | if (len < 0) { |
206 | mconsole_reply(req, "Read of file failed", 1, 0); | 157 | mconsole_reply(req, "Read of file failed", 1, 0); |
207 | goto out_free; | 158 | goto out_free; |
@@ -211,22 +162,14 @@ void mconsole_proc(struct mc_request *req) | |||
211 | mconsole_reply(req, "\n", 0, 1); | 162 | mconsole_reply(req, "\n", 0, 1); |
212 | first_chunk = 0; | 163 | first_chunk = 0; |
213 | } | 164 | } |
214 | if (len == PAGE_SIZE-1) { | 165 | buf[len] = '\0'; |
215 | buf[len] = '\0'; | 166 | mconsole_reply(req, buf, 0, (len > 0)); |
216 | mconsole_reply(req, buf, 0, 1); | 167 | } while (len > 0); |
217 | } else { | ||
218 | buf[len] = '\0'; | ||
219 | mconsole_reply(req, buf, 0, 0); | ||
220 | break; | ||
221 | } | ||
222 | } | ||
223 | |||
224 | out_free: | 168 | out_free: |
225 | kfree(buf); | 169 | kfree(buf); |
226 | out_close: | 170 | out_fput: |
227 | sys_close(fd); | 171 | fput(file); |
228 | out: | 172 | out: ; |
229 | /* nothing */; | ||
230 | } | 173 | } |
231 | 174 | ||
232 | #define UML_MCONSOLE_HELPTEXT \ | 175 | #define UML_MCONSOLE_HELPTEXT \ |