bug-fileutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

dd modifications


From: Eric Thomas
Subject: dd modifications
Date: Tue, 28 Jan 2003 01:32:28 -0800
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9) Gecko/20020408

Dear Author,

I'm submitting patches that I made to the dd program and manual page. The changes allow the use of the conv=stat keyword, which will cause the program to display copy progress based upon the number of blocks read out of the total number of blocks that will be read. This is very useful when using dd to copy disk images to harddrives. The original fileutils-4.1 package was downloaded on January 20, 2003 from rpmfind.net. Please consider the inclusion of these changes for future fileutils distributions. Thank you,

Eric Thomas
address@hidden
83a84,86
> stat
> show copy progress
> .TP
28a29,30
> #include <sys/stat.h>
> #include <unistd.h>
85a88
> #define C_STAT 010000
150a154,156
> /* Approximate # of blocks to be copied.  For progress bar. */
> static unsigned long blocks = 0;
> 
168a175
>   {"stat", C_STAT},             /* Show copy progress. */
323a331
>   stat      show copy progress\n\
440a449
>   struct stat stats;
442a452
>   
445a456,466
>   /* For the progress indicator */
>   if (options == O_RDONLY)
>   {
>     fstat(fd, &stats);
> 
>     if (stats.st_size == 0 && max_records != -1)
>       blocks = max_records;
>     else if (stats.st_size != 0)
>       blocks = stats.st_size / input_blocksize - skip_records;
>   }
> 
963a985,1011
> 
>       if (conversions_mask & C_STAT)
>       {
>         /* Progress indicator is based upon records read */
>         if (blocks == 0)
>         {
>           if (r_full % 4 == 0)
>               fprintf(stderr,
>                       _("   | Copying...To see progress specifiy count\r"));
>         else if (r_full % 4 == 1)
>               fprintf(stderr,
>                       _("   / Copying...To see progress specifiy count\r"));
>         else if (r_full % 4 == 2)
>               fprintf(stderr,
>                       _("   - Copying...To see progress specifiy count\r"));
>         else if (r_full % 4 == 3)
>               fprintf(stderr,
>                       _("   \\ Copying...To see progress specifiy count\r"));
>         fflush(stderr);
>         }
>         else
>         {
>           fprintf(stderr, _("   %3d%% Complete\r"),
>                     (int)(((double)r_full / blocks) * 100.0));
>           fflush(stderr);
>         }
>       }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]