QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1550|回复: 4

如何在uClinux上执行一个文件读写程序?

[复制链接]
发表于 2009-5-22 10:14:54 | 显示全部楼层 |阅读模式
用skyeye模拟ARM,在其上跑uClinux,文件系统是romfs,要运行一段文件读写程序:
#include <stdio.h>
#define MAXLEN 8
int main (void)  
{
        int rc;
        FILE * outfile, *infile;
        unsigned char buf[MAXLEN];
        outfile = fopen("/home/write", "wb");
        infile = fopen("/home/read", "rb");
        if(outfile == NULL || infile == NULL)
        {
                printf("open file error.\n");
                return 0;
        }
        while((rc = fread(buf,sizeof(unsigned char), MAXLEN, infile)) != 0)
        {
                printf("buf now is %s\n", buf);
                fwrite(buf, sizeof(unsigned char), rc, outfile);
        }
        fclose(infile);
        fclose(outfile);
        return 0;
}

执行结果是:
open file error.

不知道哪位高手知道应该怎么解决?
发表于 2009-5-24 18:38:00 | 显示全部楼层
romfs = READ-ONLY memory filesystem.
回复

使用道具 举报

 楼主| 发表于 2009-5-24 21:13:05 | 显示全部楼层
对啊,就是不知道怎么把只读文件系统改为可读写的
回复

使用道具 举报

发表于 2009-5-24 22:22:32 | 显示全部楼层
那就不要用 romfs 。
回复

使用道具 举报

 楼主| 发表于 2009-5-26 17:21:20 | 显示全部楼层
默认的文件系统就是romfs啊
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-4-27 14:09 , Processed in 0.105656 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

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