Skip to content

Commit

Permalink
feat: allow setting rdev on node (#1085)
Browse files Browse the repository at this point in the history
This adds it to stat too, so rdev will propagate.
  • Loading branch information
kylecarbs authored Jan 9, 2025
1 parent cdb0403 commit 2717334
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class Stats<T = TStatNumber> {
stats.uid = getStatNumber(uid);
stats.gid = getStatNumber(gid);

stats.rdev = getStatNumber(0);
stats.rdev = getStatNumber(node.rdev);
stats.blksize = getStatNumber(4096);
stats.ino = getStatNumber(node.ino);
stats.size = getStatNumber(node.getSize());
Expand Down
8 changes: 8 additions & 0 deletions src/__tests__/volume/statSync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ describe('.statSync(...)', () => {
expect(stats.size).toBe(11);
});

it('returns rdev', () => {
const vol = create({});
const fd = vol.openSync('/null', 'w');
vol.fds[fd].node.rdev = 1;
const stats = vol.statSync('/null');
expect(stats.rdev).toBe(1);
});

it('returns undefined for non-existent targets with the throwIfNoEntry option set to false', () => {
const vol = create({});

Expand Down
1 change: 1 addition & 0 deletions src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class Node extends EventEmitter {

// data: string = '';
buf: Buffer;
rdev: number = 0;

mode: number; // S_IFDIR, S_IFREG, etc..

Expand Down

0 comments on commit 2717334

Please sign in to comment.