summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>2009-09-22 16:45:51 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-23 07:39:42 -0700
commit678ad5d8aaf8925cb8465f84e1e47d9b1284666a (patch)
tree638189ae49da8da3dff9ba2f422f16a734b9388c
parent90396f96b7da0e2305ffe0266d22b6f8221f28ba (diff)
downloadlinux-3.10-678ad5d8aaf8925cb8465f84e1e47d9b1284666a.tar.gz
linux-3.10-678ad5d8aaf8925cb8465f84e1e47d9b1284666a.tar.bz2
linux-3.10-678ad5d8aaf8925cb8465f84e1e47d9b1284666a.zip
/proc/kcore: fix stat.st_size
Presently the size of /proc/kcore which can be read by 'ls -l' is 0. But it's not the correct value. On x86-64, ls -l shows ... root root 140737486266368 2009-09-17 10:29 /proc/kcore Then, 7FFFFFFE02000. This comes from vmalloc area's size. (*) This shows "core" size, not memory size. This patch shows the size by updating "size" field in struct proc_dir_entry. Later, lookup routine will create inode and fill inode->i_size based on this value. Then, this has a problem. - Once inode is cached, inode->i_size will never be updated. Then, this patch is not memory-hotplug-aware. To update inode->i_size, we have to know dentry or inode. But there is no way to lookup them by inside kernel. Hmmm.... Next patch will try it. Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Acked-by: WANG Cong <xiyou.wangcong@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/proc/kcore.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index 70733780fdd..3d0485c361c 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -107,6 +107,8 @@ static void free_kclist_ents(struct list_head *head)
*/
static void __kcore_update_ram(struct list_head *list)
{
+ int nphdr;
+ size_t size;
struct kcore_list *tmp, *pos;
LIST_HEAD(garbage);
@@ -121,6 +123,7 @@ static void __kcore_update_ram(struct list_head *list)
} else
list_splice(list, &garbage);
kcore_need_update = 0;
+ proc_root_kcore->size = get_kcore_size(&nphdr, &size);
write_unlock(&kclist_lock);
free_kclist_ents(&garbage);
@@ -429,7 +432,8 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
unsigned long start;
read_lock(&kclist_lock);
- proc_root_kcore->size = size = get_kcore_size(&nphdr, &elf_buflen);
+ size = get_kcore_size(&nphdr, &elf_buflen);
+
if (buflen == 0 || *fpos >= size) {
read_unlock(&kclist_lock);
return 0;