diff options
Diffstat (limited to 'fs/pstore/platform.c')
-rw-r--r-- | fs/pstore/platform.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index f2c3ff20ea6..c5300ec3169 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c | |||
@@ -37,6 +37,8 @@ | |||
37 | static DEFINE_SPINLOCK(pstore_lock); | 37 | static DEFINE_SPINLOCK(pstore_lock); |
38 | static struct pstore_info *psinfo; | 38 | static struct pstore_info *psinfo; |
39 | 39 | ||
40 | static char *backend; | ||
41 | |||
40 | /* How much of the console log to snapshot */ | 42 | /* How much of the console log to snapshot */ |
41 | static unsigned long kmsg_bytes = 10240; | 43 | static unsigned long kmsg_bytes = 10240; |
42 | 44 | ||
@@ -67,7 +69,8 @@ static void pstore_dump(struct kmsg_dumper *dumper, | |||
67 | unsigned long size, total = 0; | 69 | unsigned long size, total = 0; |
68 | char *dst, *why; | 70 | char *dst, *why; |
69 | u64 id; | 71 | u64 id; |
70 | int hsize, part = 1; | 72 | int hsize; |
73 | unsigned int part = 1; | ||
71 | 74 | ||
72 | if (reason < ARRAY_SIZE(reason_str)) | 75 | if (reason < ARRAY_SIZE(reason_str)) |
73 | why = reason_str[reason]; | 76 | why = reason_str[reason]; |
@@ -78,7 +81,7 @@ static void pstore_dump(struct kmsg_dumper *dumper, | |||
78 | oopscount++; | 81 | oopscount++; |
79 | while (total < kmsg_bytes) { | 82 | while (total < kmsg_bytes) { |
80 | dst = psinfo->buf; | 83 | dst = psinfo->buf; |
81 | hsize = sprintf(dst, "%s#%d Part%d\n", why, oopscount, part++); | 84 | hsize = sprintf(dst, "%s#%d Part%d\n", why, oopscount, part); |
82 | size = psinfo->bufsize - hsize; | 85 | size = psinfo->bufsize - hsize; |
83 | dst += hsize; | 86 | dst += hsize; |
84 | 87 | ||
@@ -94,14 +97,16 @@ static void pstore_dump(struct kmsg_dumper *dumper, | |||
94 | memcpy(dst, s1 + s1_start, l1_cpy); | 97 | memcpy(dst, s1 + s1_start, l1_cpy); |
95 | memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy); | 98 | memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy); |
96 | 99 | ||
97 | id = psinfo->write(PSTORE_TYPE_DMESG, hsize + l1_cpy + l2_cpy); | 100 | id = psinfo->write(PSTORE_TYPE_DMESG, part, |
101 | hsize + l1_cpy + l2_cpy, psinfo); | ||
98 | if (reason == KMSG_DUMP_OOPS && pstore_is_mounted()) | 102 | if (reason == KMSG_DUMP_OOPS && pstore_is_mounted()) |
99 | pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id, | 103 | pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id, |
100 | psinfo->buf, hsize + l1_cpy + l2_cpy, | 104 | psinfo->buf, hsize + l1_cpy + l2_cpy, |
101 | CURRENT_TIME, psinfo->erase); | 105 | CURRENT_TIME, psinfo); |
102 | l1 -= l1_cpy; | 106 | l1 -= l1_cpy; |
103 | l2 -= l2_cpy; | 107 | l2 -= l2_cpy; |
104 | total += l1_cpy + l2_cpy; | 108 | total += l1_cpy + l2_cpy; |
109 | part++; | ||
105 | } | 110 | } |
106 | mutex_unlock(&psinfo->buf_mutex); | 111 | mutex_unlock(&psinfo->buf_mutex); |
107 | } | 112 | } |
@@ -128,6 +133,12 @@ int pstore_register(struct pstore_info *psi) | |||
128 | spin_unlock(&pstore_lock); | 133 | spin_unlock(&pstore_lock); |
129 | return -EBUSY; | 134 | return -EBUSY; |
130 | } | 135 | } |
136 | |||
137 | if (backend && strcmp(backend, psi->name)) { | ||
138 | spin_unlock(&pstore_lock); | ||
139 | return -EINVAL; | ||
140 | } | ||
141 | |||
131 | psinfo = psi; | 142 | psinfo = psi; |
132 | spin_unlock(&pstore_lock); | 143 | spin_unlock(&pstore_lock); |
133 | 144 | ||
@@ -166,9 +177,9 @@ void pstore_get_records(void) | |||
166 | if (rc) | 177 | if (rc) |
167 | goto out; | 178 | goto out; |
168 | 179 | ||
169 | while ((size = psi->read(&id, &type, &time)) > 0) { | 180 | while ((size = psi->read(&id, &type, &time, psi)) > 0) { |
170 | if (pstore_mkfile(type, psi->name, id, psi->buf, (size_t)size, | 181 | if (pstore_mkfile(type, psi->name, id, psi->buf, (size_t)size, |
171 | time, psi->erase)) | 182 | time, psi)) |
172 | failed++; | 183 | failed++; |
173 | } | 184 | } |
174 | psi->close(psi); | 185 | psi->close(psi); |
@@ -196,12 +207,15 @@ int pstore_write(enum pstore_type_id type, char *buf, size_t size) | |||
196 | 207 | ||
197 | mutex_lock(&psinfo->buf_mutex); | 208 | mutex_lock(&psinfo->buf_mutex); |
198 | memcpy(psinfo->buf, buf, size); | 209 | memcpy(psinfo->buf, buf, size); |
199 | id = psinfo->write(type, size); | 210 | id = psinfo->write(type, 0, size, psinfo); |
200 | if (pstore_is_mounted()) | 211 | if (pstore_is_mounted()) |
201 | pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id, psinfo->buf, | 212 | pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id, psinfo->buf, |
202 | size, CURRENT_TIME, psinfo->erase); | 213 | size, CURRENT_TIME, psinfo); |
203 | mutex_unlock(&psinfo->buf_mutex); | 214 | mutex_unlock(&psinfo->buf_mutex); |
204 | 215 | ||
205 | return 0; | 216 | return 0; |
206 | } | 217 | } |
207 | EXPORT_SYMBOL_GPL(pstore_write); | 218 | EXPORT_SYMBOL_GPL(pstore_write); |
219 | |||
220 | module_param(backend, charp, 0444); | ||
221 | MODULE_PARM_DESC(backend, "Pstore backend to use"); | ||