npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nodeos-mount

v0.3.2

Published

Async mount / umount system devices

Downloads

32

Readme

Build Status bitHound Score

node-mount

Greenkeeper badge

Mount/umount devices from node.js

Really works on linux, may work on OS X, and will never work on windows.

##Examples Mount Tmpfs:

var mount = require("mount");
mount.mount('tmpDir', 'tmpfs', function(err) {
	if(err){
    return;
  }

  // Tmpfs mounted successfully
});

Mount DVD:

var mount = require("mount");
mount.mount('myDir', 'iso9660', {devFile: '/dev/sr0'}, function(err) {
  if(err){
    return;
  }

  //
});

Mount ReadOnly+Remount (easy)

var mount = require("mount");
mount.mount('tmpdir', 'tmpfs', ['remount', 'readonly'], function(err) {
  if(err){
    return;
  }

  //
});

Mount ReadOnly+Remount (flags)

var mount = require("mount");
mount.mount('tmpdir', 'tmpfs', mount.MS_REMOUNT | mount.MS_RDONLY,
function(err) {
  if(err){
      return;
  }

  //
});

Umount after successful mount:

var mount = requrie("mount");
mount.umount('myDir', function(err) {
  if(err){
    console.log("Umount went wrong: " + err);
    return;
  }

	//
});

##Installation This package is not featured in NPM (yet), so you have to add this dependency line to your package.json file:

Part of package.json:

{
  "name" : "myproject",
  "version" : "1.0",
  ...
  ...
  "dependencies" : {
    "mount" : "git+ssh://[email protected]:hertzg/node-mount.git"
  }
}

API

This module provides functionality to mount and unmount devices to and from specific targets. Module exports asynchronous and synchronous variants.

Most of the explanations here are from mount(2) and umount(2)

  • http://linux.die.net/man/2/umount
  • http://linux.die.net/man/2/mount

WARNING: Using synchronous methods may block the process for along time. (ex: Mounting scratched CD/DVD/BD, Network shares.. etc..)

mount.mount(source, target, fsType, [options], [dataStr], callback)

Attaches the file system specified by source (which is often a device name, but can also be a directory name or a dummy) to the directory specified by target.

Appropriate privilege is required to mount file systems.

  • target - {String} - Directory to mount the device to.
  • fsType - {String} - Filesystem identificator (one of /proc/filesystems).
  • options - {Array}|{Number} - Number describing mount flags or an Array containing String options described below:
    • bind - Perform a bind mount, making a file or a directory subtree visible at another point within a file system. Bind mounts may cross file system boundaries and span chroot(2) jails. The fstype and dataStr arguments are ignored.
    • readonly - Mount file system read-only.
    • remount - Remount an existing mount. This allows you to change the options and dataStr of an existing mount without having to unmount and remount the file system. target should be the same value specified in the initial mount() call; source and fsType are ignored.
    • noexec - Do not allow programs to be executed from this file system.
  • dataStr - The data argument is interpreted by the different file systems. Typically it is a string of comma-separated options or an options bag understood by this file system. devFile option can be used to define the Device-File being mounted (located in /dev).
  • callback - Function called after the mount operation finishes. Receives only one argument err.
    • err - Is null if mount succeeded or Error object similar to ones generated by fs module in case of failure.

Values for the fstype argument supported by the kernel are listed in /proc/filesystems (e.g., "minix", "ext2", "ext3", "jfs", "xfs", "reiserfs", "msdos", "proc", "nfs", "iso9660"). It can be auto, too.

mount.umount(target, callback)

Removes the attachment of the (topmost) file system mounted on target.

Appropriate privilege is required to unmount file systems.

  • target - {String} - Directory to unmount.
  • callback - Function called after the mount operation finishes. Receives only one argument err.
    • err - null if umount succeeded or Error object similar to ones generated by fs module in case of failure.

Returns undefined

mount.mountSync(source, target, fsType, [options], [dataStr])

Synchronous variant of mount.mount()

Returns: true if mount succeeded or throws Error object similar to ones generated by fs module in case of failure.

mount.umountSync(target)

Synchronous variant of mount.umount()

Returns: true if umount succeeded or throws Error object similar to ones generated by fs module in case of failure.

mount.unmount(target, callback)

This function is deprecated; please use mount.umount() instead.

Alias of mount.umount()

mount.unmountSync(target)

This function is deprecated; please use mount.umountSync() instead.

Alias of mount.umountSync()

mount.MS_*

Constants for easy mount flags bitmask manipulation.

TODO:

  • umount2 - force force unmounting

Credits