MCPcopy Create free account
hub / github.com/apache/nuttx / rpmsgfs_client_write

Function rpmsgfs_client_write

fs/rpmsgfs/rpmsgfs_client.c:512–578  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

510}
511
512ssize_t rpmsgfs_client_write(FAR void *handle, int fd,
513 FAR const void *buf, size_t count)
514{
515 FAR struct rpmsgfs_s *priv = handle;
516 struct rpmsgfs_cookie_s cookie;
517 size_t written = 0;
518 int ret = 0;
519
520 if (!buf || count <= 0)
521 {
522 return 0;
523 }
524
525 memset(&cookie, 0, sizeof(cookie));
526 nxsem_init(&cookie.sem, 0, 0);
527
528 while (written < count)
529 {
530 FAR struct rpmsgfs_write_s *msg;
531 uint32_t space;
532
533 msg = rpmsgfs_get_tx_payload_buffer(priv, &space);
534 if (!msg)
535 {
536 ret = -ENOMEM;
537 goto out;
538 }
539
540 space -= sizeof(*msg);
541 if (space >= count - written)
542 {
543 space = count - written;
544 msg->header.cookie = (uintptr_t)&cookie;
545 }
546 else
547 {
548 msg->header.cookie = 0;
549 }
550
551 msg->header.command = RPMSGFS_WRITE;
552 msg->header.result = -ENXIO;
553 msg->fd = fd;
554 msg->count = space;
555 memcpy(msg->buf, buf + written, space);
556
557 ret = rpmsg_send_nocopy(&priv->ept, msg, sizeof(*msg) + space);
558 if (ret < 0)
559 {
560 rpmsg_release_tx_buffer(&priv->ept, msg);
561 goto out;
562 }
563
564 written += space;
565 }
566
567 ret = rpmsg_wait(&priv->ept, &cookie.sem);
568 if (ret < 0)
569 {

Callers 1

rpmsgfs_writeFunction · 0.85

Calls 6

nxsem_initFunction · 0.85
rpmsg_waitFunction · 0.85
nxsem_destroyFunction · 0.85
memsetFunction · 0.50
memcpyFunction · 0.50

Tested by

no test coverage detected