LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-02-2006, 01:26 PM   #1
rakestraw
LQ Newbie
 
Registered: Aug 2006
Posts: 3

Rep: Reputation: 0
Question C program which copies floppy (FAT12)


Hi there!

I write one simple C program, which reads a content of diskette and than write it to another...BUT, i need to do it that program will copy just used sectors and that's sectors will stay on same place (addresses).

Please, give me some advices how to make that...cause my problem is, i don't know how to start. I know some FAT12 basics...but i don't know how to use it in a program.

Tnx!
 
Old 08-03-2006, 10:09 AM   #2
cdhgee
Member
 
Registered: Oct 2003
Location: St Paul, MN
Distribution: Fedora 8, Fedora 9
Posts: 513

Rep: Reputation: 30
You don't need to write one...it already exists.

It's called dd and it does a block-by-block copy from any device to any device. For example:

Code:
dd if=/dev/floppy1 of=/dev/floppy2
will copy the entire contents of floppy1 to floppy2, irrespective of size, filesystem format, etc.
 
Old 08-03-2006, 11:22 AM   #3
rakestraw
LQ Newbie
 
Registered: Aug 2006
Posts: 3

Original Poster
Rep: Reputation: 0
yeah I know...but, I need it to write for Faculty task...can I get source dd program...I'll check out, but I don't know if is it writen in C or if it does only this task...
 
Old 08-03-2006, 12:58 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
Originally Posted by rakestraw
can I get source dd program...I'll check out, but I don't know if is it writen in C or if it does only this task...
"dd" is written in C for sure.
"dd" is part of the GNU coreutils package which you can download from ftp://mirrors.usc.edu/pub/gnu/coreutils/

To copy the floppy, I think just copying /dev/fd0 will do. To skip unused sectors, you'll need to read and parse the File Allocation Table (FAT). Search the web on how to get that information from /dev/fd0.
 
Old 08-04-2006, 03:00 AM   #5
rakestraw
LQ Newbie
 
Registered: Aug 2006
Posts: 3

Original Poster
Rep: Reputation: 0
Tnx!
Yes i work with /dev/fd0.
I was allready workink with readig Boot sectors to calculate the start of a FAT, but i didn't know if that's right way...
I found site, where is written about "File Allocation Table Entry Cluster Values" and how to read them...smth about shiffting en reversing...

I also find that info:
Number of FATs: 2
Sectors per FAT: 9
Total Sectors: 2,880
Sectors per Cluster: 1

Somehow i need to walk through this 2880 sectors, check if they are unused and skip them...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Too many copies come out of printer Phrenchax Linux - Hardware 1 07-01-2006 04:12 AM
Slow file copies mwn Linux - Networking 2 12-18-2005 09:06 AM
code for make format floppy in fat12 mode flatronft Linux - Software 0 01-02-2004 06:50 AM
which daemon or program watches writing files on floppy disk? norman68 Linux - Software 2 04-04-2003 07:08 PM
fork and copies of variables Griffon26 Programming 3 08-23-2002 07:45 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration