Losetup library for node.js.
Allows attaching, detaching, and listing loop devices in a Linux system.
$ npm install losetup
- losetup.LoopDevice
- losetup.errors
- losetup.isLoopDevice(path)
- losetup.getLoopDevice(path)
- losetup.listAll(path = "/dev")
- losetup.listUsed(path = "/dev")
- losetup.findUnused(path = "/dev/")
- losetup.attach(loopDevice, path, opts = {})
- losetup.detach(loopDevice)
- losetup.reloadPartitionTable(loopDevice)
Class describing a loop device.
Properties:
Contains all the exported error classes:
- LosetupError: All errors inherit from this class.
- NotLoopDeviceError: The device is not a loop device.
- LoopDeviceBusyError: The device is busy (already attached).
- LoopDeviceNotUsedError: The device was expected to be attached, but isn't.
- LoopDeviceNotFoundError: The device does not exist at all.
Promise resolves to true if path is a loop device.
Resolves to a LoopDevice describing the device in path.
Resolves to a list of LoopDevice for all the loop devices in path.
List all the loop devices in path that are currently attached to a file.
Finds the first loop device in path that is currently not used.
Attaches the loop device dev to the file in path.
Result promise resolves to an updated loop device description. Does not alter the input object.
The third argument defines additional options:
- partscan: Enable partition scanning on device. Boolean, defaults to false.
- offset: Attach to an offset in the file, in bytes. Number, defaults to 0.
Detaches any files from loop device dev.
Result promise resolves to an updated loop device description. Does not alter the input object.
Forces the operating system to reload partition table for device.
Uses BLKRRPART ioctl command.
If device /dev/loopX is a disk with many partitions, then after calling this function, the operating system will create /dev/loopXpY for each partition of the disk.
To make sure the operating system will scan the partition table, attach the device with partscan option enabled.
If you're having any problem, please raise an issue on GitHub.
- Issue Tracker: github.com/abresas/losetup-js/issues
- Source Code: github.com/abresas/losetup-js
The project is licensed under the Apache License 2.0.