458 minor = getminor(*devp);
459
460 /* master control device */
461 if (minor == 0) {
462 mutex_exit(&lofi_lock);
463 return (0);
464 }
465
466 /* otherwise, the mapping should already exist */
467 lsp = ddi_get_soft_state(lofi_statep, minor);
468 if (lsp == NULL) {
469 mutex_exit(&lofi_lock);
470 return (EINVAL);
471 }
472
473 if (lsp->ls_vp == NULL) {
474 mutex_exit(&lofi_lock);
475 return (ENXIO);
476 }
477
478 if (mark_opened(lsp, otyp) == -1) {
479 mutex_exit(&lofi_lock);
480 return (EINVAL);
481 }
482
483 if (lsp->ls_readonly && (flag & FWRITE)) {
484 mutex_exit(&lofi_lock);
485 return (EROFS);
486 }
487
488 mutex_exit(&lofi_lock);
489 return (0);
490 }
491
492 /*ARGSUSED*/
493 static int
494 lofi_close(dev_t dev, int flag, int otyp, struct cred *credp)
495 {
496 minor_t minor;
497 struct lofi_state *lsp;
498
499 mutex_enter(&lofi_lock);
500 minor = getminor(dev);
501 lsp = ddi_get_soft_state(lofi_statep, minor);
502 if (lsp == NULL) {
503 mutex_exit(&lofi_lock);
504 return (EINVAL);
505 }
|
458 minor = getminor(*devp);
459
460 /* master control device */
461 if (minor == 0) {
462 mutex_exit(&lofi_lock);
463 return (0);
464 }
465
466 /* otherwise, the mapping should already exist */
467 lsp = ddi_get_soft_state(lofi_statep, minor);
468 if (lsp == NULL) {
469 mutex_exit(&lofi_lock);
470 return (EINVAL);
471 }
472
473 if (lsp->ls_vp == NULL) {
474 mutex_exit(&lofi_lock);
475 return (ENXIO);
476 }
477
478 if (lsp->ls_readonly && (flag & FWRITE)) {
479 mutex_exit(&lofi_lock);
480 return (EROFS);
481 }
482
483 if (mark_opened(lsp, otyp) == -1) {
484 mutex_exit(&lofi_lock);
485 return (EINVAL);
486 }
487
488 mutex_exit(&lofi_lock);
489 return (0);
490 }
491
492 /*ARGSUSED*/
493 static int
494 lofi_close(dev_t dev, int flag, int otyp, struct cred *credp)
495 {
496 minor_t minor;
497 struct lofi_state *lsp;
498
499 mutex_enter(&lofi_lock);
500 minor = getminor(dev);
501 lsp = ddi_get_soft_state(lofi_statep, minor);
502 if (lsp == NULL) {
503 mutex_exit(&lofi_lock);
504 return (EINVAL);
505 }
|