【发布时间】:2015-07-08 13:50:11
【问题描述】:
我正在我的代码中尝试以下内容:-
{
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);
}
我得到的输出是:-
Success - 0, size -> 0 , Error - 11
After write Success - 0, size -> 0, Error - 11 and the value of n_bytes is - 1526
大小为0,错误号为11的原因是什么? 有没有其他方法可以获取文件的大小??
注意:这里的Netdev->queue_fd[class_id] 是一个文件描述符。
在不同的调用中,n_bytes 的值在 {41,1514,66,..} 之间变化。 (总是大于 0)
谢谢
【问题讨论】:
标签: c linux file-handling fstat