| 524 | ****************************************************************************/ |
| 525 | |
| 526 | static ssize_t rpmsgfs_write(FAR struct file *filep, const char *buffer, |
| 527 | size_t buflen) |
| 528 | { |
| 529 | FAR struct inode *inode; |
| 530 | FAR struct rpmsgfs_mountpt_s *fs; |
| 531 | FAR struct rpmsgfs_ofile_s *hf; |
| 532 | ssize_t ret; |
| 533 | |
| 534 | DEBUGASSERT(filep->f_priv != NULL); |
| 535 | |
| 536 | /* Recover our private data from the struct file instance */ |
| 537 | |
| 538 | hf = filep->f_priv; |
| 539 | inode = filep->f_inode; |
| 540 | fs = inode->i_private; |
| 541 | |
| 542 | DEBUGASSERT(fs != NULL); |
| 543 | |
| 544 | /* Take the lock */ |
| 545 | |
| 546 | ret = nxmutex_lock(&fs->fs_lock); |
| 547 | if (ret < 0) |
| 548 | { |
| 549 | return ret; |
| 550 | } |
| 551 | |
| 552 | /* Test the permissions. Only allow write if the file was opened with |
| 553 | * write flags. |
| 554 | */ |
| 555 | |
| 556 | if ((hf->oflags & O_WROK) == 0) |
| 557 | { |
| 558 | ret = -EACCES; |
| 559 | goto errout_with_lock; |
| 560 | } |
| 561 | |
| 562 | /* Call the host to perform the write */ |
| 563 | |
| 564 | ret = rpmsgfs_client_write(fs->handle, hf->fd, buffer, buflen); |
| 565 | if (ret > 0) |
| 566 | { |
| 567 | filep->f_pos += ret; |
| 568 | } |
| 569 | |
| 570 | errout_with_lock: |
| 571 | nxmutex_unlock(&fs->fs_lock); |
| 572 | return ret; |
| 573 | } |
| 574 | |
| 575 | /**************************************************************************** |
| 576 | * Name: rpmsgfs_seek |
nothing calls this directly
no test coverage detected