I'm trying the following thing in my code:-
{
int y,n_bytes;
struct stat temp_data;
y = fstat(netdev->queue_fd[class_id],&temp_data);
printf("Success - %d , size -> %lld , Error- %d \n",y,temp_data.st_size,errno);
n_bytes = write(netdev->queue_fd[class_id],buffer->data,buffer->size);
y = fstat(netdev->queue_fd[class_id],&temp_data);
printf("After write Success - %d , size -> %lld , Error- %d and the value of n_bytes is - %d ",y,temp_data.st_size,errno,n_bytes);
}
and the output that I'm getting is :-
Success - 0, size -> 0 , Error - 11
After write Success - 0, size -> 0, Error - 11 and the value of n_bytes is - 1526
What is the reason behind the size being 0 and the error number 11?? Is there any other way to get the size of the file??
Note: here Netdev->queue_fd[class_id]
is a file descriptor.
The value of n_bytes is varying in between {41,1514,66,..} in different calls. (Always greater than 0)
thanks
Netdev->queue_fd[class_id]
is a file descriptor of
if it is not a regular file then its size will not be updated after write command.
check file tyeps by S_ISREG()