int raw_freopen(AFFILE *af,FILE *file) { af->fname = 0; af->vnodeprivate = (void *)calloc(1,sizeof(struct raw_private)); struct raw_private *rp = RAW_PRIVATE(af); rp->raw = file; af->image_size = raw_filesize(af); af->image_pagesize = RAW_PAGESIZE; af->cur_page = 0; return 0; }
static int raw_open(AFFILE *af) { /* Raw is the passthrough system. * Right now, it is read only... */ af->vnodeprivate = (void *)calloc(1,sizeof(struct raw_private)); struct raw_private *rp = RAW_PRIVATE(af); if(af->fname) rp->raw=fopen(af->fname,"rb"); af->image_size = raw_filesize(af); af->image_pagesize = RAW_PAGESIZE; rp->cur_page = 0; return 0; }
static int raw_open(AFFILE *af) { /* Raw is the passthrough system. * Right now, it is read only... */ const char *mode = "rb"; if(af->openflags && (O_RDWR | O_WRONLY)) mode = "r+b"; af->vnodeprivate = (void *)calloc(1,sizeof(struct raw_private)); struct raw_private *rp = RAW_PRIVATE(af); if(af->fname) rp->raw=fopen(af->fname,mode); if(rp->raw==0) return -1; // raw open failed af->image_size = raw_filesize(af); af->image_pagesize = RAW_PAGESIZE; af->cur_page = 0; return 0; }
static int raw_open(AFFILE *af) { /* Raw is the passthrough system. */ int fd = open(af->fname, af->openflags | O_BINARY, af->openmode); if(fd < 0) return -1; FILE *file = fdopen(fd, (af->openflags & (O_RDWR | O_WRONLY)) ? "r+b" : "rb"); if(!file) { close(fd); return -1; } af->vnodeprivate = (void *)calloc(1,sizeof(struct raw_private)); struct raw_private *rp = RAW_PRIVATE(af); rp->raw = file; af->image_size = raw_filesize(af); af->image_pagesize = RAW_PAGESIZE; af->cur_page = 0; return 0; }