return ret;
}
-off_t size_autodetect(int fhandle) {
+uint64_t size_autodetect(int fhandle) {
off_t es;
u64 bytes __attribute__((unused));
struct stat stat_buf;
#ifdef BLKGETSIZE64
DEBUG("looking for export size with ioctl BLKGETSIZE64\n");
if (!ioctl(fhandle, BLKGETSIZE64, &bytes) && bytes) {
- return (off_t)bytes;
+ return bytes;
}
#endif /* BLKGETSIZE64 */
#endif /* HAVE_SYS_IOCTL_H */
/* always believe stat if a regular file as it might really
* be zero length */
if (S_ISREG(stat_buf.st_mode) || (stat_buf.st_size > 0))
- return (off_t)stat_buf.st_size;
+ return (uint64_t)stat_buf.st_size;
} else {
err("fstat failed: %m");
}
DEBUG("looking for fhandle size with lseek SEEK_END\n");
es = lseek(fhandle, (off_t)0, SEEK_END);
if (es > ((off_t)0)) {
- return es;
+ return (uint64_t)es;
} else {
DEBUG("lseek failed: %d", errno==EBADF?1:(errno==ESPIPE?2:(errno==EINVAL?3:4)));
}
**/
typedef struct {
gchar* exportname; /**< (unprocessed) filename of the file we're exporting */
- off_t expected_size; /**< size of the exported file as it was told to
+ uint64_t expected_size; /**< size of the exported file as it was told to
us through configuration */
gchar* listenaddr; /**< The IP address we're listening on */
unsigned int port; /**< port we're exporting this file at */
* Variables associated with a client connection
*/
typedef struct {
- off_t exportsize; /**< size of the file we're exporting */
+ uint64_t exportsize; /**< size of the file we're exporting */
char *clientname; /**< peer, in human-readable format */
struct sockaddr_storage clientaddr; /**< peer, in binary format, network byte order */
char *exportname; /**< (processed) filename of the file we're exporting */
* Detect the size of a file.
*
* @param fhandle An open filedescriptor
- * @return the size of the file, or OFFT_MAX if detection was
+ * @return the size of the file, or UINT64_MAX if detection was
* impossible.
**/
-off_t size_autodetect(int fhandle);
+uint64_t size_autodetect(int fhandle);
#endif //NBDSRV_H