Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Nov 1998 12:03:59 -0800 (PST)
From:      info@highwind.com
To:        freebsd-gnats-submit@FreeBSD.ORG
Subject:   kern/8669: aio_write() and aio_read() do not work AT ALL.
Message-ID:  <199811122003.MAA14968@hub.freebsd.org>

index | next in thread | raw e-mail


>Number:         8669
>Category:       kern
>Synopsis:       aio_write() and aio_read() do not work AT ALL.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov 12 12:10:00 PST 1998
>Last-Modified:
>Originator:     Robert Fleischman
>Organization:
HighWind Software
>Release:        3.0
>Environment:
FreeBSD zonda.highwind.com 3.0-19980831-SNAP FreeBSD 3.0-19980831-SNAP #0: Mon Aug 31 14:03:19 GMT 1998     root@make.ican.net:/usr/src/sys/compile/GENERIC  i386

Also, we have a VERY recent libc_r
>Description:
It appears that aio_read() and aio_write() do not work.
Besides not having a man page, they don't pay any attention to the 
offset parameter. This makes it impossible to use them.

 
>How-To-Repeat:
/*****************************************************************************
File:     aioTest.c
Contents: Simple Test of the aio_write() function
Created:  12-Nov-1998

gcc -o aioTest aioTest.c -Wall -Werror

*****************************************************************************/

#include <assert.h>
#include <fcntl.h>
#include <memory.h>
#include <time.h>
#ifdef solaris
#include <aio.h>
#else
#include <sys/aio.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char **argv)
{
    int fd;
    char before[10], after[11], y;
    struct aiocb token;
    const struct aiocb *tlist;

    /* Open the test file */
    fd = open("test", O_RDWR | O_CREAT | O_TRUNC, 0666);
    assert(fd != -1);

    /* Write 10 x's */
    memset(before, 'x', 10);
    assert(write(fd, &before, 10) == 10);

    /* Use aio_write() to write a 'y' at offset 5 */
    y = 'Y';
    memset(&token, 0, sizeof(struct aiocb));
    token.aio_fildes = fd;
    token.aio_offset = 5;
    token.aio_buf = &y;
    token.aio_nbytes = 1;
    token.aio_sigevent.sigev_notify = SIGEV_NONE;
    /* Enqueue the write */
    assert(aio_write(&token) == 0);
    /* Wait for completion */
    tlist = &token;
    assert(aio_suspend(&tlist, 1, 0) == 0);
    /* Ensure the write worked! */
    assert(aio_return(&token) == 1);

    /* Read back the whole file */
    memset(after, 0, 11);
    assert(lseek(fd, 0, SEEK_SET) == 0);
    assert(read(fd, &after, 10) == 10);
    
    printf("%s\n", after);
    
    return EXIT_SUCCESS;
}

	
>Fix:
No idea. However, this test program above SHOULD print a "Y" in that
printout. It appears that the program simply appends a "Y" instead
of writing it in the correct place.

Without aio_read() and aio_write() doing threaded offset reads and write
is impossible (We don't have pwrite/pread yet!)
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message


help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199811122003.MAA14968>