Solved

C Source code to format a hard drive

Posted on 2000-03-24
6
1,737 Views
Last Modified: 2008-03-03
I am working on a drive utility and I need a little jumpstart with the formatting routines {having a major brain cramp on the hard drive routines}.  What would be of the greatest help would be some source code in C on how to format a hard drive (by the way I am writting this utility for a Intel DOS/16-bit platform, supporting FAT12/FAT16 and eventually FAT32) .  I am already able to format a floppy drive and would now like to add hard drive capabilities to the program.

Thanks.

Michael
0
Comment
Question by:mmessuri
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 5

Expert Comment

by:Wyn
ID: 2655828
FYI(maybe not your case)
HOWTO: Call SHFormatDrive in Windows 95 and Windows NT
http://support.microsoft.com/support/kb/articles/Q173/6/88.ASP 
DeviceIoContol()
0
 

Author Comment

by:mmessuri
ID: 2656009
Thanks for the FYI; However, I am sorry to say that this app will (for now) be running only in a DOS 6.x environment.

-- Michael --
0
 

Expert Comment

by:C_Dreamer
ID: 2656175
#include <stdlib.h>

system("format c:");

There's no other way in C. If you want to go to a lower level, you'll have to use platform-specific libraries and extensions, as C itself knows nothing of such things as "drives", contenting itself with the knowledge that there's probably some kind of file system.

Formatting a hard drive is, in any case, such a complex business nowadays that you are well advised not to do this. I can think of exactly one use for the program you propose - malice.



0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Accepted Solution

by:
feenix earned 995 total points
ID: 2656576
How about looking into the Linux mkdosfs sources? There you can find out how to create different FAT filesystems and more.

ftp://ftp.sunet.se/pub/multimedia/Berkeley/linux/fat32/mkdosfs-0.4.tgz
0
 

Author Comment

by:mmessuri
ID: 2656871
feenix:

Thanks for the answer.  While it was not exactly what I was looking for, it does provide enough information for me to move on past my brain block.  Besides, the multiple file system information will be helpful as I complete my disk partitioning program (it combines the fdisk program with the format program).

-- Michael --
0
 

Author Comment

by:mmessuri
ID: 2656881
C Dreamer:

Thanks for taking the time to comment; however, I was not able to put to use your suggestion as format.com is not going to be available.

BTW:

My intentions are not of malice.  The program is a hard disk partitioning application that allows for the creation / deletion and formating of the partition without the use of format.com or fdisk.exe

-- Michael --
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question