I have this file called input.txt opened using file pointer. Now I want to read this file and write this data into device node file using write() system call(Any better way). Right now I am scanning integer values one by one and writing to device node. Any way so that I can do this in block say some fixed number of bytes. input.txt contain 32 bit integers seperated by newline. Below is the code I have right now.
FILE *fp = fopen("input.txt", "r");
int fd = open("/dev/devnode", O_WRONLY);
int current = 0;
Is there any better way to do this? Please help.
To put my requirement clearly I write to device node and then have to trigger DMA but DMA capacity is 1024 bytes so rather than writing one integer (32 bytes) I want to read 32 integers (1024 bytes) from input.txt and write it to device node before triggering dma. Any way this can be done without allocating extra memory. I'm OK with loop to start with.