This repository has been archived by the owner. It is now read-only.

Don't require /proc filesystem #10426

Open
piranna opened this Issue Mar 21, 2015 · 10 comments

Comments

Projects
None yet
5 participants
@piranna

piranna commented Mar 21, 2015

When using Node.js on a Linux system that don't have mounted /proc filesystem, calling to process.memoryUsage() throw an ENOENT exception:

> process.memoryUsage()
Error: ENOENT, no such file or directory
    at Error (native)
    at repl:1:9
    at REPLServer.defaultEval (repl.js:133:27)
    at bound (domain.js:254:14)
    at REPLServer.runBound [as eval] (domain.js:267:12)
    at REPLServer.<anonymous> (repl.js:280:12)
    at REPLServer.emit (events.js:107:17)
    at REPLServer.Interface._onLine (readline.js:206:10)
    at REPLServer.Interface._line (readline.js:535:8)
    at REPLServer.Interface._ttyWrite (readline.js:812:14)

I think usage of /proc should not be necesary if the same info can be fetch by using ioctl(), specially since we support Windows and MacOS X that don't have that filesystem. This would be helpful to NodeOS.

@obastemur

This comment has been minimized.

Show comment
Hide comment
@obastemur

obastemur Mar 21, 2015

Member

/proc is part of the linux kernel and many programs require the tools from that location to function properly. I would like to know more on that linux system without '/proc'

I think usage of /proc should not be necesary if the same info can be fetch by using ioctl(), specially since we support Windows and MacOS X that don't have that filesystem.

It's linux only.

Member

obastemur commented Mar 21, 2015

/proc is part of the linux kernel and many programs require the tools from that location to function properly. I would like to know more on that linux system without '/proc'

I think usage of /proc should not be necesary if the same info can be fetch by using ioctl(), specially since we support Windows and MacOS X that don't have that filesystem.

It's linux only.

@piranna

This comment has been minimized.

Show comment
Hide comment
@piranna

piranna Mar 21, 2015

/proc is part of the linux kernel and many programs require the tools from that location to function properly.

It's true /proc is part of Linux kernel, but it's not mandatory since it only expose its internal structures as a convenient filesystem API, the same can be (mostly) done by using ioctl(), only that in most cases by using /proc is simpler since you only need to read a file to fetch the data.

I would like to know more on that linux system without '/proc'

NodeOS currently is using /proc only to be able to get the memory usage stadistics (using Node.js) and to get the Linux kernel exec arguments (on /proc/cmdline), so it could be fully removed. This would allow to need less resources on the system and remove some security flaws (/proc by default show some sensitive data).

It's linux only.

Yes, and stolen from Plan9 :-) What I mean is that it's not available on Windows or MacOS X, so since some internal APIs are being used on that systems (and probable FreeBSD), something similar could be done on Linux to don't depend on /proc at all.

piranna commented Mar 21, 2015

/proc is part of the linux kernel and many programs require the tools from that location to function properly.

It's true /proc is part of Linux kernel, but it's not mandatory since it only expose its internal structures as a convenient filesystem API, the same can be (mostly) done by using ioctl(), only that in most cases by using /proc is simpler since you only need to read a file to fetch the data.

I would like to know more on that linux system without '/proc'

NodeOS currently is using /proc only to be able to get the memory usage stadistics (using Node.js) and to get the Linux kernel exec arguments (on /proc/cmdline), so it could be fully removed. This would allow to need less resources on the system and remove some security flaws (/proc by default show some sensitive data).

It's linux only.

Yes, and stolen from Plan9 :-) What I mean is that it's not available on Windows or MacOS X, so since some internal APIs are being used on that systems (and probable FreeBSD), something similar could be done on Linux to don't depend on /proc at all.

@dayuoba

This comment has been minimized.

Show comment
Hide comment
@dayuoba

dayuoba Mar 22, 2015

@piranna yes,i agree with you,for other using with linux,it should make less deps on /proc .what should the implemention be?and i think it is low priority for nodejs.

dayuoba commented Mar 22, 2015

@piranna yes,i agree with you,for other using with linux,it should make less deps on /proc .what should the implemention be?and i think it is low priority for nodejs.

@piranna

This comment has been minimized.

Show comment
Hide comment
@piranna

piranna Mar 22, 2015

what should the implemention be?

I'm honestly not a kernel developer, but mostly change all access to /proc files to their ioctl() corresponding call to fetch the same data. I don't believe there are too much of them, unluckily I have done a quick search on Node.js source code and didn't find them... I'll need to redo it later.

i think it is low priority for nodejs

Absolutelly.

piranna commented Mar 22, 2015

what should the implemention be?

I'm honestly not a kernel developer, but mostly change all access to /proc files to their ioctl() corresponding call to fetch the same data. I don't believe there are too much of them, unluckily I have done a quick search on Node.js source code and didn't find them... I'll need to redo it later.

i think it is low priority for nodejs

Absolutelly.

@dayuoba

This comment has been minimized.

Show comment
Hide comment
@dayuoba

dayuoba Mar 22, 2015

@piranna that may be a funny work :)

dayuoba commented Mar 22, 2015

@piranna that may be a funny work :)

@piranna

This comment has been minimized.

Show comment
Hide comment
@piranna

piranna Mar 22, 2015

I'm happy you think so :-)

piranna commented Mar 22, 2015

I'm happy you think so :-)

@piranna piranna referenced this issue in NodeOS/NodeOS Mar 22, 2015

Closed

I'm rootless #118

@saghul

This comment has been minimized.

Show comment
Hide comment
@saghul

saghul Mar 23, 2015

Member

FWIW, this is not a Node issue, if anywhere, it belongs to libuv. Now, a quick glance shows that the following things depend on having /proc:

  • /proc/self/exe: for exepath
  • /proc/self/stat: for uv_resident_set_memory
  • /proc/cpuinfo: for uv_cpu_info
  • /proc/self/fd: for uv_fs_utime

I don't see this changing. But feel free to open an issue about it. Also be ready to write the code :-)

Member

saghul commented Mar 23, 2015

FWIW, this is not a Node issue, if anywhere, it belongs to libuv. Now, a quick glance shows that the following things depend on having /proc:

  • /proc/self/exe: for exepath
  • /proc/self/stat: for uv_resident_set_memory
  • /proc/cpuinfo: for uv_cpu_info
  • /proc/self/fd: for uv_fs_utime

I don't see this changing. But feel free to open an issue about it. Also be ready to write the code :-)

@dayuoba

This comment has been minimized.

Show comment
Hide comment
@dayuoba

dayuoba Mar 24, 2015

@saghul cool

dayuoba commented Mar 24, 2015

@saghul cool

@misterdjules

This comment has been minimized.

Show comment
Hide comment
@misterdjules

misterdjules Mar 25, 2015

Thank you @piranna, @saghul and @dayuoba. Let's keep this issue around if at some point libuv is able to get this information without using /proc.

Thank you @piranna, @saghul and @dayuoba. Let's keep this issue around if at some point libuv is able to get this information without using /proc.

@piranna

This comment has been minimized.

Show comment
Hide comment
@piranna

piranna Mar 26, 2015

You are welcome @misterdjules. Also, good job @saghul! :-)

piranna commented Mar 26, 2015

You are welcome @misterdjules. Also, good job @saghul! :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.