linux/fs/pstore/platform.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Persistent Storage - platform driver interface parts.
 *
 * Copyright (C) 2007-2008 Google, Inc.
 * Copyright (C) 2010 Intel Corporation <[email protected]>
 */

#define pr_fmt(fmt)

#include <linux/atomic.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/kmsg_dump.h>
#include <linux/console.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/pstore.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/jiffies.h>
#include <linux/vmalloc.h>
#include <linux/workqueue.h>
#include <linux/zlib.h>

#include "internal.h"

/*
 * We defer making "oops" entries appear in pstore - see
 * whether the system is actually still running well enough
 * to let someone see the entry
 */
static int pstore_update_ms =;
module_param_named(update_ms, pstore_update_ms, int, 0600);
MODULE_PARM_DESC();

/* Names should be in the same order as the enum pstore_type_id */
static const char * const pstore_type_names[] =;

static int pstore_new_entry;

static void pstore_timefunc(struct timer_list *);
static DEFINE_TIMER(pstore_timer, pstore_timefunc);

static void pstore_dowork(struct work_struct *);
static DECLARE_WORK(pstore_work, pstore_dowork);

/*
 * psinfo_lock protects "psinfo" during calls to
 * pstore_register(), pstore_unregister(), and
 * the filesystem mount/unmount routines.
 */
static DEFINE_MUTEX(psinfo_lock);
struct pstore_info *psinfo;

static char *backend;
module_param(backend, charp, 0444);
MODULE_PARM_DESC();

/*
 * pstore no longer implements compression via the crypto API, and only
 * supports zlib deflate compression implemented using the zlib library
 * interface. This removes additional complexity which is hard to justify for a
 * diagnostic facility that has to operate in conditions where the system may
 * have become unstable. Zlib deflate is comparatively small in terms of code
 * size, and compresses ASCII text comparatively well. In terms of compression
 * speed, deflate is not the best performer but for recording the log output on
 * a kernel panic, this is not considered critical.
 *
 * The only remaining arguments supported by the compress= module parameter are
 * 'deflate' and 'none'. To retain compatibility with existing installations,
 * all other values are logged and replaced with 'deflate'.
 */
static char *compress =;
module_param(compress, charp, 0444);
MODULE_PARM_DESC();

/* How much of the kernel log to snapshot */
unsigned long kmsg_bytes =;
module_param(kmsg_bytes, ulong, 0444);
MODULE_PARM_DESC();

static void *compress_workspace;

/*
 * Compression is only used for dmesg output, which consists of low-entropy
 * ASCII text, and so we can assume worst-case 60%.
 */
#define DMESG_COMP_PERCENT

static char *big_oops_buf;
static size_t max_compressed_size;

void pstore_set_kmsg_bytes(int bytes)
{}

/* Tag each group of saved records with a sequence number */
static int	oopscount;

const char *pstore_type_to_name(enum pstore_type_id type)
{}
EXPORT_SYMBOL_GPL();

enum pstore_type_id pstore_name_to_type(const char *name)
{}
EXPORT_SYMBOL_GPL();

static void pstore_timer_kick(void)
{}

static bool pstore_cannot_block_path(enum kmsg_dump_reason reason)
{}

static int pstore_compress(const void *in, void *out,
			   unsigned int inlen, unsigned int outlen)
{}

static void allocate_buf_for_compression(void)
{}

static void free_buf_for_compression(void)
{}

void pstore_record_init(struct pstore_record *record,
			struct pstore_info *psinfo)
{}

/*
 * callback from kmsg_dump. Save as much as we can (up to kmsg_bytes) from the
 * end of the buffer.
 */
static void pstore_dump(struct kmsg_dumper *dumper,
			enum kmsg_dump_reason reason)
{}

static struct kmsg_dumper pstore_dumper =;

/*
 * Register with kmsg_dump to save last part of console log on panic.
 */
static void pstore_register_kmsg(void)
{}

static void pstore_unregister_kmsg(void)
{}

#ifdef CONFIG_PSTORE_CONSOLE
static void pstore_console_write(struct console *con, const char *s, unsigned c)
{}

static struct console pstore_console =;

static void pstore_register_console(void)
{}

static void pstore_unregister_console(void)
{}
#else
static void pstore_register_console(void) {}
static void pstore_unregister_console(void) {}
#endif

static int pstore_write_user_compat(struct pstore_record *record,
				    const char __user *buf)
{}

/*
 * platform specific persistent storage driver registers with
 * us here. If pstore is already mounted, call the platform
 * read function right away to populate the file system. If not
 * then the pstore mount code will call us later to fill out
 * the file system.
 */
int pstore_register(struct pstore_info *psi)
{}
EXPORT_SYMBOL_GPL();

void pstore_unregister(struct pstore_info *psi)
{}
EXPORT_SYMBOL_GPL();

static void decompress_record(struct pstore_record *record,
			      struct z_stream_s *zstream)
{}

/*
 * Read all the records from one persistent store backend. Create
 * files in our filesystem.  Don't warn about -EEXIST errors
 * when we are re-scanning the backing store looking to add new
 * error records.
 */
void pstore_get_backend_records(struct pstore_info *psi,
				struct dentry *root, int quiet)
{}

static void pstore_dowork(struct work_struct *work)
{}

static void pstore_timefunc(struct timer_list *unused)
{}

static int __init pstore_init(void)
{}
late_initcall(pstore_init);

static void __exit pstore_exit(void)
{}
module_exit()

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();