eminence / procfs

Rust library for reading the Linux procfs filesystem
Other
367 stars 106 forks source link

Supporting Android platform? #148

Closed tiann closed 3 years ago

tiann commented 3 years ago

I run the demo code in Android plaform:

fn main() {
    let me = procfs::process::Process::myself().unwrap();
    println!("PID: {}", me.pid);
}

and the error occurs:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: PermissionDenied(Some("/proc/sys/kernel/osrelease"))', /Users/weishu/.cargo/registry/src/mirrors.sjtug.sjtu.edu.cn-7a04d2510079875b/procfs-0.10.1/src/lib.rs:303:34
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Normal app in Android have no permission to read /proc/sys/kernel/osrelease, (it is forbidden by SELinux), how can i fix this?

eminence commented 3 years ago

Hi, thanks for the report.

This is unfortunately a bug: #138

I'm a little surprised to see this panic while calling Process::myself() (so seeing the full stack trace would be helpful), but this is a procfs bug that still must be fixed

tiann commented 3 years ago

It seems that backtrace is not working well on Android ?

101|ginkgo:/data/local/tmp $ RUST_BACKTRACE=full ./abcd
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: PermissionDenied(Some("/proc/sys/kernel/osrelease"))', /Users/weishu/.cargo/registry/src/mirrors.sjtug.sjtu.edu.cn-7a04d2510079875b/procfs-0.10.1/src/lib.rs:303:34
stack backtrace:
   0:       0x59d42c5600 - <unknown>
   1:       0x59d42db818 - <unknown>
   2:       0x59d42c37ec - <unknown>
   3:       0x59d42c6e50 - <unknown>
   4:       0x59d42c699c - <unknown>
   5:       0x59d42c75d4 - <unknown>
   6:       0x59d42c7100 - <unknown>
   7:       0x59d42c5a84 - <unknown>
   8:       0x59d42c7068 - <unknown>
   9:       0x59d42daa64 - <unknown>
  10:       0x59d42dabe8 - <unknown>
  11:       0x59d42ad04c - <unknown>
  12:       0x59d42a59b0 - <unknown>
  13:       0x59d42aeed8 - <unknown>
  14:       0x59d42af410 - <unknown>
  15:       0x59d42c532c - <unknown>
  16:       0x59d42af3a0 - <unknown>
  17:       0x59d42a34c4 - <unknown>
  18:       0x59d42aa338 - <unknown>
  19:       0x59d42adcf0 - <unknown>
  20:       0x59d42ae024 - <unknown>
  21:       0x59d42a0b00 - <unknown>
  22:       0x59d42a08e4 - <unknown>
  23:       0x59d42a0ac4 - <unknown>
  24:       0x59d42a09b4 - <unknown>
  25:       0x59d42c78dc - <unknown>
  26:       0x59d42a0980 - <unknown>
  27:       0x59d42a0be8 - <unknown>
  28:       0x79f69cb97c - <unknown>
  29:                0x0 - <unknown>
eminence commented 3 years ago

Hello, the latest v0.11.0 release should fix this. Please try it out and let me know if you still have problems. Thanks again for the bug report.

tiann commented 3 years ago

0.11.0 works well, thanks for your great work!