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

Method bind

source/kernel/kunixsocket.cpp:433–457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

431};
432
433U32 KUnixSocketObject::bind(KThread* thread, const KFileDescriptorPtr& fd, U32 address, U32 len) {
434 KMemory* memory = thread->memory;
435
436 U32 family = memory->readw(address);
437 if (family==K_AF_UNIX) {
438 BString name = socketAddressName(memory, address, len);
439
440 if (name.length() == 0) {
441 return 0; // :TODO: why does XOrg need this
442 }
443 std::shared_ptr<FsNode> node = Fs::getNodeFromLocalPath(thread->process->currentDirectory, name, true);
444 if (node) {
445 return -K_EADDRINUSE;
446 }
447 BString fullpath = Fs::getFullPath(thread->process->currentDirectory, name);
448 std::shared_ptr<FsNode> parentNode = Fs::getNodeFromLocalPath(B(""), Fs::getParentPath(fullpath), true);
449 std::shared_ptr<UnixSocketNode> socketNode = std::make_shared<UnixSocketNode>(0, 2, fullpath, parentNode);
450 parentNode->addChild(socketNode);
451 std::shared_ptr<KUnixSocketObject> s = std::dynamic_pointer_cast<KUnixSocketObject>(fd->kobject);
452 socketNode->kobject = fd->kobject;
453 s->node = socketNode;
454 return 0;
455 }
456 return -K_EAFNOSUPPORT;
457}
458
459U32 KUnixSocketObject::connect(KThread* thread, const KFileDescriptorPtr& fd, U32 address, U32 len) {
460 KMemory* memory = thread->memory;

Callers

nothing calls this directly

Calls 5

socketAddressNameFunction · 0.85
BFunction · 0.85
addChildMethod · 0.80
readwMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected