Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I need to write a program to open a file on an usb mass storage devive(pendrive) without using mount point.

I used libusb API to open the device but how to open a file in that drive without knowing the mount point?
Any API functions are there to open text file in that?
Is it possible to open files like that?

Please give any suggestions regarding this.
Posted
Updated 3-Jan-11 21:40pm
v3
Comments
Dalek Dave 4-Jan-11 3:40am    
Edited for Readability.
GPUToaster™ 4-Jan-11 3:51am    
What happens if two or more pen drives are plugged in! You need to enumerate through the mounted devices and know there mount points.
E.F. Nijboer 4-Jan-11 6:33am    
I agree with GPUToaster because why would you want to bypass the OS? Not mounting it would also mean that the no filesystem manager is mounted and must be done by yourself (just like tools as GParted can only operate on unmounted drives). Maybe you can explain more of what must be done so maybe another solution can be found for that. Why use unmounted drives? Is there a reason for it?
mahesh_135 4-Jan-11 7:25am    
If there is only 1 device we can mount the device and open a file in that.If 2 or 3 devices are connected and if we dont know where that devices are mounted how we can open a file in that particular device without using the mount point?
Sergey Alexandrovich Kryukov 4-Jan-11 16:49pm    
This a good point -- about multiple devices. It makes the whole approach not making much sense -- however, see my answer.

1 solution

I think you cannot universally code this "without using mount point" no matter what you do.

Here is the why.
For example, I use mount points for all removable devices I use on regular basis -- this is very convenient and allows me working with just one logical drive where I mount everything (almost like in Unix).

Every time I plug in such device, it is recognized as unique known device be the plug-in-play mechanism and is re-mounted in exact same way if it was mounted to a mount point last time. It is not shown as a disk drive until you remove the mount explicitly.

You cannot disable or change this in the application code (for a good reason). So, if you need your application to work on all systems, you should re-formulate your task: how to open a file on USB device, mounted This is not a problem per se, the problem is criteria what location of the file to look for, but any limitations are useless: it can be removable drive #1, removable drive #2, mount point #1, mount point #2, etc.

For drives, you can identify if it is removable or not:

C
UINT WINAPI GetDriveType(
  __in_opt  LPCTSTR lpRootPathName
);


If this API returns DRIVE_REMOVABLE it is removable.



You should ask yourself how do you want to define this location, no more no less.
 
Share this answer
 
v4
Comments
GPUToaster™ 20-Jan-11 1:01am    
I'm in complete agreement!
Sergey Alexandrovich Kryukov 20-Jan-11 15:26pm    
Thank you, glad to hear that. Do you toast some GPUs :-) I guess I know what it may mean... :-)
GPUToaster™ 21-Jan-11 7:42am    
Oh yes...OC'ng is my favourite part I do with my GPU. Till now i have just toasted them not roasted!! (Bad Joke I guess!!) :)
Sergey Alexandrovich Kryukov 21-Jan-11 20:31pm    
I don't know; I guess it depends on the temperature the chip can withstand -- can you tell me that? :-)
Thank you.
--SA
GPUToaster™ 22-Jan-11 0:02am    
Very Close...But there is one more factor. The internal components like logic gates, should be able to handle the voltage changes. In OC'ng the recommended hardware voltage is changed which is a very crucial stage. If you are unable to provide proper change in voltage then you might hurt your card as well. Temperature is a secondary concern which is Controllable. Even a blower like a "Fox 1" having a rating of 45CFM(Cubic feet per Minute) can cool down your hardware in no time.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900