(path: string)
| 363 | // Returns errno on failure so callers can surface it to the |
| 364 | // kernel; returns 0 on success or when there's nothing to do. |
| 365 | const flushEntry = (path: string): number => { |
| 366 | const entry = files.get(path); |
| 367 | if (entry === undefined || !entry.dirty) return 0; |
| 368 | try { |
| 369 | const data = entry.buf.subarray(0, entry.size); |
| 370 | // Pass the cached mode so writeFile doesn't fall back to its |
| 371 | // 0o644 default. Without this, a chmod between create/open and |
| 372 | // flush would land on the FUSE-side meta override but never |
| 373 | // reach the persisted VFS row, so RPC consumers would see the |
| 374 | // wrong mode. |
| 375 | const writeOpts = { mode: entry.mode & 0o7777 }; |
| 376 | if (rangedWriteVfs.writeFileRangesSync !== undefined && entry.dirtyRanges.length > 0) { |
| 377 | rangedWriteVfs.writeFileRangesSync(toVfs(path), data, entry.dirtyRanges, writeOpts); |
| 378 | } else { |
| 379 | vfs.writeFileSync(toVfs(path), data, writeOpts); |
| 380 | } |
| 381 | entry.dirty = false; |
| 382 | entry.dirtyRanges = []; |
| 383 | entry.pendingCreate = false; |
| 384 | return 0; |
| 385 | } catch (error) { |
| 386 | return toErrno(error); |
| 387 | } |
| 388 | }; |
| 389 | |
| 390 | const truncatePath = (path: string, size: number, cb: StatusCallback): void => { |
| 391 | if (!exists(path)) { |
no test coverage detected