我在android平台,使用c语言中的chmod函数来修改设备文件的权限,如下:
chmod("/dev/2-1.2",777);
总是返回Operation not permitted,并且在此之间我也su - root了,怎么还不行呢?在adb shell下直接执行命令是可以的

解决方案 »

  1.   

    安装程序的权限太低,而直接shell进去的状态下已经是root权限了,所以可以执行。
      

  2.   

    程序没有成功获得root权限
    之前有人提过,已经有两种解决方案了,你去找找。
      

  3.   

    看看这篇帖子
    http://topic.csdn.net/u/20110707/11/b90dde74-bfe6-4a68-a6c9-de7fe407f319.html?8694
      

  4.   

    程序中执行system(“su - root”);
    android设备显示 unknown已获取最高权限,
    和在shell下执行su一样的显示,说明程序已经获得了root权限了吧?但执行chmod总是失败
      

  5.   


    这篇帖子我已经看了,说是要提升应用程序的root权限,需要编译android源码,这也太麻烦了吧?对于应用程序开发者,就没有权限操作别的文件了?
      

  6.   

    晕,你开发下iphone和windows phone就知道了,google不给你沙箱和隔离层已经很给面子
      

  7.   

    上传应用是不能获得root权限的,如果要获得root权限就要编译源码了。
      

  8.   

    问题解决了,用java代码可以使应用程序具有root权限,不需要修改源码。附上代码:
    public static boolean runRootCommand(String command) {
        Process process = null;
        DataOutputStream os = null;
        try {
            process = Runtime.getRuntime().exec("su");
            os = new DataOutputStream(process.getOutputStream());
            os.writeBytes(command+"\n");
            os.writeBytes("exit\n");
            os.flush();
            process.waitFor();
        } catch (Exception e) {
            Log.d("*** DEBUG ***", "Unexpected error - Here is what I know: "+e.getMessage());
            return false;
        }
        finally {
            try {
                if (os != null) {
                    os.close();
                }
                process.destroy();
            } catch (Exception e) {
                // nothing
            }
        }
        return true;
    }
    网址:http://lazyhack.net/writing-an-android-root-application/
    继续探索用c如何实现