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

Method ctl

source/kernel/kepoll.cpp:137–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135#define K_EPOLL_CTL_MOD 3
136
137U32 KEPoll::ctl(KMemory* memory, U32 op, FD fd, U32 address) {
138 KFileDescriptorPtr targetFD = KThread::currentThread()->process->getFileDescriptor(fd);
139
140 if (!targetFD) {
141 return -K_EBADF;
142 }
143
144 Data* existing = this->data[fd];
145
146 switch (op) {
147 case K_EPOLL_CTL_ADD:
148 if (existing) {
149 return -K_EEXIST;
150 }
151 existing = new Data();
152 existing->fd = fd;
153 existing->events = memory->readd(address);
154 existing->data = memory->readq(address + 4);
155 this->data.set(fd, existing);
156 break;
157 case K_EPOLL_CTL_DEL:
158 if (!existing)
159 return -K_ENOENT;
160 this->data.remove(fd);
161 delete existing;
162 break;
163 case K_EPOLL_CTL_MOD:
164 if (!existing)
165 return -K_ENOENT;
166 existing->events = memory->readd(address);
167 existing->data = memory->readq(address + 4);
168 break;
169 default:
170 return -K_EINVAL;
171 }
172 return 0;
173}
174
175U32 KEPoll::wait(KThread* thread, U32 events, U32 maxevents, U32 timeout) {
176 S32 result = 0;

Callers 1

epollctlMethod · 0.80

Calls 5

getFileDescriptorMethod · 0.80
readqMethod · 0.80
readdMethod · 0.45
setMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected