https://github.com/jhermsmeier/node-chs
Cylinder-Head-Sector Address
https://github.com/jhermsmeier/node-chs
block-device chs disk mbr
Last synced: 5 months ago
JSON representation
Cylinder-Head-Sector Address
- Host: GitHub
- URL: https://github.com/jhermsmeier/node-chs
- Owner: jhermsmeier
- License: mit
- Created: 2014-01-06T06:11:32.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-06-21T00:25:46.000Z (almost 8 years ago)
- Last Synced: 2025-01-06T03:32:10.957Z (5 months ago)
- Topics: block-device, chs, disk, mbr
- Language: JavaScript
- Size: 43 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# CHS (Cylinder-Head-Sector) Address
[](https://npmjs.com/package/chs)
[](https://npmjs.com/package/chs)
[](https://npmjs.com/package/chs)
[](https://travis-ci.org/jhermsmeier/node-chs)[CHS addressing] is an early method for giving addresses to each physical block of data on a hard disk drive,
identifying individual sectors on a disk by their position in a track, where the track is determined by the head and cylinder numbers.[CHS addressing]: https://en.wikipedia.org/wiki/Cylinder-head-sector
# Install via [npm](https://npmjs.com)
```sh
$ npm install --save chs
```# Usage
```js
// Load module
var CHS = require( 'chs' )
```
```js
// Create a CHS address
var addr = new CHS( 5, 20, 8 )
```
```js
// Properties:
var c = addr.cylinder
var h = addr.head
var s = addr.sector
```
```js
// Convert to an LBA (Logical Block Address)
var lba = addr.toLBA( headsPerTrack, sectorsPerTrack )
var lba = addr.toLBA( 12, 32 )
```
```js
// Set it to an LBA
addr.setLBA( lba, headsPerTrack, sectorsPerTrack )
addr.setLBA( 3150, 16, 63 )
```
```js
// Get it as a buffer
var buf = addr.buffer
var buf = addr.toBuffer()
```
```js
// Set from buffer
addr.buffer = new Buffer([ 0xFE, 0xFF, 0xFF ])
addr.parse( new Buffer([ 0xFE, 0xFF, 0xFF ]) )
```## CHS
**Kind**: global class* [CHS](#CHS)
* [new CHS([cylinder], [head], [sector])](#new_CHS_new)
* _instance_
* [.cylinder](#CHS+cylinder) :Number
* [.head](#CHS+head) :Number
* [.sector](#CHS+sector) :Number
* [.buffer](#CHS+buffer) :Buffer
* [.setLBA(lba, hpt, spt)](#CHS+setLBA) ⇒ [CHS
](#CHS)
* [.getLBA(hpt, spt)](#CHS+getLBA) ⇒Number
* [.toLBA(hpt, spt)](#CHS+toLBA) ⇒Number
* [.clone()](#CHS+clone) ⇒ [CHS
](#CHS)
* [.copy(target)](#CHS+copy) ⇒ [CHS
](#CHS)
* [.parse(buffer, [offset])](#CHS+parse) ⇒ [CHS
](#CHS)
* [.write(buffer, [offset])](#CHS+write) ⇒Buffer
* [.toBuffer()](#CHS+toBuffer) ⇒Buffer
* [.fromNumber(value)](#CHS+fromNumber) ⇒ [CHS
](#CHS)
* [.toNumber()](#CHS+toNumber) ⇒Number
* _static_
* [.fromBuffer(buffer, [offset])](#CHS.fromBuffer) ⇒ [CHS
](#CHS)
* [.fromLBA(lba, hpt, spt)](#CHS.fromLBA) ⇒ [CHS
](#CHS)* * *
### new CHS([cylinder], [head], [sector])
Cylinder-Head-Sector Address**Params**
- [cylinder]
Number
|Buffer
= 1023
- [head]Number
= 254
- [sector]Number
= 63
* * *
### chS.cylinder :
Number
Cylinder**Kind**: instance property of [
CHS
](#CHS)* * *
### chS.head :
Number
Head**Kind**: instance property of [
CHS
](#CHS)* * *
### chS.sector :
Number
Sector**Kind**: instance property of [
CHS
](#CHS)* * *
### chS.buffer :
Buffer
Get/set values from/to a Buffer**Kind**: instance property of [
CHS
](#CHS)* * *
### chS.setLBA(lba, hpt, spt) ⇒ [
CHS
](#CHS)
Set CHS to a Logical Block Address (LBA)**Kind**: instance method of [
CHS
](#CHS)
**Params**- lba
Number
- Logical Block Address
- hptNumber
- Heads per Track
- sptNumber
- Sectors per Track* * *
### chS.getLBA(hpt, spt) ⇒
Number
Get the Logical Block Address (LBA)
corresponding to the given disk geometry**Kind**: instance method of [
CHS
](#CHS)
**Returns**:Number
- lba
**Params**- hpt
Number
- Heads per Track
- sptNumber
- Sectors per Track* * *
### chS.toLBA(hpt, spt) ⇒
Number
**Kind**: instance method of [CHS
](#CHS)
**Returns**:Number
- lba
**See**: #getLBA()
**Params**- hpt
Number
- Heads per Track
- sptNumber
- Sectors per Track* * *
### chS.clone() ⇒ [
CHS
](#CHS)
Clone the CHS Address**Kind**: instance method of [
CHS
](#CHS)* * *
### chS.copy(target) ⇒ [
CHS
](#CHS)
Copy this address to a target address**Kind**: instance method of [
CHS
](#CHS)
**Params**- target [
CHS
](#CHS)* * *
### chS.parse(buffer, [offset]) ⇒ [
CHS
](#CHS)
Parse a given Buffer**Kind**: instance method of [
CHS
](#CHS)
**Params**- buffer
Buffer
- [offset]Number
= 0
* * *
### chS.write(buffer, [offset]) ⇒
Buffer
Write the CHS address to a given buffer**Kind**: instance method of [
CHS
](#CHS)
**Params**- buffer
Buffer
- [offset]Number
= 0
* * *
### chS.toBuffer() ⇒
Buffer
Create a Buffer representation of the CHS Address**Kind**: instance method of [
CHS
](#CHS)* * *
### chS.fromNumber(value) ⇒ [
CHS
](#CHS)
Set the CHS address from its 24bit integer value**Kind**: instance method of [
CHS
](#CHS)
**Params**- value
Number
* * *
### chS.toNumber() ⇒
Number
Get the 24bit integer value of the CHS address**Kind**: instance method of [
CHS
](#CHS)* * *
### CHS.fromBuffer(buffer, [offset]) ⇒ [
CHS
](#CHS)
Create a CHS Address from a given buffer**Kind**: static method of [
CHS
](#CHS)
**Params**- buffer
Buffer
- [offset]Number
= 0
* * *
### CHS.fromLBA(lba, hpt, spt) ⇒ [
CHS
](#CHS)
Create a CHS Address from a Logical Block Address (LBA)**Kind**: static method of [
CHS
](#CHS)
**Params**- lba
Number
- Logical Block Address
- hptNumber
- Heads per Track
- sptNumber
- Sectors per Track* * *