Lines Matching refs:rfd

71 rfd_find_prev_class(rfd_t *rfd, rfd_class_t class)  in rfd_find_prev_class()  argument
73 while (rfd != NULL && rfd->rfd_class != class) in rfd_find_prev_class()
74 rfd = rfd->rfd_prev; in rfd_find_prev_class()
75 return (rfd); in rfd_find_prev_class()
82 rfd_revoke_fd(rfd_t *rfd) in rfd_revoke_fd() argument
84 if (rfd->rfd_revoke != NULL) in rfd_revoke_fd()
85 rfd->rfd_revoke(rfd); in rfd_revoke_fd()
86 return (rfd_close(rfd->rfd_fd)); in rfd_revoke_fd()
96 rfd_t *rfd = NULL; in rfd_revoke_next() local
110 rfd = rfd_find_prev_class(tail, RFD_RESERVED); in rfd_revoke_next()
116 if (rfd == NULL) { in rfd_revoke_next()
117 rfd = rfd_find_prev_class(tail, RFD_PSINFO); in rfd_revoke_next()
118 if (rfd != NULL) in rfd_revoke_next()
119 rfd = rfd->rfd_prev_class; in rfd_revoke_next()
127 if (rfd == NULL) { in rfd_revoke_next()
128 rfd = tail; in rfd_revoke_next()
129 while (rfd != NULL && class == RFD_RESERVED && rfd->rfd_class == in rfd_revoke_next()
131 rfd = rfd->rfd_prev; in rfd_revoke_next()
134 if (rfd != NULL) in rfd_revoke_next()
135 return (rfd_revoke_fd(rfd)); in rfd_revoke_next()
153 void(*revoke)(struct rfd *), void *data, int oflag, mode_t mode) in rfd_open() argument
156 rfd_t *rfd; in rfd_open() local
171 rfd = malloc(sizeof (*rfd)); in rfd_open()
172 if (rfd == NULL) { in rfd_open()
176 (void) bzero(rfd, sizeof (*rfd)); in rfd_open()
177 rfd->rfd_fd = fd; in rfd_open()
178 rfd->rfd_class = class; in rfd_open()
179 rfd->rfd_revoke = revoke; in rfd_open()
180 rfd->rfd_data = data; in rfd_open()
182 rfd->rfd_prev_class = rfd_find_prev_class(tail, class); in rfd_open()
184 rfd->rfd_prev_class = tail; in rfd_open()
185 rfd->rfd_prev = tail; in rfd_open()
187 tail->rfd_next = rfd; in rfd_open()
188 tail = rfd; in rfd_open()
202 rfd_t *rfd; in rfd_close() local
207 rfd = tail; in rfd_close()
208 while (rfd != NULL) { in rfd_close()
209 rfdprev = rfd->rfd_prev; in rfd_close()
210 if (rfd->rfd_fd == fd) { in rfd_close()
211 if (rfd->rfd_prev != NULL) in rfd_close()
212 rfd->rfd_prev->rfd_next = rfd->rfd_next; in rfd_close()
213 if (rfd->rfd_next != NULL) in rfd_close()
214 rfd->rfd_next->rfd_prev = rfd->rfd_prev; in rfd_close()
215 if (tail == rfd) in rfd_close()
216 tail = rfd->rfd_prev; in rfd_close()
217 for (nextclass = rfd->rfd_next; nextclass != NULL; in rfd_close()
219 if (nextclass->rfd_class == rfd->rfd_class) { in rfd_close()
221 rfd->rfd_prev_class; in rfd_close()
224 free(rfd); in rfd_close()
230 rfd = rfdprev; in rfd_close()