Lines Matching refs:curlun

168 void fsg_lun_close(struct fsg_lun *curlun)  in fsg_lun_close()  argument
170 if (curlun->filp) { in fsg_lun_close()
171 LDBG(curlun, "close backing file\n"); in fsg_lun_close()
172 fput(curlun->filp); in fsg_lun_close()
173 curlun->filp = NULL; in fsg_lun_close()
178 int fsg_lun_open(struct fsg_lun *curlun, const char *filename) in fsg_lun_open() argument
191 ro = curlun->initially_ro; in fsg_lun_open()
200 LINFO(curlun, "unable to open backing file: %s\n", filename); in fsg_lun_open()
209 LINFO(curlun, "invalid file type: %s\n", filename); in fsg_lun_open()
218 LINFO(curlun, "file not readable: %s\n", filename); in fsg_lun_open()
226 LINFO(curlun, "unable to find file size: %s\n", filename); in fsg_lun_open()
231 if (curlun->cdrom) { in fsg_lun_open()
244 if (curlun->cdrom) { in fsg_lun_open()
248 LINFO(curlun, "file too big: %s\n", filename); in fsg_lun_open()
249 LINFO(curlun, "using only first %d blocks\n", in fsg_lun_open()
254 LINFO(curlun, "file too small: %s\n", filename); in fsg_lun_open()
259 if (fsg_lun_is_open(curlun)) in fsg_lun_open()
260 fsg_lun_close(curlun); in fsg_lun_open()
262 curlun->blksize = blksize; in fsg_lun_open()
263 curlun->blkbits = blkbits; in fsg_lun_open()
264 curlun->ro = ro; in fsg_lun_open()
265 curlun->filp = filp; in fsg_lun_open()
266 curlun->file_length = size; in fsg_lun_open()
267 curlun->num_sectors = num_sectors; in fsg_lun_open()
268 LDBG(curlun, "open backing file: %s\n", filename); in fsg_lun_open()
284 int fsg_lun_fsync_sub(struct fsg_lun *curlun) in fsg_lun_fsync_sub() argument
286 struct file *filp = curlun->filp; in fsg_lun_fsync_sub()
288 if (curlun->ro || !filp) in fsg_lun_fsync_sub()
318 ssize_t fsg_show_ro(struct fsg_lun *curlun, char *buf) in fsg_show_ro() argument
320 return sprintf(buf, "%d\n", fsg_lun_is_open(curlun) in fsg_show_ro()
321 ? curlun->ro in fsg_show_ro()
322 : curlun->initially_ro); in fsg_show_ro()
326 ssize_t fsg_show_nofua(struct fsg_lun *curlun, char *buf) in fsg_show_nofua() argument
328 return sprintf(buf, "%u\n", curlun->nofua); in fsg_show_nofua()
332 ssize_t fsg_show_file(struct fsg_lun *curlun, struct rw_semaphore *filesem, in fsg_show_file() argument
339 if (fsg_lun_is_open(curlun)) { /* Get the complete pathname */ in fsg_show_file()
340 p = file_path(curlun->filp, buf, PAGE_SIZE - 1); in fsg_show_file()
358 ssize_t fsg_show_cdrom(struct fsg_lun *curlun, char *buf) in fsg_show_cdrom() argument
360 return sprintf(buf, "%u\n", curlun->cdrom); in fsg_show_cdrom()
364 ssize_t fsg_show_removable(struct fsg_lun *curlun, char *buf) in fsg_show_removable() argument
366 return sprintf(buf, "%u\n", curlun->removable); in fsg_show_removable()
370 ssize_t fsg_show_inquiry_string(struct fsg_lun *curlun, char *buf) in fsg_show_inquiry_string() argument
372 return sprintf(buf, "%s\n", curlun->inquiry_string); in fsg_show_inquiry_string()
379 static ssize_t _fsg_store_ro(struct fsg_lun *curlun, bool ro) in _fsg_store_ro() argument
381 if (fsg_lun_is_open(curlun)) { in _fsg_store_ro()
382 LDBG(curlun, "read-only status change prevented\n"); in _fsg_store_ro()
386 curlun->ro = ro; in _fsg_store_ro()
387 curlun->initially_ro = ro; in _fsg_store_ro()
388 LDBG(curlun, "read-only status set to %d\n", curlun->ro); in _fsg_store_ro()
393 ssize_t fsg_store_ro(struct fsg_lun *curlun, struct rw_semaphore *filesem, in fsg_store_ro() argument
408 rc = _fsg_store_ro(curlun, ro); in fsg_store_ro()
417 ssize_t fsg_store_nofua(struct fsg_lun *curlun, const char *buf, size_t count) in fsg_store_nofua() argument
427 if (!nofua && curlun->nofua) in fsg_store_nofua()
428 fsg_lun_fsync_sub(curlun); in fsg_store_nofua()
430 curlun->nofua = nofua; in fsg_store_nofua()
436 ssize_t fsg_store_file(struct fsg_lun *curlun, struct rw_semaphore *filesem, in fsg_store_file() argument
441 if (curlun->prevent_medium_removal && fsg_lun_is_open(curlun)) { in fsg_store_file()
442 LDBG(curlun, "eject attempt prevented\n"); in fsg_store_file()
454 rc = fsg_lun_open(curlun, buf); in fsg_store_file()
456 curlun->unit_attention_data = in fsg_store_file()
458 } else if (fsg_lun_is_open(curlun)) { in fsg_store_file()
459 fsg_lun_close(curlun); in fsg_store_file()
460 curlun->unit_attention_data = SS_MEDIUM_NOT_PRESENT; in fsg_store_file()
467 ssize_t fsg_store_cdrom(struct fsg_lun *curlun, struct rw_semaphore *filesem, in fsg_store_cdrom() argument
478 ret = cdrom ? _fsg_store_ro(curlun, true) : 0; in fsg_store_cdrom()
481 curlun->cdrom = cdrom; in fsg_store_cdrom()
490 ssize_t fsg_store_removable(struct fsg_lun *curlun, const char *buf, in fsg_store_removable() argument
500 curlun->removable = removable; in fsg_store_removable()
506 ssize_t fsg_store_inquiry_string(struct fsg_lun *curlun, const char *buf, in fsg_store_inquiry_string() argument
509 const size_t len = min(count, sizeof(curlun->inquiry_string)); in fsg_store_inquiry_string()
512 curlun->inquiry_string[0] = 0; in fsg_store_inquiry_string()
514 snprintf(curlun->inquiry_string, in fsg_store_inquiry_string()
515 sizeof(curlun->inquiry_string), "%-28s", buf); in fsg_store_inquiry_string()
516 if (curlun->inquiry_string[len-1] == '\n') in fsg_store_inquiry_string()
517 curlun->inquiry_string[len-1] = ' '; in fsg_store_inquiry_string()
524 ssize_t fsg_store_forced_eject(struct fsg_lun *curlun, struct rw_semaphore *filesem, in fsg_store_forced_eject() argument
533 curlun->prevent_medium_removal = 0; in fsg_store_forced_eject()
534 ret = fsg_store_file(curlun, filesem, "", 0); in fsg_store_forced_eject()