How to get floppy disk information ?!!

This is a discussion on How to get floppy disk information ?!! within the C Programming forums, part of the General Programming Boards category; Mission accomplished !!:Lol After all i decided to use a structure to hold data ( i was tired of using ...

  1. #46
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    Mission accomplished !!:Lol
    After all i decided to use a structure to hold data ( i was tired of using loops to give a variable different numbers in order to get what i want(ex.going exactly to the Byte "12" of the floppy disk and then try to read it .. as you guys kindly mentioned it before that This is not correct , ( i know , but i couldnt get what oyu were telling me ) after all the codes are complete;t different ... here it is , tell me if any thing is wrong .. if all are alright .. if there is a better way of expressing it i would be very thankful if you tell me

    Code:
    //In the name of GOD
    /* Using Structure to hold data 
    version 0.1
    A Piece of COde that extracts floppy disk geometry information, its  been writen in pure C and has been tested and ran seccessfully under TC 3 ...
     Cod3r :Seyyed HOssein hasn pour in NOvember 12th 2007
     www.PersianOs.org*/
    //||||||||||||||||||Define Session||||||||||||||||||||||
    typedef unsigned char BYTE;
    typedef short int     WORD;
    typedef int          DWORD;
    //|||||||||||||||||||Main Session|||||||||||||||||||||||
    void profile_1(void);
    #include <stdio.h>
    #include <process.h>
    #include <string.h>
    #include <conio.h>
    #include <dos.h>
    
     int main(void)
    {
    //|||||||||||||||||||Structure To hold data|||||||||||||
    struct Floppy_DISK_INFORMATION
    {
       BYTE jumpCode[3];
       BYTE oemName[8];
       WORD bytes_Sector;
       BYTE sec_Cluster;
       WORD size_Sector_Reserved;
       BYTE fatCount;
       WORD Max_Root_Entry;
       WORD Total_Sector_FS;
       BYTE Media_Type;
       WORD sectors_per_fat;
       WORD sectors_per_track;
       WORD total_Head_Count;
       DWORD no_Sectors_Before_Part;
       DWORD no_Sector_FS32;
       BYTE BIOS_13h_Drive_No;
       BYTE reserved;
       BYTE ext_Boot_Part_Signature;
       DWORD vol_Serial_Number;
       BYTE vol_Lebel_Name[11];
       BYTE FS_Type[8];
       BYTE boot_Code[448];
       WORD signature;
    } fdi;
    
    //|||||||||||||||||||Declaring variables|||||||||||||||||
        int j,i,start,sector;
        char buf[512];
        profile_1();
        sector =0;
    //|||||||||||||||||Reading From Floppy Disk |||||||||||||
        if (absread (0, 1, sector,&fdi)!=0)
    	{
        printf ("An Error Has Occurred!");
        exit(1);
           }
    
    
       printf("Read Seccessfully !\n");
    
     // fptr=fopen("D:\temp.fds","w");
     // for (i=0;i<=1;i++)
       //	{	    // Print floppy information on Console.
    
       printf("Floppy Disk Information: \n");
       printf("===========================\n");
       printf("Assembly Instruction to jump to Boot code: 0x%x\n",
    	  fdi.jumpCode);
       printf("OEM Name: %s\n",&fdi.oemName);
       printf("Bytes per sector: %d\n",fdi.bytes_Sector);
       printf("Sector per cluster: %d\n", fdi.sec_Cluster);
       printf("Size in sector for reserved area(Boot Sector): %d\n",
    	  fdi.size_Sector_Reserved);
       printf("Number of FATs(File Allocation Table): %d\n",
    	  fdi.fatCount);
       printf("Number of files for root directory: %d\n",
    	   fdi.Max_Root_Entry);
       printf("Number of Sectors in File System: %d\n",
    	  fdi.Total_Sector_FS);
       printf("Media Type\n(According to Microsoft,0xF8 == fixed disk and 0xF0 == Removable disk):0x%x\n", fdi.Media_Type);
       printf("Number of Sectors for each FAT: %d\n",
    	  fdi.sectors_per_fat);
       printf("Sectors per track: %d\n", fdi.sectors_per_track);
       printf("Number of head in storage device: %d\n",
    	  fdi.total_Head_Count);
       printf("BIOS INT13h Drive number: 0x%x\n", fdi.BIOS_13h_Drive_No);
       printf("Volume Serial Number: %d\n", fdi.vol_Serial_Number);
       printf("Volume label Name: %s\n", fdi.vol_Lebel_Name);
       printf("Boot Sector Signature: 0x%x\n", fdi.signature);
    	     printf("                 Programed By Seyyed Hossein Hasan Pour\n");
    	     printf("                         November 10th 2007 ");
    	 printf("\n                          wWw.Persianos.org ");    
    getch();
         return 0;
        }
    void profile_1(void)
    {   int k;
        clrscr();
        gotoxy(27,5);
        printf("In the name of God\n");
       gotoxy(22,7);
        printf("A S.Hossein hasan pour Project\n\n");
        printf ("This program will show you the information stored on sector 0 of the Floppy Disk\n\n                        (FAT TABLE INFORMATION).\n\n\n              if you are ready press any key to continue ");
        for (k=0;k<=3;k++){
        //delay(50);
        printf(".");       }
        getch();
        }
    by the way how can i edit my posts? !!! i just wanted to edit some post , but i noticed i cant

  2. #47
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Code:
     // fptr=fopen("D:\temp.fds","w");
    I know it's a comment and all, but consider changing that \ to \\.

    by the way how can i edit my posts? !!! i just wanted to edit some post , but i noticed i cant
    You can't after a certain period of time, a few days I believe.

    Your indentation could use improvement.

    Since DOS labels can be up to 11 characters long, your 11-character array might not always be NULL-terminated. So don't go printing it as if it were.

    BTW, it's spelled "label" . . .
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #48
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    tanx ..

    about that "D:\*.fdi) yes , i you are write ..but i comment it cause i dont need it any more , and by actualy i forgot to delete it )
    I used that "Lebel " instead of "Label" cause i thought its some how a better idea not to use the same word . it may get errors you know
    thats why i wrote such word( cause we have "Lable " in C .. that is why .. and now i think i was wrong any way.. it wont give me any errors though !)"
    printf("Volume label Name: &#37;s\n", fdi.vol_Lebel_Name);

    tanx
    Last edited by Masterx; 11-26-2007 at 09:45 AM.

  4. #49
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Masterx View Post
    tanx ..
    i used that "Lebel " instead of "Label" cause i thought its some how a better idea not to use the same word . it may get errors you know
    thats why i wrote "
    printf("Volume label Name: %s\n", fdi.vol_Lebel_Name);

    tanx
    Incorrectly spelling words in code is never a good idea. Abbreviations is sort of OK, but misspelings are always bad - someone else will use the correct spelling and then wonder why it's not working right. In this case it would probably be OK, but may not be in other cases [typical case is overriding classes in C++].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #50
    Registered User
    Join Date
    Oct 2007
    Posts
    242
    Sorry for being such an ignorant but what's the floppy disk?
    I can see it here on Computer in Linux but what is it exactly?

    What are the WORD & BYTE and all the other type definitions you mentioned at the begging? I've never seen them before on a code.

    What does absread do?

    Thanks.
    Last edited by eXeCuTeR; 11-26-2007 at 11:18 AM.

  6. #51
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by eXeCuTeR View Post
    Sorry for being such an ignorant but what's the floppy disk?
    I can see it here on Computer in Linux but what is it exactly?

    What are the WORD & BYTE and all the other type definitions you mentioned at the begging? I've never seen them before on a code.

    What does absread do?

    Thanks.
    Why don't you look at some decent code instead of stuff that would work better on a 10 year old machine than todays machines? This piece of code is DEFINITELY NOT a good example of how to write code.

    A floppy disk is a removable storage media with a capacity of about 2.8MB per disk, or less, depending on model. Try searching on the web if you want more info.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #52
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    A floppy disk is a removable storage media with a capacity of about 2.8MB per disk, or less, depending on model. Try searching on the web if you want more info.
    I must say, nearly every floppy disk I've ever come across was 1.44MB. It's true that Microsoft floppy disks are sometimes slightly larger, but that's a MS extension and not very common.

    That's for high density disks, which are the norm these days. The old ones (double-density) were 720KB. You can tell them apart by the little hole that 1.44s have punched in the corner. Really, really old disks are 400KB or less (DOS 3.21 disks or ancient Mac ones).

    There's a little tab on one corner of all 3.5" disks. It's really neat. You slide a cover across it, and the disk is writable. You slide the cover back to expose the hole, and the disk is read-only! Very useful for transferring data to rather suspect systems. I seem to remember that it's next to impossible to circumvent this with software, so even the nastiest worm can't touch your disk. (You can always format it afterwards if you're paranoid like me.)

    On the opposite corner is the hole I mentioned. If there's a hole, it's a high density disk (1.44MB). If there isn't, it's a double density one (720KB). The smaller sizes you can't really tell apart until you read them.

    Oh, and don't try to format a double-density disk as a high density one . . . their drums or whatever are not of the same quality, usually, and it doesn't last long. The other way around is fine AFAIK.

    All of that is for 3.5" (inch) floppy disks. Really, really, really old disks were 5.25" across, the same size as a CD or DVD. They held 320KB or 1.2MB in their different incarnations, I believe. They really were floppy -- you could bend them easily. They were like semi-thick sheets of paper. Really, really, really, really old floppy disks were 8" across.

    I read somewhere that an absurdly high percentage of the world's information is still stored only on 5.25" floppy disks -- like 65&#37; or something. Take this with a truck-sized grain of salt, however, as someone else once said. (brewbuck?)

    Taking apart floppy drives is really fun . . . I have so many of them around that nearly every single 3.5" slot on the desktops around (the ones that work) have floppy drives in them . . . some of them I installed upside-down, but hey . . . .

    And all floppy disks are really, really ssslllooowww . . . .

    </floppy-digest>

    Or, read all about it at Wikipedia! http://en.wikipedia.org/wiki/Floppy_disk
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Page 4 of 4 FirstFirst 1234
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. floppy disk filesystems
    By Leeman_s in forum Tech Board
    Replies: 5
    Last Post: 12-10-2003, 04:54 PM
  2. Going out of scope
    By nickname_changed in forum C++ Programming
    Replies: 9
    Last Post: 10-12-2003, 07:27 PM
  3. Formatting Output
    By Aakash Datt in forum C++ Programming
    Replies: 2
    Last Post: 05-16-2003, 09:20 PM
  4. Special Allegro Information
    By TechWins in forum Game Programming
    Replies: 12
    Last Post: 08-21-2002, 12:35 AM
  5. Information about disk
    By GaPe in forum C Programming
    Replies: 18
    Last Post: 08-05-2002, 07:48 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21