Character driver finished

This commit is contained in:
2025-02-24 14:18:48 +00:00
parent 5500b9dc74
commit 3681dbfaac
12 changed files with 340 additions and 1 deletions

View File

@@ -0,0 +1,27 @@
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <errno.h>
int main(){
int fd, i;
ssize_t ret;
char my_buf[12] = "Hello world";
fd = open( "/dev/demo_cdrv", O_RDWR);
if(fd < 0){
printf("failed acquiring file descriptor return status %d\n", fd);
}
/* Write the contents of my buffer into the device */
ret = write(fd, my_buf, 8);
ret = read(fd, my_buf, 12);
if( ret < 0 )
printf("read operation failed with return status %d\n", ret);
close(fd);
return 0;
}