aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2017-03-03 21:16:32 -0500
committerKees Cook <keescook@chromium.org>2017-03-07 17:00:55 -0500
commit1edd1aa397ad3ca5f1fca1961c13910ef53f16e8 (patch)
tree608e00d7713f78d48cfa199d1ba9294d59587b70
parent634f8f5167c88052ce6d28e519ff6325172191dc (diff)
pstore: Switch pstore_mkfile to pass record
Instead of the long list of arguments, just pass the new record struct. Signed-off-by: Kees Cook <keescook@chromium.org>
-rw-r--r--fs/pstore/inode.c57
-rw-r--r--fs/pstore/internal.h5
-rw-r--r--fs/pstore/platform.c6
3 files changed, 34 insertions, 34 deletions
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index 57c0646479f5..a98787bab3e6 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -302,9 +302,7 @@ bool pstore_is_mounted(void)
302 * Load it up with "size" bytes of data from "buf". 302 * Load it up with "size" bytes of data from "buf".
303 * Set the mtime & ctime to the date that this record was originally stored. 303 * Set the mtime & ctime to the date that this record was originally stored.
304 */ 304 */
305int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count, 305int pstore_mkfile(struct pstore_record *record)
306 char *data, bool compressed, size_t size,
307 struct timespec time, struct pstore_info *psi)
308{ 306{
309 struct dentry *root = pstore_sb->s_root; 307 struct dentry *root = pstore_sb->s_root;
310 struct dentry *dentry; 308 struct dentry *dentry;
@@ -313,12 +311,13 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count,
313 char name[PSTORE_NAMELEN]; 311 char name[PSTORE_NAMELEN];
314 struct pstore_private *private, *pos; 312 struct pstore_private *private, *pos;
315 unsigned long flags; 313 unsigned long flags;
314 size_t size = record->size + record->ecc_notice_size;
316 315
317 spin_lock_irqsave(&allpstore_lock, flags); 316 spin_lock_irqsave(&allpstore_lock, flags);
318 list_for_each_entry(pos, &allpstore, list) { 317 list_for_each_entry(pos, &allpstore, list) {
319 if (pos->type == type && 318 if (pos->type == record->type &&
320 pos->id == id && 319 pos->id == record->id &&
321 pos->psi == psi) { 320 pos->psi == record->psi) {
322 rc = -EEXIST; 321 rc = -EEXIST;
323 break; 322 break;
324 } 323 }
@@ -336,48 +335,56 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count,
336 private = kmalloc(sizeof *private + size, GFP_KERNEL); 335 private = kmalloc(sizeof *private + size, GFP_KERNEL);
337 if (!private) 336 if (!private)
338 goto fail_alloc; 337 goto fail_alloc;
339 private->type = type; 338 private->type = record->type;
340 private->id = id; 339 private->id = record->id;
341 private->count = count; 340 private->count = record->count;
342 private->psi = psi; 341 private->psi = record->psi;
343 342
344 switch (type) { 343 switch (record->type) {
345 case PSTORE_TYPE_DMESG: 344 case PSTORE_TYPE_DMESG:
346 scnprintf(name, sizeof(name), "dmesg-%s-%lld%s", 345 scnprintf(name, sizeof(name), "dmesg-%s-%lld%s",
347 psname, id, compressed ? ".enc.z" : ""); 346 record->psi->name, record->id,
347 record->compressed ? ".enc.z" : "");
348 break; 348 break;
349 case PSTORE_TYPE_CONSOLE: 349 case PSTORE_TYPE_CONSOLE:
350 scnprintf(name, sizeof(name), "console-%s-%lld", psname, id); 350 scnprintf(name, sizeof(name), "console-%s-%lld",
351 record->psi->name, record->id);
351 break; 352 break;
352 case PSTORE_TYPE_FTRACE: 353 case PSTORE_TYPE_FTRACE:
353 scnprintf(name, sizeof(name), "ftrace-%s-%lld", psname, id); 354 scnprintf(name, sizeof(name), "ftrace-%s-%lld",
355 record->psi->name, record->id);
354 break; 356 break;
355 case PSTORE_TYPE_MCE: 357 case PSTORE_TYPE_MCE:
356 scnprintf(name, sizeof(name), "mce-%s-%lld", psname, id); 358 scnprintf(name, sizeof(name), "mce-%s-%lld",
359 record->psi->name, record->id);
357 break; 360 break;
358 case PSTORE_TYPE_PPC_RTAS: 361 case PSTORE_TYPE_PPC_RTAS:
359 scnprintf(name, sizeof(name), "rtas-%s-%lld", psname, id); 362 scnprintf(name, sizeof(name), "rtas-%s-%lld",
363 record->psi->name, record->id);
360 break; 364 break;
361 case PSTORE_TYPE_PPC_OF: 365 case PSTORE_TYPE_PPC_OF:
362 scnprintf(name, sizeof(name), "powerpc-ofw-%s-%lld", 366 scnprintf(name, sizeof(name), "powerpc-ofw-%s-%lld",
363 psname, id); 367 record->psi->name, record->id);
364 break; 368 break;
365 case PSTORE_TYPE_PPC_COMMON: 369 case PSTORE_TYPE_PPC_COMMON:
366 scnprintf(name, sizeof(name), "powerpc-common-%s-%lld", 370 scnprintf(name, sizeof(name), "powerpc-common-%s-%lld",
367 psname, id); 371 record->psi->name, record->id);
368 break; 372 break;
369 case PSTORE_TYPE_PMSG: 373 case PSTORE_TYPE_PMSG:
370 scnprintf(name, sizeof(name), "pmsg-%s-%lld", psname, id); 374 scnprintf(name, sizeof(name), "pmsg-%s-%lld",
375 record->psi->name, record->id);
371 break; 376 break;
372 case PSTORE_TYPE_PPC_OPAL: 377 case PSTORE_TYPE_PPC_OPAL:
373 sprintf(name, "powerpc-opal-%s-%lld", psname, id); 378 scnprintf(name, sizeof(name), "powerpc-opal-%s-%lld",
379 record->psi->name, record->id);
374 break; 380 break;
375 case PSTORE_TYPE_UNKNOWN: 381 case PSTORE_TYPE_UNKNOWN:
376 scnprintf(name, sizeof(name), "unknown-%s-%lld", psname, id); 382 scnprintf(name, sizeof(name), "unknown-%s-%lld",
383 record->psi->name, record->id);
377 break; 384 break;
378 default: 385 default:
379 scnprintf(name, sizeof(name), "type%d-%s-%lld", 386 scnprintf(name, sizeof(name), "type%d-%s-%lld",
380 type, psname, id); 387 record->type, record->psi->name, record->id);
381 break; 388 break;
382 } 389 }
383 390
@@ -387,13 +394,13 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count,
387 if (!dentry) 394 if (!dentry)
388 goto fail_lockedalloc; 395 goto fail_lockedalloc;
389 396
390 memcpy(private->data, data, size); 397 memcpy(private->data, record->buf, size);
391 inode->i_size = private->size = size; 398 inode->i_size = private->size = size;
392 399
393 inode->i_private = private; 400 inode->i_private = private;
394 401
395 if (time.tv_sec) 402 if (record->time.tv_sec)
396 inode->i_mtime = inode->i_ctime = time; 403 inode->i_mtime = inode->i_ctime = record->time;
397 404
398 d_add(dentry, inode); 405 d_add(dentry, inode);
399 406
diff --git a/fs/pstore/internal.h b/fs/pstore/internal.h
index da416e6591c9..af1df5a36d86 100644
--- a/fs/pstore/internal.h
+++ b/fs/pstore/internal.h
@@ -25,10 +25,7 @@ extern struct pstore_info *psinfo;
25 25
26extern void pstore_set_kmsg_bytes(int); 26extern void pstore_set_kmsg_bytes(int);
27extern void pstore_get_records(int); 27extern void pstore_get_records(int);
28extern int pstore_mkfile(enum pstore_type_id, char *psname, u64 id, 28extern int pstore_mkfile(struct pstore_record *record);
29 int count, char *data, bool compressed,
30 size_t size, struct timespec time,
31 struct pstore_info *psi);
32extern bool pstore_is_mounted(void); 29extern bool pstore_is_mounted(void);
33 30
34#endif 31#endif
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 0503380704de..168e03fd5e58 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -814,11 +814,7 @@ void pstore_get_records(int quiet)
814 record.psi)) > 0) { 814 record.psi)) > 0) {
815 815
816 decompress_record(&record); 816 decompress_record(&record);
817 rc = pstore_mkfile(record.type, psi->name, record.id, 817 rc = pstore_mkfile(&record);
818 record.count, record.buf,
819 record.compressed,
820 record.size + record.ecc_notice_size,
821 record.time, record.psi);
822 818
823 /* Free buffer other than big oops */ 819 /* Free buffer other than big oops */
824 if (record.buf != big_oops_buf) 820 if (record.buf != big_oops_buf)