免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1584 | 回复: 1
打印 上一主题 下一主题

[C] lseek 硬盘 大于0x80000000问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-12-24 16:12 |只看该作者 |倒序浏览
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS   64

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

int main()
{
    printf("sizeof(off_t) = %d\n", sizeof(off_t));
    int fd = 0;
#if 0
    fd = open("test", O_WRONLY | O_CREAT | O_LARGEFILE, 0600);
#else
    fd = open("/dev/hda1", O_RDONLY, 0600);
#endif
    if (fd > 0)
    {
        off_t l = 0x80000001LL;
        off_t l_new = lseek(fd, l, SEEK_SET);
        if (l_new < 0)
            printf("l_new =%d\n", l_new);
#if 0
        else
            write(fd, &fd, sizeof(fd));
#endif
        printf("l_new = 0x%.16x\n", l_new);
        close(fd);
    }
}

# gcc lseek.c -o lseek -std=c99

本人测试文件就可以,测试硬盘不行,分区格式为ext3,哪位大侠能指点一下,谢谢!

论坛徽章:
0
2 [报告]
发表于 2008-12-24 16:27 |只看该作者
呵呵,可能是因为我的硬盘不够大的原因!!!唉,搞不清楚,我想办法找个大硬盘试一试,有没有哪位大侠碰到类似的问题的?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP