Giter Site home page Giter Site logo

balena-io-modules / drivelist Goto Github PK

View Code? Open in Web Editor NEW
232.0 25.0 88.0 805 KB

List all connected drives in your computer, in all major operating systems

License: Apache License 2.0

Python 2.27% C++ 48.36% Objective-C 3.73% Objective-C++ 9.24% TypeScript 36.10% Nix 0.29%

drivelist's Introduction

drivelist

List all connected drives in your computer, in all major operating systems.

Current Release License Downloads Travis CI status AppVeyor status Dependency status

Notice that this module does not require admin privileges to get the drives in any supported operating system.

Supports:

  • Windows.
  • GNU/Linux distributions that include util-linux and udev.
  • Mac OS X.

When the user executes drivelist.list(), the module checks the operating system of the client and executes the corresponding drive scanning script.

Examples (the output will vary depending on your machine):

const drivelist = require('drivelist');

const drives = await drivelist.list();
console.log(drives);

Mac OS X:

[
  {
    device: '/dev/disk0',
    displayName: '/dev/disk0',
    description: 'GUID_partition_scheme',
    size: 68719476736,
    mountpoints: [
      {
        path: '/'
      }
    ],
    raw: '/dev/rdisk0',
    protected: false,
    system: true
  },
  {
    device: '/dev/disk1',
    displayName: '/dev/disk1',
    description: 'Apple_HFS Macintosh HD',
    size: 68719476736,
    mountpoints: [],
    raw: '/dev/rdisk0',
    protected: false,
    system: true
  }
]

GNU/Linux

[
  {
    device: '/dev/sda',
    displayName: '/dev/sda',
    description: 'WDC WD10JPVX-75J',
    size: 68719476736,
    mountpoints: [
      {
        path: '/'
      }
    ],
    raw: '/dev/sda',
    protected: false,
    system: true
  },
  {
    device: '/dev/sdb',
    displayName: '/dev/sdb',
    description: 'DataTraveler 2.0',
    size: 7823458304,
    mountpoints: [
      {
        path: '/media/UNTITLED'
      }
    ],
    raw: '/dev/sdb',
    protected: true,
    system: false
  }
]

Windows

[
  {
    device: '\\\\.\\PHYSICALDRIVE0',
    displayName: 'C:',
    description: 'WDC WD10JPVX-75JC3T0',
    size: 68719476736,
    mountpoints: [
      {
        path: 'C:'
      }
    ],
    raw: '\\\\.\\PHYSICALDRIVE0',
    protected: false,
    system: true
  },
  {
    device: '\\\\.\\PHYSICALDRIVE1',
    displayName: 'D:, F:',
    description: 'Generic STORAGE DEVICE USB Device',
    size: 7823458304,
    mountpoints: [
      {
        path: 'D:'
      },
      {
        path: 'F:'
      }
    ],
    raw: '\\\\.\\PHYSICALDRIVE1',
    protected: true,
    system: false
  },
  {
    device: '\\\\.\\PHYSICALDRIVE2',
    displayName: '\\\\.\\PHYSICALDRIVE2',
    description: 'Silicon-Power2G',
    size: 2014314496,
    mountpoints: [],
    raw: '\\\\.\\PHYSICALDRIVE2',
    protected: false,
    system: false
  }
]

Installation

Install drivelist by running:

$ npm install --save drivelist

Documentation

drivelist~list()

Kind: inner method of drivelist
Summary: List available drives
Example

const drivelist = require('drivelist');

const drives = await drivelist.list();
drives.forEach((drive) => {
  console.log(drive);
});

Tests

Run the test suite by doing:

$ npm test

Contribute

We're looking forward to support more operating systems. Please raise an issue or even better, send a PR to increase support!

Before submitting a PR, please make sure that you include tests, and that the linter runs without any warning:

$ npm run lint

Support

If you're having any problem, please raise an issue on GitHub.

License

The project is licensed under the Apache 2.0 license.

drivelist's People

Contributors

ab77 avatar balena-ci avatar balena-renovate[bot] avatar brownjohnf avatar dustmason avatar flowzone-app[bot] avatar fordi avatar grumpyoldman-io avatar jhermsmeier avatar joerick avatar jviotti avatar klutchell avatar lekkas avatar lurch avatar maxnet avatar otaviojacobi avatar peakwinter avatar pimterry avatar renovate-bot avatar resin-io-modules-versionbot[bot] avatar robinwassen avatar superman32432432 avatar thgreasi avatar thundron avatar userabuser avatar warpdesign avatar zkochan avatar zrzka avatar zvin avatar zwhitchcox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

