FreeBSD Bugzilla – Attachment 35829 Details for
Bug 57715
[patch] tcopy(1) enhancement
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 2.41 KB, created by
ob
on 2003-10-07 20:50:07 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
ob
Created:
2003-10-07 20:50:07 UTC
Size:
2.41 KB
patch
obsolete
>--- tcopy.c.orig Thu Nov 7 18:54:42 2002 >+++ tcopy.c Tue Oct 7 15:14:07 2003 >@@ -32,4 +32,8 @@ > */ > >+/* >+ Modification 2000 Daniel Mack, Oliver Breuninger >+*/ >+ > #ifndef lint > static const char copyright[] = >@@ -86,5 +90,10 @@ > int ch, needeof; > char *buff, *inf; >+ struct stat statbuf; >+ char Dirname[0xff], FileName[0xff]; >+ int BlockSize; > >+ bzero (Dirname, sizeof (Dirname)); >+ bzero (FileName, sizeof (FileName)); > msg = stdout; > guesslen = 1; >@@ -130,7 +139,16 @@ > op = COPY; > inf = argv[0]; >- if ((outp = open(argv[1], op == VERIFY ? O_RDONLY : >- op == COPY ? O_WRONLY : O_RDWR, DEFFILEMODE)) < 0) >- err(3, "%s", argv[1]); >+ >+ /* create file */ >+ if ((!stat (argv[1], &statbuf)) && (statbuf.st_mode & S_IFDIR)) { >+ sprintf (Dirname, "%s/tcopy.tmp", argv[1]); >+ if ((outp = open (Dirname, O_CREAT | O_RDWR, DEFFILEMODE)) < 0) >+ err (3, "%s", Dirname); >+ } >+ else { >+ if ((outp = open(argv[1], op == VERIFY ? O_RDONLY : >+ op == COPY ? O_WRONLY : O_RDWR, DEFFILEMODE)) < 0) >+ err(3, "%s", argv[1]); >+ } > break; > default: >@@ -171,4 +189,5 @@ > } > if (nread != 0) >+ BlockSize = nread; > fprintf(msg, "file %d: block size %d: ", > filen, nread); >@@ -180,7 +199,12 @@ > if (op == COPY || op == COPYVERIFY) { > if (needeof) { >- writeop(outp, MTWEOF); >- needeof = 0; >- } >+ if (! strlen (Dirname)) { >+ writeop(outp, MTWEOF); >+ needeof = 0; >+ } >+ } >+ >+ /* fprintf(msg, "tcopy: block %qu\n", record); */ >+ > nw = write(outp, buff, nread); > if (nw != nread) { >@@ -197,4 +221,14 @@ > record++; > } else { >+ if (strlen (Dirname)) { >+ nw = write(outp, buff, nread); >+ >+ sprintf (FileName, "%s/file-%03d.%d", argv[1], filen, BlockSize); >+ close (outp); >+ rename (Dirname, FileName); >+ if ((outp = open (Dirname, O_CREAT | O_RDWR, DEFFILEMODE)) < 0) >+ err (3, "%s", Dirname); >+ } >+ > if (lastnread <= 0 && lastnread != NOCOUNT) { > fprintf(msg, "eot\n"); >@@ -211,10 +245,19 @@ > } > lastnread = nread; >+ > } > fprintf(msg, "total length: %qu bytes\n", tsize); > (void)signal(SIGINT, oldsig); > if (op == COPY || op == COPYVERIFY) { >- writeop(outp, MTWEOF); >- writeop(outp, MTWEOF); >+ if (strlen (Dirname)) { >+ close (outp); >+ remove (FileName); >+ remove (Dirname); >+ } >+ else { >+ writeop(outp, MTWEOF); >+ writeop(outp, MTWEOF); >+ } >+ > if (op == COPYVERIFY) { > rewind_tape(outp);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 57715
: 35829