Lines Matching refs:fd

127 static int get_alignment(int fd)  in get_alignment()  argument
132 alignment = fpathconf(fd, _PC_REC_XFER_ALIGN); in get_alignment()
157 static int sector_size(int fd) in sector_size() argument
162 if (ioctl(fd,BLKSSZGET, &bsize) < 0) in sector_size()
171 int fd = open(device, O_RDONLY); in sector_size_for_device() local
173 if(fd < 0) in sector_size_for_device()
175 r = sector_size(fd); in sector_size_for_device()
176 close(fd); in sector_size_for_device()
180 ssize_t write_blockwise(int fd, const void *orig_buf, size_t count) in write_blockwise() argument
187 if ((bsize = sector_size(fd)) < 0) in write_blockwise()
192 alignment = get_alignment(fd); in write_blockwise()
202 r = write(fd, buf, solid); in write_blockwise()
211 r = read(fd, hangover_buf, bsize); in write_blockwise()
214 r = lseek(fd, -bsize, SEEK_CUR); in write_blockwise()
219 r = write(fd, hangover_buf, bsize); in write_blockwise()
230 ssize_t read_blockwise(int fd, void *orig_buf, size_t count) { in read_blockwise() argument
236 if ((bsize = sector_size(fd)) < 0) in read_blockwise()
241 alignment = get_alignment(fd); in read_blockwise()
250 r = read(fd, buf, solid); in read_blockwise()
258 r = read(fd, hangover_buf, bsize); in read_blockwise()
281 ssize_t write_lseek_blockwise(int fd, const char *buf, size_t count, off_t offset) { in write_lseek_blockwise() argument
282 int bsize = sector_size(fd); in write_lseek_blockwise()
292 lseek(fd, offset - frontHang, SEEK_SET); in write_lseek_blockwise()
294 r = read(fd,frontPadBuf,bsize); in write_lseek_blockwise()
299 lseek(fd, offset - frontHang, SEEK_SET); in write_lseek_blockwise()
300 r = write(fd,frontPadBuf,bsize); in write_lseek_blockwise()
308 return write_blockwise(fd, buf, count) + innerCount; in write_lseek_blockwise()
313 static int untimed_read(int fd, char *pass, size_t maxlen) in untimed_read() argument
317 i = read(fd, pass, maxlen); in untimed_read()
328 static int timed_read(int fd, char *pass, size_t maxlen, long timeout) in timed_read() argument
335 FD_SET(fd, &fds); in timed_read()
339 if (select(fd+1, &fds, NULL, NULL, &t) > 0) in timed_read()
340 failed = untimed_read(fd, pass, maxlen); in timed_read()
403 int fd = -1; in get_key() local
420 fd = read_stdin ? STDIN_FILENO : open(key_file, O_RDONLY); in get_key()
421 if (fd < 0) { in get_key()
427 if(isatty(fd)) { in get_key()
487 r = read(fd, pass + i, 1); in get_key()
506 if(fd != STDIN_FILENO) in get_key()
507 close(fd); in get_key()
511 if(fd >= 0 && fd != STDIN_FILENO) in get_key()
512 close(fd); in get_key()
560 int fd; in get_device_infos() local
563 fd = open(device, O_RDWR); in get_device_infos()
564 if (fd < 0) { in get_device_infos()
567 fd = open(device, O_RDONLY); in get_device_infos()
570 close(fd); in get_device_infos()
571 fd = open(device, O_RDONLY); in get_device_infos()
573 if (fd < 0) { in get_device_infos()
579 if (ioctl(fd, BLKGETSIZE64, &size) >= 0) { in get_device_infos()
587 if (ioctl(fd, BLKGETSIZE, &size_small) >= 0) { in get_device_infos()
593 if (ioctl(fd, DIOCGPART, &pinfo) >= 0) { in get_device_infos()
606 close(fd); in get_device_infos()
691 int fd; in get_topology_alignment() local
696 fd = open(device, O_RDONLY); in get_topology_alignment()
697 if (fd == -1) in get_topology_alignment()
701 if (ioctl(fd, BLKIOMIN, &min_io_size) == -1) { in get_topology_alignment()
708 if (ioctl(fd, BLKIOOPT, &opt_io_size) == -1) in get_topology_alignment()
712 if (ioctl(fd, BLKALIGNOFF, &dev_alignment_offset) == -1 || (int)dev_alignment_offset < 0) in get_topology_alignment()
726 (void)close(fd); in get_topology_alignment()