drivelist's Issues

Electron + Enigma Virtual Box

Hi,

Firstly, thanks for this module ! ;)

I use it in Electron and it work fine !!
Next, I consolidate my app in a single .exe file for windows with Enigma Virtual Box and I got this javascript error:

Error: spawn C:\mainDev\Apprim\releases\resources\app\node_modules\drivelist\scripts\win32.bat ENOENT (code ENOENT)
at exports._errnoException (util.js:1022)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193)
at onErrorNT (internal/child_process.js:359)
at _combinedTickCallback (internal/process/next_tick.js:74)
at process._tickCallback (internal/process/next_tick.js:98)

I don't know how to fix it, I don't even know if it's a problem from drivelist, Enigma, or just incompatibility between them ?

Help would be appreciated to make it works, or just telling me that it is impossible ;)

ENOENT error on windows

Hi,
I tried using the drivelist.list function and it returned this error:
Error: spawn \scripts\win32.bat ENOENT

Not really sure is this a problem on my end or something is buggy with the the library.

device on Linux should be more specific

currently, module returns something like:
device: /dev/sdf
description: Expansion Desk
size: 4.6T
mountpoint: /media/dave/Seagate\040Expansion\040Drive,
name: /dev/sdf
system: False

but this is really /dev/sdf3.

Seems like it should include the device/partition, not just the raw device

Drive name inconsistencies on MacOSx

Hello,

There seem to be some inconsistencies with what is returned as the description. Unsure if this is related to OS (Mac OSX) or the format of the drives, but what is output in Finder, is not what is returned as the description in drivelist.

For instance, the 'name' of the following drive is "DAYJOS USB" or at least this is what is shown up on Finder.

{
     device: '/dev/disk2',
     description: 'Flash Disk',
     size: 501219328,
     mountpoint: '/Volumes/DAYJOS USB',
     name: '/dev/disk2',
     raw: '/dev/rdisk2',
     protected: false,
     system: true
}

However this is what is found by diskutil;

Device Identifier:        disk2s1
   Device Node:              /dev/disk2s1
   Whole:                    No
   Part of Whole:            disk2
   Device / Media Name:      Untitled 1

   Volume Name:              DAYJOS USB

   Mounted:                  Yes
   Mount Point:              /Volumes/DAYJOS USB

   File System Personality:  MS-DOS FAT16
   Type (Bundle):            msdos
   Name (User Visible):      MS-DOS (FAT16)

   Partition Type:           DOS_FAT_16
   OS Can Be Installed:      No
   Media Type:               Generic
   Protocol:                 USB
   SMART Status:             Not Supported
   Volume UUID:              2532FA31-46B3-3FEA-B37F-9D958B64CB67

   Total Size:               501.2 MB (501170176 Bytes) (exactly 978848 512-Byte-Units)
   Volume Free Space:        471.5 MB (471506944 Bytes) (exactly 920912 512-Byte-Units)
   Device Block Size:        512 Bytes
   Allocation Block Size:    8192 Bytes

   Read-Only Media:          No
   Read-Only Volume:         No

   Device Location:          External
   Removable Media:          No

As you can see there seems to be some issues with what Diskutil is returning, i.e.Removable Media: No, for instance must be incorrect, another external USB drive appears like so;


   Device Identifier:        disk1s1
   Device Node:              /dev/disk1s1
   Whole:                    No
   Part of Whole:            disk1
   Device / Media Name:      Untitled 1

   Volume Name:              USB Disk

   Mounted:                  Yes
   Mount Point:              /Volumes/USB Disk

   File System Personality:  MS-DOS FAT32
   Type (Bundle):            msdos
   Name (User Visible):      MS-DOS (FAT32)

   Partition Type:           Windows_FAT_32
   OS Can Be Installed:      No
   Media Type:               Generic
   Protocol:                 USB
   SMART Status:             Not Supported
   Volume UUID:              0AF86554-9EB1-3535-89E2-4F930292CBE3

   Total Size:               15.7 GB (15703457792 Bytes) (exactly 30670816 512-Byte-Units)
   Volume Free Space:        14.7 GB (14689353728 Bytes) (exactly 28690144 512-Byte-Units)
   Device Block Size:        512 Bytes
   Allocation Block Size:    8192 Bytes

   Read-Only Media:          No
   Read-Only Volume:         No

   Device Location:          External
   Removable Media:          Yes
   Media Removal:            Software-Activated

