Commit 9ad2cbe0 authored by Aruna Balakrishnaiah's avatar Aruna Balakrishnaiah Committed by Tony Luck

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: default avatarAruna Balakrishnaiah <aruna@linux.vnet.ibm.com>
Reviewed-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
parent adb42f5e
...@@ -275,8 +275,8 @@ int pstore_is_mounted(void) ...@@ -275,8 +275,8 @@ int pstore_is_mounted(void)
* Set the mtime & ctime to the date that this record was originally stored. * Set the mtime & ctime to the date that this record was originally stored.
*/ */
int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count, int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count,
char *data, size_t size, struct timespec time, char *data, bool compressed, size_t size,
struct pstore_info *psi) struct timespec time, struct pstore_info *psi)
{ {
struct dentry *root = pstore_sb->s_root; struct dentry *root = pstore_sb->s_root;
struct dentry *dentry; struct dentry *dentry;
...@@ -315,7 +315,8 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count, ...@@ -315,7 +315,8 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count,
switch (type) { switch (type) {
case PSTORE_TYPE_DMESG: case PSTORE_TYPE_DMESG:
sprintf(name, "dmesg-%s-%lld", psname, id); sprintf(name, "dmesg-%s-%lld%s", psname, id,
compressed ? ".enc.z" : "");
break; break;
case PSTORE_TYPE_CONSOLE: case PSTORE_TYPE_CONSOLE:
sprintf(name, "console-%s", psname); sprintf(name, "console-%s", psname);
......
...@@ -50,8 +50,9 @@ extern struct pstore_info *psinfo; ...@@ -50,8 +50,9 @@ extern struct pstore_info *psinfo;
extern void pstore_set_kmsg_bytes(int); extern void pstore_set_kmsg_bytes(int);
extern void pstore_get_records(int); extern void pstore_get_records(int);
extern int pstore_mkfile(enum pstore_type_id, char *psname, u64 id, extern int pstore_mkfile(enum pstore_type_id, char *psname, u64 id,
int count, char *data, size_t size, int count, char *data, bool compressed,
struct timespec time, struct pstore_info *psi); size_t size, struct timespec time,
struct pstore_info *psi);
extern int pstore_is_mounted(void); extern int pstore_is_mounted(void);
#endif #endif
...@@ -479,13 +479,15 @@ void pstore_get_records(int quiet) ...@@ -479,13 +479,15 @@ void pstore_get_records(int quiet)
if (unzipped_len > 0) { if (unzipped_len > 0) {
buf = big_oops_buf; buf = big_oops_buf;
size = unzipped_len; size = unzipped_len;
compressed = false;
} else { } else {
pr_err("pstore: decompression failed;" pr_err("pstore: decompression failed;"
"returned %d\n", unzipped_len); "returned %d\n", unzipped_len);
compressed = true;
} }
} }
rc = pstore_mkfile(type, psi->name, id, count, buf, rc = pstore_mkfile(type, psi->name, id, count, buf,
(size_t)size, time, psi); compressed, (size_t)size, time, psi);
if (unzipped_len < 0) { if (unzipped_len < 0) {
/* Free buffer other than big oops */ /* Free buffer other than big oops */
kfree(buf); kfree(buf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment