From owner-freebsd-current Thu Nov 12 10:57:05 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA08663 for freebsd-current-outgoing; Thu, 12 Nov 1998 10:57:05 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from highwind.com (hurricane.highwind.com [209.61.45.50]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA08652 for ; Thu, 12 Nov 1998 10:57:00 -0800 (PST) (envelope-from info@highwind.com) Received: (from info@localhost) by highwind.com (8.8.6/8.8.6) id NAA23101; Thu, 12 Nov 1998 13:56:41 -0500 (EST) Date: Thu, 12 Nov 1998 13:56:41 -0500 (EST) Message-Id: <199811121856.NAA23101@highwind.com> From: HighWind Software Information To: current@FreeBSD.ORG Subject: aio_write() doesn't work! Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Is is me or does "aio_write()" under FreeBSD 3.0 simply NOT work? This prints all x's. Considering I used aio_write() to write a 'y' in there, why doesn't it work?? -Rob --- /***************************************************************************** File: aioTest.c Contents: Simple Test of the aio_write() function gcc -o aioTest aioTest.c -Wall -Werror *****************************************************************************/ #include #include #include #include #include #include #include #include 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; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message