1 Aug 2012 04:49
short read/write and error code
David Xu <davidxu <at> freebsd.org>
2012-08-01 02:49:16 GMT
2012-08-01 02:49:16 GMT
POSIX requires write() to return actually bytes written, same rule is applied to read(). http://pubs.opengroup.org/onlinepubs/009695399/functions/write.html > ETURN VALUE > > Upon successful completion, write() [XSI] and pwrite() shall > return the number of bytes actually written to the file associated > with fildes. This number shall never be greater than nbyte. > Otherwise, -1 shall be returned and errno set to indicate the error. http://pubs.opengroup.org/onlinepubs/009695399/functions/read.html > RETURN VALUE > > Upon successful completion, read() [XSI] and pread() shall return > a non-negative integer indicating the number of bytes actually read. > Otherwise, the functions shall return -1 and set errno to indicate > the error. I have following patch to fix our code to be compatible with POSIX: Index: sys_generic.c =================================================================== --- sys_generic.c (revision 238927) +++ sys_generic.c (working copy) <at> <at> -333,8 +333,7 <at> <at> #endif cnt = auio->uio_resid; if ((error = fo_read(fp, auio, td->td_ucred, flags, td))) { - if (auio->uio_resid != cnt && (error == ERESTART ||(Continue reading)
_______________________________________________
freebsd-arch <at> freebsd.org mailing list
RSS Feed