Lines Matching refs:fd
56 int fd; in read_to_safe_mem() local
58 if ((fd = open(file, O_RDONLY)) < 0) { in read_to_safe_mem()
68 if ((lseek(fd, offset, (offset >= 0) ? SEEK_SET : SEEK_END) < 0)) { in read_to_safe_mem()
73 if ((r = read(fd, mem, *sz)) <= 0) { in read_to_safe_mem()
80 close(fd); in read_to_safe_mem()
86 close(fd); in read_to_safe_mem()
114 int fd; in get_random() local
121 if ((fd = open((weak) ? "/dev/urandom" : "/dev/random", O_RDONLY)) < 0) { in get_random()
138 if ((r = read(fd, buf+rd, sz)) < 0) { in get_random()
140 fd, strerror(errno)); in get_random()
141 close(fd); in get_random()
150 close(fd); in get_random()
180 int fd_rand, fd; in secure_erase() local
195 if ((fd = open(dev, O_WRONLY)) < 0) { in secure_erase()
215 close(fd); in secure_erase()
225 if ((w = write(fd, buf, r)) < 0) { in secure_erase()
227 close(fd); in secure_erase()
237 close(fd); in secure_erase()
251 int fd; in get_disk_info() local
253 if ((fd = open(dev, O_RDONLY)) < 0) { in get_disk_info()
260 if (ioctl(fd, DIOCGPART, &pinfo) < 0) { in get_disk_info()
261 close(fd); in get_disk_info()
268 close(fd); in get_disk_info()
277 int fd; in get_disk_info() local
279 if ((fd = open(dev, O_RDONLY)) < 0) { in get_disk_info()
284 if ((ioctl(fd, BLKSSZGET, &blocksz)) < 0) { in get_disk_info()
285 close(fd); in get_disk_info()
289 if ((ioctl(fd, BLKGETSIZE64, &nbytes)) < 0) { in get_disk_info()
290 close(fd); in get_disk_info()
297 close(fd); in get_disk_info()
310 int fd; in write_to_disk() local
337 if ((fd = open(dev, O_WRONLY)) < 0) { in write_to_disk()
342 if ((lseek(fd, offset, (offset >= 0) ? SEEK_SET : SEEK_END) < 0)) { in write_to_disk()
344 close(fd); in write_to_disk()
348 if ((w = write(fd, (mem_buf != NULL) ? mem_buf : mem, bytes)) <= 0) { in write_to_disk()
350 close(fd); in write_to_disk()
354 close(fd); in write_to_disk()
365 int fd; in write_to_file() local
368 if ((fd = open(file, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR)) < 0) { in write_to_file()
373 if ((w = write(fd, mem, bytes)) < 0) { in write_to_file()
375 close(fd); in write_to_file()
379 close(fd); in write_to_file()
400 int fd = STDIN_FILENO, r = 0, nready; in read_passphrase() local
402 int is_tty = isatty(fd); in read_passphrase()
415 tcgetattr(fd, &termios_old); in read_passphrase()
423 tty_fd = fd; in read_passphrase()
426 tcsetattr(fd, TCSAFLUSH, &termios_new); in read_passphrase()
434 FD_SET(fd, &fds); in read_passphrase()
435 nready = select(fd + 1, &fds, NULL, NULL, &to); in read_passphrase()
442 n = read(fd, pass, bufsz-1); in read_passphrase()
459 tcsetattr(fd, TCSAFLUSH, &termios_old); in read_passphrase()