Lines Matching refs:curlun

169 void fsg_lun_close(struct fsg_lun *curlun)  in fsg_lun_close()  argument
171 if (curlun->filp) { in fsg_lun_close()
172 LDBG(curlun, "close backing file\n"); in fsg_lun_close()
173 fput(curlun->filp); in fsg_lun_close()
174 curlun->filp = NULL; in fsg_lun_close()
179 int fsg_lun_open(struct fsg_lun *curlun, const char *filename) in fsg_lun_open() argument
192 ro = curlun->initially_ro; in fsg_lun_open()
201 LINFO(curlun, "unable to open backing file: %s\n", filename); in fsg_lun_open()
210 LINFO(curlun, "invalid file type: %s\n", filename); in fsg_lun_open()
219 LINFO(curlun, "file not readable: %s\n", filename); in fsg_lun_open()
227 LINFO(curlun, "unable to find file size: %s\n", filename); in fsg_lun_open()
232 if (curlun->cdrom) { in fsg_lun_open()
245 if (curlun->cdrom) { in fsg_lun_open()
249 LINFO(curlun, "file too big: %s\n", filename); in fsg_lun_open()
250 LINFO(curlun, "using only first %d blocks\n", in fsg_lun_open()
255 LINFO(curlun, "file too small: %s\n", filename); in fsg_lun_open()
260 if (fsg_lun_is_open(curlun)) in fsg_lun_open()
261 fsg_lun_close(curlun); in fsg_lun_open()
263 curlun->blksize = blksize; in fsg_lun_open()
264 curlun->blkbits = blkbits; in fsg_lun_open()
265 curlun->ro = ro; in fsg_lun_open()
266 curlun->filp = filp; in fsg_lun_open()
267 curlun->file_length = size; in fsg_lun_open()
268 curlun->num_sectors = num_sectors; in fsg_lun_open()
269 LDBG(curlun, "open backing file: %s\n", filename); in fsg_lun_open()
285 int fsg_lun_fsync_sub(struct fsg_lun *curlun) in fsg_lun_fsync_sub() argument
287 struct file *filp = curlun->filp; in fsg_lun_fsync_sub()
289 if (curlun->ro || !filp) in fsg_lun_fsync_sub()
319 ssize_t fsg_show_ro(struct fsg_lun *curlun, char *buf) in fsg_show_ro() argument
321 return sprintf(buf, "%d\n", fsg_lun_is_open(curlun) in fsg_show_ro()
322 ? curlun->ro in fsg_show_ro()
323 : curlun->initially_ro); in fsg_show_ro()
327 ssize_t fsg_show_nofua(struct fsg_lun *curlun, char *buf) in fsg_show_nofua() argument
329 return sprintf(buf, "%u\n", curlun->nofua); in fsg_show_nofua()
333 ssize_t fsg_show_file(struct fsg_lun *curlun, struct rw_semaphore *filesem, in fsg_show_file() argument
340 if (fsg_lun_is_open(curlun)) { /* Get the complete pathname */ in fsg_show_file()
341 p = file_path(curlun->filp, buf, PAGE_SIZE - 1); in fsg_show_file()
359 ssize_t fsg_show_cdrom(struct fsg_lun *curlun, char *buf) in fsg_show_cdrom() argument
361 return sprintf(buf, "%u\n", curlun->cdrom); in fsg_show_cdrom()
365 ssize_t fsg_show_removable(struct fsg_lun *curlun, char *buf) in fsg_show_removable() argument
367 return sprintf(buf, "%u\n", curlun->removable); in fsg_show_removable()
371 ssize_t fsg_show_inquiry_string(struct fsg_lun *curlun, char *buf) in fsg_show_inquiry_string() argument
373 return sprintf(buf, "%s\n", curlun->inquiry_string); in fsg_show_inquiry_string()
380 static ssize_t _fsg_store_ro(struct fsg_lun *curlun, bool ro) in _fsg_store_ro() argument
382 if (fsg_lun_is_open(curlun)) { in _fsg_store_ro()
383 LDBG(curlun, "read-only status change prevented\n"); in _fsg_store_ro()
387 curlun->ro = ro; in _fsg_store_ro()
388 curlun->initially_ro = ro; in _fsg_store_ro()
389 LDBG(curlun, "read-only status set to %d\n", curlun->ro); in _fsg_store_ro()
394 ssize_t fsg_store_ro(struct fsg_lun *curlun, struct rw_semaphore *filesem, in fsg_store_ro() argument
409 rc = _fsg_store_ro(curlun, ro); in fsg_store_ro()
418 ssize_t fsg_store_nofua(struct fsg_lun *curlun, const char *buf, size_t count) in fsg_store_nofua() argument
428 if (!nofua && curlun->nofua) in fsg_store_nofua()
429 fsg_lun_fsync_sub(curlun); in fsg_store_nofua()
431 curlun->nofua = nofua; in fsg_store_nofua()
437 ssize_t fsg_store_file(struct fsg_lun *curlun, struct rw_semaphore *filesem, in fsg_store_file() argument
442 if (curlun->prevent_medium_removal && fsg_lun_is_open(curlun)) { in fsg_store_file()
443 LDBG(curlun, "eject attempt prevented\n"); in fsg_store_file()
455 rc = fsg_lun_open(curlun, buf); in fsg_store_file()
457 curlun->unit_attention_data = in fsg_store_file()
459 } else if (fsg_lun_is_open(curlun)) { in fsg_store_file()
460 fsg_lun_close(curlun); in fsg_store_file()
461 curlun->unit_attention_data = SS_MEDIUM_NOT_PRESENT; in fsg_store_file()
468 ssize_t fsg_store_cdrom(struct fsg_lun *curlun, struct rw_semaphore *filesem, in fsg_store_cdrom() argument
479 ret = cdrom ? _fsg_store_ro(curlun, true) : 0; in fsg_store_cdrom()
482 curlun->cdrom = cdrom; in fsg_store_cdrom()
491 ssize_t fsg_store_removable(struct fsg_lun *curlun, const char *buf, in fsg_store_removable() argument
501 curlun->removable = removable; in fsg_store_removable()
507 ssize_t fsg_store_inquiry_string(struct fsg_lun *curlun, const char *buf, in fsg_store_inquiry_string() argument
510 const size_t len = min(count, sizeof(curlun->inquiry_string)); in fsg_store_inquiry_string()
513 curlun->inquiry_string[0] = 0; in fsg_store_inquiry_string()
515 snprintf(curlun->inquiry_string, in fsg_store_inquiry_string()
516 sizeof(curlun->inquiry_string), "%-28s", buf); in fsg_store_inquiry_string()
517 if (curlun->inquiry_string[len-1] == '\n') in fsg_store_inquiry_string()
518 curlun->inquiry_string[len-1] = ' '; in fsg_store_inquiry_string()
525 ssize_t fsg_store_forced_eject(struct fsg_lun *curlun, struct rw_semaphore *filesem, in fsg_store_forced_eject() argument
534 curlun->prevent_medium_removal = 0; in fsg_store_forced_eject()
535 ret = fsg_store_file(curlun, filesem, "", 0); in fsg_store_forced_eject()