#include "stdio.h" #include "stdlib.h" #include "sys/stat.h" #include "sys/types.h" #include "fcntl.h" #define BLOCK_SIZE 512 #define BUF_SIZE 1024 #define TOTAL_BUF (BUF_SIZE<<1) typedef struct { char data[BUF_SIZE*2+1]; int base,top; int length; }buf_queue; void do_dd(int infilefd ,int outfilefd ,int iperbytes ,int operbytes ,int cperbytes ,int totalblocks); static inline int buf_empty(buf_queue *buf); static inline int buf_length(buf_queue *buf); int read2buf(int fd,buf_queue *buf,int size); int writefrombuf(int fd,buf_queue *buf,int size); int main(int argc,char **argv) { int i; int iperbytes=BLOCK_SIZE,operbytes=BLOCK_SIZE,cperbytes=0; int totalblocks = -1,seekblocks=0,skipblocks=0; clock_t begin,end; off_t fbegin,fend; int noxfer=0; int infilefd,outfilefd; char *infile=NULL,*outfile=NULL,*iflags=NULL,*oflags=NULL; for(i=1;i<argc ;i++) { if(!strncmp(argv[i],"bs",strlen("bs"))) { iperbytes = operbytes = atoi(argv[i]+strlen("bs")+1); }else if (!strncmp(argv[i],"cbs",strlen("cbs"))) { cperbytes = atoi(argv[i]+strlen("cbs&#
Linux dd 源程序
最新推荐文章于 2024-12-18 18:03:54 发布