Changeset 17ab62c in rtems-libbsd


Ignore:
Timestamp:
Jul 28, 2017, 6:42:42 AM (2 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5283630d2c9d40deb0183696d278e02644fe4326, bc2ba9a9cdc7381c2a4f2ae6ee303be636f31368
Children:
6e328c3
Parents:
0913210
git-author:
Sebastian Huber <sebastian.huber@…> (07/28/17 06:42:42)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/28/17 06:46:20)
Message:

PIPE(2): Add missing file handler

File:
1 edited

Legend:

Unmodified
Added
Removed
  • freebsd/sys/kern/sys_pipe.c

    r0913210 r17ab62c  
    180180#define PRIBIO                  (0)
    181181
    182 static int rtems_bsd_pipe_open(rtems_libio_t *iop, const char *path, int oflag, mode_t mode);
     182static int rtems_bsd_pipe_open(rtems_libio_t *iop, const char *path,
     183    int oflag, mode_t mode);
    183184static int rtems_bsd_pipe_close(rtems_libio_t *iop);
    184 static ssize_t rtems_bsd_pipe_read(rtems_libio_t *iop, void *buffer, size_t count);
    185 static ssize_t rtems_bsd_pipe_write(rtems_libio_t *iop, const void *buffer, size_t count);
    186 static int rtems_bsd_pipe_ioctl(rtems_libio_t *iop, ioctl_command_t request, void *buffer);
    187 static int rtems_bsd_pipe_stat(const rtems_filesystem_location_info_t *loc,     struct stat *buf);
     185static ssize_t rtems_bsd_pipe_read(rtems_libio_t *iop, void *buffer,
     186    size_t count);
     187static ssize_t rtems_bsd_pipe_readv(rtems_libio_t *iop,
     188    const struct iovec *iov, int iovcnt, ssize_t total);
     189static ssize_t rtems_bsd_pipe_write(rtems_libio_t *iop, const void *buffer,
     190    size_t count);
     191static ssize_t rtems_bsd_pipe_writev(rtems_libio_t *iop,
     192    const struct iovec *iov, int iovcnt, ssize_t total);
     193static int rtems_bsd_pipe_ioctl(rtems_libio_t *iop, ioctl_command_t request,
     194    void *buffer);
     195static int rtems_bsd_pipe_stat(const rtems_filesystem_location_info_t *loc,
     196    struct stat *buf);
    188197static int rtems_bsd_pipe_fcntl(rtems_libio_t *iop, int cmd);
    189198static int rtems_bsd_pipe_poll(rtems_libio_t *iop, int events);
     
    203212        .fcntl_h = rtems_bsd_pipe_fcntl,
    204213        .poll_h = rtems_bsd_pipe_poll,
    205         .kqfilter_h = rtems_bsd_pipe_kqfilter
     214        .kqfilter_h = rtems_bsd_pipe_kqfilter,
     215        .readv_h = rtems_bsd_pipe_readv,
     216        .writev_h = rtems_bsd_pipe_writev,
     217        .mmap_h = rtems_filesystem_default_mmap
    206218};
    207219
     
    936948        if (error == 0) {
    937949                return (count - auio.uio_resid);
     950        } else {
     951                rtems_set_errno_and_return_minus_one(error);
     952        }
     953}
     954
     955static ssize_t
     956rtems_bsd_pipe_readv(rtems_libio_t *iop, const struct iovec *iov,
     957    int iovcnt, ssize_t total)
     958{
     959        struct thread *td = rtems_bsd_get_curthread_or_null();
     960        struct file *fp = rtems_bsd_iop_to_fp(iop);
     961        struct uio auio = {
     962                .uio_iov = __DECONST(struct iovec *, iov),
     963                .uio_iovcnt = iovcnt,
     964                .uio_offset = 0,
     965                .uio_resid = total,
     966                .uio_segflg = UIO_USERSPACE,
     967                .uio_rw = UIO_READ,
     968                .uio_td = td
     969        };
     970        int error;
     971
     972        if (td != NULL) {
     973                error = pipe_read(fp, &auio, NULL, 0, NULL);
     974        } else {
     975                error = ENOMEM;
     976        }
     977
     978        if (error == 0) {
     979                return (total - auio.uio_resid);
    938980        } else {
    939981                rtems_set_errno_and_return_minus_one(error);
     
    14711513        }
    14721514}
     1515
     1516static ssize_t
     1517rtems_bsd_pipe_writev(rtems_libio_t *iop, const struct iovec *iov,
     1518    int iovcnt, ssize_t total)
     1519{
     1520        struct thread *td = rtems_bsd_get_curthread_or_null();
     1521        struct file *fp = rtems_bsd_iop_to_fp(iop);
     1522        struct uio auio = {
     1523                .uio_iov = __DECONST(struct iovec *, iov),
     1524                .uio_iovcnt = iovcnt,
     1525                .uio_offset = 0,
     1526                .uio_resid = total,
     1527                .uio_segflg = UIO_USERSPACE,
     1528                .uio_rw = UIO_WRITE,
     1529                .uio_td = td
     1530        };
     1531        int error;
     1532
     1533        if (td != NULL) {
     1534                error = pipe_write(fp, &auio, NULL, 0, NULL);
     1535        } else {
     1536                error = ENOMEM;
     1537        }
     1538
     1539        if (error == 0) {
     1540                return (total - auio.uio_resid);
     1541        } else {
     1542                rtems_set_errno_and_return_minus_one(error);
     1543        }
     1544}
    14731545#endif /* __rtems__ */
    14741546
Note: See TracChangeset for help on using the changeset viewer.