Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pstore: Add file extension to pstore file if compressed

In case decompression fails, add a ".enc.z" to indicate the file has
compressed data. This will help user space utilities to figure
out the file contents.

Signed-off-by: Aruna Balakrishnaiah <aruna@linux.vnet.ibm.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>

authored by

Aruna Balakrishnaiah and committed by
Tony Luck
9ad2cbe0 adb42f5e

+10 -6
+4 -3
fs/pstore/inode.c
··· 275 275 * Set the mtime & ctime to the date that this record was originally stored. 276 276 */ 277 277 int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count, 278 - char *data, size_t size, struct timespec time, 279 - struct pstore_info *psi) 278 + char *data, bool compressed, size_t size, 279 + struct timespec time, struct pstore_info *psi) 280 280 { 281 281 struct dentry *root = pstore_sb->s_root; 282 282 struct dentry *dentry; ··· 315 315 316 316 switch (type) { 317 317 case PSTORE_TYPE_DMESG: 318 - sprintf(name, "dmesg-%s-%lld", psname, id); 318 + sprintf(name, "dmesg-%s-%lld%s", psname, id, 319 + compressed ? ".enc.z" : ""); 319 320 break; 320 321 case PSTORE_TYPE_CONSOLE: 321 322 sprintf(name, "console-%s", psname);
+3 -2
fs/pstore/internal.h
··· 50 50 extern void pstore_set_kmsg_bytes(int); 51 51 extern void pstore_get_records(int); 52 52 extern int pstore_mkfile(enum pstore_type_id, char *psname, u64 id, 53 - int count, char *data, size_t size, 54 - struct timespec time, struct pstore_info *psi); 53 + int count, char *data, bool compressed, 54 + size_t size, struct timespec time, 55 + struct pstore_info *psi); 55 56 extern int pstore_is_mounted(void); 56 57 57 58 #endif
+3 -1
fs/pstore/platform.c
··· 479 479 if (unzipped_len > 0) { 480 480 buf = big_oops_buf; 481 481 size = unzipped_len; 482 + compressed = false; 482 483 } else { 483 484 pr_err("pstore: decompression failed;" 484 485 "returned %d\n", unzipped_len); 486 + compressed = true; 485 487 } 486 488 } 487 489 rc = pstore_mkfile(type, psi->name, id, count, buf, 488 - (size_t)size, time, psi); 490 + compressed, (size_t)size, time, psi); 489 491 if (unzipped_len < 0) { 490 492 /* Free buffer other than big oops */ 491 493 kfree(buf);