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

require('fs').openSync('\\\\.\\PhysicalDrive2', fs.constants.O_RDWR) is broken #54025

Closed
kuseni opened this issue Jul 24, 2024 · 0 comments · Fixed by #54224 or #55623
Closed

require('fs').openSync('\\\\.\\PhysicalDrive2', fs.constants.O_RDWR) is broken #54025

kuseni opened this issue Jul 24, 2024 · 0 comments · Fixed by #54224 or #55623
Labels
fs Issues and PRs related to the fs subsystem / file system. windows Issues and PRs related to the Windows platform.

Comments

@kuseni
Copy link

kuseni commented Jul 24, 2024

Version

v20.15.1

Platform

Microsoft Windows NT 10.0.19045.0 x64

Subsystem

No response

What steps will reproduce the bug?

const disk = require('fs').openSync('\\\\.\\PhysicalDrive2', fs.constants.O_RDWR)

How often does it reproduce? Is there a required condition?

every call

What is the expected behavior? Why is that the expected behavior?

open disk for RW, no error

What do you see instead?

Error: EIO: i/o error, open '\\.\PhysicalDrive2\'
    at Object.openSync (node:fs:573:18)
    at Object.<anonymous> (***)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
    at node:internal/main/run_main_module:28:49 {
  errno: -4070,
  code: 'EIO',
  syscall: 'open',
  path: '\\\\.\\PhysicalDrive2\\'
}

Node.js v20.15.1

Additional information

I think the problem is in the call of getValidatedPath() or pathModule.toNamespacedPath() in the openSync() implementation, which adds an additional backslash to the path, because the error looks like error, open '\\.\PhysicalDrive2\'. Using

node --expose-internals

const { internalBinding, primordials } = require('internal/test/binding')
const binding = internalBinding('fs');
const { stringToFlags } = require('internal/fs/utils');
const { parseFileMode } = require('internal/validators');
const disk = binding.open('\\\\.\\PhysicalDrive2', stringToFlags(fs.constants.O_RDWR), parseFileMode(undefined, 'mode', 0o666),);

it works.

@VoltrexKeyva VoltrexKeyva added the fs Issues and PRs related to the fs subsystem / file system. label Jul 25, 2024
@lpinca lpinca added the windows Issues and PRs related to the Windows platform. label Aug 2, 2024
huseyinacacak-janea added a commit to JaneaSystems/node that referenced this issue Aug 7, 2024
huseyinacacak-janea added a commit to JaneaSystems/node that referenced this issue Aug 15, 2024
huseyinacacak-janea added a commit to JaneaSystems/node that referenced this issue Aug 15, 2024
huseyinacacak-janea added a commit to JaneaSystems/node that referenced this issue Aug 15, 2024
huseyinacacak-janea added a commit to JaneaSystems/node that referenced this issue Aug 16, 2024
nodejs-github-bot pushed a commit that referenced this issue Sep 14, 2024
Fixes: #54025
PR-URL: #54224
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
@lpinca lpinca reopened this Oct 21, 2024
huseyinacacak-janea added a commit to JaneaSystems/node that referenced this issue Oct 31, 2024
huseyinacacak-janea added a commit to JaneaSystems/node that referenced this issue Oct 31, 2024
huseyinacacak-janea added a commit to JaneaSystems/node that referenced this issue Oct 31, 2024
louwers pushed a commit to louwers/node that referenced this issue Nov 2, 2024
Fixes: nodejs#54025
PR-URL: nodejs#54224
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
aduh95 pushed a commit that referenced this issue Nov 6, 2024
Fixes: #54025
PR-URL: #55623
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
aduh95 pushed a commit that referenced this issue Nov 6, 2024
Fixes: #54025
PR-URL: #55623
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
tpoisseau pushed a commit to tpoisseau/node that referenced this issue Nov 21, 2024
Fixes: nodejs#54025
PR-URL: nodejs#54224
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
tpoisseau pushed a commit to tpoisseau/node that referenced this issue Nov 21, 2024
Fixes: nodejs#54025
PR-URL: nodejs#55623
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system. windows Issues and PRs related to the Windows platform.
Projects
None yet
3 participants