Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 317334
b: refs/heads/master
c: 755d66b
h: refs/heads/master
v: v3
  • Loading branch information
Anton Vorontsov authored and Greg Kroah-Hartman committed Jun 13, 2012
1 parent 0762662 commit b81eec7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f4c5d2423c64266ba0daa9cc803d1d5ba469fe36
refs/heads/master: 755d66b48fe5a1f2a07802fcc8704e8b9e775e7d
41 changes: 32 additions & 9 deletions trunk/fs/pstore/ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,33 @@ static int ramoops_pstore_open(struct pstore_info *psi)
return 0;
}

static struct persistent_ram_zone *
ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max,
u64 *id,
enum pstore_type_id *typep, enum pstore_type_id type,
bool update)
{
struct persistent_ram_zone *prz;
int i = (*c)++;

if (i >= max)
return NULL;

prz = przs[i];

if (update) {
/* Update old/shadowed buffer. */
persistent_ram_save_old(prz);
if (!persistent_ram_old_size(prz))
return NULL;
}

*typep = type;
*id = i;

return prz;
}

static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
struct timespec *time,
char **buf,
Expand All @@ -94,20 +121,16 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
struct ramoops_context *cxt = psi->data;
struct persistent_ram_zone *prz;

if (cxt->dump_read_cnt >= cxt->max_dump_cnt)
return -EINVAL;

*id = cxt->dump_read_cnt++;
prz = cxt->przs[*id];
prz = ramoops_get_next_prz(cxt->przs, &cxt->dump_read_cnt,
cxt->max_dump_cnt, id, type,
PSTORE_TYPE_DMESG, 1);
if (!prz)
return 0;

/* Only supports dmesg output so far. */
*type = PSTORE_TYPE_DMESG;
/* TODO(kees): Bogus time for the moment. */
time->tv_sec = 0;
time->tv_nsec = 0;

/* Update old/shadowed buffer. */
persistent_ram_save_old(prz);
size = persistent_ram_old_size(prz);
*buf = kmalloc(size, GFP_KERNEL);
if (*buf == NULL)
Expand Down

0 comments on commit b81eec7

Please sign in to comment.