Skip to content

Commit

Permalink
pstore: Add file extension to pstore file if compressed
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Signed-off-by: Tony Luck <[email protected]>
  • Loading branch information
arunabal authored and aegl committed Aug 19, 2013
1 parent adb42f5 commit 9ad2cbe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions fs/pstore/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ int pstore_is_mounted(void)
* 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,
char *data, size_t size, struct timespec time,
struct pstore_info *psi)
char *data, bool compressed, size_t size,
struct timespec time, struct pstore_info *psi)
{
struct dentry *root = pstore_sb->s_root;
struct dentry *dentry;
Expand Down Expand Up @@ -315,7 +315,8 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count,

switch (type) {
case PSTORE_TYPE_DMESG:
sprintf(name, "dmesg-%s-%lld", psname, id);
sprintf(name, "dmesg-%s-%lld%s", psname, id,
compressed ? ".enc.z" : "");
break;
case PSTORE_TYPE_CONSOLE:
sprintf(name, "console-%s", psname);
Expand Down
5 changes: 3 additions & 2 deletions fs/pstore/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ extern struct pstore_info *psinfo;
extern void pstore_set_kmsg_bytes(int);
extern void pstore_get_records(int);
extern int pstore_mkfile(enum pstore_type_id, char *psname, u64 id,
int count, char *data, size_t size,
struct timespec time, struct pstore_info *psi);
int count, char *data, bool compressed,
size_t size, struct timespec time,
struct pstore_info *psi);
extern int pstore_is_mounted(void);

#endif
4 changes: 3 additions & 1 deletion fs/pstore/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,13 +479,15 @@ void pstore_get_records(int quiet)
if (unzipped_len > 0) {
buf = big_oops_buf;
size = unzipped_len;
compressed = false;
} else {
pr_err("pstore: decompression failed;"
"returned %d\n", unzipped_len);
compressed = true;
}
}
rc = pstore_mkfile(type, psi->name, id, count, buf,
(size_t)size, time, psi);
compressed, (size_t)size, time, psi);
if (unzipped_len < 0) {
/* Free buffer other than big oops */
kfree(buf);
Expand Down

0 comments on commit 9ad2cbe

Please sign in to comment.