How do I find out if drive (possibly WITHOUT file system) exists?

Discussion in 'C++' started by Tony Bansten, Aug 4, 2005.

  1. Tony Bansten

    Tony Bansten Guest

    Assume I have a partition (under WIn2000/WInXP) which is possibly NOT
    formatted with a files system (e.g. NTFS). This could be a partition on an external
    USB harddisc.

    How do I find out if this partition exist?

    Notice that "normal" program code that refers to the root directory or a file system do
    not work.

    The C++ or C code should use not use .NET functions.

    Tony
     
    Tony Bansten, Aug 4, 2005
    #1
    1. Advertising

  2. In article <42f2266a$0$11752$-online.net>,
    Tony Bansten <> wrote:
    >Assume I have a partition (under WIn2000/WInXP) which is possibly NOT
    >formatted with a files system (e.g. NTFS). This could be a partition on an external
    >USB harddisc.


    >How do I find out if this partition exist?


    The C and C++ languages do not know themselves anything about
    partitions. You should ask in a Windows newsgroup.



    FYI, there are some traditional approaches to this problem --
    approaches which might or might not be applicable to Windows:

    a) Wander through the operating system's mount table to figure out
    whether the partition is -already- mounted

    b) Ask the operating system to mount it for you. If the response
    is that it doesn't exist, then you know it doesn't exist.
    If the response is that you don't have permission to mount it,
    then you need to know the OS-specific checking sequence: on
    some OS's, it would be an indication that it has determined that
    a filesystem is there, whereas on other OS's, it would be an
    indication that you don't have enough privilege to mount -any-
    filesystem.

    c) Research technical details about each filesystem type you
    might want to deal with. Ask the operating system to allow you raw
    access to the blocks that make up the partition. Check through
    the blocks, looking for the "magic numbers" that signal various
    different filesystem types. Note: on Unix systems, you would
    normally be disallowed access to the raw partition blocks unless
    you were privileged; I don't know whether the same is true for Windows.

    --
    "I want to make sure [a user] can't get through ... an online
    experience without hitting a Microsoft ad"
    -- Steve Ballmer [Microsoft Chief Executive]
     
    Walter Roberson, Aug 4, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tom Anderson
    Replies:
    8
    Views:
    403
    Gerrit Holl
    Sep 15, 2005
  2. Tony Bansten
    Replies:
    1
    Views:
    289
    Walter Roberson
    Aug 4, 2005
  3. shailesh
    Replies:
    1
    Views:
    813
    Tim Golden
    Mar 28, 2007
  4. Gelonida N
    Replies:
    3
    Views:
    157
    Gelonida N
    Aug 6, 2012
  5. Michael Poeltl
    Replies:
    0
    Views:
    145
    Michael Poeltl
    Aug 7, 2012
Loading...

Share This Page