1

我有一个要求,我需要读取一个接口(比如/sys/module/my_file/parameters/val),然后根据它的值在另一个接口上写入一些值。这必须在 Android 文件系统的 init.rc 中完成。

流程是这样的

if ( read /sys/module/my_file/parameters/val == "yes") then
write /sys/devices/platform/target_file/val 100

任何人都可以帮我做同样的事情吗?可能吗??

4

2 回答 2

1

您可以使用 exec 节来实现它:

exec <path> [ <argument> ]*
   Fork and execute a program (<path>). This will block until
   the program completes execution. It is best to avoid exec
   as unlike the builtin commands, it runs the risk of getting
   init "stuck".

有关详细信息,请参阅https://github.com/android/platform_system_core/blob/master/init/readme.txt

示例:将您的代码移动到脚本 (my_script.sh) 中。将此添加到您的 init.rc

on boot:
  ...
  exec /path/to/my_script.sh
于 2012-09-04T09:18:52.370 回答
0

您可以使用 init 的服务概念来运行脚本。下面是代码示例表单 init script.rc 文件。

chmod 0750 /system/bin/myscript.sh
start script
[...]
service script /system/bin/myscript.sh
    class main
    user root
    group root
    oneshot

于 2016-10-26T12:18:26.313 回答