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 = TEMP_FAILURE_RETRY(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()
282 static int read_block(const MtdPartition *partition, int fd, char *data) in read_block() argument
285 if (ioctl(fd, ECCGETSTATS, &before)) { in read_block()
290 loff_t pos = TEMP_FAILURE_RETRY(lseek64(fd, 0, SEEK_CUR)); in read_block()
300 if (TEMP_FAILURE_RETRY(lseek64(fd, pos, SEEK_SET)) != pos || in read_block()
301 TEMP_FAILURE_RETRY(read(fd, data, size)) != size) { in read_block()
304 } else if (ioctl(fd, ECCGETSTATS, &after)) { in read_block()
313 } else if ((mgbb = ioctl(fd, MEMGETBADBLOCK, &pos))) { in read_block()
343 if (read_block(ctx->partition, ctx->fd, data + read)) return -1; in mtd_read_data()
353 if (read_block(ctx->partition, ctx->fd, ctx->buffer)) return -1; in mtd_read_data()
363 close(ctx->fd); in mtd_read_close()
385 ctx->fd = open(mtddevname, O_RDWR); in mtd_write_partition()
386 if (ctx->fd < 0) { in mtd_write_partition()
409 int fd = ctx->fd; in write_block() local
411 off_t pos = TEMP_FAILURE_RETRY(lseek(fd, 0, SEEK_CUR)); in write_block()
420 int ret = ioctl(fd, MEMGETBADBLOCK, &bpos); in write_block()
435 if (ioctl(fd, MEMERASE, &erase_info) < 0) { in write_block()
440 if (TEMP_FAILURE_RETRY(lseek(fd, pos, SEEK_SET)) != pos || in write_block()
441 TEMP_FAILURE_RETRY(write(fd, data, size)) != size) { in write_block()
447 if (TEMP_FAILURE_RETRY(lseek(fd, pos, SEEK_SET)) != pos || in write_block()
448 TEMP_FAILURE_RETRY(read(fd, verify, size)) != size) { in write_block()
469 ioctl(fd, MEMERASE, &erase_info); in write_block()
517 off_t pos = TEMP_FAILURE_RETRY(lseek(ctx->fd, 0, SEEK_CUR)); in mtd_erase_blocks()
533 if (ioctl(ctx->fd, MEMGETBADBLOCK, &bpos) > 0) { in mtd_erase_blocks()
542 if (ioctl(ctx->fd, MEMERASE, &erase_info) < 0) { in mtd_erase_blocks()
556 if (close(ctx->fd)) r = -1; in mtd_write_close()