c - fstat() return 0, with file size 0 and errno 11 -


i'm trying following thing in 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 , value of n_bytes - %d ",y,temp_data.st_size,errno,n_bytes);  } 

and output i'm getting :-

success - 0, size -> 0 , error - 11  after write success - 0, size -> 0, error - 11 , value of n_bytes - 1526  

what reason behind size being 0 , error number 11?? there other way size of file??

note: here netdev->queue_fd[class_id] file descriptor. value of n_bytes varying in between {41,1514,66,..} in different calls. (always greater 0)

thanks

netdev->queue_fd[class_id] file descriptor of

  • regular file or
  • any sys/fs entry or
  • char/block/network device file?

if not regular file size not updated after write command.

check file tyeps s_isreg()


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -