Lines Matching refs:fd
42 int fd; member
49 int fd; member
75 int fd; in mtd_scan_partitions() local
107 fd = open(MTD_PROC_FILENAME, O_RDONLY); in mtd_scan_partitions()
108 if (fd < 0) { in mtd_scan_partitions()
111 nbytes = read(fd, buf, sizeof(buf) - 1); in mtd_scan_partitions()
112 close(fd); in mtd_scan_partitions()
243 int fd = open(mtddevname, O_RDONLY); in mtd_partition_info() local
244 if (fd < 0) return -1; in mtd_partition_info()
247 int ret = ioctl(fd, MEMGETINFO, &mtd_info); in mtd_partition_info()
248 close(fd); in mtd_partition_info()
270 ctx->fd = open(mtddevname, O_RDONLY); in mtd_read_partition()
271 if (ctx->fd < 0) { in mtd_read_partition()
285 lseek64(ctx->fd, offset, SEEK_SET); in mtd_read_skip_to()
288 static int read_block(const MtdPartition *partition, int fd, char *data) in read_block() argument
291 if (ioctl(fd, ECCGETSTATS, &before)) { in read_block()
296 loff_t pos = lseek64(fd, 0, SEEK_CUR); in read_block()
302 if (lseek64(fd, pos, SEEK_SET) != pos || read(fd, data, size) != size) { in read_block()
305 } else if (ioctl(fd, ECCGETSTATS, &after)) { in read_block()
314 } else if ((mgbb = ioctl(fd, MEMGETBADBLOCK, &pos))) { in read_block()
344 if (read_block(ctx->partition, ctx->fd, data + read)) return -1; in mtd_read_data()
354 if (read_block(ctx->partition, ctx->fd, ctx->buffer)) return -1; in mtd_read_data()
364 close(ctx->fd); in mtd_read_close()
386 ctx->fd = open(mtddevname, O_RDWR); in mtd_write_partition()
387 if (ctx->fd < 0) { in mtd_write_partition()
410 int fd = ctx->fd; in write_block() local
412 off_t pos = lseek(fd, 0, SEEK_CUR); in write_block()
418 int ret = ioctl(fd, MEMGETBADBLOCK, &bpos); in write_block()
433 if (ioctl(fd, MEMERASE, &erase_info) < 0) { in write_block()
438 if (lseek(fd, pos, SEEK_SET) != pos || in write_block()
439 write(fd, data, size) != size) { in write_block()
445 if (lseek(fd, pos, SEEK_SET) != pos || in write_block()
446 read(fd, verify, size) != size) { in write_block()
467 ioctl(fd, MEMERASE, &erase_info); in write_block()
515 off_t pos = lseek(ctx->fd, 0, SEEK_CUR); in mtd_erase_blocks()
528 if (ioctl(ctx->fd, MEMGETBADBLOCK, &bpos) > 0) { in mtd_erase_blocks()
537 if (ioctl(ctx->fd, MEMERASE, &erase_info) < 0) { in mtd_erase_blocks()
551 if (close(ctx->fd)) r = -1; in mtd_write_close()