Find the answer to your Linux question:
Results 1 to 3 of 3
Hi! I'm new to this place and dont bother if my query is a little wierd.I wanted to know whether direct disk access(low level;at CHS level)is possible in Linux.I wanted ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2004
    Posts
    3

    Accessing VFAT from Linux


    Hi!
    I'm new to this place and dont bother if my query is a little wierd.I wanted to know whether direct disk access(low level;at CHS level)is possible in Linux.I wanted to develop an app for myself that could give me access to FAT32 filesystems.I know I can mount the VFAT devices,but I donot want to use the option.Kindly let me know any/all possibilities.

  2. #2
    Linux Newbie
    Join Date
    Feb 2004
    Location
    UK
    Posts
    131

    Vfat

    As far as i know you will have to mount them, but this can be done at boot up to save you having to type in the command everytime

  3. #3
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Sorry to bring up old posts like this, but I just couldn't help myself, since it's so incredibly simple. Just open the device file and access it like any other file. You won't get CHS-style access, but who'd want to anyway when you get linear access instead?

    For example, if your VFAT partition is hda3, just something like this will do it:
    Code:
    #include <unistd.h>
    #include <fcntl.h>
    
    int main&#40;int argc, char **argv&#41;
    &#123;
        int fd;
        
        fd = open&#40;"/dev/hda3", O_RDWR&#41;;
        /* Use normal lseek&#40;&#41;, read&#40;&#41;, write&#40;&#41;, etc. operations on fd */
        close&#40;fd&#41;;
        return&#40;0&#41;;
    &#125;
    I think there's some ioctl that you can use to query the CHS geometry of the drive as well if you feel you need it. Naturally, the user running the program will need access to the device file.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •