MCPcopy Create free account
hub / github.com/ElementsProject/lightning / check_with_child

Function check_with_child

ccan/ccan/ptr_valid/ptr_valid.c:239–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239static bool check_with_child(struct ptr_valid_batch *batch,
240 const void *p, size_t size, bool is_write)
241{
242 char ret;
243
244 if (!child_alive(batch)) {
245 if (!create_child(batch))
246 return false;
247 }
248
249 if (write(batch->to_child, &p, sizeof(p))
250 + write(batch->to_child, &size, sizeof(size))
251 + write(batch->to_child, &is_write, sizeof(is_write))
252 != sizeof(p) + sizeof(size) + sizeof(is_write)) {
253 finish_child(batch);
254 errno = EFAULT;
255 return false;
256 }
257
258 if (read(batch->from_child, &ret, sizeof(ret)) != sizeof(ret)) {
259 finish_child(batch);
260 errno = EFAULT;
261 return false;
262 }
263 return true;
264}
265
266/* msync seems most well-defined test, but page could be mapped with
267 * no permissions, and can't distiguish readonly from writable. */

Callers 1

ptr_valid_batchFunction · 0.85

Calls 3

child_aliveFunction · 0.85
create_childFunction · 0.85
finish_childFunction · 0.85

Tested by

no test coverage detected