+ else if (S_ISREG (st.st_mode))
+ {
+ off_t fsize = st.st_size;
+ if (fsize > 0 && fsize < ST_BLKSIZE (st) && size > fsize)
+ i_size = fsize;
+ }
This can be simplified. There's no need to worry about checking whether
st.st_size == 0 since the code would do the right thing if that test
were removed. (Or are you worried about st.st_size < 0? If so, that
check should be hoisted out of the previous 'if' and done on all regular
files.) We generally prefer "<" and "<=" for size comparisons, as it
makes code easier to visualize. Something like this, perhaps:
else if (S_ISREG (st.st_mode)
&& st.st_size < MIN (ST_BLKSIZE (st), size))
i_size = st.st_size;
The rest looks good. I didn't quite follow the part about pass_size but
I assume it's OK. Thanks.