Home
last modified time | relevance | path

Searched refs:fd (Results 1 – 25 of 46) sorted by relevance

12

/coreutils/gl/lib/
Dtargetdir.c66 int fd = -1; in target_directory_operand() local
90 fd = open (file, O_PATHSEARCH | O_DIRECTORY); in target_directory_operand()
96 if (O_PATHSEARCH == O_SEARCH && fd < 0 && errno == EACCES) in target_directory_operand()
102 if (!O_DIRECTORY && 0 <= fd) in target_directory_operand()
107 if (fstat (fd, st) == 0 in target_directory_operand()
111 close (fd); in target_directory_operand()
113 fd = -1; in target_directory_operand()
117 return fd - (AT_FDCWD == -1 && fd < 0); in target_directory_operand()
Dfd-reopen.c34 int fd = open (file, flags, mode); in fd_reopen() local
36 if (fd == desired_fd || fd < 0) in fd_reopen()
37 return fd; in fd_reopen()
40 int fd2 = dup2 (fd, desired_fd); in fd_reopen()
42 close (fd); in fd_reopen()
Dtargetdir.h38 target_dirfd_valid (int fd) in target_dirfd_valid() argument
40 return fd != -1 - (AT_FDCWD == -1); in target_dirfd_valid()
Dfadvise.c31 fdadvise (int fd, off_t offset, off_t len, fadvice_t advice) in fdadvise() argument
34 ignore_value (posix_fadvise (fd, offset, len, advice)); in fdadvise()
/coreutils/src/
Dtail.c139 int fd; member
365 return ((f->fd == -1) ^ (f->errnum == 0)); in valid_file_spec()
378 record_open_fd (struct File_spec *f, int fd, in record_open_fd() argument
382 f->fd = fd; in record_open_fd()
396 close_fd (int fd, char const *filename) in close_fd() argument
398 if (fd != -1 && fd != STDIN_FILENO && close (fd)) in close_fd()
400 error (0, errno, _("closing %s (fd=%d)"), quoteaf (filename), fd); in close_fd()
433 dump_remainder (bool want_header, char const *pretty_filename, int fd, in dump_remainder() argument
444 size_t bytes_read = safe_read (fd, buffer, n); in dump_remainder()
478 xlseek (int fd, off_t offset, int whence, char const *filename) in xlseek() argument
[all …]
Dsync.c92 int fd; in sync_arg() local
102 fd = open (file, open_flags); in sync_arg()
103 if (fd < 0) in sync_arg()
109 fd = open (file, O_WRONLY | O_NONBLOCK); in sync_arg()
110 if (fd < 0) in sync_arg()
119 int fdflags = fcntl (fd, F_GETFL); in sync_arg()
121 || fcntl (fd, F_SETFL, fdflags & ~O_NONBLOCK) < 0) in sync_arg()
135 sync_status = fdatasync (fd); in sync_arg()
139 sync_status = fsync (fd); in sync_arg()
144 sync_status = syncfs (fd); in sync_arg()
[all …]
Dhead.c224 elseek (int fd, off_t offset, int whence, char const *filename) in elseek() argument
226 off_t new_offset = lseek (fd, offset, whence); in elseek()
248 elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0, in elide_tail_bytes_pipe() argument
302 size_t n_read = full_read (fd, b[i], n_to_read); in elide_tail_bytes_pipe()
385 n_read = full_read (fd, b[i], READ_BUFSIZE); in elide_tail_bytes_pipe()
451 if (0 <= current_pos && elseek (fd, desired_pos, SEEK_SET, filename) < 0) in elide_tail_bytes_pipe()
465 elide_tail_bytes_file (char const *filename, int fd, uintmax_t n_elide, in elide_tail_bytes_file() argument
470 return elide_tail_bytes_pipe (filename, fd, n_elide, current_pos); in elide_tail_bytes_file()
481 enum Copy_fd_status err = copy_fd (fd, bytes_remaining - n_elide); in elide_tail_bytes_file()
498 elide_tail_lines_pipe (char const *filename, int fd, uintmax_t n_elide, in elide_tail_lines_pipe() argument
[all …]
Dshred.c299 dosync (int fd, char const *qname) in dosync() argument
303 if (fdatasync (fd) == 0) in dosync()
313 if (fsync (fd) == 0) in dosync()
330 direct_mode (int fd, bool enable) in direct_mode() argument
334 int fd_flags = fcntl (fd, F_GETFL); in direct_mode()
341 fcntl (fd, F_SETFL, new_flags); in direct_mode()
347 directio (fd, enable ? DIRECTIO_ON : DIRECTIO_OFF); in direct_mode()
353 dorewind (int fd, struct stat const *st) in dorewind() argument
364 if (ioctl (fd, MTIOCTOP, &op) == 0) in dorewind()
368 off_t offset = lseek (fd, 0, SEEK_SET); in dorewind()
[all …]
Dselinux.c187 int fd; in restorecon_private() local
205 fd = open (path, O_RDONLY | O_NOFOLLOW); in restorecon_private()
206 if (fd == -1 && (errno != ELOOP)) in restorecon_private()
209 if (fd != -1) in restorecon_private()
211 if (fstat (fd, &sb) < 0) in restorecon_private()
234 if (fd != -1) in restorecon_private()
236 if (fgetfilecon (fd, &tcon) < 0) in restorecon_private()
255 if (fd != -1) in restorecon_private()
256 rc = fsetfilecon (fd, constr); in restorecon_private()
262 if (fd != -1) in restorecon_private()
[all …]
Dtemp-stream.c126 int fd = mkstemp (tempfile); in temp_stream() local
127 if (fd < 0) in temp_stream()
134 tmp_fp = fdopen (fd, (O_BINARY ? "w+b" : "w+")); in temp_stream()
139 close (fd); in temp_stream()
Dtruncate.c105 do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize, in do_ftruncate() argument
111 if ((block_mode || (rel_mode && rsize < 0)) && fstat (fd, &sb) != 0) in do_ftruncate()
150 fsize = lseek (fd, 0, SEEK_END); in do_ftruncate()
188 if (ftruncate (fd, nsize) != 0) in do_ftruncate()
356 int fd = open (fname, oflags, MODE_RW_UGO); in main() local
357 if (fd < 0) in main()
372 errors |= !do_ftruncate (fd, fname, size, rsize, rel_mode); in main()
373 if (close (fd) != 0) in main()
Diopoll.c67 { .fd = fdin, .events = POLLIN | POLLRDBAND, .revents = 0 }, in iopoll_internal()
68 { .fd = fdout, .events = POLLRDBAND, .revents = 0 }, in iopoll_internal()
185 int fd = fileno (f); in fwait_for_nonblocking_write() local
186 if (fd == -1) in fwait_for_nonblocking_write()
190 if (iopoll_internal (-1, fd, true, false) != 0) in fwait_for_nonblocking_write()
Dwc.c250 wc_lines (int fd) in wc_lines() argument
257 return wc_lines_avx2 (fd); in wc_lines()
266 ssize_t bytes_read = read (fd, buf, BUFFER_SIZE); in wc_lines()
304 wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos) in wc() argument
330 fdadvise (fd, 0, 0, FADVISE_SEQUENTIAL); in wc()
347 fstatus->failed = fstat (fd, &fstatus->st); in wc()
357 current_pos = lseek (fd, 0, SEEK_CUR); in wc()
370 if (bytes && 0 <= lseek (fd, bytes, SEEK_CUR)) in wc()
380 && 0 <= lseek (fd, hi_pos, SEEK_CUR)) in wc()
387 fdadvise (fd, 0, 0, FADVISE_SEQUENTIAL); in wc()
[all …]
Dtouch.c123 int fd = -1; in touch() local
128 fd = STDOUT_FILENO; in touch()
132 fd = fd_reopen (STDIN_FILENO, file, in touch()
134 if (fd < 0) in touch()
157 char const *file_opt = fd == STDOUT_FILENO ? nullptr : file; in touch()
159 int utime_errno = (fdutimensat (fd, AT_FDCWD, file_opt, t, atflag) == 0 in touch()
162 if (fd == STDIN_FILENO) in touch()
170 else if (fd == STDOUT_FILENO) in touch()
Dsplit.c280 copy_to_tmpfile (int fd, char *buf, idx_t bufsize) in copy_to_tmpfile() argument
288 while (0 < (r = read (fd, buf, bufsize))) in copy_to_tmpfile()
301 r = dup2 (fileno (tmp), fd); in copy_to_tmpfile()
315 input_file_size (int fd, struct stat const *st, char *buf, idx_t bufsize) in input_file_size() argument
320 ssize_t n_read = read (fd, buf + size, bufsize - size); in input_file_size()
329 || (cur = lseek (fd, 0, SEEK_CUR)) < 0 in input_file_size()
331 || (end = lseek (fd, 0, SEEK_END)) < 0) in input_file_size()
334 end = copy_to_tmpfile (fd, tmpbuf, bufsize); in input_file_size()
350 off_t r = lseek (fd, cur, SEEK_SET); in input_file_size()
480 int fd = open (name, oflags | O_EXCL, MODE_RW_UGO); in create() local
[all …]
Dtac.c445 int fd; in tac_file() local
451 fd = STDIN_FILENO; in tac_file()
457 fd = open (filename, O_RDONLY | O_BINARY); in tac_file()
458 if (fd < 0) in tac_file()
466 file_size = lseek (fd, 0, SEEK_END); in tac_file()
468 ok = (file_size < 0 || isatty (fd) in tac_file()
469 ? tac_nonseekable (fd, filename) in tac_file()
470 : tac_seekable (fd, filename, file_size)); in tac_file()
472 if (!is_stdin && close (fd) != 0) in tac_file()
Ddd.c253 static ssize_t (*iread_fnc) (int fd, char *buf, idx_t size);
917 iclose (int fd) in iclose() argument
919 if (close (fd) != 0) in iclose()
923 while (close (fd) != 0 && errno != EBADF); in iclose()
1007 cache_round (int fd, off_t len) in cache_round() argument
1010 off_t *pending = (fd == STDIN_FILENO ? &i_pending : &o_pending); in cache_round()
1034 invalidate_cache (int fd, off_t len) in invalidate_cache() argument
1038 bool nocache_eof = (fd == STDIN_FILENO ? i_nocache_eof : o_nocache_eof); in invalidate_cache()
1041 off_t clen = cache_round (fd, len); in invalidate_cache()
1046 off_t pending = len ? cache_round (fd, 0) : 0; in invalidate_cache()
[all …]
Dpwd.c155 int fd; in find_dir_entry() local
165 fd = dirfd (dirp); in find_dir_entry()
166 if ((0 <= fd ? fchdir (fd) : chdir ("..")) < 0) in find_dir_entry()
170 if ((0 <= fd ? fstat (fd, &parent_sb) : stat (".", &parent_sb)) < 0) in find_dir_entry()
Dchown-core.c237 int fd; in restricted_chown() local
250 fd = openat (cwd_fd, file, O_RDONLY | open_flags); in restricted_chown()
251 if (! (0 <= fd in restricted_chown()
253 && 0 <= (fd = openat (cwd_fd, file, O_WRONLY | open_flags))))) in restricted_chown()
256 if (fstat (fd, &st) != 0) in restricted_chown()
264 if (fchown (fd, uid, gid) == 0) in restricted_chown()
265 return close (fd) < 0 ? RC_error : RC_ok; in restricted_chown()
271 close (fd); in restricted_chown()
Dlibstdbuf.c68 fileno_to_name (const int fd) in fileno_to_name() argument
72 switch (fd) in fileno_to_name()
Dwc_avx2.c32 wc_lines_avx2 (int fd) in wc_lines_avx2() argument
52 ssize_t bytes_read = read (fd, avx_buf, sizeof avx_buf); in wc_lines_avx2()
Dstat.c248 int fd, char const *filename, void const *data);
860 int fd, char const *filename, in print_statfs() argument
1130 print_it (char const *format, int fd, char const *filename, in print_it() argument
1193 fd, filename, data); in print_it()
1370 int fd = STREQ (filename, "-") ? 0 : AT_FDCWD; in do_stat() local
1379 if (AT_FDCWD != fd) in do_stat()
1397 fd = statx (fd, pathname, flags, format_to_mask (format), &stx); in do_stat()
1398 if (fd < 0) in do_stat()
1414 bool fail = print_it (format, fd, filename, print_stat, &pa); in do_stat()
1421 get_birthtime (int fd, char const *filename, struct stat const *st) in get_birthtime() argument
[all …]
/coreutils/gl/modules/
Dfd-reopen5 lib/fd-reopen.c
6 lib/fd-reopen.h
14 lib_SOURCES += fd-reopen.c fd-reopen.h
17 "fd-reopen.h"
/coreutils/scripts/build-older-versions/
Dcoreutils-5.97-on-glibc-2.28.diff8 -futimens (int fd ATTRIBUTE_UNUSED,
9 +futimens_FOO (int fd ATTRIBUTE_UNUSED,
47 - ok = (futimens (fd, (fd == STDOUT_FILENO ? NULL : file), t) == 0);
48 + ok = (futimens_FOO (fd, (fd == STDOUT_FILENO ? NULL : file), t) == 0);
50 if (fd == STDIN_FILENO)
/coreutils/tests/
Dseek-data-capable23 fd = os.open(sys.argv[1], os.O_RDONLY)
28 data = os.lseek(fd, 0, SEEK_DATA)

12