summaryrefslogtreecommitdiff
path: root/fs/coredump.c
diff options
context:
space:
mode:
authorSumit Semwal <sumit.semwal@linaro.org>2017-08-29 15:19:14 +0530
committerSumit Semwal <sumit.semwal@linaro.org>2017-08-29 15:19:14 +0530
commitef403470dda92373053a19df8fb4a2b3852572f8 (patch)
tree8f35b840f4ac75db3c269adf9eae635a0454aa1e /fs/coredump.c
parentf5ec4ffd9c9ddf29aaf339a8619a5cd145f62342 (diff)
parent21da057573dbaa35b7fe01f19848edb5b0af2a3c (diff)
Merge remote-tracking branch 'stable-rc/linux-4.4.y' into 4.4.85-rc-hikeytemp-4.4.85-rc-hikey
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Diffstat (limited to 'fs/coredump.c')
-rw-r--r--fs/coredump.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/fs/coredump.c b/fs/coredump.c
index 5d15c4975ba1..a8852293038a 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -810,3 +810,21 @@ int dump_align(struct coredump_params *cprm, int align)
return mod ? dump_skip(cprm, align - mod) : 1;
}
EXPORT_SYMBOL(dump_align);
+
+/*
+ * Ensures that file size is big enough to contain the current file
+ * postion. This prevents gdb from complaining about a truncated file
+ * if the last "write" to the file was dump_skip.
+ */
+void dump_truncate(struct coredump_params *cprm)
+{
+ struct file *file = cprm->file;
+ loff_t offset;
+
+ if (file->f_op->llseek && file->f_op->llseek != no_llseek) {
+ offset = file->f_op->llseek(file, 0, SEEK_CUR);
+ if (i_size_read(file->f_mapping->host) < offset)
+ do_truncate(file->f_path.dentry, offset, 0, file);
+ }
+}
+EXPORT_SYMBOL(dump_truncate);