11cb0ef41Sopenharmony_ci// Copyright Joyent, Inc. and other Node contributors. 21cb0ef41Sopenharmony_ci// 31cb0ef41Sopenharmony_ci// Permission is hereby granted, free of charge, to any person obtaining a 41cb0ef41Sopenharmony_ci// copy of this software and associated documentation files (the 51cb0ef41Sopenharmony_ci// "Software"), to deal in the Software without restriction, including 61cb0ef41Sopenharmony_ci// without limitation the rights to use, copy, modify, merge, publish, 71cb0ef41Sopenharmony_ci// distribute, sublicense, and/or sell copies of the Software, and to permit 81cb0ef41Sopenharmony_ci// persons to whom the Software is furnished to do so, subject to the 91cb0ef41Sopenharmony_ci// following conditions: 101cb0ef41Sopenharmony_ci// 111cb0ef41Sopenharmony_ci// The above copyright notice and this permission notice shall be included 121cb0ef41Sopenharmony_ci// in all copies or substantial portions of the Software. 131cb0ef41Sopenharmony_ci// 141cb0ef41Sopenharmony_ci// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 151cb0ef41Sopenharmony_ci// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 161cb0ef41Sopenharmony_ci// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 171cb0ef41Sopenharmony_ci// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 181cb0ef41Sopenharmony_ci// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 191cb0ef41Sopenharmony_ci// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 201cb0ef41Sopenharmony_ci// USE OR OTHER DEALINGS IN THE SOFTWARE. 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ci'use strict'; 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ciconst { 251cb0ef41Sopenharmony_ci ArrayPrototypePush, 261cb0ef41Sopenharmony_ci Float64Array, 271cb0ef41Sopenharmony_ci NumberParseInt, 281cb0ef41Sopenharmony_ci ObjectDefineProperties, 291cb0ef41Sopenharmony_ci StringPrototypeEndsWith, 301cb0ef41Sopenharmony_ci StringPrototypeSlice, 311cb0ef41Sopenharmony_ci SymbolToPrimitive, 321cb0ef41Sopenharmony_ci} = primordials; 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ciconst { safeGetenv } = internalBinding('credentials'); 351cb0ef41Sopenharmony_ciconst constants = internalBinding('constants').os; 361cb0ef41Sopenharmony_ciconst isWindows = process.platform === 'win32'; 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_ciconst { 391cb0ef41Sopenharmony_ci codes: { 401cb0ef41Sopenharmony_ci ERR_SYSTEM_ERROR, 411cb0ef41Sopenharmony_ci }, 421cb0ef41Sopenharmony_ci hideStackFrames, 431cb0ef41Sopenharmony_ci} = require('internal/errors'); 441cb0ef41Sopenharmony_ciconst { validateInt32 } = require('internal/validators'); 451cb0ef41Sopenharmony_ci 461cb0ef41Sopenharmony_ciconst { 471cb0ef41Sopenharmony_ci getAvailableParallelism, 481cb0ef41Sopenharmony_ci getCPUs, 491cb0ef41Sopenharmony_ci getFreeMem, 501cb0ef41Sopenharmony_ci getHomeDirectory: _getHomeDirectory, 511cb0ef41Sopenharmony_ci getHostname: _getHostname, 521cb0ef41Sopenharmony_ci getInterfaceAddresses: _getInterfaceAddresses, 531cb0ef41Sopenharmony_ci getLoadAvg, 541cb0ef41Sopenharmony_ci getPriority: _getPriority, 551cb0ef41Sopenharmony_ci getOSInformation: _getOSInformation, 561cb0ef41Sopenharmony_ci getTotalMem, 571cb0ef41Sopenharmony_ci getUserInfo, 581cb0ef41Sopenharmony_ci getUptime: _getUptime, 591cb0ef41Sopenharmony_ci isBigEndian, 601cb0ef41Sopenharmony_ci setPriority: _setPriority, 611cb0ef41Sopenharmony_ci} = internalBinding('os'); 621cb0ef41Sopenharmony_ci 631cb0ef41Sopenharmony_cifunction getCheckedFunction(fn) { 641cb0ef41Sopenharmony_ci return hideStackFrames(function checkError(...args) { 651cb0ef41Sopenharmony_ci const ctx = {}; 661cb0ef41Sopenharmony_ci const ret = fn(...args, ctx); 671cb0ef41Sopenharmony_ci if (ret === undefined) { 681cb0ef41Sopenharmony_ci throw new ERR_SYSTEM_ERROR(ctx); 691cb0ef41Sopenharmony_ci } 701cb0ef41Sopenharmony_ci return ret; 711cb0ef41Sopenharmony_ci }); 721cb0ef41Sopenharmony_ci} 731cb0ef41Sopenharmony_ci 741cb0ef41Sopenharmony_ciconst { 751cb0ef41Sopenharmony_ci 0: type, 761cb0ef41Sopenharmony_ci 1: version, 771cb0ef41Sopenharmony_ci 2: release, 781cb0ef41Sopenharmony_ci 3: machine, 791cb0ef41Sopenharmony_ci} = _getOSInformation(); 801cb0ef41Sopenharmony_ci 811cb0ef41Sopenharmony_ciconst getHomeDirectory = getCheckedFunction(_getHomeDirectory); 821cb0ef41Sopenharmony_ciconst getHostname = getCheckedFunction(_getHostname); 831cb0ef41Sopenharmony_ciconst getInterfaceAddresses = getCheckedFunction(_getInterfaceAddresses); 841cb0ef41Sopenharmony_ciconst getUptime = getCheckedFunction(_getUptime); 851cb0ef41Sopenharmony_ci 861cb0ef41Sopenharmony_ci/** 871cb0ef41Sopenharmony_ci * @returns {string} 881cb0ef41Sopenharmony_ci */ 891cb0ef41Sopenharmony_ciconst getOSRelease = () => release; 901cb0ef41Sopenharmony_ci/** 911cb0ef41Sopenharmony_ci * @returns {string} 921cb0ef41Sopenharmony_ci */ 931cb0ef41Sopenharmony_ciconst getOSType = () => type; 941cb0ef41Sopenharmony_ci/** 951cb0ef41Sopenharmony_ci * @returns {string} 961cb0ef41Sopenharmony_ci */ 971cb0ef41Sopenharmony_ciconst getOSVersion = () => version; 981cb0ef41Sopenharmony_ci/** 991cb0ef41Sopenharmony_ci * @returns {string} 1001cb0ef41Sopenharmony_ci */ 1011cb0ef41Sopenharmony_ciconst getMachine = () => machine; 1021cb0ef41Sopenharmony_ci 1031cb0ef41Sopenharmony_cigetAvailableParallelism[SymbolToPrimitive] = () => getAvailableParallelism(); 1041cb0ef41Sopenharmony_cigetFreeMem[SymbolToPrimitive] = () => getFreeMem(); 1051cb0ef41Sopenharmony_cigetHostname[SymbolToPrimitive] = () => getHostname(); 1061cb0ef41Sopenharmony_cigetOSVersion[SymbolToPrimitive] = () => getOSVersion(); 1071cb0ef41Sopenharmony_cigetOSType[SymbolToPrimitive] = () => getOSType(); 1081cb0ef41Sopenharmony_cigetOSRelease[SymbolToPrimitive] = () => getOSRelease(); 1091cb0ef41Sopenharmony_cigetMachine[SymbolToPrimitive] = () => getMachine(); 1101cb0ef41Sopenharmony_cigetHomeDirectory[SymbolToPrimitive] = () => getHomeDirectory(); 1111cb0ef41Sopenharmony_cigetTotalMem[SymbolToPrimitive] = () => getTotalMem(); 1121cb0ef41Sopenharmony_cigetUptime[SymbolToPrimitive] = () => getUptime(); 1131cb0ef41Sopenharmony_ci 1141cb0ef41Sopenharmony_ciconst kEndianness = isBigEndian ? 'BE' : 'LE'; 1151cb0ef41Sopenharmony_ci 1161cb0ef41Sopenharmony_ciconst avgValues = new Float64Array(3); 1171cb0ef41Sopenharmony_ci 1181cb0ef41Sopenharmony_ci/** 1191cb0ef41Sopenharmony_ci * @returns {[number, number, number]} 1201cb0ef41Sopenharmony_ci */ 1211cb0ef41Sopenharmony_cifunction loadavg() { 1221cb0ef41Sopenharmony_ci getLoadAvg(avgValues); 1231cb0ef41Sopenharmony_ci return [avgValues[0], avgValues[1], avgValues[2]]; 1241cb0ef41Sopenharmony_ci} 1251cb0ef41Sopenharmony_ci 1261cb0ef41Sopenharmony_ci/** 1271cb0ef41Sopenharmony_ci * Returns an array of objects containing information about each 1281cb0ef41Sopenharmony_ci * logical CPU core. 1291cb0ef41Sopenharmony_ci * @returns {Array<{ 1301cb0ef41Sopenharmony_ci * model: string, 1311cb0ef41Sopenharmony_ci * speed: number, 1321cb0ef41Sopenharmony_ci * times: { 1331cb0ef41Sopenharmony_ci * user: number, 1341cb0ef41Sopenharmony_ci * nice: number, 1351cb0ef41Sopenharmony_ci * sys: number, 1361cb0ef41Sopenharmony_ci * idle: number, 1371cb0ef41Sopenharmony_ci * irq: number, 1381cb0ef41Sopenharmony_ci * }, 1391cb0ef41Sopenharmony_ci * }>} 1401cb0ef41Sopenharmony_ci */ 1411cb0ef41Sopenharmony_cifunction cpus() { 1421cb0ef41Sopenharmony_ci // [] is a bugfix for a regression introduced in 51cea61 1431cb0ef41Sopenharmony_ci const data = getCPUs() || []; 1441cb0ef41Sopenharmony_ci const result = []; 1451cb0ef41Sopenharmony_ci let i = 0; 1461cb0ef41Sopenharmony_ci while (i < data.length) { 1471cb0ef41Sopenharmony_ci ArrayPrototypePush(result, { 1481cb0ef41Sopenharmony_ci model: data[i++], 1491cb0ef41Sopenharmony_ci speed: data[i++], 1501cb0ef41Sopenharmony_ci times: { 1511cb0ef41Sopenharmony_ci user: data[i++], 1521cb0ef41Sopenharmony_ci nice: data[i++], 1531cb0ef41Sopenharmony_ci sys: data[i++], 1541cb0ef41Sopenharmony_ci idle: data[i++], 1551cb0ef41Sopenharmony_ci irq: data[i++], 1561cb0ef41Sopenharmony_ci }, 1571cb0ef41Sopenharmony_ci }); 1581cb0ef41Sopenharmony_ci } 1591cb0ef41Sopenharmony_ci return result; 1601cb0ef41Sopenharmony_ci} 1611cb0ef41Sopenharmony_ci 1621cb0ef41Sopenharmony_ci/** 1631cb0ef41Sopenharmony_ci * @returns {string} 1641cb0ef41Sopenharmony_ci */ 1651cb0ef41Sopenharmony_cifunction arch() { 1661cb0ef41Sopenharmony_ci return process.arch; 1671cb0ef41Sopenharmony_ci} 1681cb0ef41Sopenharmony_ciarch[SymbolToPrimitive] = () => process.arch; 1691cb0ef41Sopenharmony_ci 1701cb0ef41Sopenharmony_ci/** 1711cb0ef41Sopenharmony_ci * @returns {string} 1721cb0ef41Sopenharmony_ci */ 1731cb0ef41Sopenharmony_cifunction platform() { 1741cb0ef41Sopenharmony_ci return process.platform; 1751cb0ef41Sopenharmony_ci} 1761cb0ef41Sopenharmony_ciplatform[SymbolToPrimitive] = () => process.platform; 1771cb0ef41Sopenharmony_ci 1781cb0ef41Sopenharmony_ci/** 1791cb0ef41Sopenharmony_ci * @returns {string} 1801cb0ef41Sopenharmony_ci */ 1811cb0ef41Sopenharmony_cifunction tmpdir() { 1821cb0ef41Sopenharmony_ci let path; 1831cb0ef41Sopenharmony_ci if (isWindows) { 1841cb0ef41Sopenharmony_ci path = process.env.TEMP || 1851cb0ef41Sopenharmony_ci process.env.TMP || 1861cb0ef41Sopenharmony_ci (process.env.SystemRoot || process.env.windir) + '\\temp'; 1871cb0ef41Sopenharmony_ci if (path.length > 1 && StringPrototypeEndsWith(path, '\\') && 1881cb0ef41Sopenharmony_ci !StringPrototypeEndsWith(path, ':\\')) 1891cb0ef41Sopenharmony_ci path = StringPrototypeSlice(path, 0, -1); 1901cb0ef41Sopenharmony_ci } else { 1911cb0ef41Sopenharmony_ci path = safeGetenv('TMPDIR') || 1921cb0ef41Sopenharmony_ci safeGetenv('TMP') || 1931cb0ef41Sopenharmony_ci safeGetenv('TEMP') || 1941cb0ef41Sopenharmony_ci '/tmp'; 1951cb0ef41Sopenharmony_ci if (path.length > 1 && StringPrototypeEndsWith(path, '/')) 1961cb0ef41Sopenharmony_ci path = StringPrototypeSlice(path, 0, -1); 1971cb0ef41Sopenharmony_ci } 1981cb0ef41Sopenharmony_ci 1991cb0ef41Sopenharmony_ci return path; 2001cb0ef41Sopenharmony_ci} 2011cb0ef41Sopenharmony_citmpdir[SymbolToPrimitive] = () => tmpdir(); 2021cb0ef41Sopenharmony_ci 2031cb0ef41Sopenharmony_ci/** 2041cb0ef41Sopenharmony_ci * @returns {'BE' | 'LE'} 2051cb0ef41Sopenharmony_ci */ 2061cb0ef41Sopenharmony_cifunction endianness() { 2071cb0ef41Sopenharmony_ci return kEndianness; 2081cb0ef41Sopenharmony_ci} 2091cb0ef41Sopenharmony_ciendianness[SymbolToPrimitive] = () => kEndianness; 2101cb0ef41Sopenharmony_ci 2111cb0ef41Sopenharmony_ci// Returns the number of ones in the binary representation of the decimal 2121cb0ef41Sopenharmony_ci// number. 2131cb0ef41Sopenharmony_cifunction countBinaryOnes(n) { 2141cb0ef41Sopenharmony_ci // Count the number of bits set in parallel, which is faster than looping 2151cb0ef41Sopenharmony_ci n = n - ((n >>> 1) & 0x55555555); 2161cb0ef41Sopenharmony_ci n = (n & 0x33333333) + ((n >>> 2) & 0x33333333); 2171cb0ef41Sopenharmony_ci return ((n + (n >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24; 2181cb0ef41Sopenharmony_ci} 2191cb0ef41Sopenharmony_ci 2201cb0ef41Sopenharmony_cifunction getCIDR(address, netmask, family) { 2211cb0ef41Sopenharmony_ci let ones = 0; 2221cb0ef41Sopenharmony_ci let split = '.'; 2231cb0ef41Sopenharmony_ci let range = 10; 2241cb0ef41Sopenharmony_ci let groupLength = 8; 2251cb0ef41Sopenharmony_ci let hasZeros = false; 2261cb0ef41Sopenharmony_ci let lastPos = 0; 2271cb0ef41Sopenharmony_ci 2281cb0ef41Sopenharmony_ci if (family === 'IPv6') { 2291cb0ef41Sopenharmony_ci split = ':'; 2301cb0ef41Sopenharmony_ci range = 16; 2311cb0ef41Sopenharmony_ci groupLength = 16; 2321cb0ef41Sopenharmony_ci } 2331cb0ef41Sopenharmony_ci 2341cb0ef41Sopenharmony_ci for (let i = 0; i < netmask.length; i++) { 2351cb0ef41Sopenharmony_ci if (netmask[i] !== split) { 2361cb0ef41Sopenharmony_ci if (i + 1 < netmask.length) { 2371cb0ef41Sopenharmony_ci continue; 2381cb0ef41Sopenharmony_ci } 2391cb0ef41Sopenharmony_ci i++; 2401cb0ef41Sopenharmony_ci } 2411cb0ef41Sopenharmony_ci const part = StringPrototypeSlice(netmask, lastPos, i); 2421cb0ef41Sopenharmony_ci lastPos = i + 1; 2431cb0ef41Sopenharmony_ci if (part !== '') { 2441cb0ef41Sopenharmony_ci if (hasZeros) { 2451cb0ef41Sopenharmony_ci if (part !== '0') { 2461cb0ef41Sopenharmony_ci return null; 2471cb0ef41Sopenharmony_ci } 2481cb0ef41Sopenharmony_ci } else { 2491cb0ef41Sopenharmony_ci const binary = NumberParseInt(part, range); 2501cb0ef41Sopenharmony_ci const binaryOnes = countBinaryOnes(binary); 2511cb0ef41Sopenharmony_ci ones += binaryOnes; 2521cb0ef41Sopenharmony_ci if (binaryOnes !== groupLength) { 2531cb0ef41Sopenharmony_ci if ((binary & 1) !== 0) { 2541cb0ef41Sopenharmony_ci return null; 2551cb0ef41Sopenharmony_ci } 2561cb0ef41Sopenharmony_ci hasZeros = true; 2571cb0ef41Sopenharmony_ci } 2581cb0ef41Sopenharmony_ci } 2591cb0ef41Sopenharmony_ci } 2601cb0ef41Sopenharmony_ci } 2611cb0ef41Sopenharmony_ci 2621cb0ef41Sopenharmony_ci return `${address}/${ones}`; 2631cb0ef41Sopenharmony_ci} 2641cb0ef41Sopenharmony_ci 2651cb0ef41Sopenharmony_ci/** 2661cb0ef41Sopenharmony_ci * @returns {Record<string, Array<{ 2671cb0ef41Sopenharmony_ci * address: string, 2681cb0ef41Sopenharmony_ci * netmask: string, 2691cb0ef41Sopenharmony_ci * family: 'IPv4' | 'IPv6', 2701cb0ef41Sopenharmony_ci * mac: string, 2711cb0ef41Sopenharmony_ci * internal: boolean, 2721cb0ef41Sopenharmony_ci * scopeid: number, 2731cb0ef41Sopenharmony_ci * cidr: string | null, 2741cb0ef41Sopenharmony_ci * }>>} 2751cb0ef41Sopenharmony_ci */ 2761cb0ef41Sopenharmony_cifunction networkInterfaces() { 2771cb0ef41Sopenharmony_ci const data = getInterfaceAddresses(); 2781cb0ef41Sopenharmony_ci const result = {}; 2791cb0ef41Sopenharmony_ci 2801cb0ef41Sopenharmony_ci if (data === undefined) 2811cb0ef41Sopenharmony_ci return result; 2821cb0ef41Sopenharmony_ci for (let i = 0; i < data.length; i += 7) { 2831cb0ef41Sopenharmony_ci const name = data[i]; 2841cb0ef41Sopenharmony_ci const entry = { 2851cb0ef41Sopenharmony_ci address: data[i + 1], 2861cb0ef41Sopenharmony_ci netmask: data[i + 2], 2871cb0ef41Sopenharmony_ci family: data[i + 3], 2881cb0ef41Sopenharmony_ci mac: data[i + 4], 2891cb0ef41Sopenharmony_ci internal: data[i + 5], 2901cb0ef41Sopenharmony_ci cidr: getCIDR(data[i + 1], data[i + 2], data[i + 3]), 2911cb0ef41Sopenharmony_ci }; 2921cb0ef41Sopenharmony_ci const scopeid = data[i + 6]; 2931cb0ef41Sopenharmony_ci if (scopeid !== -1) 2941cb0ef41Sopenharmony_ci entry.scopeid = scopeid; 2951cb0ef41Sopenharmony_ci 2961cb0ef41Sopenharmony_ci const existing = result[name]; 2971cb0ef41Sopenharmony_ci if (existing !== undefined) 2981cb0ef41Sopenharmony_ci ArrayPrototypePush(existing, entry); 2991cb0ef41Sopenharmony_ci else 3001cb0ef41Sopenharmony_ci result[name] = [entry]; 3011cb0ef41Sopenharmony_ci } 3021cb0ef41Sopenharmony_ci 3031cb0ef41Sopenharmony_ci return result; 3041cb0ef41Sopenharmony_ci} 3051cb0ef41Sopenharmony_ci 3061cb0ef41Sopenharmony_ci/** 3071cb0ef41Sopenharmony_ci * @param {number} [pid=0] 3081cb0ef41Sopenharmony_ci * @param {number} priority 3091cb0ef41Sopenharmony_ci * @returns {void} 3101cb0ef41Sopenharmony_ci */ 3111cb0ef41Sopenharmony_cifunction setPriority(pid, priority) { 3121cb0ef41Sopenharmony_ci if (priority === undefined) { 3131cb0ef41Sopenharmony_ci priority = pid; 3141cb0ef41Sopenharmony_ci pid = 0; 3151cb0ef41Sopenharmony_ci } 3161cb0ef41Sopenharmony_ci 3171cb0ef41Sopenharmony_ci validateInt32(pid, 'pid'); 3181cb0ef41Sopenharmony_ci validateInt32(priority, 'priority', -20, 19); 3191cb0ef41Sopenharmony_ci 3201cb0ef41Sopenharmony_ci const ctx = {}; 3211cb0ef41Sopenharmony_ci 3221cb0ef41Sopenharmony_ci if (_setPriority(pid, priority, ctx) !== 0) 3231cb0ef41Sopenharmony_ci throw new ERR_SYSTEM_ERROR(ctx); 3241cb0ef41Sopenharmony_ci} 3251cb0ef41Sopenharmony_ci 3261cb0ef41Sopenharmony_ci/** 3271cb0ef41Sopenharmony_ci * @param {number} [pid=0] 3281cb0ef41Sopenharmony_ci * @returns {number} 3291cb0ef41Sopenharmony_ci */ 3301cb0ef41Sopenharmony_cifunction getPriority(pid) { 3311cb0ef41Sopenharmony_ci if (pid === undefined) 3321cb0ef41Sopenharmony_ci pid = 0; 3331cb0ef41Sopenharmony_ci else 3341cb0ef41Sopenharmony_ci validateInt32(pid, 'pid'); 3351cb0ef41Sopenharmony_ci 3361cb0ef41Sopenharmony_ci const ctx = {}; 3371cb0ef41Sopenharmony_ci const priority = _getPriority(pid, ctx); 3381cb0ef41Sopenharmony_ci 3391cb0ef41Sopenharmony_ci if (priority === undefined) 3401cb0ef41Sopenharmony_ci throw new ERR_SYSTEM_ERROR(ctx); 3411cb0ef41Sopenharmony_ci 3421cb0ef41Sopenharmony_ci return priority; 3431cb0ef41Sopenharmony_ci} 3441cb0ef41Sopenharmony_ci 3451cb0ef41Sopenharmony_ci/** 3461cb0ef41Sopenharmony_ci * @param {{ encoding?: string }} [options=utf8] If `encoding` is set to 3471cb0ef41Sopenharmony_ci * `'buffer'`, the `username`, `shell`, and `homedir` values will 3481cb0ef41Sopenharmony_ci * be `Buffer` instances. 3491cb0ef41Sopenharmony_ci * @returns {{ 3501cb0ef41Sopenharmony_ci * uid: number, 3511cb0ef41Sopenharmony_ci * gid: number, 3521cb0ef41Sopenharmony_ci * username: string, 3531cb0ef41Sopenharmony_ci * homedir: string, 3541cb0ef41Sopenharmony_ci * shell: string | null, 3551cb0ef41Sopenharmony_ci * }} 3561cb0ef41Sopenharmony_ci */ 3571cb0ef41Sopenharmony_cifunction userInfo(options) { 3581cb0ef41Sopenharmony_ci if (typeof options !== 'object') 3591cb0ef41Sopenharmony_ci options = null; 3601cb0ef41Sopenharmony_ci 3611cb0ef41Sopenharmony_ci const ctx = {}; 3621cb0ef41Sopenharmony_ci const user = getUserInfo(options, ctx); 3631cb0ef41Sopenharmony_ci 3641cb0ef41Sopenharmony_ci if (user === undefined) 3651cb0ef41Sopenharmony_ci throw new ERR_SYSTEM_ERROR(ctx); 3661cb0ef41Sopenharmony_ci 3671cb0ef41Sopenharmony_ci if (isWindows) { 3681cb0ef41Sopenharmony_ci user.uid |= 0; 3691cb0ef41Sopenharmony_ci user.gid |= 0; 3701cb0ef41Sopenharmony_ci } 3711cb0ef41Sopenharmony_ci 3721cb0ef41Sopenharmony_ci return user; 3731cb0ef41Sopenharmony_ci} 3741cb0ef41Sopenharmony_ci 3751cb0ef41Sopenharmony_cimodule.exports = { 3761cb0ef41Sopenharmony_ci arch, 3771cb0ef41Sopenharmony_ci availableParallelism: getAvailableParallelism, 3781cb0ef41Sopenharmony_ci cpus, 3791cb0ef41Sopenharmony_ci endianness, 3801cb0ef41Sopenharmony_ci freemem: getFreeMem, 3811cb0ef41Sopenharmony_ci getPriority, 3821cb0ef41Sopenharmony_ci homedir: getHomeDirectory, 3831cb0ef41Sopenharmony_ci hostname: getHostname, 3841cb0ef41Sopenharmony_ci loadavg, 3851cb0ef41Sopenharmony_ci networkInterfaces, 3861cb0ef41Sopenharmony_ci platform, 3871cb0ef41Sopenharmony_ci release: getOSRelease, 3881cb0ef41Sopenharmony_ci setPriority, 3891cb0ef41Sopenharmony_ci tmpdir, 3901cb0ef41Sopenharmony_ci totalmem: getTotalMem, 3911cb0ef41Sopenharmony_ci type: getOSType, 3921cb0ef41Sopenharmony_ci userInfo, 3931cb0ef41Sopenharmony_ci uptime: getUptime, 3941cb0ef41Sopenharmony_ci version: getOSVersion, 3951cb0ef41Sopenharmony_ci machine: getMachine, 3961cb0ef41Sopenharmony_ci}; 3971cb0ef41Sopenharmony_ci 3981cb0ef41Sopenharmony_ciObjectDefineProperties(module.exports, { 3991cb0ef41Sopenharmony_ci constants: { 4001cb0ef41Sopenharmony_ci __proto__: null, 4011cb0ef41Sopenharmony_ci configurable: false, 4021cb0ef41Sopenharmony_ci enumerable: true, 4031cb0ef41Sopenharmony_ci value: constants, 4041cb0ef41Sopenharmony_ci }, 4051cb0ef41Sopenharmony_ci 4061cb0ef41Sopenharmony_ci EOL: { 4071cb0ef41Sopenharmony_ci __proto__: null, 4081cb0ef41Sopenharmony_ci configurable: true, 4091cb0ef41Sopenharmony_ci enumerable: true, 4101cb0ef41Sopenharmony_ci writable: false, 4111cb0ef41Sopenharmony_ci value: isWindows ? '\r\n' : '\n', 4121cb0ef41Sopenharmony_ci }, 4131cb0ef41Sopenharmony_ci 4141cb0ef41Sopenharmony_ci devNull: { 4151cb0ef41Sopenharmony_ci __proto__: null, 4161cb0ef41Sopenharmony_ci configurable: true, 4171cb0ef41Sopenharmony_ci enumerable: true, 4181cb0ef41Sopenharmony_ci writable: false, 4191cb0ef41Sopenharmony_ci value: isWindows ? '\\\\.\\nul' : '/dev/null', 4201cb0ef41Sopenharmony_ci }, 4211cb0ef41Sopenharmony_ci}); 422