Lines Matching refs:fd

21     file->fd = open((char *) file->name, mode, access);  in nxt_file_open()
23 file->error = (file->fd == -1) ? nxt_errno : 0; in nxt_file_open()
30 file->name, mode, access, file->fd, file->error); in nxt_file_open()
32 if (file->fd != -1) { in nxt_file_open()
63 file->fd = syscall(SYS_openat2, dfd, file->name, &how, sizeof(how)); in nxt_file_openat2()
65 file->error = (file->fd == -1) ? nxt_errno : 0; in nxt_file_openat2()
72 file->fd, file->error); in nxt_file_openat2()
74 if (file->fd != -1) { in nxt_file_openat2()
92 nxt_debug(task, "close(%FD)", file->fd); in nxt_file_close()
94 if (close(file->fd) != 0) { in nxt_file_close()
96 file->fd, file->name, nxt_errno); in nxt_file_close()
109 n = pwrite(file->fd, buf, size, offset); in nxt_file_write()
116 file->fd, buf, size, offset, n); in nxt_file_write()
123 file->fd, file->name, buf, size, in nxt_file_write()
137 n = pread(file->fd, buf, size, offset); in nxt_file_read()
144 file->fd, buf, size, offset, n); in nxt_file_read()
151 file->fd, file->name, buf, size, in nxt_file_read()
168 ret = fcntl(file->fd, F_READAHEAD, (int) size); in nxt_file_read_ahead()
171 file->fd, size, ret); in nxt_file_read_ahead()
179 file->fd, file->name, size, nxt_errno); in nxt_file_read_ahead()
205 err = posix_fadvise(file->fd, offset, size, POSIX_FADV_WILLNEED); in nxt_file_read_ahead()
208 file->fd, file->name, offset, size, in nxt_file_read_ahead()
216 file->fd, file->name, offset, size, in nxt_file_read_ahead()
230 ret = fcntl(file->fd, F_RDAHEAD, 1); in nxt_file_read_ahead()
232 nxt_thread_log_debug("fcntl(%FD, F_RDAHEAD, 1): %d", file->fd, ret); in nxt_file_read_ahead()
240 file->fd, file->name, nxt_errno); in nxt_file_read_ahead()
261 if (file->fd == NXT_FILE_INVALID) { in nxt_file_info()
280 n = fstat(file->fd, fi); in nxt_file_info()
284 nxt_thread_log_debug("fstat(%FD): %d", file->fd, n); in nxt_file_info()
293 file->fd, file->name, file->error); in nxt_file_info()
362 nxt_fd_nonblocking(nxt_task_t *task, nxt_fd_t fd) in nxt_fd_nonblocking() argument
368 if (nxt_fast_path(ioctl(fd, FIONBIO, &nb) != -1)) { in nxt_fd_nonblocking()
372 nxt_alert(task, "ioctl(%d, FIONBIO) failed %E", fd, nxt_errno); in nxt_fd_nonblocking()
380 nxt_fd_blocking(nxt_task_t *task, nxt_fd_t fd) in nxt_fd_blocking() argument
386 if (nxt_fast_path(ioctl(fd, FIONBIO, &nb) != -1)) { in nxt_fd_blocking()
390 nxt_alert(task, "ioctl(%d, !FIONBIO) failed %E", fd, nxt_errno); in nxt_fd_blocking()
398 nxt_fd_nonblocking(nxt_task_t *task, nxt_fd_t fd) in nxt_fd_nonblocking() argument
402 flags = fcntl(fd, F_GETFL); in nxt_fd_nonblocking()
405 nxt_alert(task, "fcntl(%d, F_GETFL) failed %E", fd, nxt_errno); in nxt_fd_nonblocking()
411 if (nxt_slow_path(fcntl(fd, F_SETFL, flags) == -1)) { in nxt_fd_nonblocking()
413 fd, nxt_errno); in nxt_fd_nonblocking()
422 nxt_fd_blocking(nxt_task_t *task, nxt_fd_t fd) in nxt_fd_blocking() argument
426 flags = fcntl(fd, F_GETFL); in nxt_fd_blocking()
429 nxt_alert(task, "fcntl(%d, F_GETFL) failed %E", fd, nxt_errno); in nxt_fd_blocking()
435 if (nxt_slow_path(fcntl(fd, F_SETFL, flags) == -1)) { in nxt_fd_blocking()
437 fd, nxt_errno); in nxt_fd_blocking()
448 nxt_fd_write(nxt_fd_t fd, u_char *buf, size_t size) in nxt_fd_write() argument
453 n = write(fd, buf, size); in nxt_fd_write()
457 nxt_thread_log_debug("write(%FD, %p, %uz): %z", fd, buf, size, n); in nxt_fd_write()
460 nxt_thread_log_alert("write(%FD) failed %E", fd, err); in nxt_fd_write()
468 nxt_fd_read(nxt_fd_t fd, u_char *buf, size_t size) in nxt_fd_read() argument
473 n = read(fd, buf, size); in nxt_fd_read()
477 nxt_thread_log_debug("read(%FD, %p, %uz): %z", fd, buf, size, n); in nxt_fd_read()
485 nxt_thread_log_alert("read(%FD) failed %E", fd, err); in nxt_fd_read()
493 nxt_fd_close(nxt_fd_t fd) in nxt_fd_close() argument
495 nxt_thread_log_debug("close(%FD)", fd); in nxt_fd_close()
497 if (nxt_slow_path(close(fd) != 0)) { in nxt_fd_close()
498 nxt_thread_log_alert("close(%FD) failed %E", fd, nxt_errno); in nxt_fd_close()
509 nxt_file_redirect(nxt_file_t *file, nxt_fd_t fd) in nxt_file_redirect() argument
511 nxt_thread_log_debug("dup2(%FD, %FD, \"%FN\")", fd, file->fd, file->name); in nxt_file_redirect()
513 if (dup2(fd, file->fd) == -1) { in nxt_file_redirect()
515 fd, file->fd, file->name, nxt_errno); in nxt_file_redirect()
519 if (close(fd) != 0) { in nxt_file_redirect()
521 fd, file->name, nxt_errno); in nxt_file_redirect()
535 file->fd, STDERR_FILENO, file->name); in nxt_file_stderr()
537 if (dup2(file->fd, STDERR_FILENO) != -1) { in nxt_file_stderr()
542 file->fd, STDERR_FILENO, file->name, nxt_errno); in nxt_file_stderr()
551 int flags, fd; in nxt_stderr_start() local
571 fd = open("/dev/null", O_WRONLY | O_APPEND); in nxt_stderr_start()
573 if (fd != -1) { in nxt_stderr_start()
574 (void) dup2(fd, nxt_stderr); in nxt_stderr_start()
576 if (fd != nxt_stderr) { in nxt_stderr_start()
577 (void) close(fd); in nxt_stderr_start()