Here we should remember that the prototypes of the read() and write() system calls were the following:
ssize_t (*read) (struct file *filp,
char __user *buf, size_t len, loff_t *ppos);
ssize_t (*write) (struct file *filp,
const char __user *buff, size_t len, loff_t *ppos);
When we tested our char driver using the program in the chapter_03/chrdev_test.c file, we noticed that we weren't able to reread written data unless we patched our file as follows:
--- a/chapter_03/chrdev_test.c
+++ b/chapter_03/chrdev_test.c
@@ -55,6 +55,16 @@ int main(int argc, char *argv[])
dump("data written are: ", buf, n);
}
+ close(fd);
+
+ ret = open(argv[1], O_RDWR);
+ if (ret < 0) {
+ perror("open");
+ exit(EXIT_FAILURE);
+ }
+ printf("file %s reopened\n", argv[1]);
+ fd = ret...