Lines Matching defs:procFd

94 static bool IsValidProcessFd(struct fd_table_s *fdt, int procFd)
99 if ((procFd < 0) || (procFd >= fdt->max_fds)) {
105 void AssociateSystemFd(int procFd, int sysFd)
109 if (!IsValidProcessFd(fdt, procFd)) {
118 fdt->ft_fds[procFd].sysFd = sysFd;
122 int CheckProcessFd(int procFd)
126 if (!IsValidProcessFd(fdt, procFd)) {
133 int GetAssociatedSystemFd(int procFd)
137 if (!IsValidProcessFd(fdt, procFd)) {
142 if (fdt->ft_fds[procFd].sysFd < 0) {
146 int sysFd = fdt->ft_fds[procFd].sysFd;
152 /* Occupy the procFd, there are three circumstances:
153 * 1.procFd is already associated, we need disassociate procFd with relevant sysfd.
154 * 2.procFd is not allocated, we occupy it immediately.
155 * 3.procFd is in open(), close(), dup() process, we return EBUSY immediately.
157 int AllocSpecifiedProcessFd(int procFd)
161 if (!IsValidProcessFd(fdt, procFd)) {
166 if (fdt->ft_fds[procFd].sysFd >= 0) {
167 /* Disassociate procFd */
168 fdt->ft_fds[procFd].sysFd = -1;
173 if (FD_ISSET(procFd, fdt->proc_fds)) {
174 /* procFd in race condition */
178 /* Unused procFd */
179 FD_SET(procFd, fdt->proc_fds);
186 void FreeProcessFd(int procFd)
190 if (!IsValidProcessFd(fdt, procFd)) {
195 FD_CLR(procFd, fdt->proc_fds);
196 FD_CLR(procFd, fdt->cloexec_fds);
197 fdt->ft_fds[procFd].sysFd = -1;
201 int DisassociateProcessFd(int procFd)
205 if (!IsValidProcessFd(fdt, procFd)) {
210 if (fdt->ft_fds[procFd].sysFd < 0) {
214 int sysFd = fdt->ft_fds[procFd].sysFd;
215 if (procFd >= MIN_START_FD) {
216 fdt->ft_fds[procFd].sysFd = -1;
243 int procFd = AssignProcessFd(fdt, minFd);
244 if (procFd == VFS_ERROR) {
250 FD_SET(procFd, fdt->proc_fds);
253 return procFd;
271 int procFd = AssignProcessFd(fdt, minFd);
272 if (procFd == VFS_ERROR) {
278 FD_SET(procFd, fdt->proc_fds);
279 fdt->ft_fds[procFd].sysFd = sysFd;
282 return procFd;
285 int AllocAndAssocSystemFd(int procFd, int minFd)
289 if (!IsValidProcessFd(fdt, procFd)) {
299 fdt->ft_fds[procFd].sysFd = sysFd;
380 int procFd;
406 procFd = AssignProcessFd(fdt, 3); // minfd is 3
407 if (procFd < 0) {
416 FD_SET(procFd, fdt->proc_fds);
417 fdt->ft_fds[procFd].sysFd = sysFd;
422 return procFd;
426 int CloseProcFd(int procFd, unsigned int targetPid)
450 if (!IsValidProcessFd(fdt, procFd)) {
457 sysFd = fdt->ft_fds[procFd].sysFd;
466 FD_CLR(procFd, fdt->proc_fds);
467 FD_CLR(procFd, fdt->cloexec_fds);
468 fdt->ft_fds[procFd].sysFd = -1;