20 #include <linux/module.h>
25 #include <linux/time.h>
27 #include <linux/list.h>
28 #include <linux/string.h>
33 #include <linux/sched.h>
34 #include <linux/magic.h>
36 #include <linux/slab.h>
42 #define PSTORE_NAMELEN 64
62 #define REC_SIZE sizeof(struct pstore_ftrace_record)
64 static void *pstore_ftrace_seq_start(
struct seq_file *
s, loff_t *
pos)
75 if (data->
off + REC_SIZE > ps->
size) {
84 static void pstore_ftrace_seq_stop(
struct seq_file *
s,
void *
v)
89 static void *pstore_ftrace_seq_next(
struct seq_file *
s,
void *
v, loff_t *
pos)
102 static int pstore_ftrace_seq_show(
struct seq_file *s,
void *v)
109 pstore_ftrace_decode_cpu(rec), rec->
ip, rec->
parent_ip,
116 .start = pstore_ftrace_seq_start,
117 .next = pstore_ftrace_seq_next,
118 .stop = pstore_ftrace_seq_stop,
119 .show = pstore_ftrace_seq_show,
122 static ssize_t pstore_file_read(
struct file *
file,
char __user *userbuf,
123 size_t count, loff_t *ppos)
129 return seq_read(file, userbuf, count, ppos);
133 static int pstore_file_open(
struct inode *
inode,
struct file *file)
141 sops = &pstore_ftrace_seq_ops;
153 static loff_t pstore_file_llseek(
struct file *file, loff_t off,
int origin)
163 .open = pstore_file_open,
164 .read = pstore_file_read,
165 .llseek = pstore_file_llseek,
173 static int pstore_unlink(
struct inode *dir,
struct dentry *
dentry)
183 static void pstore_evict_inode(
struct inode *inode)
192 spin_unlock_irqrestore(&allpstore_lock, flags);
199 .unlink = pstore_unlink,
202 static struct inode *pstore_get_inode(
struct super_block *
sb)
221 static void parse_options(
char *
options)
246 static int pstore_remount(
struct super_block *sb,
int *flags,
char *data)
256 .evict_inode = pstore_evict_inode,
257 .remount_fs = pstore_remount,
265 return pstore_sb !=
NULL;
278 struct dentry *dentry;
287 if (pos->
type == type &&
294 spin_unlock_irqrestore(&allpstore_lock, flags);
299 inode = pstore_get_inode(pstore_sb);
303 inode->
i_fop = &pstore_file_operations;
307 private->type =
type;
313 sprintf(name,
"dmesg-%s-%lld", psname,
id);
316 sprintf(name,
"console-%s", psname);
319 sprintf(name,
"ftrace-%s", psname);
322 sprintf(name,
"mce-%s-%lld", psname,
id);
325 sprintf(name,
"unknown-%s-%lld", psname,
id);
328 sprintf(name,
"type%d-%s-%lld", type, psname,
id);
337 goto fail_lockedalloc;
339 memcpy(private->data, data, size);
347 d_add(dentry, inode);
350 list_add(&private->list, &allpstore);
351 spin_unlock_irqrestore(&allpstore_lock, flags);
367 static int pstore_fill_super(
struct super_block *sb,
void *data,
int silent)
379 sb->
s_op = &pstore_ops;
384 inode = pstore_get_inode(sb);
387 inode->
i_op = &pstore_dir_inode_operations;
401 int flags,
const char *dev_name,
void *data)
403 return mount_single(fs_type, flags, data, pstore_fill_super);
414 .mount = pstore_mount,
415 .kill_sb = pstore_kill_sb,
418 static int __init init_pstore_fs(
void)