summaryrefslogtreecommitdiff
path: root/src/node_os.cc
AgeCommit message (Collapse)Author
2017-12-01src: use nullptr instead of NULLDaniel Bevenius
PR-URL: https://github.com/nodejs/node/pull/17373 Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2017-11-13src: explicitly register built-in modulesYihong Wang
Previously, built-in modules are registered before main() via __attribute__((constructor)) mechanism in GCC and similiar mechanism in MSVC. This causes some issues when node is built as static library. Calling module registration function for built-in modules in node::Init() helps to avoid the issues. Signed-off-by: Yihong Wang <yh.wang@ibm.com> PR-URL: https://github.com/nodejs/node/pull/16565 Refs: https://github.com/nodejs/node/pull/14986#issuecomment-332758206 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-11-02os: migrate node_os.cc to internal/errorsJames M Snell
PR-URL: https://github.com/nodejs/node/pull/16567 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2017-09-14src: refactor `#include` handlingAnna Henningsen
`node_internals.h` already includes the most common headers, so double includes can be avoided in a lot of cases. Also don’t include `node_internals.h` from `node.h` implicitly anymore, as that is mostly unnecessary. PR-URL: https://github.com/nodejs/node/pull/14697 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-08-24src: use proper errors as coming from StringBytesAnna Henningsen
The previous errors were incorrect here, as the code only failed in situations where strings exceeded size limits or an OOM situation was encountered, not for invalid encodings (which aren’t even detected explicitly). Unfortunately, these situations are hard to test for. PR-URL: https://github.com/nodejs/node/pull/14579 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-05-03src: do proper StringBytes error handlingAnna Henningsen
- Return `MaybeLocal`s from `StringBytes::Encode` - Add an `error` out parameter to pass JS exceptions to the callers (instead of directly throwing) - Simplify some of the string generation methods in `string_bytes.cc` by unifying the `EXTERN_APEX` logic - Reduce usage of deprecated V8 APIs. - Remove error handling logic from JS, the `buffer.*Slice()` methods now throw errors themselves. - Left TODO comments for future semver-major error message improvements. This paves the way for better error messages coming out of the StringBytes methods. Ref: https://github.com/nodejs/node/issues/3175 PR-URL: https://github.com/nodejs/node/pull/12765 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2017-04-14os,vm: fix segfaults and CHECK failureTobias Nießen
Fixes multiple possible segmentation faults in node_contextify.cc and an assertion failure in node_os.cc Fixes: https://github.com/nodejs/node/issues/12369 Fixes: https://github.com/nodejs/node/issues/12370 PR-URL: https://github.com/nodejs/node/pull/12371 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-03-10meta: restore original copyright headerJames M Snell
A prior io.js era commit inappropriately removed the original copyright statements from the source. This restores those in any files still remaining from that edit. Ref: https://github.com/nodejs/TSC/issues/174 Ref: https://github.com/nodejs/node/pull/10599 PR-URL: https://github.com/nodejs/node/pull/10155 Note: This PR was required, reviewed-by and approved by the Node.js Foundation Legal Committee and the TSC. There is no `Approved-By:` meta data.
2017-03-02os: improve cpus() performanceBrian White
PR-URL: https://github.com/nodejs/node/pull/11564 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
2017-02-25os: improve loadavg() performanceBrian White
PR-URL: https://github.com/nodejs/node/pull/11516 Reviewed-By: Jackson Tian <shyvo1987@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2017-01-23src: add a missing space in node_os.ccAlexey Orlenko
This commit makes a small stylistic fix adding a missing space in GetOSType function in node_os.cc PR-URL: https://github.com/nodejs/node/pull/10931 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michal Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-27os: fix os.release() for aix and add testjBarz
PR-URL: https://github.com/nodejs/node/pull/10245 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-10-10src: fix typo in #endif commentJuan Andres Andrango
PR-URL: https://github.com/nodejs/node/pull/8989 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Brian White <mscdex@mscdex.net>
2016-04-12os: add userInfo() methodcjihrig
os.userInfo() calls libuv's uv_os_get_passwd() function. It returns an object containing the current effective user's username, uid, gid, shell, and home directory. On Windows, the uid and gid are -1, and the shell is null. Refs: https://github.com/nodejs/node/issues/5582 PR-URL: https://github.com/nodejs/node/pull/6104 Reviewed-By: James M Snell <jasnell@gmail.com>
2016-03-03src: replace usage of deprecated HasMichaël Zasso
PR-URL: https://github.com/nodejs/node/pull/5159 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-01-04os: fix crash in GetInterfaceAddressesMartin Bark
If uv_interface_addresses() returns UV_ENOSYS then interfaces and count are uninitialised. This can cause a segmentation fault inside GetInterfaceAddresses when it tries to use the invalid interfaces[]. Fix the issue by returning from GetInterfaceAddresses on the UV_ENOSYS error. This issue was observed when using uCLibc-ng version 1.0.9 because uv_interface_addresses() in deps/uv/src/unix/linux-core.c incorrectly undefines HAVE_IFADDRS_H. Signed-off-by: Martin Bark <martin@barkynet.com> PR-URL: https://github.com/nodejs/node/pull/4272 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
2015-09-06src: replace usage of v8::Handle with v8::LocalMichaël Zasso
v8::Handle is deprecated: https://codereview.chromium.org/1224623004 PR-URL: https://github.com/nodejs/io.js/pull/2202 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-06-05os: add homedir()cjihrig
os.homedir() calls libuv's uv_os_homedir() to retrieve the current user's home directory. PR-URL: https://github.com/nodejs/io.js/pull/1791 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rod Vagg <rod@vagg.org>
2015-01-12Remove excessive copyright/license boilerplateisaacs
The copyright and license notice is already in the LICENSE file. There is no justifiable reason to also require that it be included in every file, since the individual files are not individually distributed except as part of the entire package.
2015-01-08win: suppress GetVersionEx deprecation warningBert Belder
There is no other way to retrieve the Windows version. The stated reason this API is deprecated is that applications are not supposed to check whether the Windows it's running on is recent enough. But that's not what we use it for. PR-URL: https://github.com/iojs/io.js/pull/261 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-08win: use GetVersionExW instead of GetVersionExABert Belder
For consistency with the rest of the source code, use the wide-char version of this API. PR-URL: https://github.com/iojs/io.js/pull/261 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2014-11-11lib,src: make os.endianness() inlinableBen Noordhuis
Turn os.endianness() from a run-time function into a pure JS function. Upsides: makes it a good candidate for inlining at the call site. Downsides: none that I can think of. PR-URL: https://github.com/node-forward/node/pull/55 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-11-05src: network interface names are UTF-8 encodedBen Noordhuis
Fixes a bug that was introduced in commit f674b09 when v8::String::New() calls were replaced with calls to one-byte, two-byte and UTF-8 versions. It turns out that for network interface names, using a one-byte encoding can produce the wrong results on Windows. Use UTF-8 instead. Libuv on Windows correctly encodes non-ASCII characters in the interface name as UTF-8. On Unices however, the interface name is just a binary string with no particular encoding; that's why on UNIX platforms, we keep interpreting it as a one-byte string. Fixes joyent/node#8633. PR-URL: https://github.com/node-forward/node/pull/44 Reviewed-By: Bert Belder <bertbelder@gmail.com>
2014-10-13src: attach env directly to api functionsBen Noordhuis
Attach the per-context execution environment directly to API functions. Rationale: * Gets node one step closer to multi-isolate readiness. * Avoids multi-context confusion, e.g. when the caller and callee live in different contexts. * Avoids expensive calls to pthread_getspecific() on platforms where V8 does not know how to use the thread-local storage directly. (Linux, the BSDs.) PR-URL: https://github.com/node-forward/node/pull/18 Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-10-12src: remove unnecessary HandleScopesBen Noordhuis
API callback functions don't need to create a v8::HandleScope instance because V8 already creates one in the JS->C++ adapter frame. PR-URL: https://github.com/node-forward/node/pull/16 Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-03-13src: update to v8 3.24 APIsFedor Indutny
2014-02-22src: remove `node_isolate` from sourceFedor Indutny
fix #6899
2014-02-18os: networkInterfaces include scopeid for ipv6Xidorn Quan
2014-01-27node: register modules from DSO constructorsKeith M Wesolowski
Built-in modules should be automatically registered, replacing the static module list. Add-on modules should also be automatically registered via DSO constructors. This improves flexibility in adding built-in modules and is also a prerequisite to pure-C addon modules.
2014-01-13Merge remote-tracking branch 'upstream/v0.10'Timothy J Fontaine
Conflicts: deps/uv/ChangeLog deps/uv/build.mk deps/uv/src/version.c deps/uv/test/test-ipc.c deps/v8/src/objects.cc src/node.cc src/node_os.cc
2014-01-12src: return empty set on ENOSYS for interfacesTimothy J Fontaine
If node was compiled with --no-ifaddrs to support older operating systems, don't throw instead simply return an empty object Fixes #6846
2013-10-17cpplint: disallow if one-linersFedor Indutny
2013-09-06src: add multi-context supportBen Noordhuis
This commit makes it possible to use multiple V8 execution contexts within a single event loop. Put another way, handle and request wrap objects now "remember" the context they belong to and switch back to that context when the time comes to call into JS land. This could have been done in a quick and hacky way by calling v8::Object::GetCreationContext() on the wrap object right before making a callback but that leaves a fairly wide margin for bugs. Instead, we make the context explicit through a new Environment class that encapsulates everything (or almost everything) that belongs to the context. Variables that used to be a static or a global are now members of the aforementioned class. An additional benefit is that this approach should make it relatively straightforward to add full isolate support in due course. There is no JavaScript API yet but that will be added in the near future. This work was graciously sponsored by GitHub, Inc.
2013-08-26src: remove pointless node_os.h header fileBen Noordhuis
src/node_os.cc doesn't export anything that's used elsewhere. Remove it.
2013-08-09src: use v8::String::NewFrom*() functionsBen Noordhuis
* Change calls to String::New() and String::NewSymbol() to their respective one-byte, two-byte and UTF-8 counterparts. * Add a FIXED_ONE_BYTE_STRING macro that takes a string literal and turns it into a v8::Local<v8::String>. * Add helper functions that make v8::String::NewFromOneByte() easier to work with. Said function expects a `const uint8_t*` but almost every call site deals with `const char*` or `const unsigned char*`. Helps us avoid doing reinterpret_casts all over the place. * Code that handles file system paths keeps using UTF-8 for backwards compatibility reasons. At least now the use of UTF-8 is explicit. * Remove v8::String::NewSymbol() entirely. Almost all call sites were effectively minor de-optimizations. If you create a string only once, there is no point in making it a symbol. If you are create the same string repeatedly, it should probably be cached in a persistent handle.
2013-08-01os: add mac address to networkInterfaces() outputBrian White
2013-07-31src: lint c++ codeFedor Indutny
2013-07-30src: remove unused import in src/node_os.ccBen Noordhuis
2013-07-30Merge remote-tracking branch 'origin/v0.10'Ben Noordhuis
Conflicts: AUTHORS ChangeLog deps/uv/ChangeLog deps/uv/src/version.c deps/uv/src/win/fs.c src/node.cc src/node_crypto.cc src/node_os.cc src/node_version.h
2013-07-23src: os: use Number::New() for CPU infoBen Noordhuis
The return values from uv_cpu_info() don't necessarily fit in a 32 bits signed integer. Fixes #5732.
2013-07-20src, lib: update after internal api changeBen Noordhuis
Libuv now returns errors directly. Make everything in src/ and lib/ follow suit. The changes to lib/ are not strictly necessary but they remove the need for the abominations that are process._errno and node::SetErrno().
2013-07-06lib, src: upgrade after v8 api changeBen Noordhuis
This is a big commit that touches just about every file in the src/ directory. The V8 API has changed in significant ways. The most important changes are: * Binding functions take a const v8::FunctionCallbackInfo<T>& argument rather than a const v8::Arguments& argument. * Binding functions return void rather than v8::Handle<v8::Value>. The return value is returned with the args.GetReturnValue().Set() family of functions. * v8::Persistent<T> no longer derives from v8::Handle<T> and no longer allows you to directly dereference the object that the persistent handle points to. This means that the common pattern of caching oft-used JS values in a persistent handle no longer quite works, you first need to reconstruct a v8::Local<T> from the persistent handle with the Local<T>::New(isolate, persistent) factory method. A handful of (internal) convenience classes and functions have been added to make dealing with the new API a little easier. The most visible one is node::Cached<T>, which wraps a v8::Persistent<T> with some template sugar. It can hold arbitrary types but so far it's exclusively used for v8::Strings (which was by far the most commonly cached handle type.)
2013-05-30os: use IsBigEndian() in GetEndianness() functionBen Noordhuis
2013-05-08os: Include netmask in os.networkInterfaces()Ben Kelly
re #3765 and #5432 fixes #4743
2013-04-29Merge remote-tracking branch 'origin/v0.10'Ben Noordhuis
Conflicts: AUTHORS ChangeLog deps/uv/ChangeLog deps/uv/src/version.c lib/http.js src/node_crypto.cc src/node_os.cc src/node_version.h test/simple/helper-debugger-repl.js
2013-04-22os: Fix uname() error handling on sunosisaacs
The uname function can return any non-negative int to indicate success. Strange, but that's how it is documented. This also fixes a similar buffer overflow in the even more unlikely event that info.release is > 255 characters, similar to how 78c5de5 did for info.sysname.
2013-04-18Merge remote-tracking branch 'origin/v0.10'Ben Noordhuis
Conflicts: src/node_os.cc
2013-04-15os: unbreak windows buildBen Noordhuis
Windows doesn't have MAXHOSTNAMELEN. Introduced in afbadde.
2013-04-15os: handle 256 character hostnamesBen Noordhuis
Fix a (rather academic) buffer overflow. MAXHOSTNAMELEN is 256 on most platforms, which means the buffer wasn't big enough to hold the trailing nul byte on a system with a maximum length hostname.
2013-04-15os: fix unlikely buffer overflow in os.type()Ben Noordhuis
* Fix a buffer overflow that happens iff strlen(info.sysname) > 255. * Check the return value of uname().