|
25 | 25 | 'use strict'; |
26 | 26 |
|
27 | 27 | const constants = process.binding('constants').fs; |
28 | | -const { S_IFMT, S_IFREG, S_IFLNK } = constants; |
| 28 | +const { S_IFIFO, S_IFLNK, S_IFMT, S_IFREG, S_IFSOCK } = constants; |
29 | 29 | const util = require('util'); |
30 | 30 | const pathModule = require('path'); |
31 | 31 | const { isUint8Array } = process.binding('util'); |
@@ -228,11 +228,11 @@ Stats.prototype.isSymbolicLink = function() { |
228 | 228 | }; |
229 | 229 |
|
230 | 230 | Stats.prototype.isFIFO = function() { |
231 | | - return this._checkModeProperty(constants.S_IFIFO); |
| 231 | + return this._checkModeProperty(S_IFIFO); |
232 | 232 | }; |
233 | 233 |
|
234 | 234 | Stats.prototype.isSocket = function() { |
235 | | - return this._checkModeProperty(constants.S_IFSOCK); |
| 235 | + return this._checkModeProperty(S_IFSOCK); |
236 | 236 | }; |
237 | 237 |
|
238 | 238 | const statValues = binding.getStatValues(); |
@@ -1625,8 +1625,12 @@ fs.realpathSync = function realpathSync(p, options) { |
1625 | 1625 | pos = result + 1; |
1626 | 1626 | } |
1627 | 1627 |
|
1628 | | - // continue if not a symlink |
| 1628 | + // continue if not a symlink, break if a pipe/socket |
1629 | 1629 | if (knownHard[base] || (cache && cache.get(base) === base)) { |
| 1630 | + if ((statValues[1/*mode*/] & S_IFMT) === S_IFIFO || |
| 1631 | + (statValues[1/*mode*/] & S_IFMT) === S_IFSOCK) { |
| 1632 | + break; |
| 1633 | + } |
1630 | 1634 | continue; |
1631 | 1635 | } |
1632 | 1636 |
|
@@ -1752,8 +1756,12 @@ fs.realpath = function realpath(p, options, callback) { |
1752 | 1756 | pos = result + 1; |
1753 | 1757 | } |
1754 | 1758 |
|
1755 | | - // continue if not a symlink |
| 1759 | + // continue if not a symlink, break if a pipe/socket |
1756 | 1760 | if (knownHard[base]) { |
| 1761 | + if ((statValues[1/*mode*/] & S_IFMT) === S_IFIFO || |
| 1762 | + (statValues[1/*mode*/] & S_IFMT) === S_IFSOCK) { |
| 1763 | + return callback(null, encodeRealpathResult(p, options)); |
| 1764 | + } |
1757 | 1765 | return process.nextTick(LOOP); |
1758 | 1766 | } |
1759 | 1767 |
|
|
0 commit comments