Shoot!  Cracked open my old Unix System programming book,
and the very first example has (almost) everything you would
need, other that a Perl Wrapper or such.....  but it's
not quite what I would use... I've appended both.  Comments,
debugging (I haven't even tested the code to see it compiles...)
etc., welcome.

This snippet of code can be modified easily.  It's from 
"Advanced Programming in the Unix Environment" copyright 1992
by W. Richard Stevens.   p7 
-----------------------------------
#include "ourhdr.h"
#define BUFFSIZE 8192

int
main(void)
(
        int     n;
        char    buf[BUFFSIZE];

        while ( (n = read(STDIN_FILENO,buf,BUFFSIZE)) > 0)
                if (write(STDOUT_FILENO,buf,n) !=n)
                        err_sys("Write error");

        if (n<0)
                err_sys("read error");

        exit(0);
}
------------------------------------------------------------
Ok, that's my base.  Here's my code (NOT TESTED):

/* Diskcopy v0.1 */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>

/* I'm not currently doing much error handling... that needs to be fixed */
/* By William Ward 4/20/2000.  Please leave me in the list of contributors
*/

#define BUFFSIZE 1572864  /* Is this right?  Should be close... */
int
main(int argc, char *argv[])
{
        int             n,m,err;
        char            buf[BUFFSIZE];
        char            keypress[16];  /* doesn't need to be this big,
though... */

        if (argc<1)
        {
                fprintf(stderr,"Usage:  %s /dev/fd<diskno>\n",argv[0]);
                exit(0);
        }
        n=open(argv[1],O_RDONLY);
        if (n<>0)
        {
                fprintf(stderr,"Error opening diskette.  Do you have a disk
inserted?\n");
                exit(-1);
        }
        err=read(n,buf,BUFFSIZE);
        if (err<0)
        {
                err_sys("read error");
                exit(-2);
        }
        err=close(n);
        fprintf(stdout,"%s read.  Change diskettes and press any
key\n",argv[1]);
        while (err=read(STDIN_FILENO,keybress,16))>0
        {
        }
        m=open(argv[1],O_WONLY);
        if (m<>0)
        {
                fprintf(stderr,"Error opening diskette.  Did you have a
diskette inserted?\n");
                exit(-3);
        }
        err=write(m,buf,BUFFSIZE);
        if (err<0)
        {
                err_sys("write error");
                exit(-4);
        }
        err=close(m);
        exit(err);
}
---------------------------------------------------------------
-----Original Message-----
From: Manuel A. Camacho Q. [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 19, 2000 11:25 PM
To: Danny
Cc: recipient.list.not.shown; @nswcphdn.navy.mil
Subject: Re: How to copy floppy disks.


Danny wrote:
> 
> I believe you might be typing about tansferring files to the Windows OS.
> Maybe not!!! anyway if you are typing about transfering floppies with
Microsoft
> OS check out this tool called "mtool" from

Nop. Duplicating a diskette using the Linux shell (bash). Seems by the
replies I have that there is not a way of avoiding doing a temporal file
on a hdd, except installing a /dev/fd1...

-Manuel.


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.

Reply via email to