main_temp.c

00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <unistd.h>
00004 #include <signal.h>
00005 #include <fcntl.h>
00006 
00007 #include <linux/delay.h>
00008 
00009 
00010 int gotdata=0;
00011 
00012 void sighandler(int signo)
00013 {
00014     signal(SIGIO, &sighandler); /* reinstall yourself */
00015     if (signo==SIGIO)
00016         gotdata++;
00017     return;
00018 }
00019 
00020 char buffer[4096];
00021 
00022 // wait_queue_head_t queue;
00023 
00024 int main(int argc, char **argv)
00025 {
00026     int i, j;
00027     int count;
00028     int fd;
00029     fd = open("/dev/rkfschar_dev",O_RDWR );
00030     if (fd<=0) {
00031         printf("Opening rkfschar_dev failed.\n");
00032         return 1;
00033     }   
00034 // init_waitqueue_head(&queue);
00035 
00036 //     signal(SIGIO, &sighandler); /* the dirty way, sigaction() is better */
00037 //     fcntl(fd, F_SETOWN, getpid());
00038 //     fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | FASYNC);
00039     while (1) {
00040         count=read(fd,buffer,4096);
00041         printf("%s\n", buffer);
00042 //      wait_event_interruptible(queue, 0, 10);
00043         msleep(100);
00044 
00045 //      for (i=1; i<1000000; i++) {
00046 //              for (j=1; j<1000; j++) {
00047 //                      printf("");
00048 //              }
00049 //      }
00050         printf("Write:%s\n", buffer);
00051     }
00052 //     while(1) {
00053 //         /* this only returns if a signal arrives */
00054 //         sleep(~0); /* infinite */
00055 //         if (!gotdata)
00056 //             continue;
00057 //         count=read(fd, buffer, 4096);
00058 //      /* buggy: if avail data is more than 4kbytes... */
00059 //         printf("%s\n", buffer);
00060 // //   write(1,buffer,count);
00061 //         gotdata=0;
00062 //     }
00063 
00064     close(fd);
00065 }

Generated on Mon May 28 12:56:36 2007 for MYSQLFS by  doxygen 1.5.0