lib/blockdevice.js
function( callback ) {

    var self = this

    // Close a previously opened handle
    if( this.fd != null ) {
      return this.close( function( error ) {
        if( error != null )
          return callback.call( self, error )
        self.open( callback )
      })
    }

    // Open a new fd handle
    debug( 'fs:open', this.mode, this.path )
    this.fs.open( this.path, this.mode, function( error, fd ) {

      if( error != null )
        return callback.call( self, error, fd )

      // Set file descriptor
      self.fd = fd

      // If no blockSize has been set, attempt to
      // detect it after opening the device
      if( self.blockSize == null || self.blockSize <= 0 ) {
        self.detectBlockSize( 0, 0, 0, function( error, blockSize ) {
          self.blockSize = blockSize || -1
          callback.call( self, error, self.fd )
        })
      } else {
        callback.call( self, error, fd )
      }

    })

    return this

  }
function( callback ) {

    var self = this

    // Close a previously opened handle
    if( this.fd != null ) {
      return this.close( function( error ) {
        if( error != null )
          return callback.call( self, error )
        self.open( callback )
      })
    }

    // Open a new fd handle
    debug( 'fs:open', this.mode, this.path )
    this.fs.open( this.path, this.mode, function( error, fd ) {

      if( error != null )
        return callback.call( self, error, fd )

      // Set file descriptor
      self.fd = fd

      // If no blockSize has been set, attempt to
      // detect it after opening the device
      if( self.blockSize == null || self.blockSize <= 0 ) {
        self.detectBlockSize( 0, 0, 0, function( error, blockSize ) {
          self.blockSize = blockSize || -1
          callback.call( self, error, self.fd )
        })
      } else {
        callback.call( self, error, fd )
      }

    })

    return this

  }
function ( callback ) { var self = this // Close a previously opened handle if ( this . fd != null ) { return this . close ( function ( error ) { if ( error != null ) return callback . call ( self , error ) self . open ( callback ) } ) } // Open a new fd handle debug ( 'fs:open' , this . mode , this . path ) this . fs . open ( this . path , this . mode , function ( error , fd ) { if ( error != null ) return callback . call ( self , error , fd ) // Set file descriptor self . fd = fd // If no blockSize has been set, attempt to // detect it after opening the device if ( self . blockSize == null || self . blockSize <= 0 ) { self . detectBlockSize ( 0 , 0 , 0 , function ( error , blockSize ) { self . blockSize = blockSize || - 1 callback . call ( self , error , self . fd ) } ) } else { callback . call ( self , error , fd ) } } ) return this }
Opens a file descriptor for this device
@param {Function} callback
@return {BlockDevice}
Opens a file descriptor for this device