My OS must be bootable from HDD and USB.
But some hardware (like USB) is easy to remove and replace.
Is there a Unique hardware of the device I boot from so I can check before destroing a USB-stick with OS info. I can make a function that checks if the bootdevice is unpluged and tell te user to put it back. But I want to check-it befor writing to it.
Is there a way to check it's the same device with-out reading from the device (and check some signatures on a sector. (that would be to slow))
I found that INT 0x13 function AH=48 tells me the PCI port that was used for the device. So I think I can check the VENDOR and DEVICE_ID. But I have 10 USB sticks with the same VENDOR and DEVICE_ID. Is there a other way?
Unique ID for removeble hardware
Unique ID for removeble hardware
Computer says NOOOO
Re: Unique ID for removeble hardware
Since you are going to write to it anyway, I don't see why reading the device first would be "too slow"...?Holus wrote:I want to check-it befor writing to it.
Is there a way to check it's the same device with-out reading from the device (and check some signatures on a sector. (that would be to slow))
Every good solution is obvious once you've found it.
Re: Unique ID for removeble hardware
Yes. But I do not want an write action to be 1 read and 1 write action.Solar wrote: Since you are going to write to it anyway, I don't see why reading the device first would be "too slow"...?
Waiting and checking the status 2x. Wait for the IRQ 2x. Process te information 2x.
Is there an other way??
Computer says NOOOO
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Unique ID for removeble hardware
For USB: write a proper driver so you can actually detect plug events.
In general there's a certain amount of time needed for a user to physically switch USB sticks (the same goes for floppy drives where it's generally not possible to tell if it's present), if you haven't written or read the device in the past n seconds then you may want to check the signature again. If the device gets unplugged live, the read or write will return a failure so that you know it's not there.
In other words, there should not be a read for every write
In general there's a certain amount of time needed for a user to physically switch USB sticks (the same goes for floppy drives where it's generally not possible to tell if it's present), if you haven't written or read the device in the past n seconds then you may want to check the signature again. If the device gets unplugged live, the read or write will return a failure so that you know it's not there.
In other words, there should not be a read for every write
Re: Unique ID for removeble hardware
Thanks. Read 1x on plug-in and detect. That sounds like a nice simple solution.Combuster wrote:For USB: write a proper driver so you can actually detect plug events.
In general there's a certain amount of time needed for a user to physically switch USB sticks (the same goes for floppy drives where it's generally not possible to tell if it's present), if you haven't written or read the device in the past n seconds then you may want to check the signature again. If the device gets unplugged live, the read or write will return a failure so that you know it's not there.
In other words, there should not be a read for every write
Is there a unplugsignal to an IRQ?
Computer says NOOOO
Re: Unique ID for removeble hardware
Hi,
For all USB devices; when a USB device is plugged in you first have to find out what the device is (get the class and subclass codes to determine if it's a storage device or a keyboard or mouse or whatever). To do this you ask the device for a "Device Descriptor". In addition to class and subclass codes, the "Device Descriptor" includes a vendor ID, a product ID and a serial number. The serial number is a string of at least 12 Unicode characters that must be unique for the vendor ID and product ID; and by concatenating "vendor + product + serial" you end up with a globally unique identifier.
Basically, you have to get this data from the device anyway (to determine what sort of device it is), and can use it to determine if the device is the same one.
Note: For hard disks it's slightly similar. You have to get device information (e.g. the "identify device" command), and (for modern drives) this data includes an (up to) 40 byte serial number.
Cheers,
Brendan
What are you reading? If you read a magic signature from a sector, then the user can clone the raw data (e.g. copy the raw data onto other USB sticks), and you won't be able to tell the difference between the clones.Holus wrote:Thanks. Read 1x on plug-in and detect. That sounds like a nice simple solution.
For all USB devices; when a USB device is plugged in you first have to find out what the device is (get the class and subclass codes to determine if it's a storage device or a keyboard or mouse or whatever). To do this you ask the device for a "Device Descriptor". In addition to class and subclass codes, the "Device Descriptor" includes a vendor ID, a product ID and a serial number. The serial number is a string of at least 12 Unicode characters that must be unique for the vendor ID and product ID; and by concatenating "vendor + product + serial" you end up with a globally unique identifier.
Basically, you have to get this data from the device anyway (to determine what sort of device it is), and can use it to determine if the device is the same one.
Note: For hard disks it's slightly similar. You have to get device information (e.g. the "identify device" command), and (for modern drives) this data includes an (up to) 40 byte serial number.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.