balena-io-modules / drivelist

List all connected drives in your computer, in all major operating systems
Apache License 2.0
242 stars 90 forks source link

Detect "operating system" drives #126

Open lurch opened 7 years ago

lurch commented 7 years ago

As mentioned in https://github.com/resin-io/etcher/issues/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 https://github.com/resin-io/etcher/issues/1435

jviotti commented 7 years ago

I think we can add a new property that is a subset of system. That is, if a drive is an "operating system drive", then its also system: true, but the opposite might not always be true.

BTW, this might be good opportunity to rename the system property to something more meaningful. What about renaming system to removable, and using system for the new "operating system drive" meaning?

lurch commented 7 years ago

As long as changing the meaning of "system drive" won't be too confusing to Etcher's existing users...?

Other than Etcher, does drivelist have any other downstream projects that would be impacted by such a change?

jviotti commented 7 years ago

As long as changing the meaning of "system drive" won't be too confusing to Etcher's existing users...?

I don't think that will be a problem. We don't show "system drives" at all yet (but we might show them all in the near future), and the only place that refers to them is the unsafe mode modal, in which I guess a minor wording change won't make a difference to users.

Other than Etcher, does drivelist have any other downstream projects that would be impacted by such a change?

I know there are many modules depending on it (we can re-check NPM). This would come as a major version increment, so compatibility shouldn't be a problem. Since the new removable property will have the same meaning as system does now, we can add an entry in the CHANGELOG describing that to upgrade to the new version, simply change any reference to system with removable.

On Tue, Nov 29, 2016 at 04:29:38PM -0800, Andrew Scheller wrote:

As long as changing the meaning of "system drive" won't be too confusing to Etcher's existing users...?

Other than Etcher, does drivelist have any other downstream projects that would be impacted by such a change?

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/resin-io-modules/drivelist/issues/126#issuecomment-263745434

-- Juan Cruz Viotti Software Engineer

lurch commented 7 years ago

We don't show "system drives" at all yet

We do when unsafe mode is enabled, although they're currently not labelled as "system" in the drive selector modal.

Since the new removable property will have the same meaning as system does now

Um, surely the removable property will have the same meaning as not system ??

jviotti commented 7 years ago

We do when unsafe mode is enabled, although they're currently not labelled as "system" in the drive selector modal.

Sure, but since we don't label them as "drive" we still have a good chance of change the wording if we like.

Um, surely the removable property will have the same meaning as not system ??

Yeah, my bad! :)

On Tue, Nov 29, 2016 at 08:34:10PM -0800, Andrew Scheller wrote:

We don't show "system drives" at all yet

We do when unsafe mode is enabled, although they're currently not labelled as "system" in the drive selector modal.

Since the new removable property will have the same meaning as system does now

Um, surely the removable property will have the same meaning as not system ??

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/resin-io-modules/drivelist/issues/126#issuecomment-263780815

-- Juan Cruz Viotti Software Engineer

lurch commented 7 years ago

Occurred to me yesterday that "fixed drive" is probably the most sensible name for "non-removable drive"? (which then frees up the "system drive" name for the operating-system drives discussed in this issue)

jviotti commented 7 years ago

Sounds good to me!

lurch commented 7 years ago

We could use https://msdn.microsoft.com/en-us/library/bb762188.aspx for this on Windows.

jhermsmeier commented 6 years ago

Closing as this has already been added in various PRs referenced above

lurch commented 6 years ago

Re-opening, as this has only been added for Windows and not other OSes :stuck_out_tongue_winking_eye: