MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / SysReadLink

Function SysReadLink

Kernel/src/arch/x86_64/syscalls.cpp:1880–1901  ·  view source on GitHub ↗

//////////////////////// \brief SysReadLink(pathname, buf, bufsize) Read a symbolic link \param pathname - const char*, Path of the symbolic link \param buf - char*, Buffer to store the link data \param bufsize - size_t, Size of buf \return Amount of bytes read on success \return Negative value on failure ////////////////////////

Source from the content-addressed store, hash-verified

1878/// \return Negative value on failure
1879/////////////////////////////
1880long SysReadLink(regs64_t* r){
1881 process_t* proc = Scheduler::GetCurrentProcess();
1882
1883 if(!Memory::CheckUsermodePointer(SC_ARG0(r), 0, proc->addressSpace)){
1884 return -EFAULT; // Invalid path pointer
1885 }
1886
1887 if(!Memory::CheckUsermodePointer(SC_ARG1(r), SC_ARG2(r), proc->addressSpace)){
1888 return -EFAULT; // Invalid buffer
1889 }
1890
1891 const char* path = reinterpret_cast<const char*>(SC_ARG0(r));
1892 char* buffer = reinterpret_cast<char*>(SC_ARG1(r));
1893 size_t bufferSize = SC_ARG2(r);
1894
1895 FsNode* link = fs::ResolvePath(path);
1896 if(!link){
1897 return -ENOENT; // path does not exist
1898 }
1899
1900 return link->ReadLink(buffer, bufferSize);
1901}
1902
1903/////////////////////////////
1904/// \brief SysSpawnThread(entry, stack) Spawn a new thread under current process

Callers

nothing calls this directly

Calls 4

GetCurrentProcessFunction · 0.85
CheckUsermodePointerFunction · 0.85
ResolvePathFunction · 0.85
ReadLinkMethod · 0.45

Tested by

no test coverage detected