#include "y16t_internal.h" #include #include __attribute__((nonnull)) static ssize_t y16t_pall_hret(const ssize_t tmp, size_t *dnb) { if(tmp > 0) { *dnb += tmp; return tmp; } else if(!tmp) { return -EIO; } else { return -errno; } } ssize_t y16t_pread_all(const int fd, void *buf, size_t nbyte, off_t offset) { size_t dnb = 0; while(nbyte) { const ssize_t tmp = y16t_pall_hret(pread( fd, buf + dnb, nbyte - dnb, offset + dnb), &dnb); switch(tmp) { case -EINTR: continue; default: if(tmp > 0) continue; return tmp; } } return (ssize_t)dnb; } ssize_t y16t_pwrite_all(const int fd, const void *buf, size_t nbyte, off_t offset) { size_t dnb = 0; while(nbyte) { const ssize_t tmp = y16t_pall_hret(pwrite( fd, buf + dnb, nbyte - dnb, offset + dnb), &dnb); switch(tmp) { case -EINTR: continue; default: if(tmp > 0) continue; return tmp; } } return (ssize_t)dnb; }