However at least on mac, on these USB disks, 'Volume Name' seems to be a valid value to use as the name/description within drivelist.

This second drive above appears like so in drivelist;

{ 
    device: '/dev/disk1',
     description: 'USB Flash Drive',
     size: 15703474176,
     mountpoint: '/Volumes/USB Disk',
     name: '/dev/disk1',
     raw: '/dev/rdisk1',
     protected: false,
     system: false
}

As you can see, the description is "USB Flash Drive" but the 'name' (the end of the mount point" is "USB Disk" as per the diskutil's 'Volume Name'.

If there's any more info I can get, please let me know :)

[Windows] Show drives without any Windows partitions

Presently on Windows, this module only shows drives that have Windows mountable partitions (i.e. drives that show up with drive letters after Win32_LogicalDiskToPartition). Empty removable drives, or removable drives that only have HFS or ext partitions, will not show up. Is this intended behaviour or just an oversight? If the latter I would be happy to submit a pull request to fix...

Thanks!

diskinfo[0]: unbound variable

I was trying to get a list of devices every half a second, like the code below:

setInterval(function(){
  drivelist.list((error, drives) => {
    if (error) {
      throw error;
    }
    callback(drives);
  });
}, 500);

However, I was getting an error of unbound variable whenever I unplugged the usb flash drive:
Unbound variable

It seems that this modification to the line 29 solved my problem:

#Check for diskinfo before continuing
if [ -z "${diskinfo-}" ]; then
  continue
fi
size=${diskinfo[0]}
...

Could you check that?

Empty drive list on VPS

I have a VPS on DigitalOcean (Ubuntu 14.04).
drivelist.list function gives me no error in callback but empty list of drives.

df -h gives me following output:

Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        20G  4.4G   15G  24% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
udev            235M   12K  235M   1% /dev
tmpfs            50M  340K   49M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            246M  384K  245M   1% /run/shm
none            100M     0  100M   0% /run/user

as you see, at least one drive attached (/dev/vda1)

Test the scripts on "dummy input"

While reading through #138 it occurred to me that while we check that the JS is able to correctly parse example script output (i.e. convert YAML to JSON), we don't currently test the scripts themselves.
I dunno how difficult it would be to set up, but I guess it's conceivable that different versions of an OS could output info in (slightly?) different formats, so it might be nice if we could mock up "sample input" to test the drive scripts.

Alternatively, given how low-level the scripts operate, it may actually be impossible to "unit test" them (especially the Windows VBScript stuff) :-/
(this is just a quick suggestion, I haven't thought about it too deeply...!)

Use npm WMI module?

So, from the little I've learned of Etcher so far, it seems the ideal situation is to try and move as much "native code" as possible into NodeJS libraries? To that end, would it be worth replacing the current scripts/win32.bat with a script using one of these instead?
Or does that just end up shifting the native-code-dependency further down the stack?

Method of getting drive size on Windows needs changing

For all the gory details, see my comments in balena-io/etcher#995

But in summary: scripts/win32.bat in this repo currently gets the size of the drive using Win32_DiskDrive which erroneously calculates the size of the raw drive using the CHS values. While this works fine for mechanical hard drives, it doesn't work for flash media (SD cards, USB sticks, etc.) and often under-reports the actual size of the drive. IOCTL_DISK_GET_DRIVE_GEOMETRY_EX needs to be used instead, to get the actual size of the raw drive.

I believe that fixing this will fix all the problems mentioned in balena-io/etcher#995

[REQ] Drive serial number

Hello!

I love this project, the support across all major operating systems is a big plus to me. Currently I have a project that works with raw drives and in Linux it's rather trivial because of the vast packages available to get information about hardware such as drives.

One piece of information I require is the unique serial number of the hard-drive so that I can store tags in a local database and index that hard-drive by serial so that it is identifiable in the future. There doesn't seem to be a means to query this.

So this is my request, the unique serial number exposed with the drivelist. I've not viewed the source but I will later and offer a PR if it's a simple implementation. Otherwise this issue sits for anyone else wishing to consider it.

Thank you for this project.

Win32 Physical Drive 0 always reports system property as being true

Win32.bat will always report \\.\PHYSICALDRIVE0 as being system drive when in actual fact system drive can exist on any physical drive of one's choosing.

As in my case, \\.\PHYSICALDRIVE1 is the system drive.

//drive 1
description: "OCZ-VERTEX3 ATA Device"
device: "\\.\PHYSICALDRIVE1"
mountpoint: "C:"
name: "C:"
size: "120 GB"
system: false //should be true

//drive 2
description: "WDC WD5000AAKS-00YGA0 ATA Device"
device: "\\.\PHYSICALDRIVE0"
mountpoint: "D:"
name: "D:"
size: "500 GB"
system: true  //should be false

The only reliable way that I can tell to determine the system drive is to query against Win32_OperatingSystem for the SystemDrive property.

Private OSDrive

Set colOperatingSystems = objWMIService.ExecQuery ("SELECT SystemDrive FROM Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
    On Error Resume Next
    '' get the OS System Drive if exists
    OSDrive = objOperatingSystem.Properties_("SystemDrive")   
    If Err.Number <> 0 Then
        OSDrive = Err.Description
        Err.Clear
    End If
Next

The result of which is stored against the variable OSDrive for which we can later compare against...

If objLogicalDisk.DeviceID = OSDrive Then
  Wscript.Echo "system: True"
Else
  Wscript.Echo "system: False"
End If

This results in the correct drive attaining (bool) true for the system property returned by drivelist.list()

Related PR for this issue:
#60

Display name of a drive

Thanks for the nice module!

Would it be possible to display a device name?
For example, my usb drive has this name PHY_RH_252.
But I don't see it in the list of options
On mac:

description:"AT90USB128 M S"
device:"/dev/disk3"
mountpoints: {
    path:"/Volumes/PHY_RH_252"
    raw:"/dev/rdisk3"
size:3980394496
system:false

On windows:

description:"ATMEL AT90USB128 M S USB DEVICE"
device:"\\.\PHYSICALDRIVE1"
mountpoints:
    path:"D:"
    raw:"\\.\PHYSICALDRIVE1"
size:3980394496
system:false

Detect when a drive has been inserted

Firstly, thanks for the module!

Is it possible to listen for when a drive has been inserted into the computer without setting a timeout that would check every x seconds, for example to listen for when a USB has been inserted?

Implement handy filter/reject functions

So the user can do:

drivelist.reject drivelist.isSystem, (error, drives) ->
drivelist.filter drivelist.isSystem, (error, drives) ->

More easily, without having to deal with async directly.

missing mountpoints on some drives on linux

same issue as #68

here is what is returned for my root drive:

description:"Hitachi HDT72101"
device:"/dev/sda"
mountpoint:null
name:"/dev/sda"
size:"931.5G"
system:true

Mountpoint is null. This drive is mounted via UUID:
UUID=7af69416-051a-4149-a3e8-9b59becb56f7 / ext4 errors=remount-ro 0 1

I thought this was fixed recently? now it is back

I have 3.1.0 installed...

Unable to list drives on my ubuntu since 5.0.0

Drivelist does not work on my PC since 5.0.0.
Config : Ubuntu 16.04, one HDD with ubuntu + windows

Error:

[...]/node_modules/drivelist/scripts/linux.sh: ligne 93: UDEV_net.ifnames=0 : commande introuvable
at [...]/node_modules/drivelist/build/scripts.js:27:23
at ChildProcess.exithandler (child_process.js:204:7)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:821:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

When running linux.sh:

./linux.sh
device: /dev/sda
description: "WDC [...]"
size: 1000204886016
mountpoints:

  • path: /
  • path: /boot/efi
  • path: /home
    raw: /dev/sda
    protected: False
    ./linux.sh: ligne 114: UDEV_net.ifnames=0 : commande introuvable
    system: True

('commande introuvable" = "command not found")

"UDEV_net.ifnames=0" is the last line returned by "udevadm info --query=property --export --export-prefix=UDEV_ --name=sda" (linux.sh, line 47).

[linux] Multiple partitions result in null mountpoint, description

For example, when examining an SD card being used as a system drive for something embedded, I get the following object:

{
    "device": "/dev/mmcblk0",
    "description": null,
    "size": 31914983424,
    "mountpoint": null,
    "name": "/dev/mmcblk0",
    "protected": false,
    "system": false
}

What I expect to see is more like:

{
    "device": "/dev/mmcblk0p2",
    "size": "67108864",
    "mountpoint": null,
    "name": "/dev/mmcblk0p2",
    "protected": false,
    "system": false,
    "description": "system-boot"
},
{
    "device": "/dev/mmcblk0p3",
    "size": "1073741824",
    "mountpoint": "/media/rsi-bryan/system-a",
    "name": "/dev/mmcblk0p3",
    "protected": false,
    "system": false,
    "description": "system-a"
},
{
    "device": "/dev/mmcblk0p4",
    "size": "1073741824",
    "mountpoint": "/media/rsi-bryan/system-b",
    "name": "/dev/mmcblk0p4",
    "protected": false,
    "system": false,
    "description": "system-b"
},
{
    "device": "/dev/mmcblk0p5",
    "size": "1675624448",
    "mountpoint": "/media/rsi-bryan/writable",
    "name": "/dev/mmcblk0p5",
    "protected": false,
    "system": false,
    "description": "writable"
},
{
    "device": "/dev/mmcblk0p6",
    "size": "28015853568",
    "mountpoint": "/media/rsi-bryan/68C2-99CB",
    "name": "/dev/mmcblk0p6",
    "protected": false,
    "system": false,
    "description": "68C2-99CB"
}

Note that, on this SD card, mmcblk0p1 is a UEFI BIOS boot parititon, so it doesn't (and shouldn't) actually appear as a "drive".

The following gets the complete block device table in linux without resorting to scripts (just one call to lsblk), and adapts it to drivelist-like output.

### In addition to the RM flag, any device on the USB or MMC bus must be removable. 
uDev is actually really bad at recognizing this, and often marks MMCs as non-removable.
###
rxRemovable = /(?:^|\:)(?:mmc|usb)(?:\:|$)/

### translates from lsblk's output into drivelist's expected output ###
Drive = (device, parent) ->
    {
        device: device.name,
        size: device.size,
        mountpoint: device.mountpoint,
        ### in the linux scripts, drive.name and drive.device MUST be the same.  Why?  ###
        name: device.name,
        protected: device.ro == '1'
        system: !(device.rm == '1' || device.hotplug == '1' || rxRemovable.test(device.subsystems)),
        description:
            (device.label || device.model || device.uuid || device.serial) || (parent && (
             parent.label || parent.model || parent.uuid || parent.serial
        ))
    }

getDrivesLinux = (callback) ->
    child_process.exec 'lsblk -a -p -J -O -b', (error, stdout, stderr) ->
        return callback(error) if error?

        if not _.str.isBlank(stderr)
            return callback(new Error(stderr))

        ###
        lsblk incorrectly uses '\xHH' for escaping quotes in its JSON output.
        Incorrectly, as \x is not part of JSON.
        This replaces those with the \uCCCC equivalent, which is totes OK in JSON.
        ###

        stdout = stdout.replace(/\\x(\d{2})/g, '\\u00$1')
        devices = JSON.parse(stdout)
        ###
        Structure of lsblk -J output:
        {
            blockdevices: [
                { /* ... block device ... */
                    children: {
                        /* ... partition ... */
                    }
                }
            ]
        }
        ###
        return callback(new Error("Couldn't read block devices"), null) if !devices.blockdevices
        devices = devices.blockdevices
        drives = []
        devices.forEach (device) ->
            ### 
            a block device without a recognizable filesystem (e.g., with partition table)
            is not a drive, but raw device filesystems (e.g., no partition table) are a 
            reasonably common thing, especially in USB drives and SD cards. So we 
            try to make a drive object for both, skipping those without an fstype.
            ###
            drives.push Drive(device) if device.fstype?
            return if !device.children
            device.children.forEach (partition) ->
                drives.push Drive(partition, device) if partition.fstype?
        callback(null, drives)

Removable Drive

Request for one more info, is drive removable?

For OSX, we can use Ejectable property.
For Windows, we can use drive type.
For Linux, lsblk have RM column.

Improve "mountpoint" contents

Hi guys,

I am using Kubuntu and I am having a problem to get the my mountpoints, I am having just one value in the 'disks' array, having the 'mountpoint' value equal '/,/usr'. Maybe the right output should be something like:

disks = [{mountpoint: '/', ...}, {mountpoint: '/usr', ...}]

Tell me if I can help with something. Thx

Get drive letters.

Hi. I'm using a windows machine and I don't want the

[{"device":"\\\\.\\PHYSICALDRIVE0","description":"ST3750528AS ATA Device ","size":"750 GB"},{"device":"\\\\.\\PHYSICALDRIVE1","description":"TOSHIBA MQ01ABD100 ATA  Device","size":"1000 GB"}]

Info as this in no way serves of any use to me.
I'd like to see a way of getting the drive letters, for example, C:\ and D:\ instead of the PHYSICALDRIVE0 and PHYSICALDRIVE1.

Thanks

- Mackan

Script fails to run if path to module contains space

script.run fails if there is space in path to module directory.
/projects/drivelist test/node_modules/drivelist/scripts/darwin.sh will try to execute until to space
[Error: Command failed: /bin/sh: /projects/drivelist: No such file or directory]

Possible solution is to escape spaces in script paths scripts.coffee:10
darwin: path.join(scriptsPath, 'darwin.sh').replace /[ ]/g, '\\ '

does not find mountpoint for disk mounted by UUID

on Ubuntu (and probably all other Linux), drives mounted by UUID like this line from /etc/fstab:

UUID=7af69416-051a-4149-a3e8-9b59becb56f7 / ext4 errors=remount-ro 0 1

do not return a mountpoint using this module. The entry in /procs/mounts for such a disk looks like this:

/dev/disk/by-uuid/7af69416-051a-4149-a3e8-9b59becb56f7 / ext4 rw,relatime,errors=remount-ro,data=ordered 0 0

so the code that greps for the the device fails.

Prepare easy way to have someone run drivelist for debugging

In the course of debugging drive detection issues, it's pretty common to ask people to download the drivelist script and run it. It would be nice if there were a wiki page here (or a similar resource) with one-liners to accomplish this. I prepared something like this for Windows, if it's useful:

@powershell -NoProfile -ExecutionPolicy Bypass -Command "(New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/resin-io-modules/drivelist/master/scripts/win32.bat')" > drivelist-win32.bat && .\drivelist-win32.bat

It's not exactly optimal (it saves the file before executing it) because I couldn't figure out how to execute the WSH script dynamically, but it gets the job done.

Description on El Capitain

I m getting WDC WD5000LPVX-22V0TT0 for the description instead of a readable name. What I m I doing wrong.

Mountpoint path problem in Mac OS X

Hi,

I've just started using your module, which is truly fantastic, but I encoutered one problem while plugging in one of my pendrives. It is called EXTRNL #2 and of course it is mounted in Mac OS X with path /Volumes/EXTRNL #2, but after running drivelist it shows the path trimmed after space (/Volumes/EXTRNL). When using name without space or without hash sign it works as expected.

OS report

EXTRNL #2:
  Capacity:	32,01 GB (32 009 879 552 bytes)
  Available:	31,62 GB (31 617 187 840 bytes)
  Writable:	Yes
  File System:	MS-DOS FAT32
  BSD Name:	disk2s1
  Mount Point:	/Volumes/EXTRNL #2
  Content:	Windows_FAT_32

Module

{
  "device": "/dev/disk2",
  "description": "Cruzer Blade",
  "size": 32010928128,
  "mountpoints": [
    {
      "path": "/Volumes/EXTRNL"
    }
  ],
  "raw": "/dev/rdisk2",
  "protected": false,
  "system": false
}

Mount point not provide

Hi
I have a cell phone connected as /dev/disk3
And run drivelist, result:

[ { device: '/dev/disk0',
    size: '*500.3 GB',
    description: 'GUID_partition_scheme',
    mountpoint: undefined },
  { device: '/dev/disk1',
    size: '*499.1 GB',
    description: 'Apple_HFS Macintosh HD',
    mountpoint: '/' },
  { device: '/dev/disk3',
    size: '*21.8 MB',
    description: 'CD_partition_scheme',
    mountpoint: undefined } ]

The partition is not provided.

When run diskutil list

/dev/disk3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:        CD_partition_scheme                        *21.8 MB    disk3
   1:     Apple_partition_scheme                         19.0 MB    disk3s1
   2:        Apple_partition_map                         1.5 KB     disk3s1s1
   3:                  Apple_HFS HTC Sync Manager        18.9 MB    disk3s1s2

and diskutil info /dev/disk3

   Device Identifier:        disk3
   Device Node:              /dev/disk3
   Part of Whole:            disk3
   Device / Media Name:      HTC Android Phone Media

   Volume Name:              Not applicable (no file system)

   Mounted:                  Not applicable (no file system)

   File System:              None

   Content (IOContent):      CD_partition_scheme
   OS Can Be Installed:      No
   Media Type:
   Protocol:                 USB
   SMART Status:             Not Supported

   Total Size:               21.8 MB (21798336 Bytes) (42574 512-Byte-Units + 448 Byte(s))
   Volume Free Space:        Not applicable (no file system)
   Device Block Size:        2352 Bytes

   Read-Only Media:          Yes
   Read-Only Volume:         Not applicable (no file system)
   Ejectable:                Yes

   Whole:                    Yes
   Internal:                 No
   OS 9 Drivers:             No
   Low Level Format:         Not supported

   Optical Drive Type:
   Optical Media Type:
   Optical Media Erasable:   No

The one mounted is /dev/disk3s1s2

   Device Identifier:        disk3s1s2
   Device Node:              /dev/disk3s1s2
   Part of Whole:            disk3
   Device / Media Name:      Disk Image

   Volume Name:              HTC Sync Manager

   Mounted:                  Yes
   Mount Point:              /Volumes/HTC Sync Manager

   File System Personality:  HFS+
   Type (Bundle):            hfs
   Name (User Visible):      Mac OS Extended
   Owners:                   Disabled

   Partition Type:           Apple_HFS
   OS Can Be Installed:      No
   Media Type:
   Protocol:                 USB
   SMART Status:             Not Supported
   Volume UUID:              21DCE46F-1A18-35D3-9038-FD5B9EB8C266

   Total Size:               18.9 MB (18874368 Bytes) (exactly 36864 512-Byte-Units)
   Volume Free Space:        0 B (0 Bytes) (exactly 0 512-Byte-Units)
   Device Block Size:        2048 Bytes
   Allocation Block Size:    2048 Bytes

   Read-Only Media:          Yes
   Read-Only Volume:         Yes
   Ejectable:                Yes

   Whole:                    No
   Internal:                 No

   Optical Drive Type:
   Optical Media Type:
   Optical Media Erasable:   No

Not sure how to detect this.

Detect a drive type

For example, determine if a drive is a USB drive, an SDCard, an SSD HD, etc.

error reading SD card on rpi2

01.12.15 19:13:04 [+0000] Unhandled rejection Error: lsblk: /dev/sda: not a block device
01.12.15 19:13:04 [+0000] lsblk: /dev/sda: not a block device
01.12.15 19:13:04 [+0000] lsblk: /dev/sda: not a block device
01.12.15 19:13:04 [+0000]
01.12.15 19:13:04 [+0000] at /usr/src/app/node_modules/drivelist-scanner/node_modules/drivelist/build/scripts.js:27:23
01.12.15 19:13:04 [+0000] at ChildProcess.exithandler (child_process.js:194:7)
01.12.15 19:13:04 [+0000] at emitTwo (events.js:87:13)
01.12.15 19:13:04 [+0000] at ChildProcess.emit (events.js:172:7)
01.12.15 19:13:04 [+0000] at maybeClose (internal/child_process.js:817:16)
01.12.15 19:13:04 [+0000] at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

More information

Hello,

Is there a way to get more information on disks like :

  • Free space
  • Filesystem type (vfat, ext4, hfs, etc.)
  • Mounted point or drive letter based on OS type (/, /home, C:, etc.)

Getting an error when using drivelist on Windows

After I installed drivelist and using the example code in my Electron app, I got the following error:

Uncaught Error: process.binding is not supported
at Object.process.binding (index.js:30296)
at Object. (index.js:46258)
at Object.312._process (index.js:46732)
at s (index.js:1)
at index.js:1
at Object.275.../package.json (index.js:35949)
at s (index.js:1)
at index.js:1
at Object.274../execute (index.js:35884)
at s (index.js:1)
at index.js:1
at Object. (index.js:13)
at Object.1../listWidgets.js (index.js:649)
at s (index.js:1)
at index.js:1
at Object. (index.js:4534)

Is this just an Electron thing? Or is there a workaround?

Detect "operating system" drives

As mentioned in balena-io/etcher#888 it would be nice if we could identify drives where the currently-running operating system is loaded from. This would allow Etcher to prevent writing to those drives, even if the user has enabled "Unsafe mode" (which allows you to write to "system" drives). (Unfortunately Removable Drives often get misidentified by drivelist as "system" drives)

We could do this by detecting drives containing partitions mounted at /, /boot, /home, etc. in the case of UNIX (and checking for root= in /proc/cmdline on Linux), and drives containing drive letters that match %SYSTEMDRIVE%, %PROGRAMFILES% and %HOMEPATH% in Windows.

See also balena-io/etcher#1435

OS X: No `mountpoint` for USB devices

The OS X script ends up running diskutil info /dev/disk2, when it should be running diskutil info /dev/disk2s1. Using something like this is more reliable, but a bit slower

list_disks () {
    mounts=$(mount)
    diskutil list | while read line; do
        id=$(echo "$line" | rev | cut -d ' ' -f 1 | rev)
        if [[ "$id" == disk* ]]; then
            if [[ "$mounts" == *"/dev/$id on"* ]]; then
                echo "/dev/$id"
            fi
        fi
    done
}

for disk in $(list_disks); do
  # ...

YAMLException: incomplete explicit mapping pair

The current version of drivelist gives me the following error:

YAMLException: incomplete explicit mapping pair; a key node is missed at line 2, column 14:
    description: :
                 ^
    at generateError (/myproject/node_modules/drivelist/node_modules/js-yaml/lib/js-yaml/loader.js:162:10)
    at throwError (/myproject/node_modules/drivelist/node_modules/js-yaml/lib/js-yaml/loader.js:168:9)
    at readBlockMapping (/myproject/node_modules/drivelist/node_modules/js-yaml/lib/js-yaml/loader.js:995:9)
    at composeNode (/myproject/node_modules/drivelist/node_modules/js-yaml/lib/js-yaml/loader.js:1327:12)
    at readDocument (/myproject/node_modules/drivelist/node_modules/js-yaml/lib/js-yaml/loader.js:1489:3)
    at loadDocuments (/myproject/node_modules/drivelist/node_modules/js-yaml/lib/js-yaml/loader.js:1545:5)
    at load (/myproject/node_modules/drivelist/node_modules/js-yaml/lib/js-yaml/loader.js:1562:19)
    at Object.safeLoad (/myproject/node_modules/drivelist/node_modules/js-yaml/lib/js-yaml/loader.js:1580:10)
    at _.compact._.map (/myproject/node_modules/drivelist/lib/parse.js:89:25)
    at arrayMap (/myproject/node_modules/drivelist/node_modules/lodash/lodash.js:660:23)

It seems that the references version of js-yaml is at fault. Any idea?

Disks not found - older diskutil format

In some versions of diskutil there is no paren in disk name line.
/dev/disk0 instead of /dev/disk0 (internal, physical):
Could this be fixed by changing darwin.sh get_until_paren pattern to match paren or end of line?
I tried with \\(|$ and it found both cases.

YAMLException when listing drives in Windows

Hey,
I am getting an exception whenever I try to list drives. Any ideas?

OS: Windows 10 x64.
line: parse.js 89

Uncaught Exception:
YAMLException: bad indentation of a sequence entry at line 8, column 12:
- path: C:
^
at generateError (F:\Projekty\myproject\myproject\node_modules\js-yaml\lib\js-yaml\loader.js:162:10)
at throwError (F:\Projekty\myproject\myproject\node_modules\js-yaml\lib\js-yaml\loader.js:168:9)
at readBlockSequence (F:\Projekty\myproject\myproject\node_modules\js-yaml\lib\js-yaml\loader.js:932:7)
at composeNode (F:\Projekty\myproject\myproject\node_modules\js-yaml\lib\js-yaml\loader.js:1326:12)
at readBlockMapping (F:\Projekty\myproject\myproject\node_modules\js-yaml\lib\js-yaml\loader.js:1057:11)
at composeNode (F:\Projekty\myproject\myproject\node_modules\js-yaml\lib\js-yaml\loader.js:1327:12)
at readDocument (F:\Projekty\myproject\myproject\node_modules\js-yaml\lib\js-yaml\loader.js:1489:3)
at loadDocuments (F:\Projekty\myproject\myproject\node_modules\js-yaml\lib\js-yaml\loader.js:1545:5)
at load (F:\Projekty\myproject\myproject\node_modules\js-yaml\lib\js-yaml\loader.js:1562:19)
at Object.safeLoad (F:\Projekty\myproject\myproject\node_modules\js-yaml\lib\js-yaml\loader.js:1580:10)

[OK]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.