🚀 Launch Week Day 5:Introducing Immutable Scans.Learn More →
Socket
Book a DemoInstallSign in
Socket

fuse-block-device

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fuse-block-device

A virtual block device backed by FUSE

latest
Source
npmnpm
Version
1.2.1
Version published
Maintainers
1
Created
Source

fuse-block-device

A virtual block device backed by FUSE

npm install fuse-block-device

Usage

const blockDevice = require('fuse-block-device')

const device = blockDevice('./mnt/4gb', {
  read (index, blocks, buffer, cb) {
    // Read {blocks} x 512 blocks into {buffer} from some storage
    cb(null)
  },
  write (index, blocks, buffer, cb) {
    // Store {blocks} x 512 from {buffer} into some storage
    cb(null)
  }
})

You can use a block device to create various file systems on top.

Try running the example from the repo (that implements an in-memory block device) and make an ext4 file system on top:

# cd fuse-block-device
node example.js
# in another shell in the same folder
mkfs.ext4 ./mnt/4gb # creates an ext4 file system on the block device \o/

API

const device = blockDevice(mountPoint, [options])

Create a new virtual block device.

Options include

{
  size: fixedFixedOfTheDevice, // must be divisable by 512
  read: (index, blockCount, buffer, cb), // called when the device wants to read blocks
  write: (index, blockCount, buffer, cb), // called when the device wants to write blocks
  mount: (), // called when the device is fully mounted
  error: (err), // called if the device experienced an error during mount
  uid: process.getuid(), // optionally set the uid of the block device
  gid: process.getgid(), // optionally set the gid of the block device
  options: [ ... ], // fuse mount options that are forwarded
}

Each stored block is 512 bytes, but note that your write/read method might be called with more than one block at the time.

device.close([callback])

Fully close the block device. You should call this before shutting down the program to nicely unmount it first.

device.open([callback])

Optionally you can call this to be notificed when the device is mounted.

License

MIT

FAQs

Package last updated on 31 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts