Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ps command says /proc not mounted on LG G4 #1625

Closed
tigran123 opened this issue Oct 6, 2017 · 11 comments
Closed

ps command says /proc not mounted on LG G4 #1625

tigran123 opened this issue Oct 6, 2017 · 11 comments

Comments

@tigran123
Copy link

The ps command works fine on UMI Super running Android 7, but fails on LG G4 running Android 6, see:

$ ps --version
parser from procps-ng 3.3.12
$ ps
Error: /proc must be mounted
  To mount /proc at boot you need an /etc/fstab line like:
      proc   /proc   proc    defaults
  In the meantime, run "mount proc /proc -t proc"
$ ls /proc
1      117    15411  179    18954  19820  235  260   297   32	 3492  379   430   47	 590   78      bluetooth    meminfo
10     1174   15466  17997  18963  19821  236  261   298   320	 3503  3817  4306  4722  593   79      buddyinfo    misc
100    118    15493  18     19	   19834  237  262   299   321	 3518  3846  4323  48	 5983  8       bus	    modules
10067  119    15703  180    190    2	  238  263   3	   322	 352   3944  433   483	 6401  80      cgroups	    mounts
101    12     15704  18025  19154  20	  239  264   30    323	 353   3969  434   484	 646   81      cmdline	    net
102    12036  16     181    19239  211	  24   265   300   3236  3530  398   435   49	 647   8116    consoles     pagetypeinfo
103    12378  16066  18137  19321  212	  240  266   301   324	 3542  399   4357  5	 6649  82      cpuinfo	    partitions
104    12409  1659   18150  19322  213	  241  267   302   325	 355   40    4361  50	 667   83      crypto	    schedstat
105    13422  167    18196  19383  214	  242  268   303   326	 3557  400   438   505	 6689  8307    devices	    scsi
106    13441  16721  18198  19418  215	  243  269   304   327	 356   401   439   521	 67    84      diskstats    self
107    13574  168    182    19437  216	  244  27    305   328	 3573  402   44    523	 6729  85      driver	    softirqs
108    1386   169    183    19453  217	  245  270   306   33	 358   403   4413  524	 6761  86      execdomains  stat
109    1387   16902  184    19485  218	  246  272   307   330	 3588  4030  4419  525	 68    87      fb	    swaps
11     13996  16968  18467  19515  22	  247  274   308   332	 359   406   443   526	 6876  88      filesystems  sys
110    14     170    18468  19564  221	  248  275   309   333	 3601  408   446   527	 69    89      fs	    sysrq-trigger
11005  14115  171    185    19581  223	  249  276   31    335	 361   409   447   528	 6921  9       interrupts   timer_list
111    142    172    18560  19594  224	  250  277   310   341	 362   41    45    529	 7     90      iomem	    timer_stats
11132  14240  173    186    19632  225	  251  278   311   342	 3620  410   453   541	 70    91      ioports	    tty
11181  143    17386  18699  19640  227	  252  279   312   3421  364   411   454   5441  71    92      irq	    uid_cputime
112    144    174    187    19650  228	  253  28    3124  3425  365   414   458   551	 72    93      kallsyms     uid_stat
113    14538  17438  188    19657  229	  254  280   313   3437  368   4180  46    558	 73    94      key-users    uptime
114    14631  17485  18815  19666  23	  255  281   314   3448  369   42    461   560	 735   95      kmsg	    version
1142   14676  175    18816  19682  230	  256  282   315   346	 3697  420   463   569	 736   96      kpagecount   vmallocinfo
1143   14800  176    18853  19683  231	  257  283   316   3463  370   423   464   5766  74    97      kpageflags   vmstat
115    15     177    18866  19799  232	  258  284   317   347	 371   426   465   577	 75    98      lge_power    zoneinfo
1155   15358  178    189    19816  233	  259  2918  318   3474  372   429   466   578	 76    99      loadavg
116    15377  17854  18928  19817  234	  26   2945  319   348	 3775  43    467   5878  77    asound  locks
$ uname -a
Linux localhost 3.10.84-g21e6a83 #1 SMP PREEMPT Wed Jul 20 15:25:57 KST 2016 aarch64 Android

@tigran123
Copy link
Author

Btw, htop works fine, but top crashes, leaving the terminal in the raw state (which is cured by reset command).

@tigran123 tigran123 changed the title ps command says /proc not mount on LG G4 ps command says /proc not mounted on LG G4 Oct 6, 2017
@tigran123
Copy link
Author

The free command fails in the same way and here is a possible reason why:

openat(AT_FDCWD, "/proc/sys/vm/min_free_kbytes", O_RDONLY) = -1 EACCES (Permission denied)
write(2, "Error: /proc must be mounted\n  T"..., 176Error: /proc must be mounted
  To mount /proc at boot you need an /etc/fstab line like:
      proc   /proc   proc    defaults
  In the meantime, run "mount proc /proc -t proc"
) = 176
exit_group(102)                         = ?
+++ exited with 102 +++

At least that system call is the only thing that is failing, according to strace free output.

@ghost
Copy link

ghost commented Oct 6, 2017

SELinux enforcing ?

@tigran123
Copy link
Author

Yes, unfortunately. And this phone is not rooted, so I can't just setenforce 0...

@tigran123
Copy link
Author

I can "get by" using /system/bin/ps | grep $(id -un) but it would be nice to have the normal ps(1) command working...

@tigran123
Copy link
Author

The error is coming from the function proc/sysinfo.c:meminfo() which needs access to the file /proc/sys/vm/min_free_kbytes in order to calculate the amount of available memory (for Linux kernels > 2.6.27). This variable kb_main_available is actually used by the top(1) and free(1) utilities, but not by ps(1), so we could, in principle make ps(1) work correctly on LG G4, but that would mean quite serious changes to the meminfo() function, because ps(1) calls meminfo() for other reasons...

@tigran123
Copy link
Author

tigran123 commented Oct 11, 2017

The complete workaround for the free command is easy to implement by putting this in ~/.profile:

alias free='/system/bin/free'

The switches like -m work fine. However, a similar workaround for ps is very deficient, because it only allows a simple "grepping" for a process name, as far as I can see... (i.e. ps per shows perf and perl processes).

@ghost ghost mentioned this issue Aug 7, 2019
ghost pushed a commit that referenced this issue Aug 7, 2019
Access to this file is prohibited on some devices by SELinux and causes
utilities to treat /proc as not mounted.

Related issues:

 * #1625
 * #4132
@ghost
Copy link

ghost commented Aug 7, 2019

Should be fixed in 196f0a6.

@ghost ghost closed this as completed Aug 7, 2019
ghost pushed a commit that referenced this issue Aug 7, 2019
Access to this file is prohibited on some devices by SELinux and causes
utilities to treat /proc as not mounted.

Related issues:

 * #1625
 * #4132
@tigran123
Copy link
Author

tigran123 commented Aug 7, 2019

Hmm, on one device (Samsung Galaxy Tab S4) pkg upgrade upgraded procps to version 3.3.15-4, but on another device pkg upgrade says that all packages are up to date even though procps is 3.3.15-3. The architecture is the same aarch64, but Android versions are different (9 on S4 and 6 on LG G4). And it is on the LG G4 that I would need to use procps 3.3.15-4 with today's fix, because that is where ps fails.

@ghost
Copy link

ghost commented Aug 7, 2019

termux.net doesn't receive updates immediately. Wait until @fornwall will rebuild necessary packages.

@tigran123
Copy link
Author

tigran123 commented Aug 7, 2019

Ok, but how come my Samsung Galaxy Tab S4 (Android 9) updated to 3.3.15-4? Anyway, I will wait for the package to become visible to LG G4 (Android 6) as well. UPDATE: Your answer in the other issue #4121 explained everything.

amuramatsu pushed a commit to amuramatsu/termux-packages that referenced this issue Dec 7, 2019
Access to this file is prohibited on some devices by SELinux and causes
utilities to treat /proc as not mounted.

Related issues:

 * termux#1625
 * termux#4132
@ghost ghost locked and limited conversation to collaborators Oct 9, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant