src/stored/device.c
bool first_open_device(DCR *dcr)
{
   DEVICE *dev = dcr->dev;
   bool ok = true;

   Dmsg0(120, "start open_output_device()\n");
   if (!dev) {
      return false;
   }

   dev->rLock(false);

   /* Defer opening files */
   if (!dev->is_tape()) {
      Dmsg0(129, "Device is file, deferring open.\n");
      goto bail_out;
   }

   Dmsg0(129, "Opening device.\n");
   if (!dev->open_device(dcr, OPEN_READ_ONLY)) {
      Jmsg1(NULL, M_FATAL, 0, _("dev open failed: %s\n"), dev->errmsg);
      ok = false;
      goto bail_out;
   }
   Dmsg1(129, "open dev %s OK\n", dev->print_name());

bail_out:
   dev->rUnlock();
   return ok;
}
/*
 *   First Open of the device. Expect dev to already be initialized.
 *
 *   This routine is used only when the Storage daemon starts
 *   and always_open is set, and in the stand-alone utility
 *   routines such as bextract.
 *
 *   Note, opening of a normal file is deferred to later so
 *    that we can get the filename; the device_name for
 *    a file is the directory only.
 *
 *   Returns: false on failure
 *            true  on success
 */
First Open of the device. Expect dev to already be initialized.
This routine is used only when the Storage daemon starts
and always_open is set, and in the stand-alone utility
routines such as bextract.

Note, opening of a normal file is deferred to later so
that we can get the filename; the device_name for
a file is the directory only.

false on failure
true  on success
First Open of the device . Expect dev to already be initialized . This routine is used only when the Storage daemon starts and always_open is set and in the stand - alone utility routines such as bextract . Note opening of a normal file is deferred to later so that we can get the filename ; the device_name for a file is the directory only . false on failure true on success
bool first_open_device(DCR *dcr)
{
   DEVICE *dev = dcr->dev;
   bool ok = true;
   Dmsg0(120, "start open_output_device()\n");
   if (!dev) {
      return false;
   }
   dev->rLock(false);
   if (!dev->is_tape()) {
      Dmsg0(129, "Device is file, deferring open.\n");
      goto bail_out;
   }
   Dmsg0(129, "Opening device.\n");
   if (!dev->open_device(dcr, OPEN_READ_ONLY)) {
      Jmsg1(NULL, M_FATAL, 0, _("dev open failed: %s\n"), dev->errmsg);
      ok = false;
      goto bail_out;
   }
   Dmsg1(129, "open dev %s OK\n", dev->print_name());
bail_out:
   dev->rUnlock();
   return ok;
}
bool first_open_device ( DCR * dcr ) { DEVICE * dev = dcr -> dev ; bool ok = true ; Dmsg0 ( 120 , " \n " ) ; if ( ! dev ) { return false ; } dev -> rLock ( false ) ; if ( ! dev -> is_tape ( ) ) { Dmsg0 ( 129 , " \n " ) ; goto bail_out ; } Dmsg0 ( 129 , " \n " ) ; if ( ! dev -> open_device ( dcr , OPEN_READ_ONLY ) ) { Jmsg1 ( NULL , M_FATAL , 0 , _ ( " \n " ) , dev -> errmsg ) ; ok = false ; goto bail_out ; } Dmsg1 ( 129 , " \n " , dev -> print_name ( ) ) ; bail_out : dev -> rUnlock ( ) ; return ok ; }
First Open of the device.
First Open of the device .
/* Defer opening files */