Date: Mon, 29 Jan 2001 18:22:47 -0800 (PST) From: Joe Albowicz <joe@CS.UCLA.EDU> To: freebsd-hackers@freebsd.org Subject: aio_read gives ENOSYS Message-ID: <Pine.SOL.4.10.10101291513330.17386-100000@panther.cs.ucla.edu>
next in thread | raw e-mail | index | archive | help
Hi, I'm trying to write a sample program to use aio. However, I'm getting back "function not implemented." I *know* I must be doing something stupid, but I can't seem to find info on the web. Help! My code (that works on a Sun box) is below. The only difference was "-lrt" on Sun. Note that I'm using "4.2-STABLE" and the io in question is for a scsi disk. Thanks in advance! Joe ******* #include <signal.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <unistd.h> #include <time.h> #include <aio.h> #include <errno.h> #include <string.h> void create_file(); void aio_handler(int signo, siginfo_t * info, void * data) { printf("aio_handler!!!\n"); } int main(int argc, char * argv[]) { int ret_val; //create_file(); aiocb iocb; struct sigaction sa; sa.sa_flags = SA_SIGINFO; sigemptyset(&sa.sa_mask); sa.sa_sigaction = aio_handler; sigaction(SIGUSR1, &sa, NULL); int buff[1000]; int fh = open("test_file", O_RDONLY); assert(fh > 0); printf("Setting up aio_read()\n"); iocb.aio_fildes = fh; iocb.aio_offset = 0; iocb.aio_buf = &buff[0]; iocb.aio_nbytes = sizeof(int) * 400; iocb.aio_sigevent.sigev_notify = SIGEV_SIGNAL; iocb.aio_sigevent.sigev_signo = SIGUSR1; ret_val = aio_read(&iocb); printf("aio_read() == %d\n", ret_val); if(ret_val == -1) printf("Error: %s\n", strerror(errno)); sleep(10); close(fh); } void create_file() { int result; system("rm -f test_file"); int fh = open("test_file", O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IROTH); assert(fh != -1); for(int i = 0; i < 10 * 4096; i++) { result = write(fh, &i, sizeof(i)); assert(result != -1); } close(fh); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SOL.4.10.10101291513330.17386-100000>