主题 : hal 层我写文件失败 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 99274
精华: 0
发帖: 17
金钱: 85 两
威望: 17 点
综合积分: 34 分
注册时间: 2013-12-24
最后登录: 2014-07-09
楼主  发表于: 2014-03-04 11:35

 hal 层我写文件失败

我在hal层需要open一个文件写东西,但是怎么做都是失败的,我该怎么操作???只读打开文件是ok的。
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2014-03-04 12:24

 回 楼主(zdcspace) 的帖子

是什么文件?你用的是哪个HAL?
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 99274
精华: 0
发帖: 17
金钱: 85 两
威望: 17 点
综合积分: 34 分
注册时间: 2013-12-24
最后登录: 2014-07-09
2楼  发表于: 2014-03-04 13:05
写的是gps hal,就是想创建一个文件写些东西进去,比如文件保存到/system/etc/temp.txt
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
3楼  发表于: 2014-03-04 14:42

 回 2楼(zdcspace) 的帖子

一般情况下,system分区在启动后是挂载成只读的,不允许修改里面的内容。你可以试试/data目录
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 99274
精华: 0
发帖: 17
金钱: 85 两
威望: 17 点
综合积分: 34 分
注册时间: 2013-12-24
最后登录: 2014-07-09
4楼  发表于: 2014-03-04 15:36
我想修改init.rc,实现system的读写挂载,该怎么做呢?
(我的板子是tiny4412,使用手册说,如想system分区一直处于可读写,可以修改Android源代码中的以下文件:
device/friendly-arm/tiny4412/fstab.tiny4412,将文件对应内容修改为:/dev/block/mmcblk0p2 /system ext4 rw wait,这样修改后是要重新编译源码,还是打包一次就可以了??)
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
5楼  发表于: 2014-03-04 17:52

 回 4楼(zdcspace) 的帖子

这需要重新编译system.img
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 99274
精华: 0
发帖: 17
金钱: 85 两
威望: 17 点
综合积分: 34 分
注册时间: 2013-12-24
最后登录: 2014-07-09
6楼  发表于: 2014-03-06 15:42
我通过修改init.rc创建一个可读写的目录,再重新打包system.img就可以创建文件了;
在安卓下,文件的所有者和用户组是怎么来的,我看到有很多如(0-root, 1000-system...),这是每一个驱动或APP就自动创建一个同名的所有者和用户组吗???
有没有较好的资料书参考。
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
7楼  发表于: 2014-03-07 11:55

 回 6楼(zdcspace) 的帖子

Android使用了Linux传统的用户和组机制,并且在这个基础上加上了基于package的权限管理,我想你可以参考http://developer.android.com/guide/topics/security/permissions.htmlhttp://source.android.com/devices/tech/security/index.html
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."