Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

blockdevice

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blockdevice - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

lib/partition.js

54

lib/blockdevice.js

@@ -25,11 +25,6 @@ var os = require( 'os' )

// Heads per Track (for CHS addressing)
this.hpt = -1
this.headsPerTrack = -1
// Sectors per Track (for CHS addressing)
this.spt = -1
this.sectorsPerTrack = -1
// Make 'this.fs' non-enumerable
Object.defineProperty( this, 'fs', {
enumerable: false
})
}

@@ -45,3 +40,3 @@

'\\\\.\\PhysicalDrive' + id :
'/dev/device' + id
'/dev/disk' + id
}

@@ -81,4 +76,18 @@

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
callback.call( self, error, 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 )
})
}
})

@@ -115,3 +124,3 @@

* @param {Number} [limit=8192]
* @param {Function} callback
* @param {Function} callback( err, blockSize )
* @return {BlockDevice}

@@ -199,9 +208,10 @@ */

// console.log( 'bytes read:', bytesRead )
// console.log( 'buffer:', block )
// console.log( 'offset:', offset )
// console.log( 'step size:', step )
// console.log( 'size:', size / 1024 / 1024 / 1024, 'GB' )
if( error != null ) {
if( error != null || bytesRead !== self.blockSize ) {
// We're only interested in I/O errors,
// since they signal OOB reading, otherwise break out of loop
if( error.code !== 'EIO') {
if( error && error.code !== 'EIO') {
return callback.call( self, error, size )

@@ -239,2 +249,11 @@ }

/**
* Return a new partition
* @param {Object} options
* @return {BlockDevice.Partition}
*/
partition: function( options ) {
return new BlockDevice.Partition( this, options )
},
/**
* Converts a CHS address to an LBA

@@ -248,7 +267,7 @@ * @param {Number} cylinder

if( this.hpt < 0 || this.spt < 0 )
if( this.headsPerTrack < 0 || this.sectorsPerTrack < 0 )
throw new Error( 'Unspecified device geometry' )
return ( cylinder * this.hpt + head ) *
this.spt + ( sector - 1 )
return ( cylinder * this.headsPerTrack + head ) *
this.sectorsPerTrack + ( sector - 1 )

@@ -301,7 +320,2 @@ },

console.log( '' )
console.log( toLBA - fromLBA + ' blocks' )
console.log( 'fromLBA', fromLBA, '->', toLBA )
console.log( 'from', from, '->', to )
this.read( from, to - from, buffer, callback )

@@ -308,0 +322,0 @@

{
"name": "blockdevice",
"version": "0.1.0",
"version": "0.2.0",
"description": "Block Device",

@@ -5,0 +5,0 @@ "main": "lib/blockdevice",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc