int fsimage_open(disk_image_t *image) { fsimage_t *fsimage; fsimage = image->media.fsimage; fsimage->error_info.map = NULL; if (image->read_only) { fsimage->fd = zfile_fopen(fsimage->name, MODE_READ); } else { fsimage->fd = zfile_fopen(fsimage->name, MODE_READ_WRITE); /* If we cannot open the image read/write, try to open it read only. */ if (fsimage->fd == NULL) { fsimage->fd = zfile_fopen(fsimage->name, MODE_READ); image->read_only = 1; } } if (fsimage->fd == NULL) { log_error(fsimage_log, "Cannot open file `%s'.", fsimage->name); return -1; } if (fsimage_probe(image) == 0) { return 0; } log_message(fsimage_log, "Unknown disk image `%s'.", fsimage->name); fsimage_close(image); return -1; }
int fsimage_open(disk_image_t *image) { fsimage_t *fsimage; fsimage = image->media.fsimage; if (image->read_only) { fsimage->fd = zfile_fopen(fsimage->name, MODE_READ); } else { fsimage->fd = zfile_fopen(fsimage->name, MODE_READ_WRITE); /* If we cannot open the image read/write, try to open it read only. */ if (fsimage->fd == NULL) { fsimage->fd = zfile_fopen(fsimage->name, MODE_READ); image->read_only = 1; } } if (fsimage->fd == NULL) { #ifdef CELL_DEBUG printf("INFO: Cannot open file `%s'.\n", fsimage->name); #endif return -1; } if (fsimage_probe(image) == 0) return 0; zfile_fclose(fsimage->fd); #ifdef CELL_DEBUG printf("ERROR: Unknown disk image `%s'.\n", fsimage->name); #endif return -1; }