Now,I'm reading the code of mkdosfs and the "count_blocks" function confuse me!The function is pasted follewing!
static unsigned long long count_blocks (char *filename)
{
off_t high, low;
int fd;

if ((fd = open (filename, O_RDONLY)) < 0){
perror (filename);
exit (1);
}

/* first try SEEK_END, which should work on most devices nowadays */
if ((low = llseek(fd, 0, SEEK_END)) <= 0) {
low = 0;
for (high = 1; valid_offset (fd, high); high *= 2)
low = high;
while (low < high - 1) {
const loff_t mid = (low + high) / 2;
if (valid_offset (fd, mid))
low = mid;
else
high = mid;
}
++low;
}

close (fd);
return low / BLOCK_SIZE;
}
My first question is why the relational operator in "if ((low = llseek(fd, 0, SEEK_END)) <= 0) {" is "<="?
sometimes , the result of count_blocks differ from the blocks of using command fdisk.That is my second question!
who can tell me why!
Thank you for your help!