LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 577|回复: 2

在问关于"超出文件大小限制"?

[复制链接]
发表于 2004-7-29 16:14:33 | 显示全部楼层 |阅读模式
今天测试程序.我用如下程序测试:

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
        int fd;
        char* pszText = "this is a test, this is a test,this is a test, \
                this is a test,this is a test,this is a test,this is test\r\n";
          fd = open( "/home/test/test.txt", O_CREAT|O_EXCL|O_APPEND|O_RDWR);

         while(1)
                      write(fd, pszText, strlen(pszText) );
         
          close(fd);
          return 0;
}


结果当test.txt文件超过 2,147,483,647 时报错

文件大小超出限制

我接着改用fopen,还是如此,用c++ 的ofstream, 结果都是一样阿,深受打击.

我把我的程序拿到windows下,切没有这个问题,一切很好.

担心是linux内核问题. 升级到2.6以后问题依然存在, 实在想不出为什么那,呵呵,大家帮忙
 楼主| 发表于 2004-7-29 16:15:44 | 显示全部楼层
我发表程序的时候有缩进的,不知道为什么发到版上就没有了,请教!

问题一经解决,是 open调用的时候必需加 O_LARGEFILE 标志!
发表于 2004-7-29 17:39:34 | 显示全部楼层
帖代码到版上时用
  1. [code]
复制代码
[/code]括起。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表