MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / statx

Method statx

source/kernel/kprocess.cpp:2326–2372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2324 memory->writed(buf, 0); // stx_dio_offset_align
2325}
2326U32 KProcess::statx(FD dirfd, BString path, U32 flags, U32 mask, U32 buf) {
2327 BString dir;
2328 U32 result = 0;
2329
2330 if (path.startsWith("/") || (flags & K_AT_EMPTY_PATH)) {
2331 result = getCurrentDirectoryFromDirFD(dirfd, dir);
2332 if (result == 0 && (flags & K_AT_EMPTY_PATH)) {
2333 path = dir;
2334 dir = BString::empty;
2335 }
2336 } else if (!path.startsWith("/")) {
2337 result = getCurrentDirectoryFromDirFD(dirfd, dir);
2338 }
2339 if (result) {
2340 if ((S32)result == -K_ENOTDIR) {
2341 KFileDescriptorPtr fd = this->getFileDescriptor(dirfd);
2342 if (fd->kobject->type == KTYPE_UNIX_SOCKET) {
2343 std::shared_ptr<KUnixSocketObject> s = std::dynamic_pointer_cast<KUnixSocketObject>(fd->kobject);
2344 U64 t = s->lastModifiedTime;
2345 U32 seconds = (U32)(t / 1000);
2346 U32 n = (U32)(t % 1000) * 1000000;
2347 writeStatX(memory, buf, (s->node ? s->node->id : 0), (s->node ? s->node->rdev : 0), 1, userId, groupId, K_S_IFSOCK | K__S_IWRITE | K__S_IREAD, 0, seconds, n);
2348 return 0;
2349 }
2350 }
2351 return result;
2352 }
2353 bool isLink = false;
2354
2355 std::shared_ptr<FsNode> node = Fs::getNodeFromLocalPath(dir, path, (flags & 0x100) == 0, &isLink);
2356 if (!node) {
2357 return -K_ENOENT;
2358 }
2359
2360 U64 len = node->length();
2361 U32 mode = node->getMode();
2362 if (node->isLink() || isLink) {
2363 mode |= K__S_IFLNK;
2364 }
2365 U64 t = node->lastModified();
2366 U32 seconds = (U32)(t / 1000);
2367 U32 n = (U32)(t % 1000) * 1000000;
2368 U32 hardLinkCount = node->getHardLinkCount();
2369
2370 writeStatX(memory, buf, node->id, node->rdev, hardLinkCount, userId, groupId, mode, len, seconds, n);
2371 return 0;
2372}
2373
2374U32 KProcess::fstatat64(FD dirfd, BString path, U32 buf, U32 flag) {
2375 BString dir;

Callers 1

syscall_statxFunction · 0.80

Calls 7

getFileDescriptorMethod · 0.95
startsWithMethod · 0.80
getHardLinkCountMethod · 0.80
lengthMethod · 0.45
getModeMethod · 0.45
isLinkMethod · 0.45
lastModifiedMethod · 0.45

Tested by

no test coverage detected