Thread: Standard Low-Level Disk Operations

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    719

    Standard Low-Level Disk Operations

    ....are there any? I have searched but all my searching has gone in <vane|vein|vien>

    edit: ok, i am tired...what a stupid question.... let's try, are there any low-level disk operations for linux?
    Last edited by misplaced; 12-17-2004 at 08:33 AM.
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >all my searching has gone in <vane|vein|vien>
    "all my searching has been in vain".

    >....are there any?
    What kind of low level disk operations are you talking about? That's a rather broad topic, so it's difficult to give you an accurate answer.

    >let's try, are there any low-level disk operations for linux?
    Yes.
    My best code is written with the delete key.

  3. #3
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    For some reason I'm thinking he means something in the way of direct hardware access. If so, no there aren't any. All such operations are very OS specific.

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Well, there are, but not in userspace. Kernel modules are a different matter. (Not that it is a good idea to use them even there.)
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    well, i would like to be able to emulate linux's "dd" command...i think if i knew how to do that, then i would know how to do anything else that i might possibly want to do (write a bootloader{just to say i can}, copy the FAT, copy partition table, etc)......

    now that i realize i pretty much have to choose an OS and stick with it, maybe i should look at the "dd" source
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    dd's source looks something like this:
    Code:
    int main(int argc, char **argv)
    {
      handle_absurdly_complex_cmdline(argc, argv);
    
      int input = open(inputfilename_or_stdin, F_READ);
      int output = open(outputfilename_or_stdout, F_WRITE | configured_additional_flags);
    
      char *buffer = malloc(configured_buffer_size);
    
      while(!input_eof_or_configured_copy_size_reached) {
        read(input, buffer, configured_block_size);
        write(output, buffer, configured_block_size);
      }
    }
    This simple (relatively...) source is possible because Unices offer access to the devices via the device files in a uniform way. Whether the input and output are files, hard disks, tape drives or whatever doesn't matter at all to dd.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #7
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    well then, i guess there's only one thing left to figure out before i get start (doing what ever i'm going to do)....

    i'm still unclear on one thing however....to my understanding -
    the master boot record is the first sector on the master drive. within this sector is the partition table for the master drive. each partition has it's own boot sector which is located in the first sector of the partition. the filesystem resides within it's partition's boot sector.

    is this correct so far?
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  8. #8
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I her code isn't clear to you if you are used to a windows environment. But as far as things go in a Unix type system, everything is a file. Thus everything can be operated on as a file. I should point out that if you are wanting to make your own simple dd program, you could start by reading the actual dd source code.

  9. #9
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    perhaps being able to emulate dd is not what i want.....

    let's put it this way, i want to be able to read and write to the mbr, boot sectors, filesystems, etc......maybe i should look at the source to lilo installer, fdisk, and mk2fs instead/also.

    (btw, my intentions are pure...this curiosity came about while i was trying to figure out a way to make an image of windows that i could easily restore which has now spawned into a much grander desire - TOTAL DOMINATION! BWAAAHAHAH BWAAAHAAHAHAHA - my PC will bow down before me and be my subservient gimp for all eternity)
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  10. #10
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Power over computers is an illusion.

    Yes, you can read all that stuff by directly accessing hdx(n), but that doesn't mean that you'd actually know where the stuff is. lilo installer might be a good place to look, though.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Low level programming question
    By phooey in forum C++ Programming
    Replies: 2
    Last Post: 02-16-2003, 08:59 AM
  2. Game Structure
    By Travis Dane in forum Game Programming
    Replies: 7
    Last Post: 12-27-2002, 12:34 PM
  3. Low level access to parallel ports under win2k
    By Incubus in forum Windows Programming
    Replies: 1
    Last Post: 04-23-2002, 01:52 AM
  4. Low level debuggers
    By Korn1699 in forum C++ Programming
    Replies: 8
    Last Post: 03-27-2002, 01:39 PM
  5. Looking low level tcp/ip tracker program
    By Hoxu in forum Windows Programming
    Replies: 3
    Last Post: 01-07-2002, 11:46 PM