Skip to content

Commit

Permalink
pipe: Dump and restore pipe size
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Emelyanov <[email protected]>
  • Loading branch information
xemul committed Jan 11, 2013
1 parent 42d7bc0 commit a82cb23
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pipes.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash
}

if (!pd->pde->bytes)
return 0;
goto out;

if (!pd->data) {
pr_err("Double data restore occurred on %#x\n", id);
Expand Down Expand Up @@ -207,7 +207,17 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash

munmap(pd->data, pd->pde->bytes);
pd->data = NULL;
out:
ret = 0;
if (pd->pde->has_size) {
pr_info("Restoring size %#x for %#x\n",
pd->pde->size, pd->pde->pipe_id);
ret = fcntl(pfd, F_SETPIPE_SZ, pd->pde->size);
if (ret < 0)
pr_perror("Can't restore pipe size");
else
ret = 0;
}
err:
return ret;
}
Expand Down Expand Up @@ -400,6 +410,8 @@ int dump_one_pipe_data(struct pipe_data_dump *pd, int lfd, const struct fd_parms

pde.pipe_id = pipe_id(p);
pde.bytes = bytes;
pde.has_size = true;
pde.size = pipe_size;

if (pb_write_one(img, &pde, PB_PIPES_DATA))
goto err_close;
Expand Down
1 change: 1 addition & 0 deletions protobuf/pipe-data.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
message pipe_data_entry {
required uint32 pipe_id = 1;
required uint32 bytes = 2;
optional uint32 size = 3;
}

0 comments on commit a82cb23

Please sign in to comment.