Domanda

#define _FILE_OFFSET_BITS 64 
#define _LARGEFILE64_SOURCE    

...

off64_t st_size; 

...

st_size = (off64_t)lseek64(fd, (off64_t)0, SEEK_END);
fprintf(stderr, "QQQ st_size=%llx %lld\n", st_size, st_size);

strace Poi:

$ strace -e _llseek ./the_program
_llseek(3, 0, [20974464000], SEEK_END)  = 0
QQQ st_size=ffffffffe22cec00 -500372480
  • 20974464000 == 0x4E22CEC00 - buona
  • -500.372.480 == 0xffffffffe22cec00 - male

E 'passare alla (off64_t)lseek64(fd, 0, SEEK_END); chiama _llseek in modo non corretto:

_llseek(3, 8589934592, [8589934592], SEEK_SET) = 0
st_size=0 0

Che altro devo fare per assicurarsi che ottiene la dimensione corretta, senza tagliando importante DWORD?

È stato utile?

Soluzione

Assicurarsi che si sta definendo _FILE_OFFSET_BITS e _LARGEFILE64_SOURCE prima tra cui sys / types.h e unistd.h. Preferibilmente, in te compilatore di riga di comando.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top