Author Topic: How to determine OS Type while Mass storage Driver is enumerating  (Read 9563 times)

coolsunny2012

  • Member
  • ***
  • Posts: 19
I would like to find the host OS while enumerating and select only the corresponding OS image file with the mass storage driver.

For example:
"insmod g_mass_storage.ko file=/win.iso,mac.iso"

While executing the above command, when the device is attached to WINDOWS, i need to show up win.iso instead of exposing mac.iso.
The command should look like "insmod g_mass_storage.ko file=/win.iso"

While executing the above command, when the device is attached to MAC, i need to show up mac.iso instead of exposing win.iso.
The command should look like "insmod g_mass_storage.ko file=/mac.iso".

I would appreciate any other thoughts/work around to this problem.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: How to determine OS Type while Mass storage Driver is enumerating
« Reply #1 on: December 14, 2012, 08:22:10 pm »
The host doesn't announce its OS during enumeration.

Plus, the device must install the gadget driver before enumeration.

coolsunny2012

  • Member
  • ***
  • Posts: 19
Re: How to determine OS Type while Mass storage Driver is enumerating
« Reply #2 on: December 14, 2012, 10:08:51 pm »
Is there any way to determine the OS Type may be with some other driver or something?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: How to determine OS Type while Mass storage Driver is enumerating
« Reply #3 on: December 15, 2012, 11:26:48 am »
If you're designing the device, it could include a HID interface that sends a vendor-defined request for the OS. On the host system, you would have to provide an application that knows how to respond to the request.

But surely there are emulated CDs that can function on both OSes. Maybe it makes more sense to figure out how to get that working.

coolsunny2012

  • Member
  • ***
  • Posts: 19
Re: How to determine OS Type while Mass storage Driver is enumerating
« Reply #4 on: December 15, 2012, 08:04:53 pm »
In fact it's a composite USB driver with HID + Mass Storage. And we do have a similar mechanism to  your suggestion for detecting the OS.
But we need to find it while enumeration itself as the existing mechanism takes several seconds to determine the OS type.

I was wondering if there is already a mechanism instead of re-inventing the wheel.
There is also a patent for this approach: http://www.google.com/patents/US20120054372.

I am trying to quickly hack the mass storage & HID driver so that i can select only one image based on the OS even though the driver allows to take both windows & mac ISO images.

Bret

  • Frequent Contributor
  • ****
  • Posts: 68
Re: How to determine OS Type while Mass storage Driver is enumerating
« Reply #5 on: December 17, 2012, 05:35:59 pm »
I'm not familiar with Windows or Mac scripting, but can you do it with environment variables?

coolsunny2012

  • Member
  • ***
  • Posts: 19
Re: How to determine OS Type while Mass storage Driver is enumerating
« Reply #6 on: December 17, 2012, 05:41:20 pm »
It has to be done in Linux while it is booting and enumerating the mass storage driver. The tricky part is that, i should be aware of what OS the device is connected before i insert the mass storage driver.
I've not quite figured out this yet..

Bret

  • Frequent Contributor
  • ****
  • Posts: 68
Re: How to determine OS Type while Mass storage Driver is enumerating
« Reply #7 on: December 18, 2012, 11:01:43 am »
I don't know about anybody else, but I'm completely confused as to what you're trying to do.

You say the device is "attached" to Windows or Mac, but this is being done while Linux is booting.  Is this some kind of Linux virtual machine running under Windows / Mac, and you're trying to determine the Host OS?

coolsunny2012

  • Member
  • ***
  • Posts: 19
Re: How to determine OS Type while Mass storage Driver is enumerating
« Reply #8 on: December 18, 2012, 11:08:05 am »
Yes, this is similar to USB thumb drive which has iMX processor running linux kernel and i am trying to figure out the OS before i pretend the thumb drive as Mass storage driver (using g_mass_storage.ko)