- if (fd > 2 && readto == NOFSIZE) {
- readto = tfc_fdsize(fd);
- if (readto == NOFSIZE) goto _fail;
+ if (fd > 2) {
+ if (readto == NOFSIZE) {
+ readto = tfc_fdsize(fd);
+ if (readto == NOFSIZE) goto _fail;
+ }
+ if (offset != 0 && offset != NOFSIZE) {
+ if (lseek(fd, (off_t)offset, SEEK_SET) == -1) goto _fail;
+ }