Lines Matching refs:fd

8 #include "fd.h"
35 /*** General fd routines ***/
39 void dump_fd(int fd, struct file_descriptor *descriptor);
42 dump_fd(int fd,struct file_descriptor *descriptor)
44 fssh_dprintf("fd[%d] = %p: type = %d, ref_count = %d, ops = %p, u.vnode = %p, u.mount = %p, cookie = %p, open_mode = %x, pos = %lld\n",
45 fd, descriptor, (int)descriptor->type, (int)descriptor->ref_count, descriptor->ops,
74 fd_close_on_exec(struct io_context *context, int fd)
76 return CHECK_BIT(context->fds_close_on_exec[fd / 8], fd & 7) ? true : false;
81 fd_set_close_on_exec(struct io_context *context, int fd, bool closeFD)
84 context->fds_close_on_exec[fd / 8] |= (1 << (fd & 7));
86 context->fds_close_on_exec[fd / 8] &= ~(1 << (fd & 7));
98 int fd = -1;
105 fd = i;
109 if (fd < 0) {
110 fd = FSSH_B_NO_MORE_FDS;
114 context->fds[fd] = descriptor;
121 return fd;
213 get_fd(struct io_context *context, int fd)
217 if (fd < 0)
222 if ((uint32_t)fd < context->table_size)
223 descriptor = context->fds[fd];
243 remove_fd(struct io_context *context, int fd)
247 if (fd < 0)
252 if ((uint32_t)fd < context->table_size)
253 descriptor = context->fds[fd];
256 // fd is valid
257 context->fds[fd] = NULL;
258 fd_set_close_on_exec(context, fd, false);
272 dup_fd(int fd, bool kernel)
278 TRACE(("dup_fd: fd = %d\n", fd));
280 // Try to get the fd structure
281 descriptor = get_fd(context, fd);
285 // now put the fd in place
349 // Say bye bye to the evicted fd
360 select_fd(int fd, uint8_t event, uint32_t ref, struct select_sync *sync, bool kernel)
365 // TRACE(("select_fd(fd = %d, event = %u, ref = %lu, selectsync = %p)\n", fd, event, ref, sync));
367 // descriptor = get_fd(get_current_io_context(kernel), fd);
387 deselect_fd(int fd, uint8_t event, struct select_sync *sync, bool kernel)
392 // TRACE(("deselect_fd(fd = %d, event = %u, selectsync = %p)\n", fd, event, sync));
394 // descriptor = get_fd(get_current_io_context(kernel), fd);
410 /** This function checks if the specified fd is valid in the current
411 * context. It can be used for a quick check; the fd is not locked
416 fd_is_valid(int fd, bool kernel)
418 struct file_descriptor *descriptor = get_fd(get_current_io_context(kernel), fd);
443 common_close(int fd, bool kernel)
446 struct file_descriptor *descriptor = remove_fd(io, fd);
469 _kern_read(int fd, fssh_off_t pos, void *buffer, fssh_size_t length)
474 descriptor = get_fd(get_current_io_context(true), fd);
504 _kern_readv(int fd, fssh_off_t pos, const fssh_iovec *vecs, fssh_size_t count)
511 descriptor = get_fd(get_current_io_context(true), fd);
548 _kern_write(int fd, fssh_off_t pos, const void *buffer, fssh_size_t length)
553 descriptor = get_fd(get_current_io_context(true), fd);
583 _kern_writev(int fd, fssh_off_t pos, const fssh_iovec *vecs, fssh_size_t count)
590 descriptor = get_fd(get_current_io_context(true), fd);
627 _kern_seek(int fd, fssh_off_t pos, int seekType)
631 descriptor = get_fd(get_current_io_context(true), fd);
646 _kern_ioctl(int fd, uint32_t op, void *buffer, fssh_size_t length)
651 TRACE(("sys_ioctl: fd %d\n", fd));
653 descriptor = get_fd(get_current_io_context(true), fd);
668 _kern_read_dir(int fd, struct fssh_dirent *buffer, fssh_size_t bufferSize, uint32_t maxCount)
673 TRACE(("sys_read_dir(fd = %d, buffer = %p, bufferSize = %ld, count = %lu)\n",fd, buffer, bufferSize, maxCount));
675 descriptor = get_fd(get_current_io_context(true), fd);
693 _kern_rewind_dir(int fd)
698 TRACE(("sys_rewind_dir(fd = %d)\n",fd));
700 descriptor = get_fd(get_current_io_context(true), fd);
715 _kern_close(int fd)
717 return common_close(fd, true);
722 _kern_dup(int fd)
724 return dup_fd(fd, true);