[英]lseek EOVERFLOW error handling
I've noticed that when I try to seek more bytes than off_t can represent I get an EOVERFLOW error. 我注意到,当我尝试寻找比off_t可以代表的字节更多的字节时,我收到EOVERFLOW错误。 How can I seek more than the bigger number in off_t?
如何在off_t中寻找比更大的数字更多的东西?
Enable large file support . 启用大文件支持 。
In a nutshell for using LFS you can choose either of the following:
简而言之,使用LFS时,您可以选择以下任一选项:
- Compile your programs with "
gcc -D_FILE_OFFSET_BITS=64
".用“
gcc -D_FILE_OFFSET_BITS=64
”编译程序。 This forces all file access calls to use the 64 bit variants.这将强制所有文件访问调用使用64位变体。 Several types change also, eg
off_t
becomesoff64_t
.几种类型也会更改,例如
off_t
变为off64_t
。 It's therefore important to always use the correct types and to not use egint
instead ofoff_t
.因此,务必始终使用正确的类型并且不要使用例如
int
而不是off_t
这一点很重要。 For portability with other platforms you should usegetconf LFS_CFLAGS
which will return-D_FILE_OFFSET_BITS=64
on Linux platforms but might return something else on eg Solaris.为了与其他平台
getconf LFS_CFLAGS
,您应该使用getconf LFS_CFLAGS
,它将在Linux平台上返回-D_FILE_OFFSET_BITS=64
,但在Solaris上可能返回其他内容。 For linking, you should use the link flags that are reported viagetconf LFS_LDFLAGS
.对于链接,应该使用通过
getconf LFS_LDFLAGS
报告的链接标志。 On Linux systems, you do not need special link flags.在Linux系统上,您不需要特殊的链接标志。
- Define
_LARGEFILE_SOURCE
and_LARGEFILE64_SOURCE
.定义
_LARGEFILE_SOURCE
和_LARGEFILE64_SOURCE
。 With these defines you can use the LFS functions like open64 directly.使用这些定义,您可以直接使用像open64这样的LFS函数。
- Use the
O_LARGEFILE
flag withopen
to operate on large files.将
O_LARGEFILE
标志与open
一起使用可对大文件进行操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.