Skip to content

Commit 9ad2cbe

Browse files
arunabalaegl
authored andcommitted
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>
1 parent adb42f5 commit 9ad2cbe

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

‎fs/pstore/inode.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ int pstore_is_mounted(void)
275275
* Set the mtime & ctime to the date that this record was originally stored.
276276
*/
277277
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)
280280
{
281281
struct dentry *root = pstore_sb->s_root;
282282
struct dentry *dentry;
@@ -315,7 +315,8 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count,
315315

316316
switch (type) {
317317
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" : "");
319320
break;
320321
case PSTORE_TYPE_CONSOLE:
321322
sprintf(name, "console-%s", psname);

‎fs/pstore/internal.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ extern struct pstore_info *psinfo;
5050
extern void pstore_set_kmsg_bytes(int);
5151
extern void pstore_get_records(int);
5252
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);
5556
extern int pstore_is_mounted(void);
5657

5758
#endif

‎fs/pstore/platform.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,13 +479,15 @@ void pstore_get_records(int quiet)
479479
if (unzipped_len > 0) {
480480
buf = big_oops_buf;
481481
size = unzipped_len;
482+
compressed = false;
482483
} else {
483484
pr_err("pstore: decompression failed;"
484485
"returned %d\n", unzipped_len);
486+
compressed = true;
485487
}
486488
}
487489
rc = pstore_mkfile(type, psi->name, id, count, buf,
488-
(size_t)size, time, psi);
490+
compressed, (size_t)size, time, psi);
489491
if (unzipped_len < 0) {
490492
/* Free buffer other than big oops */
491493
kfree(buf);

0 commit comments

Comments
 (0)