Changeset 1693 for zzuf


Ignore:
Timestamp:
Jan 17, 2007, 10:12:27 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Added aio_read() and aio_return(). They don’t work well yet, I’ll need to fix the _zz_disabled mess first.
Location:
zzuf/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/doc/zzuf.1

    r1691 r1693  
    323323\fBopen\fR(), \fBlseek\fR(), \fBread\fR(), \fBreadv\fR(), \fBpread\fR(),
    324324\fBaccept\fR(), \fBsocket\fR(), \fBrecv\fR(), \fBrecvfrom\fR(), \fBrecvmsg\fR(),
    325 \fBclose\fR()
     325\fBaio_read\fR(), \fBaio_return\fR(), \fBclose\fR()
    326326.TP
    327327Standard IO streams:
  • zzuf/trunk/src/fuzz.c

    r1663 r1693  
    5353}
    5454
    55 void _zz_fuzz(int fd, uint8_t *buf, uint64_t len)
     55void _zz_fuzz(int fd, volatile uint8_t *buf, uint64_t len)
    5656{
    5757    uint64_t start, stop;
    5858    struct fuzz *fuzz;
    59     uint8_t *aligned_buf;
     59    volatile uint8_t *aligned_buf;
    6060    unsigned long int pos = _zz_getpos(fd);
    6161    unsigned int i, j, todo;
  • zzuf/trunk/src/fuzz.h

    r1663 r1693  
    2020extern void _zz_refuse(char const *);
    2121
    22 extern void _zz_fuzz(int, uint8_t *, uint64_t);
     22extern void _zz_fuzz(int, volatile uint8_t *, uint64_t);
    2323
  • zzuf/trunk/src/lib-fd.c

    r1691 r1693  
    4242#include <fcntl.h>
    4343#include <stdarg.h>
     44#include <aio.h>
    4445
    4546#include "libzzuf.h"
     
    7475static ssize_t (*readv_orig)   (int fd, const struct iovec *iov, int count);
    7576static ssize_t (*pread_orig)   (int fd, void *buf, size_t count, off_t offset);
     77static int     (*aio_read_orig)   (struct aiocb *aiocbp);
     78static ssize_t (*aio_return_orig) (struct aiocb *aiocbp);
    7679static off_t   (*lseek_orig)   (int fd, off_t offset, int whence);
    7780#ifdef HAVE_LSEEK64
     
    345348#endif
    346349
     350int aio_read(struct aiocb *aiocbp)
     351{
     352    int ret;
     353    int fd = aiocbp->aio_fildes;
     354
     355    LOADSYM(aio_read);
     356    if(!_zz_ready || !_zz_iswatched(fd) || _zz_disabled)
     357        return aio_read_orig(aiocbp);
     358
     359    _zz_disabled = 1;
     360    ret = aio_read_orig(aiocbp);
     361
     362    debug("%s({%i, %i, %i, %p, %li, ..., %li}) = %i", __func__,
     363          fd, aiocbp->aio_lio_opcode, aiocbp->aio_reqprio, aiocbp->aio_buf,
     364          (long int)aiocbp->aio_nbytes, (long int)aiocbp->aio_offset, ret);
     365
     366    return ret;
     367}
     368
     369ssize_t aio_return(struct aiocb *aiocbp)
     370{
     371    ssize_t ret;
     372    int fd = aiocbp->aio_fildes;
     373
     374    LOADSYM(aio_return);
     375    if(!_zz_ready || !_zz_iswatched(fd))
     376        return aio_return_orig(aiocbp);
     377
     378    ret = aio_return_orig(aiocbp);
     379    _zz_disabled = 0;
     380
     381    /* FIXME: make sure we’re actually *reading* */
     382    if(ret > 0)
     383    {
     384        _zz_setpos(fd, aiocbp->aio_offset);
     385        _zz_fuzz(fd, aiocbp->aio_buf, ret);
     386        _zz_addpos(fd, ret);
     387    }
     388
     389    debug("%s({%i, %i, %i, %p, %li, ..., %li}) = %li", __func__,
     390          fd, aiocbp->aio_lio_opcode, aiocbp->aio_reqprio, aiocbp->aio_buf,
     391          (long int)aiocbp->aio_nbytes, (long int)aiocbp->aio_offset,
     392          (long int)ret);
     393
     394    return ret;
     395}
     396
    347397int close(int fd)
    348398{
     
    366416/* XXX: the following functions are local */
    367417
    368 static void fuzz_iovec (int fd, const struct iovec *iov, ssize_t ret)
     418static void fuzz_iovec(int fd, const struct iovec *iov, ssize_t ret)
    369419{
    370420    /* NOTE: We assume that iov countains at least <ret> bytes. */
Note: See TracChangeset for help on using the changeset viewer.