MCPcopy Create free account
hub / github.com/cloudflare/computer / getattr

Function getattr

packages/computerd/src/fuse/driver.ts:476–503  ·  view source on GitHub ↗
(path, cb)

Source from the content-addressed store, hash-verified

474 },
475
476 getattr(path, cb) {
477 try {
478 const entry = files.get(path);
479 const stat =
480 entry?.pendingCreate === true ? pendingStat(entry) : statNode(vfs.lstatSync(toVfs(path)));
481 // File content lives outside the VFS, so prefer our size. The
482 // buffered size can outrun the persisted inode before a spill,
483 // so recompute block accounting from it to keep st_blocks
484 // coherent with the size the kernel sees.
485 if (entry !== undefined) {
486 stat.size = entry.size;
487 stat.blocks = blocksForSize(entry.size);
488 }
489 const override = meta.get(path);
490 if (override) {
491 if (override.mode !== undefined) {
492 stat.mode = (stat.mode & 0o170000) | (override.mode & 0o7777);
493 }
494 if (override.uid !== undefined) stat.uid = override.uid;
495 if (override.gid !== undefined) stat.gid = override.gid;
496 if (override.atime) stat.atime = override.atime;
497 if (override.mtime) stat.mtime = override.mtime;
498 }
499 cb(0, stat);
500 } catch (error) {
501 cb(toErrno(error), null);
502 }
503 },
504
505 fgetattr(path, _fh, cb) {
506 this.getattr(path, cb);

Callers

nothing calls this directly

Calls 7

pendingStatFunction · 0.85
statNodeFunction · 0.85
toVfsFunction · 0.85
blocksForSizeFunction · 0.85
toErrnoFunction · 0.85
lstatSyncMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected