Author Topic: Identify host operating system at mass storage enumeration  (Read 12218 times)

Adrien Decostre

  • Member
  • ***
  • Posts: 12
Identify host operating system at mass storage enumeration
« on: December 18, 2015, 05:29:39 am »
Dear all,

I am working on a Linux mass storage device implementation and I am wondering if it is possible for the USB device to identify the host operating system during enumeration. Is such mechanism defined in the USB standard?

More specifically, I would like the disk driver loaded by the usb mass storage device to be specific to the host operating system. Would it also be possible to have the mass storage device having multiple LUNs and enabling or disabling each LUN based on the host OS?

Thanks a lot in advance for any help or any advise,

Adrien

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Identify host operating system at mass storage enumeration
« Reply #1 on: December 18, 2015, 10:00:06 am »
The USB specifications say nothing at all about OSes. Why do you need a different driver depending on OS? Maybe there is a different approach to accomplish the same thing.

Adrien Decostre

  • Member
  • ***
  • Posts: 12
Re: Identify host operating system at mass storage enumeration
« Reply #2 on: December 18, 2015, 10:19:14 am »
Hello Jan,

Thanks a lot for your quick answer.

The goal would be to provide a mass storage hosting specific Linux applications on Linux and a mass storage  hosting specific Windows applications on Windows.

I was also thinking on having a mass storage with 2 LUNs: one valid for Linux and another valid for Windows. I would then suppose that the host would select the valid LUN, right?

Thanks a lot in advance for any help or suggestion.

Best regards

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Identify host operating system at mass storage enumeration
« Reply #3 on: December 18, 2015, 10:53:07 am »
I believe Linux supports all Windows file systems, so I don't know how one would make a LUN that is valid for only one OS.

However, you could provide a partition or directory for each OS. Both might be visible, but for example, if you name the directories Windows and Linux, their functions would be clear.

How to manage this may also depend on whether you are planning to run the applications from the drive or just install the applications from the USB drive onto an internal drive.

You could write an application to hide a partition in Windows:

http://www.sevenforums.com/general-discussion/11623-how-do-i-hide-specific-drives-partitions-windows-7-a.html

And use autorun to run it.

Possibly you can do similar in Linux.

But this might be more complexity than you need.

Adrien Decostre

  • Member
  • ***
  • Posts: 12
Re: Identify host operating system at mass storage enumeration
« Reply #4 on: December 18, 2015, 10:56:36 am »
Hello Jan,

Thanks a lot for this suggestion. This seems a very good idea.
I will give it a try.

Best regards

Barry Twycross

  • Frequent Contributor
  • ****
  • Posts: 263
Re: Identify host operating system at mass storage enumeration
« Reply #5 on: December 18, 2015, 05:16:07 pm »
In general, its a bad idea for the device to try to work out what the host is.

If you wrote a host driver, it could send the device a message telling it to enable or disable features. I've done this sort of thing, we had trouble with one particular host. I added a vendor specific command to the device, the host OSs added drivers to send that vendor specific command.

The vendor specific command did not identify the host, but directed the device to do the appropriate thing. In this case the problem was with power, so the command told the device to use more or less power as necessary. The command was general enough it solved the original problem and found a whole host of other uses. The device still doesn't care what OS the host is running, it just does as its told.

Writing a host driver is not a trivial exercise, particularly on Windows.