@lousy-agents/mcp 5.22.21 → 5.22.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mcp-server.js +153 -95
- package/package.json +1 -1
package/dist/mcp-server.js
CHANGED
|
@@ -39157,7 +39157,7 @@ function sameCleanupStatValue(left, right) {
|
|
|
39157
39157
|
return false;
|
|
39158
39158
|
return sameStatValue(left, right);
|
|
39159
39159
|
}
|
|
39160
|
-
function
|
|
39160
|
+
function sameFileIdentityForCleanup(left, right, platform = process.platform) {
|
|
39161
39161
|
if (platform !== "win32") {
|
|
39162
39162
|
return sameCleanupStatValue(left.dev, right.dev) && sameCleanupStatValue(left.ino, right.ino);
|
|
39163
39163
|
}
|
|
@@ -41145,19 +41145,32 @@ async function serializePathWrite(key, run) {
|
|
|
41145
41145
|
|
|
41146
41146
|
function assertOwnedDirectory(expected, actual) {
|
|
41147
41147
|
if (actual.isSymbolicLink() || !actual.isDirectory()) {
|
|
41148
|
-
throw new
|
|
41148
|
+
throw new errors_FsSafeError("not-file", "directory mode target must be a real directory");
|
|
41149
41149
|
}
|
|
41150
41150
|
if (!sameFileIdentityForCleanup(expected, actual)) {
|
|
41151
|
-
throw new
|
|
41151
|
+
throw new errors_FsSafeError("path-mismatch", "directory changed before its mode could be applied");
|
|
41152
|
+
}
|
|
41153
|
+
}
|
|
41154
|
+
/** The caller retains a verified native mkdir receipt and owns the descriptor lifetime. */
|
|
41155
|
+
function finalizeCreatedDirectoryModeSync(child, mode) {
|
|
41156
|
+
if (mode === undefined || !child.created || process.platform === "win32")
|
|
41157
|
+
return;
|
|
41158
|
+
const expected = strict_file_identity_inspectFileIdentitySync(() => external_node_fs_.fstatSync(child.fd, { bigint: true }));
|
|
41159
|
+
assertOwnedDirectory(expected, expected);
|
|
41160
|
+
external_node_fs_.fchmodSync(child.fd, mode & 0o7777);
|
|
41161
|
+
const finalized = strict_file_identity_inspectFileIdentitySync(() => external_node_fs_.fstatSync(child.fd, { bigint: true }), expected);
|
|
41162
|
+
assertOwnedDirectory(expected, finalized);
|
|
41163
|
+
if ((finalized.mode & 4095n) !== BigInt(mode & 0o7777)) {
|
|
41164
|
+
throw new errors_FsSafeError("path-mismatch", "created directory mode could not be finalized");
|
|
41152
41165
|
}
|
|
41153
41166
|
}
|
|
41154
41167
|
/** Serializes use and close: even a queued path-based fd operation retains its descriptor. */
|
|
41155
|
-
function
|
|
41168
|
+
function ownDirectoryMode(params) {
|
|
41156
41169
|
let pending = Promise.resolve();
|
|
41157
41170
|
let closing;
|
|
41158
41171
|
const enqueue = (run) => {
|
|
41159
41172
|
if (closing)
|
|
41160
|
-
return Promise.reject(new
|
|
41173
|
+
return Promise.reject(new errors_FsSafeError("path-mismatch", "directory mode owner is closed"));
|
|
41161
41174
|
const operation = pending.then(run);
|
|
41162
41175
|
pending = operation.catch(() => undefined);
|
|
41163
41176
|
return operation;
|
|
@@ -41210,7 +41223,7 @@ function directory_mode_node_ownDirectoryMode(params) {
|
|
|
41210
41223
|
throw dispatchDeadlineFailure.error;
|
|
41211
41224
|
checks.check?.();
|
|
41212
41225
|
if (!params.ignoreChmodError && finalMode !== mode) {
|
|
41213
|
-
throw new
|
|
41226
|
+
throw new errors_FsSafeError("path-mismatch", "directory final mode could not be verified");
|
|
41214
41227
|
}
|
|
41215
41228
|
}),
|
|
41216
41229
|
close() {
|
|
@@ -41258,7 +41271,7 @@ async function pinNodeDirectoryForMode(dirPath, options = {}) {
|
|
|
41258
41271
|
assertOwner(expected);
|
|
41259
41272
|
if (process.platform === "win32") {
|
|
41260
41273
|
// POSIX mode enforcement is unsupported; retain strict path identity checks.
|
|
41261
|
-
return
|
|
41274
|
+
return ownDirectoryMode({
|
|
41262
41275
|
inspect: async () => { assertOwner(await inspectDirectoryIdentity(dirPath, expected)); return 0; },
|
|
41263
41276
|
chmod: async () => undefined, close: async () => undefined, ignoreChmodError: true,
|
|
41264
41277
|
});
|
|
@@ -41305,7 +41318,7 @@ async function pinNodeDirectoryForMode(dirPath, options = {}) {
|
|
|
41305
41318
|
assertOwner(followed);
|
|
41306
41319
|
};
|
|
41307
41320
|
const observeCanonical = observer;
|
|
41308
|
-
const owner =
|
|
41321
|
+
const owner = ownDirectoryMode({
|
|
41309
41322
|
inspect,
|
|
41310
41323
|
inspectCanonical: observeCanonical ? () => {
|
|
41311
41324
|
const observed = observeCanonical();
|
|
@@ -42486,7 +42499,7 @@ function creation_boundary_assertPrivateCreationFile(stat, fd) {
|
|
|
42486
42499
|
assertDarwinCreationAcl(fd);
|
|
42487
42500
|
}
|
|
42488
42501
|
function assertRecordedFile(current, identity) {
|
|
42489
|
-
if (!current.isFile() || current.isSymbolicLink() || !
|
|
42502
|
+
if (!current.isFile() || current.isSymbolicLink() || !sameFileIdentityForCleanup(current, identity)) {
|
|
42490
42503
|
throw new errors_FsSafeError("path-mismatch", "created file cleanup preserved a replacement");
|
|
42491
42504
|
}
|
|
42492
42505
|
}
|
|
@@ -43266,7 +43279,7 @@ function exclusive_create_assertExclusiveCreateLeaf(pathname) {
|
|
|
43266
43279
|
|
|
43267
43280
|
|
|
43268
43281
|
|
|
43269
|
-
function*
|
|
43282
|
+
function* wait(value) {
|
|
43270
43283
|
return (yield value);
|
|
43271
43284
|
}
|
|
43272
43285
|
async function runAsync(procedure) {
|
|
@@ -43291,7 +43304,7 @@ function runSync(procedure) {
|
|
|
43291
43304
|
step = procedure.next(step.value);
|
|
43292
43305
|
return step.value;
|
|
43293
43306
|
}
|
|
43294
|
-
function
|
|
43307
|
+
function inspectAtomicIdentity(io, read, expected, synchronous = false, admit) {
|
|
43295
43308
|
if (io.asynchronous && !synchronous) {
|
|
43296
43309
|
const inspect = admit ? async () => {
|
|
43297
43310
|
const stat = await read();
|
|
@@ -43343,7 +43356,7 @@ class AtomicIo {
|
|
|
43343
43356
|
}
|
|
43344
43357
|
}
|
|
43345
43358
|
const resource = this.asyncFs
|
|
43346
|
-
? yield*
|
|
43359
|
+
? yield* wait(withMode
|
|
43347
43360
|
? this.asyncFs.open(pathname, flags, mode)
|
|
43348
43361
|
: this.asyncFs.open(pathname, flags))
|
|
43349
43362
|
: withMode
|
|
@@ -43356,7 +43369,7 @@ class AtomicIo {
|
|
|
43356
43369
|
return this.syncFs.lstatSync(pathname);
|
|
43357
43370
|
if (this.asyncFs === promises_)
|
|
43358
43371
|
return external_node_fs_.lstatSync(pathname);
|
|
43359
|
-
return yield*
|
|
43372
|
+
return yield* wait(this.asyncFs.lstat(pathname));
|
|
43360
43373
|
}
|
|
43361
43374
|
lstatExact(pathname, synchronousBuiltin = true) {
|
|
43362
43375
|
if (!this.asyncFs)
|
|
@@ -43368,34 +43381,40 @@ class AtomicIo {
|
|
|
43368
43381
|
*mkdir(directory, mode) {
|
|
43369
43382
|
if (this.asyncFs) {
|
|
43370
43383
|
const pathname = this.asyncFs === promises_ ? recursiveMkdirPath(directory) : directory;
|
|
43371
|
-
yield*
|
|
43384
|
+
yield* wait(this.asyncFs.mkdir(pathname, { recursive: true, mode }));
|
|
43372
43385
|
}
|
|
43373
43386
|
else {
|
|
43374
43387
|
const pathname = this.syncFs === external_node_fs_ ? recursiveMkdirPath(directory) : directory;
|
|
43375
43388
|
this.syncFs.mkdirSync(pathname, { recursive: true, mode });
|
|
43376
43389
|
}
|
|
43377
43390
|
}
|
|
43391
|
+
*mkdirExclusive(directory, mode) {
|
|
43392
|
+
if (this.asyncFs)
|
|
43393
|
+
yield* wait(this.asyncFs.mkdir(directory, { recursive: false, mode }));
|
|
43394
|
+
else
|
|
43395
|
+
this.syncFs.mkdirSync(directory, { recursive: false, mode });
|
|
43396
|
+
}
|
|
43378
43397
|
*rename(source, destination) {
|
|
43379
43398
|
if (this.asyncFs)
|
|
43380
|
-
yield*
|
|
43399
|
+
yield* wait(this.asyncFs.rename(source, destination));
|
|
43381
43400
|
else
|
|
43382
43401
|
this.syncFs.renameSync(source, destination);
|
|
43383
43402
|
}
|
|
43384
43403
|
*remove(pathname) {
|
|
43385
43404
|
if (this.asyncFs)
|
|
43386
|
-
yield*
|
|
43405
|
+
yield* wait(this.asyncFs.rm(pathname, { force: true }));
|
|
43387
43406
|
else
|
|
43388
43407
|
this.syncFs.rmSync(pathname, { force: true });
|
|
43389
43408
|
}
|
|
43390
43409
|
*unlink(pathname) {
|
|
43391
43410
|
if (this.asyncFs)
|
|
43392
|
-
yield*
|
|
43411
|
+
yield* wait(this.asyncFs.unlink(pathname));
|
|
43393
43412
|
else
|
|
43394
43413
|
this.syncFs.unlinkSync(pathname);
|
|
43395
43414
|
}
|
|
43396
43415
|
*delay(milliseconds) {
|
|
43397
43416
|
if (this.asynchronous)
|
|
43398
|
-
yield*
|
|
43417
|
+
yield* wait(sleep(milliseconds));
|
|
43399
43418
|
else
|
|
43400
43419
|
sleepSync(milliseconds);
|
|
43401
43420
|
}
|
|
@@ -43415,7 +43434,7 @@ class AtomicFile {
|
|
|
43415
43434
|
return this.io.syncFs.fstatSync(this.resource);
|
|
43416
43435
|
if (this.io.asyncFs === promises_)
|
|
43417
43436
|
return external_node_fs_.fstatSync(this.resource.fd);
|
|
43418
|
-
return yield*
|
|
43437
|
+
return yield* wait(this.resource.stat());
|
|
43419
43438
|
}
|
|
43420
43439
|
statExact() {
|
|
43421
43440
|
if (typeof this.resource === "number")
|
|
@@ -43434,7 +43453,7 @@ class AtomicFile {
|
|
|
43434
43453
|
if (typeof this.resource === "number")
|
|
43435
43454
|
this.io.syncFs.fsyncSync(this.resource);
|
|
43436
43455
|
else
|
|
43437
|
-
yield*
|
|
43456
|
+
yield* wait(this.resource.sync());
|
|
43438
43457
|
}
|
|
43439
43458
|
*syncBestEffort() {
|
|
43440
43459
|
try {
|
|
@@ -43467,7 +43486,7 @@ class AtomicFile {
|
|
|
43467
43486
|
}
|
|
43468
43487
|
*readFile(sizeHint) {
|
|
43469
43488
|
if (typeof this.resource !== "number")
|
|
43470
|
-
return yield*
|
|
43489
|
+
return yield* wait(readFileHandleBounded(this.resource, Infinity));
|
|
43471
43490
|
if (sizeHint === undefined)
|
|
43472
43491
|
return this.io.syncFs.readFileSync(this.resource);
|
|
43473
43492
|
const fd = this.resource;
|
|
@@ -43497,7 +43516,7 @@ class AtomicFile {
|
|
|
43497
43516
|
if (typeof this.resource === "number")
|
|
43498
43517
|
this.io.syncFs.ftruncateSync(this.resource, length);
|
|
43499
43518
|
else
|
|
43500
|
-
yield*
|
|
43519
|
+
yield* wait(this.resource.truncate(length));
|
|
43501
43520
|
}
|
|
43502
43521
|
}
|
|
43503
43522
|
|
|
@@ -43532,14 +43551,14 @@ function* replace_file_descriptor_syncDirectoryBestEffort(io, dirPath) {
|
|
|
43532
43551
|
}
|
|
43533
43552
|
}
|
|
43534
43553
|
function replace_file_descriptor_directoryOpenFlags() {
|
|
43535
|
-
return (
|
|
43536
|
-
|
|
43537
|
-
|
|
43538
|
-
|
|
43554
|
+
return (external_node_fs_.constants.O_RDONLY |
|
|
43555
|
+
external_node_fs_.constants.O_DIRECTORY |
|
|
43556
|
+
external_node_fs_.constants.O_NOFOLLOW |
|
|
43557
|
+
external_node_fs_.constants.O_NONBLOCK);
|
|
43539
43558
|
}
|
|
43540
43559
|
function assertDirectory(identity, dirPath) {
|
|
43541
43560
|
if (identity.isSymbolicLink() || !identity.isDirectory()) {
|
|
43542
|
-
throw new
|
|
43561
|
+
throw new errors_FsSafeError("not-file", `Atomic replace parent must be a real directory: ${dirPath}`);
|
|
43543
43562
|
}
|
|
43544
43563
|
return identity;
|
|
43545
43564
|
}
|
|
@@ -43550,16 +43569,16 @@ async function pinDirectoryForMode(params) {
|
|
|
43550
43569
|
if (process.platform === "win32") {
|
|
43551
43570
|
return;
|
|
43552
43571
|
}
|
|
43553
|
-
const expected = params.fsModule ===
|
|
43554
|
-
?
|
|
43555
|
-
: await
|
|
43572
|
+
const expected = params.expectedIdentity ?? (params.fsModule === promises_
|
|
43573
|
+
? strict_file_identity_inspectFileIdentitySync(() => assertDirectory(external_node_fs_.lstatSync(params.dirPath, { bigint: true }), params.dirPath))
|
|
43574
|
+
: await strict_file_identity_inspectFileIdentity(async () => assertDirectory(await params.fsModule.lstat(params.dirPath, { bigint: true }), params.dirPath)));
|
|
43556
43575
|
const handle = await params.fsModule.open(params.dirPath, replace_file_descriptor_directoryOpenFlags());
|
|
43557
43576
|
try {
|
|
43558
43577
|
const owner = ownDirectoryMode({
|
|
43559
43578
|
async inspect() {
|
|
43560
|
-
const opened = params.fsModule ===
|
|
43561
|
-
?
|
|
43562
|
-
: await
|
|
43579
|
+
const opened = params.fsModule === promises_
|
|
43580
|
+
? strict_file_identity_inspectFileIdentitySync(() => assertDirectory(external_node_fs_.fstatSync(handle.fd, { bigint: true }), params.dirPath), expected)
|
|
43581
|
+
: await strict_file_identity_inspectFileIdentity(async () => assertDirectory(await handle.stat({ bigint: true }), params.dirPath), expected);
|
|
43563
43582
|
return Number(opened.mode & 4095n);
|
|
43564
43583
|
},
|
|
43565
43584
|
chmod: (mode) => {
|
|
@@ -43590,7 +43609,7 @@ function* applyDirectoryMode(io, params) {
|
|
|
43590
43609
|
}));
|
|
43591
43610
|
let primary;
|
|
43592
43611
|
try {
|
|
43593
|
-
if (owner)
|
|
43612
|
+
if (owner && params.mode !== "preserve")
|
|
43594
43613
|
yield* wait(owner.apply(params.mode));
|
|
43595
43614
|
}
|
|
43596
43615
|
catch (error) {
|
|
@@ -43611,13 +43630,15 @@ function* applyDirectoryMode(io, params) {
|
|
|
43611
43630
|
if (process.platform === "win32")
|
|
43612
43631
|
return;
|
|
43613
43632
|
const admit = (stat) => assertDirectory(stat, params.dirPath);
|
|
43614
|
-
const expected = inspectAtomicIdentity(io, () => io.lstatExact(params.dirPath), undefined, false, admit);
|
|
43633
|
+
const expected = params.expectedIdentity ?? inspectAtomicIdentity(io, () => io.lstatExact(params.dirPath), undefined, false, admit);
|
|
43615
43634
|
const file = yield* io.open(params.dirPath, replace_file_descriptor_directoryOpenFlags());
|
|
43616
43635
|
let primary;
|
|
43617
43636
|
try {
|
|
43618
43637
|
inspectAtomicIdentity(io, () => file.statExact(), expected, false, admit);
|
|
43619
|
-
params.
|
|
43620
|
-
|
|
43638
|
+
if (params.mode !== "preserve") {
|
|
43639
|
+
params.mutation?.assert();
|
|
43640
|
+
file.chmod(params.mode & 0o7777);
|
|
43641
|
+
}
|
|
43621
43642
|
}
|
|
43622
43643
|
catch (error) {
|
|
43623
43644
|
primary = { error };
|
|
@@ -43636,7 +43657,7 @@ function* writeTempFile(io, params) {
|
|
|
43636
43657
|
params.mutation?.assert();
|
|
43637
43658
|
const file = yield* io.open(params.tempPath, "wx", params.mode);
|
|
43638
43659
|
try {
|
|
43639
|
-
const openedInspection =
|
|
43660
|
+
const openedInspection = inspectAtomicIdentity(io, () => file.statExact());
|
|
43640
43661
|
const identity = (io.asynchronous ? (yield openedInspection) : openedInspection);
|
|
43641
43662
|
params.onIdentity?.(identity);
|
|
43642
43663
|
params.mutation?.assert();
|
|
@@ -43645,7 +43666,7 @@ function* writeTempFile(io, params) {
|
|
|
43645
43666
|
yield writing;
|
|
43646
43667
|
if ((io.asyncFs === promises_ || (process.platform === "win32" && io.syncFs === external_node_fs_)) && !params.sync) {
|
|
43647
43668
|
// Matching non-durable writes have no I/O left after this identity fence.
|
|
43648
|
-
const current =
|
|
43669
|
+
const current = inspectAtomicIdentity(io, () => file.statExact(), identity, true);
|
|
43649
43670
|
const modeMask = process.platform === "win32" ? 0o200 : 0o7777;
|
|
43650
43671
|
if (Number(current.mode & BigInt(modeMask)) === (params.mode & modeMask))
|
|
43651
43672
|
return { file, identity };
|
|
@@ -43655,7 +43676,7 @@ function* writeTempFile(io, params) {
|
|
|
43655
43676
|
yield chmod;
|
|
43656
43677
|
if (params.sync)
|
|
43657
43678
|
yield* file.syncBestEffort();
|
|
43658
|
-
const currentInspection =
|
|
43679
|
+
const currentInspection = inspectAtomicIdentity(io, () => file.statExact(), identity);
|
|
43659
43680
|
if (io.asynchronous)
|
|
43660
43681
|
yield currentInspection;
|
|
43661
43682
|
return { file, identity };
|
|
@@ -43701,7 +43722,7 @@ async function removeOwnedPath(params) {
|
|
|
43701
43722
|
if (current.isSymbolicLink() ||
|
|
43702
43723
|
!current.isFile() ||
|
|
43703
43724
|
current.nlink !== 1n ||
|
|
43704
|
-
!
|
|
43725
|
+
!sameFileIdentityForCleanup(current, params.identity)) {
|
|
43705
43726
|
return "preserved";
|
|
43706
43727
|
}
|
|
43707
43728
|
await promises_.unlink(params.pathname);
|
|
@@ -43724,11 +43745,11 @@ async function cleanupPinnedFilePath(params) {
|
|
|
43724
43745
|
await assertAsyncDirectoryGuard(guard);
|
|
43725
43746
|
const parent = external_node_fs_.lstatSync(guard.dir, { bigint: true });
|
|
43726
43747
|
if (parent.isSymbolicLink() || !parent.isDirectory() ||
|
|
43727
|
-
!
|
|
43748
|
+
!sameFileIdentityForCleanup(parent, guard.stat))
|
|
43728
43749
|
return "preserved";
|
|
43729
43750
|
const opened = external_node_fs_.fstatSync(params.handle.fd, { bigint: true });
|
|
43730
43751
|
if (!opened.isFile() || opened.nlink !== 1n ||
|
|
43731
|
-
!
|
|
43752
|
+
!sameFileIdentityForCleanup(opened, params.identity))
|
|
43732
43753
|
return "preserved";
|
|
43733
43754
|
}
|
|
43734
43755
|
catch (error) {
|
|
@@ -43863,7 +43884,7 @@ function pathStillMatchesReceipt(entry) {
|
|
|
43863
43884
|
try {
|
|
43864
43885
|
const current = external_node_fs_.lstatSync(entry.path, { bigint: true });
|
|
43865
43886
|
return (!entry.singleLinkFile || (current.isFile() && current.nlink === 1n)) &&
|
|
43866
|
-
|
|
43887
|
+
sameFileIdentityForCleanup(current, entry.identity);
|
|
43867
43888
|
}
|
|
43868
43889
|
catch {
|
|
43869
43890
|
// A missing pathname grants no authority over an entry created after this lookup.
|
|
@@ -43967,7 +43988,7 @@ async function removePathIfIdentityUnchanged(targetPath, identity) {
|
|
|
43967
43988
|
const parentGuard = await directory_guard_createAsyncDirectoryGuard(external_node_path_.dirname(targetPath), { bigint: true });
|
|
43968
43989
|
await withAsyncDirectoryGuards([parentGuard], async () => {
|
|
43969
43990
|
const current = external_node_fs_.lstatSync(targetPath, { bigint: true });
|
|
43970
|
-
if (current.isSymbolicLink() || !current.isFile() || !
|
|
43991
|
+
if (current.isSymbolicLink() || !current.isFile() || !sameFileIdentityForCleanup(current, identity))
|
|
43971
43992
|
return;
|
|
43972
43993
|
await promises_.unlink(targetPath);
|
|
43973
43994
|
});
|
|
@@ -44042,7 +44063,7 @@ class AtomicTempOwner {
|
|
|
44042
44063
|
this.onIdentity(temp.identity);
|
|
44043
44064
|
}
|
|
44044
44065
|
inspectOwned(read, pathname, pathnameEntry, expected) {
|
|
44045
|
-
return
|
|
44066
|
+
return inspectAtomicIdentity(this.io, read, expected, false, stat => assertOwnedFile(stat, pathname, pathnameEntry));
|
|
44046
44067
|
}
|
|
44047
44068
|
*assertCurrent(pathname = this.pathname) {
|
|
44048
44069
|
const openedInspection = this.inspectOwned(() => this.resource.statExact(), pathname, false, this.identity);
|
|
@@ -44122,9 +44143,9 @@ class AtomicTempOwner {
|
|
|
44122
44143
|
try {
|
|
44123
44144
|
const observation = this.io.lstatExact(this.pathname);
|
|
44124
44145
|
const current = this.io.asyncFs && this.io.asyncFs !== promises_
|
|
44125
|
-
? yield*
|
|
44146
|
+
? yield* wait(observation) : observation;
|
|
44126
44147
|
if (!current.isSymbolicLink() && current.isFile() && current.nlink === 1n &&
|
|
44127
|
-
|
|
44148
|
+
sameFileIdentityForCleanup(current, identity)) {
|
|
44128
44149
|
yield* this.io.unlink(this.pathname);
|
|
44129
44150
|
}
|
|
44130
44151
|
return true;
|
|
@@ -44195,7 +44216,7 @@ function probeEntry(directory, name, names) {
|
|
|
44195
44216
|
original = strict_file_identity_inspectFileIdentitySync(() => external_node_fs_.lstatSync(originalPath, { bigint: true }));
|
|
44196
44217
|
try {
|
|
44197
44218
|
const other = strict_file_identity_inspectFileIdentitySync(() => external_node_fs_.lstatSync(external_node_path_.join(directory, alternate), { bigint: true }));
|
|
44198
|
-
const sameIdentity =
|
|
44219
|
+
const sameIdentity = sameFileIdentityForCleanup(original, other);
|
|
44199
44220
|
if (sameIdentity || bothListed) {
|
|
44200
44221
|
// Matching inodes can belong to newly linked case-distinct names.
|
|
44201
44222
|
const currentNames = new Set(external_node_fs_.readdirSync(directory));
|
|
@@ -47929,7 +47950,7 @@ async function withNativeDirectory(params, operation, discard) {
|
|
|
47929
47950
|
}
|
|
47930
47951
|
}
|
|
47931
47952
|
/** Admit only an ordinary direct child; aliases keep the full resolver. */
|
|
47932
|
-
function tryMkdirNativeDirectChild(root, relativePath) {
|
|
47953
|
+
function tryMkdirNativeDirectChild(root, relativePath, mode) {
|
|
47933
47954
|
if (!isSafePathSegment(relativePath, { allowDotPrefix: true }) || relativePath.endsWith(".") ||
|
|
47934
47955
|
getFsSafeTestHooks()?.beforeRootFallbackMutation)
|
|
47935
47956
|
return false;
|
|
@@ -47945,7 +47966,7 @@ function tryMkdirNativeDirectChild(root, relativePath) {
|
|
|
47945
47966
|
return false;
|
|
47946
47967
|
}
|
|
47947
47968
|
try {
|
|
47948
|
-
mkdirNativeRootChild({ root, target });
|
|
47969
|
+
mkdirNativeRootChild({ root, target }, mode);
|
|
47949
47970
|
return true;
|
|
47950
47971
|
}
|
|
47951
47972
|
catch (error) {
|
|
@@ -48054,7 +48075,7 @@ function ensureNativeRootCurrentLegacy(root, binding) {
|
|
|
48054
48075
|
root_create_native_disposeResources(env_4);
|
|
48055
48076
|
}
|
|
48056
48077
|
}
|
|
48057
|
-
function mkdirNativeRootChild(params) {
|
|
48078
|
+
function mkdirNativeRootChild(params, mode) {
|
|
48058
48079
|
const env_5 = { stack: [], error: void 0, hasError: false };
|
|
48059
48080
|
try {
|
|
48060
48081
|
const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
|
|
@@ -48064,19 +48085,28 @@ function mkdirNativeRootChild(params) {
|
|
|
48064
48085
|
rootPath: params.root.rootReal, rootIdentity: params.root.rootIdentity,
|
|
48065
48086
|
}), false);
|
|
48066
48087
|
verifyMkdirDirectory(binding, rootOwner.fd, params.root.rootReal);
|
|
48067
|
-
const flags = (nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_.constants.O_RDONLY) |
|
|
48088
|
+
const flags = (mode === undefined ? nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_.constants.O_RDONLY : external_node_fs_.constants.O_RDONLY) |
|
|
48068
48089
|
(external_node_fs_.constants.O_DIRECTORY ?? 0) | (external_node_fs_.constants.O_NOFOLLOW ?? 0);
|
|
48069
48090
|
const name = external_node_path_.basename(params.target);
|
|
48070
48091
|
// The admitted Root is already this operation's immediate parent. Retain
|
|
48071
48092
|
// both handles through the same fresh pathname and canonical identity fences.
|
|
48072
48093
|
const child = binding.mkdirOpenChildBeneath
|
|
48073
|
-
? binding.mkdirOpenChildBeneath(rootOwner.fd, name, 0o777, flags)
|
|
48074
|
-
:
|
|
48094
|
+
? binding.mkdirOpenChildBeneath(rootOwner.fd, name, mode ?? 0o777, flags)
|
|
48095
|
+
: {
|
|
48096
|
+
created: binding.mkdirChildBeneath(rootOwner.fd, name, mode ?? 0o777),
|
|
48097
|
+
fd: binding.openBeneath(rootOwner.fd, name, flags).fd,
|
|
48098
|
+
};
|
|
48075
48099
|
const close = captureNativeFdClose(binding);
|
|
48076
|
-
const childOwner = root_create_native_addDisposableResource(env_5, { [Symbol.dispose]() { close(child); } }, false);
|
|
48100
|
+
const childOwner = root_create_native_addDisposableResource(env_5, { [Symbol.dispose]() { close(child.fd); } }, false);
|
|
48077
48101
|
root_context_assertRootIdentityCurrentSync(params.root);
|
|
48078
|
-
verifyMkdirDirectory(binding, child, params.target);
|
|
48102
|
+
verifyMkdirDirectory(binding, child.fd, params.target);
|
|
48079
48103
|
verifyMkdirDirectory(binding, rootOwner.fd, params.root.rootReal);
|
|
48104
|
+
if (mode !== undefined && child.created) {
|
|
48105
|
+
finalizeCreatedDirectoryModeSync(child, mode);
|
|
48106
|
+
verifyMkdirDirectory(binding, child.fd, params.target);
|
|
48107
|
+
verifyMkdirDirectory(binding, rootOwner.fd, params.root.rootReal);
|
|
48108
|
+
root_context_assertRootIdentityCurrentSync(params.root);
|
|
48109
|
+
}
|
|
48080
48110
|
}
|
|
48081
48111
|
catch (e_5) {
|
|
48082
48112
|
env_5.error = e_5;
|
|
@@ -48444,7 +48474,7 @@ function removeSiblingIfOwned(params) {
|
|
|
48444
48474
|
if (current.isSymbolicLink() ||
|
|
48445
48475
|
!current.isFile() ||
|
|
48446
48476
|
(current.nlink !== 1n && current.nlink !== 2n) ||
|
|
48447
|
-
!
|
|
48477
|
+
!sameFileIdentityForCleanup(current, params.identity)) {
|
|
48448
48478
|
throw pathMismatch("isolated producer sibling changed before cleanup");
|
|
48449
48479
|
}
|
|
48450
48480
|
external_node_fs_.unlinkSync(params.targetPath);
|
|
@@ -49146,6 +49176,8 @@ async function createPrivateWindowsFileHandle(selected, options) {
|
|
|
49146
49176
|
|
|
49147
49177
|
|
|
49148
49178
|
|
|
49179
|
+
|
|
49180
|
+
|
|
49149
49181
|
function sameDirectoryFacts(left, right) {
|
|
49150
49182
|
return left.dev === right.dev && left.ino === right.ino && left.mode === right.mode &&
|
|
49151
49183
|
left.nlink === right.nlink;
|
|
@@ -49405,6 +49437,13 @@ async function mkdirPathComponentsWithGuards(params) {
|
|
|
49405
49437
|
if (!createdAuthorization || !createdEvidence) {
|
|
49406
49438
|
directory_guard_assertDirectoryGuard(parentGuard, "native");
|
|
49407
49439
|
}
|
|
49440
|
+
if (created && params.finalizeCreatedMode && params.mode !== undefined) {
|
|
49441
|
+
await runAsync(applyDirectoryMode(AtomicIo.async(promises_), {
|
|
49442
|
+
dirPath: currentGuard.dir, mode: params.mode, expectedIdentity: currentGuard.stat,
|
|
49443
|
+
}));
|
|
49444
|
+
directory_guard_assertDirectoryGuard(parentGuard, "native");
|
|
49445
|
+
directory_guard_assertDirectoryGuard(currentGuard, "native");
|
|
49446
|
+
}
|
|
49408
49447
|
current = admittedNextPath;
|
|
49409
49448
|
}
|
|
49410
49449
|
return current;
|
|
@@ -50207,9 +50246,9 @@ function removeNativeCreatedFileIfStillPinned(params) {
|
|
|
50207
50246
|
const targetPath = external_node_path_.join(params.parentPath, params.basename);
|
|
50208
50247
|
const target = external_node_fs_.lstatSync(targetPath, { bigint: true });
|
|
50209
50248
|
if (!parentPathStat.isSymbolicLink() && parentPathStat.isDirectory() &&
|
|
50210
|
-
|
|
50249
|
+
sameFileIdentityForCleanup(parentPathStat, parentFdStat) &&
|
|
50211
50250
|
!target.isSymbolicLink() && target.isFile() &&
|
|
50212
|
-
|
|
50251
|
+
sameFileIdentityForCleanup(target, params.created)) {
|
|
50213
50252
|
external_node_fs_.rmSync(targetPath);
|
|
50214
50253
|
}
|
|
50215
50254
|
}
|
|
@@ -51907,7 +51946,7 @@ function sidecarLockSnapshotMatches(current, observed) {
|
|
|
51907
51946
|
}
|
|
51908
51947
|
if (observed.stat &&
|
|
51909
51948
|
current.stat &&
|
|
51910
|
-
!
|
|
51949
|
+
!sameFileIdentityForCleanup(observed.stat, current.stat)) {
|
|
51911
51950
|
return false;
|
|
51912
51951
|
}
|
|
51913
51952
|
if (observed.raw !== undefined) {
|
|
@@ -52673,7 +52712,7 @@ function cleanupCreatedSidecar(lockPath, raw, fd, parent, identity) {
|
|
|
52673
52712
|
throw new errors_FsSafeError("helper-unavailable", "creator cleanup is unavailable");
|
|
52674
52713
|
}
|
|
52675
52714
|
const entry = parent.binding.rootRemovalStat(parent.fd, name);
|
|
52676
|
-
if (entry.directory || entry.symlink || !
|
|
52715
|
+
if (entry.directory || entry.symlink || !sameFileIdentityForCleanup(identity, entry))
|
|
52677
52716
|
throw sidecar_lock_retained_mismatch("identity");
|
|
52678
52717
|
}
|
|
52679
52718
|
else if (!parent.binding.stagedFileMatches || !parent.binding.removeStagedFile) {
|
|
@@ -52689,7 +52728,7 @@ function cleanupCreatedSidecar(lockPath, raw, fd, parent, identity) {
|
|
|
52689
52728
|
throw error;
|
|
52690
52729
|
}
|
|
52691
52730
|
const stat = external_node_fs_.fstatSync(fd, { bigint: true });
|
|
52692
|
-
if (!stat.isFile() || stat.nlink !== 1n || !
|
|
52731
|
+
if (!stat.isFile() || stat.nlink !== 1n || !sameFileIdentityForCleanup(identity, stat))
|
|
52693
52732
|
throw sidecar_lock_retained_mismatch("identity");
|
|
52694
52733
|
assertOwnerRecord(fd, Buffer.from(raw));
|
|
52695
52734
|
if (windows) {
|
|
@@ -52747,7 +52786,7 @@ function retainCreatedSidecar(lockPath, raw, createdFd, guard, nativeParent) {
|
|
|
52747
52786
|
let fd;
|
|
52748
52787
|
try {
|
|
52749
52788
|
const parentStat = external_node_fs_.fstatSync(parentFd, { bigint: true });
|
|
52750
|
-
if (!parentStat.isDirectory() || !
|
|
52789
|
+
if (!parentStat.isDirectory() || !sameFileIdentityForCleanup(guard.stat, parentStat))
|
|
52751
52790
|
throw sidecar_lock_retained_mismatch("identity");
|
|
52752
52791
|
fd = binding.openBeneath(parentFd, name, nativeOpenFlags(external_node_fs_.constants.O_RDONLY | external_node_fs_.constants.O_NONBLOCK)).fd;
|
|
52753
52792
|
const ownedFd = fd;
|
|
@@ -52762,7 +52801,7 @@ function retainCreatedSidecar(lockPath, raw, createdFd, guard, nativeParent) {
|
|
|
52762
52801
|
throw error;
|
|
52763
52802
|
}
|
|
52764
52803
|
const current = external_node_fs_.fstatSync(ownedFd, { bigint: true });
|
|
52765
|
-
if (!current.isFile() || current.nlink !== 1n || !
|
|
52804
|
+
if (!current.isFile() || current.nlink !== 1n || !sameFileIdentityForCleanup(created, current))
|
|
52766
52805
|
throw sidecar_lock_retained_mismatch("identity");
|
|
52767
52806
|
return true;
|
|
52768
52807
|
};
|
|
@@ -53189,7 +53228,7 @@ async function acquireSidecarLock(options, context) {
|
|
|
53189
53228
|
}
|
|
53190
53229
|
const snapshot = { raw, payload, stat: external_node_fs_.fstatSync(handle.fd, { bigint: true }), ownershipToken };
|
|
53191
53230
|
createdSnapshot = snapshot;
|
|
53192
|
-
if (retainedSidecar && !
|
|
53231
|
+
if (retainedSidecar && !sameFileIdentityForCleanup(retainedSidecar.identity, snapshot.stat)) {
|
|
53193
53232
|
throw new errors_FsSafeError("path-mismatch", "created sidecar lock identity changed before admission");
|
|
53194
53233
|
}
|
|
53195
53234
|
if (snapshot.stat.nlink === 0n) {
|
|
@@ -53465,7 +53504,7 @@ function snapshotMatchesSync(lockPath, observed) {
|
|
|
53465
53504
|
const openedStat = external_node_fs_.fstatSync(fd, { bigint: true });
|
|
53466
53505
|
// Token-owned files can have different descriptor/path identities on VirtioFS.
|
|
53467
53506
|
// Require a known descriptor identity without rejecting that supported drift.
|
|
53468
|
-
if (!openedStat.isFile() || !
|
|
53507
|
+
if (!openedStat.isFile() || !sameFileIdentityForCleanup(openedStat, openedStat)) {
|
|
53469
53508
|
return false;
|
|
53470
53509
|
}
|
|
53471
53510
|
if (observed.raw !== undefined && openedStat.size !== BigInt(Buffer.byteLength(observed.raw))) {
|
|
@@ -53473,7 +53512,7 @@ function snapshotMatchesSync(lockPath, observed) {
|
|
|
53473
53512
|
}
|
|
53474
53513
|
const raw = external_node_fs_.readFileSync(fd, "utf8");
|
|
53475
53514
|
const afterStat = external_node_fs_.lstatSync(lockPath, { bigint: true });
|
|
53476
|
-
if (!afterStat.isFile() || !
|
|
53515
|
+
if (!afterStat.isFile() || !sameFileIdentityForCleanup(beforeStat, afterStat)) {
|
|
53477
53516
|
return false;
|
|
53478
53517
|
}
|
|
53479
53518
|
return sidecarLockSnapshotMatches({ raw, payload: null, stat: afterStat }, observed);
|
|
@@ -53748,8 +53787,8 @@ async function publishCopyStage(params) {
|
|
|
53748
53787
|
const staged = external_node_fs_.lstatSync(temporaryPath, { bigint: true });
|
|
53749
53788
|
const opened = external_node_fs_.fstatSync(params.fd, { bigint: true });
|
|
53750
53789
|
if (!staged.isFile() || staged.isSymbolicLink() || staged.nlink !== 1n ||
|
|
53751
|
-
!
|
|
53752
|
-
!
|
|
53790
|
+
!sameFileIdentityForCleanup(staged, identity) ||
|
|
53791
|
+
!sameFileIdentityForCleanup(opened, identity)) {
|
|
53753
53792
|
throw new errors_FsSafeError("path-mismatch", "exclusive copy stage changed before publication");
|
|
53754
53793
|
}
|
|
53755
53794
|
};
|
|
@@ -53790,7 +53829,7 @@ async function publishCopyStage(params) {
|
|
|
53790
53829
|
}
|
|
53791
53830
|
const target = external_node_fs_.lstatSync(targetPath, { bigint: true });
|
|
53792
53831
|
if (!target.isFile() || target.isSymbolicLink() || target.nlink !== 1n ||
|
|
53793
|
-
!
|
|
53832
|
+
!sameFileIdentityForCleanup(target, identity)) {
|
|
53794
53833
|
throw new errors_FsSafeError("path-mismatch", "renamed copy target changed after publication");
|
|
53795
53834
|
}
|
|
53796
53835
|
}
|
|
@@ -53801,10 +53840,10 @@ async function publishCopyStage(params) {
|
|
|
53801
53840
|
const current = external_node_fs_.lstatSync(temporaryPath, { bigint: true });
|
|
53802
53841
|
const target = external_node_fs_.lstatSync(targetPath, { bigint: true });
|
|
53803
53842
|
if (parent.isSymbolicLink() || !parent.isDirectory() ||
|
|
53804
|
-
!
|
|
53843
|
+
!sameFileIdentityForCleanup(parent, params.parentGuard.stat) ||
|
|
53805
53844
|
current.isSymbolicLink() || !current.isFile() || current.nlink !== 2n ||
|
|
53806
53845
|
target.isSymbolicLink() || !target.isFile() || target.nlink !== 2n ||
|
|
53807
|
-
!
|
|
53846
|
+
!sameFileIdentityForCleanup(current, identity) || !sameFileIdentityForCleanup(target, identity)) {
|
|
53808
53847
|
throw new errors_FsSafeError("path-mismatch", "published copy temporary name changed before cleanup");
|
|
53809
53848
|
}
|
|
53810
53849
|
};
|
|
@@ -53828,7 +53867,7 @@ async function publishCopyStage(params) {
|
|
|
53828
53867
|
}
|
|
53829
53868
|
function isEmptyPlaceholder(current, identity) {
|
|
53830
53869
|
return current.isFile() && !current.isSymbolicLink() && current.nlink === 1n &&
|
|
53831
|
-
current.size === 0n &&
|
|
53870
|
+
current.size === 0n && sameFileIdentityForCleanup(current, identity);
|
|
53832
53871
|
}
|
|
53833
53872
|
function publishThroughPlaceholder(params, assertCurrent) {
|
|
53834
53873
|
const { targetPath, temporaryPath } = params;
|
|
@@ -53907,7 +53946,7 @@ async function openPublicationHandle(targetPath, identity) {
|
|
|
53907
53946
|
const opened = external_node_fs_.fstatSync(handle.fd, { bigint: true });
|
|
53908
53947
|
const named = external_node_fs_.lstatSync(targetPath, { bigint: true });
|
|
53909
53948
|
if (!opened.isFile() || !named.isFile() || named.isSymbolicLink() ||
|
|
53910
|
-
!
|
|
53949
|
+
!sameFileIdentityForCleanup(opened, identity) || !sameFileIdentityForCleanup(named, identity)) {
|
|
53911
53950
|
throw new errors_FsSafeError("path-mismatch", "publication descriptor handoff identity changed");
|
|
53912
53951
|
}
|
|
53913
53952
|
return handle;
|
|
@@ -54911,9 +54950,9 @@ var root_mkdir_native_disposeResources = (undefined && undefined.__disposeResour
|
|
|
54911
54950
|
|
|
54912
54951
|
|
|
54913
54952
|
|
|
54914
|
-
function tryMkdirNativeParents(root, relativePath) {
|
|
54953
|
+
function tryMkdirNativeParents(root, relativePath, mode) {
|
|
54915
54954
|
try {
|
|
54916
|
-
return mkdirOrdinaryNativeParents(root, relativePath);
|
|
54955
|
+
return mkdirOrdinaryNativeParents(root, relativePath, mode);
|
|
54917
54956
|
}
|
|
54918
54957
|
catch (error) {
|
|
54919
54958
|
if (hasNodeErrorCode(error, "ENOTDIR"))
|
|
@@ -54921,7 +54960,7 @@ function tryMkdirNativeParents(root, relativePath) {
|
|
|
54921
54960
|
throw error;
|
|
54922
54961
|
}
|
|
54923
54962
|
}
|
|
54924
|
-
function mkdirOrdinaryNativeParents(root, relativePath) {
|
|
54963
|
+
function mkdirOrdinaryNativeParents(root, relativePath, mode) {
|
|
54925
54964
|
if (getFsSafeTestHooks()?.beforeRootFallbackMutation)
|
|
54926
54965
|
return false;
|
|
54927
54966
|
const segments = relativePath.split(external_node_path_.sep === "\\" ? /[\\/]/ : "/");
|
|
@@ -54946,7 +54985,7 @@ function mkdirOrdinaryNativeParents(root, relativePath) {
|
|
|
54946
54985
|
catch (error) {
|
|
54947
54986
|
// Reuse this exact Root snapshot and failed parent observation without an
|
|
54948
54987
|
// intervening await. All opened ancestors still receive fresh native fences.
|
|
54949
|
-
return hasNodeErrorCode(error, "ENOENT") ? mkdirMissingParents(root, segments, rootStat) : false;
|
|
54988
|
+
return hasNodeErrorCode(error, "ENOENT") ? mkdirMissingParents(root, segments, rootStat, mode) : false;
|
|
54950
54989
|
}
|
|
54951
54990
|
try {
|
|
54952
54991
|
if (realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(parentPath)) !== parentPath)
|
|
@@ -54955,12 +54994,12 @@ function mkdirOrdinaryNativeParents(root, relativePath) {
|
|
|
54955
54994
|
catch {
|
|
54956
54995
|
return false;
|
|
54957
54996
|
}
|
|
54958
|
-
return mkdirExistingParent(root, segments, parentIdentity);
|
|
54997
|
+
return mkdirExistingParent(root, segments, parentIdentity, mode);
|
|
54959
54998
|
}
|
|
54960
54999
|
/** Ordinary missing suffixes need no policy callbacks or repeated path resolution. */
|
|
54961
|
-
function mkdirMissingParents(root, segments, rootStat) {
|
|
55000
|
+
function mkdirMissingParents(root, segments, rootStat, mode) {
|
|
54962
55001
|
const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
|
|
54963
|
-
if (!binding?.openBeneath || !binding.mkdirOpenChildBeneath)
|
|
55002
|
+
if (!binding?.openBeneath || !binding.mkdirChildBeneath || (!binding.mkdirOpenChildBeneath && mode === undefined))
|
|
54964
55003
|
return false;
|
|
54965
55004
|
let parentDepth = segments.length - 2;
|
|
54966
55005
|
let parentPath;
|
|
@@ -55000,7 +55039,7 @@ function mkdirMissingParents(root, segments, rootStat) {
|
|
|
55000
55039
|
if (errors.length)
|
|
55001
55040
|
throw new AggregateError(errors, "mkdir directory close failed");
|
|
55002
55041
|
} }, false);
|
|
55003
|
-
const flags = (nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_.constants.O_RDONLY) |
|
|
55042
|
+
const flags = (mode === undefined ? nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_.constants.O_RDONLY : external_node_fs_.constants.O_RDONLY) |
|
|
55004
55043
|
(external_node_fs_.constants.O_DIRECTORY ?? 0) | (external_node_fs_.constants.O_NOFOLLOW ?? 0);
|
|
55005
55044
|
let current = rootOwner.fd;
|
|
55006
55045
|
if (parentDepth > 0) {
|
|
@@ -55016,12 +55055,21 @@ function mkdirMissingParents(root, segments, rootStat) {
|
|
|
55016
55055
|
};
|
|
55017
55056
|
assertCurrent();
|
|
55018
55057
|
for (const segment of segments.slice(parentDepth)) {
|
|
55019
|
-
const child = binding.mkdirOpenChildBeneath
|
|
55058
|
+
const child = binding.mkdirOpenChildBeneath
|
|
55059
|
+
? binding.mkdirOpenChildBeneath(current, segment, mode ?? 0o777, flags)
|
|
55060
|
+
: {
|
|
55061
|
+
created: binding.mkdirChildBeneath(current, segment, mode ?? 0o777),
|
|
55062
|
+
fd: binding.openBeneath(current, segment, flags).fd,
|
|
55063
|
+
};
|
|
55020
55064
|
parentPath = external_node_path_.join(parentPath, segment);
|
|
55021
55065
|
directories.push({ fd: child.fd, pathname: parentPath });
|
|
55022
55066
|
// Retain every ancestor until the complete suffix is admitted. The
|
|
55023
55067
|
// post-create fence also precedes the next synchronous child mutation.
|
|
55024
55068
|
assertCurrent();
|
|
55069
|
+
if (mode !== undefined && child.created) {
|
|
55070
|
+
finalizeCreatedDirectoryModeSync(child, mode);
|
|
55071
|
+
assertCurrent();
|
|
55072
|
+
}
|
|
55025
55073
|
current = child.fd;
|
|
55026
55074
|
}
|
|
55027
55075
|
return true;
|
|
@@ -55040,7 +55088,7 @@ function mkdirMissingParents(root, segments, rootStat) {
|
|
|
55040
55088
|
throw error;
|
|
55041
55089
|
}
|
|
55042
55090
|
}
|
|
55043
|
-
function mkdirExistingParent(root, segments, parentIdentity) {
|
|
55091
|
+
function mkdirExistingParent(root, segments, parentIdentity, mode) {
|
|
55044
55092
|
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
55045
55093
|
try {
|
|
55046
55094
|
const target = external_node_path_.join(root.rootReal, ...segments);
|
|
@@ -55053,7 +55101,7 @@ function mkdirExistingParent(root, segments, parentIdentity) {
|
|
|
55053
55101
|
rootPath: root.rootReal, rootIdentity: root.rootIdentity,
|
|
55054
55102
|
}), false);
|
|
55055
55103
|
verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
|
|
55056
|
-
const flags = (nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_.constants.O_RDONLY) |
|
|
55104
|
+
const flags = (mode === undefined ? nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_.constants.O_RDONLY : external_node_fs_.constants.O_RDONLY) |
|
|
55057
55105
|
(external_node_fs_.constants.O_DIRECTORY ?? 0) | (external_node_fs_.constants.O_NOFOLLOW ?? 0);
|
|
55058
55106
|
const close = captureNativeFdClose(binding);
|
|
55059
55107
|
const parent = binding.openBeneath(rootOwner.fd, segments.slice(0, -1).join("/"), flags).fd;
|
|
@@ -55063,14 +55111,24 @@ function mkdirExistingParent(root, segments, parentIdentity) {
|
|
|
55063
55111
|
root_context_assertRootIdentityCurrentSync(root);
|
|
55064
55112
|
const name = segments.at(-1);
|
|
55065
55113
|
const child = binding.mkdirOpenChildBeneath
|
|
55066
|
-
? binding.mkdirOpenChildBeneath(parent, name, 0o777, flags)
|
|
55067
|
-
:
|
|
55068
|
-
|
|
55114
|
+
? binding.mkdirOpenChildBeneath(parent, name, mode ?? 0o777, flags)
|
|
55115
|
+
: {
|
|
55116
|
+
created: binding.mkdirChildBeneath(parent, name, mode ?? 0o777),
|
|
55117
|
+
fd: binding.openBeneath(parent, name, flags).fd,
|
|
55118
|
+
};
|
|
55119
|
+
const childOwner = root_mkdir_native_addDisposableResource(env_2, { [Symbol.dispose]() { close(child.fd); } }, false);
|
|
55069
55120
|
root_context_assertRootIdentityCurrentSync(root);
|
|
55070
|
-
verifyMkdirDirectory(binding, child, target);
|
|
55121
|
+
verifyMkdirDirectory(binding, child.fd, target);
|
|
55071
55122
|
directory_guard_inspectDirectoryIdentitySync(parentPath, parentIdentity);
|
|
55072
55123
|
verifyMkdirDirectory(binding, parent, parentPath);
|
|
55073
55124
|
verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
|
|
55125
|
+
if (mode !== undefined && child.created) {
|
|
55126
|
+
finalizeCreatedDirectoryModeSync(child, mode);
|
|
55127
|
+
verifyMkdirDirectory(binding, child.fd, target);
|
|
55128
|
+
verifyMkdirDirectory(binding, parent, parentPath);
|
|
55129
|
+
verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
|
|
55130
|
+
root_context_assertRootIdentityCurrentSync(root);
|
|
55131
|
+
}
|
|
55074
55132
|
return true;
|
|
55075
55133
|
}
|
|
55076
55134
|
catch (e_2) {
|
|
@@ -56230,7 +56288,7 @@ async function assertMissingRemovalPrefixCurrent(rootGuard, intermediates) {
|
|
|
56230
56288
|
catch (error) {
|
|
56231
56289
|
throw removalAncestorChanged(error);
|
|
56232
56290
|
}
|
|
56233
|
-
if (!
|
|
56291
|
+
if (!sameFileIdentityForCleanup(deepestGuard.stat, deepest) ||
|
|
56234
56292
|
!sameCanonicalDirectory(deepestGuard.realPath, deepest.path)) {
|
|
56235
56293
|
throw removalAncestorChanged();
|
|
56236
56294
|
}
|
|
@@ -56255,7 +56313,7 @@ async function captureNonrecursiveRemovalAdmission(root, targetPath, options, re
|
|
|
56255
56313
|
await assertRootIdentityCurrent(root);
|
|
56256
56314
|
throw normalizeRemoveGuardError(error);
|
|
56257
56315
|
}
|
|
56258
|
-
if (!
|
|
56316
|
+
if (!sameFileIdentityForCleanup(rootGuard.stat, root.rootIdentity))
|
|
56259
56317
|
throw rootPathChangedError();
|
|
56260
56318
|
if (parentPath === root.rootReal) {
|
|
56261
56319
|
const rootAssertion = createRemovalDirectoryAssertion(rootGuard.dir, rootGuard.stat, rootGuard.realPath);
|
|
@@ -56419,7 +56477,7 @@ async function removePathInRootFallback(root, targetPath, options, receipts) {
|
|
|
56419
56477
|
});
|
|
56420
56478
|
let examined = 0;
|
|
56421
56479
|
const rootGuard = await directory_guard_createAsyncDirectoryGuard(root.rootReal, { bigint: true });
|
|
56422
|
-
if (!
|
|
56480
|
+
if (!sameFileIdentityForCleanup(rootGuard.stat, root.rootIdentity))
|
|
56423
56481
|
throw rootPathChangedError();
|
|
56424
56482
|
const guards = [
|
|
56425
56483
|
createRemovalDirectoryAssertion(rootGuard.dir, rootGuard.stat, rootGuard.realPath),
|
|
@@ -56496,7 +56554,7 @@ async function removePathInRootFallback(root, targetPath, options, receipts) {
|
|
|
56496
56554
|
throw normalizeRemovePathError(error, details(target, "inspect"));
|
|
56497
56555
|
}
|
|
56498
56556
|
if (!isPathInside(directoryGuard.realPath, target) || !isPathInside(target, directoryGuard.realPath) ||
|
|
56499
|
-
!
|
|
56557
|
+
!sameFileIdentityForCleanup(directoryGuard.stat, initial)) {
|
|
56500
56558
|
throw new errors_FsSafeError("path-mismatch", "removal directory changed during operation");
|
|
56501
56559
|
}
|
|
56502
56560
|
guards.push(createRemovalDirectoryAssertion(directoryGuard.dir, directoryGuard.stat, directoryGuard.realPath));
|
|
@@ -57171,7 +57229,7 @@ async function finishRootFallbackWrite(params) {
|
|
|
57171
57229
|
// identity without reading bytes; a different object must still fail.
|
|
57172
57230
|
await verify();
|
|
57173
57231
|
}
|
|
57174
|
-
else if (!
|
|
57232
|
+
else if (!sameFileIdentityForCleanup(current, identity)) {
|
|
57175
57233
|
const opened = await params.openForCompatibility();
|
|
57176
57234
|
accepted = handle = opened.opened.handle;
|
|
57177
57235
|
identity = opened.identity;
|