buf_subs.c (36049) | buf_subs.c (46684) |
---|---|
1/*- 2 * Copyright (c) 1992 Keith Muller. 3 * Copyright (c) 1992, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Keith Muller of the University of California, San Diego. 8 * --- 26 unchanged lines hidden (view full) --- 35 * SUCH DAMAGE. 36 */ 37 38#ifndef lint 39#if 0 40static char sccsid[] = "@(#)buf_subs.c 8.2 (Berkeley) 4/18/94"; 41#endif 42static const char rcsid[] = | 1/*- 2 * Copyright (c) 1992 Keith Muller. 3 * Copyright (c) 1992, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Keith Muller of the University of California, San Diego. 8 * --- 26 unchanged lines hidden (view full) --- 35 * SUCH DAMAGE. 36 */ 37 38#ifndef lint 39#if 0 40static char sccsid[] = "@(#)buf_subs.c 8.2 (Berkeley) 4/18/94"; 41#endif 42static const char rcsid[] = |
43 "$Id$"; | 43 "$Id: buf_subs.c,v 1.10 1998/05/15 06:27:37 charnier Exp $"; |
44#endif /* not lint */ 45 46#include <sys/types.h> 47#include <sys/stat.h> 48#include <errno.h> 49#include <unistd.h> 50#include <stdlib.h> 51#include <string.h> --- 45 unchanged lines hidden (view full) --- 97 * does not specify a blocksize, we use the format default blocksize. 98 * We must be picky on writes, so we do not allow the user to create an 99 * archive that might be hard to read elsewhere. If all ok, we then 100 * open the first archive volume 101 */ 102 if (!wrblksz) 103 wrblksz = frmt->bsz; 104 if (wrblksz > MAXBLK) { | 44#endif /* not lint */ 45 46#include <sys/types.h> 47#include <sys/stat.h> 48#include <errno.h> 49#include <unistd.h> 50#include <stdlib.h> 51#include <string.h> --- 45 unchanged lines hidden (view full) --- 97 * does not specify a blocksize, we use the format default blocksize. 98 * We must be picky on writes, so we do not allow the user to create an 99 * archive that might be hard to read elsewhere. If all ok, we then 100 * open the first archive volume 101 */ 102 if (!wrblksz) 103 wrblksz = frmt->bsz; 104 if (wrblksz > MAXBLK) { |
105 pax_warn(1, "Write block size of %d too large, maximium is: %d", | 105 pax_warn(1, "Write block size of %d too large, maximum is: %d", |
106 wrblksz, MAXBLK); 107 return(-1); 108 } 109 if (wrblksz % BLKMULT) { 110 pax_warn(1, "Write block size of %d is not a %d byte multiple", 111 wrblksz, BLKMULT); 112 return(-1); 113 } --- 28 unchanged lines hidden (view full) --- 142 /* 143 * leave space for the header pushback (see get_arc()). If we are 144 * going to append and user specified a write block size, check it 145 * right away 146 */ 147 buf = &(bufmem[BLKMULT]); 148 if ((act == APPND) && wrblksz) { 149 if (wrblksz > MAXBLK) { | 106 wrblksz, MAXBLK); 107 return(-1); 108 } 109 if (wrblksz % BLKMULT) { 110 pax_warn(1, "Write block size of %d is not a %d byte multiple", 111 wrblksz, BLKMULT); 112 return(-1); 113 } --- 28 unchanged lines hidden (view full) --- 142 /* 143 * leave space for the header pushback (see get_arc()). If we are 144 * going to append and user specified a write block size, check it 145 * right away 146 */ 147 buf = &(bufmem[BLKMULT]); 148 if ((act == APPND) && wrblksz) { 149 if (wrblksz > MAXBLK) { |
150 pax_warn(1,"Write block size %d too large, maximium is: %d", | 150 pax_warn(1,"Write block size %d too large, maximum is: %d", |
151 wrblksz, MAXBLK); 152 return(-1); 153 } 154 if (wrblksz % BLKMULT) { 155 pax_warn(1, "Write block size %d is not a %d byte multiple", 156 wrblksz, BLKMULT); 157 return(-1); 158 } --- 445 unchanged lines hidden (view full) --- 604 incnt -= cnt; 605 in += cnt; 606 } 607 return(cpcnt); 608} 609 610/* 611 * wr_skip() | 151 wrblksz, MAXBLK); 152 return(-1); 153 } 154 if (wrblksz % BLKMULT) { 155 pax_warn(1, "Write block size %d is not a %d byte multiple", 156 wrblksz, BLKMULT); 157 return(-1); 158 } --- 445 unchanged lines hidden (view full) --- 604 incnt -= cnt; 605 in += cnt; 606 } 607 return(cpcnt); 608} 609 610/* 611 * wr_skip() |
612 * skip foward during a write. In other words add padding to the file. | 612 * skip forward during a write. In other words add padding to the file. |
613 * we add zero filled padding as it makes flawed archives much easier to 614 * recover from. the caller tells us how many bytes of padding to add 615 * This routine was not designed to add HUGE amount of padding, just small 616 * amounts (a few 512 byte blocks at most) 617 * Return: 618 * 0 if ok, -1 if there was a buf_flush failure 619 */ 620 --- 173 unchanged lines hidden (view full) --- 794 } else 795 bufpt += res; 796 size -= res; 797 } 798 799 /* 800 * if the last block has a file hole (all zero), we must make sure this 801 * gets updated in the file. We force the last block of zeros to be | 613 * we add zero filled padding as it makes flawed archives much easier to 614 * recover from. the caller tells us how many bytes of padding to add 615 * This routine was not designed to add HUGE amount of padding, just small 616 * amounts (a few 512 byte blocks at most) 617 * Return: 618 * 0 if ok, -1 if there was a buf_flush failure 619 */ 620 --- 173 unchanged lines hidden (view full) --- 794 } else 795 bufpt += res; 796 size -= res; 797 } 798 799 /* 800 * if the last block has a file hole (all zero), we must make sure this 801 * gets updated in the file. We force the last block of zeros to be |
802 * written. just closing with the file offset moved foward may not put | 802 * written. just closing with the file offset moved forward may not put |
803 * a hole at the end of the file. 804 */ 805 if (isem && (arcn->sb.st_size > 0L)) 806 file_flush(ofd, fnm, isem); 807 808 /* 809 * if we failed from archive read, we do not want to skip 810 */ --- 83 unchanged lines hidden (view full) --- 894 sys_warn(1, errno, "Failed stat of %s", arcn->org_name); 895 else if (arcn->sb.st_mtime != sb.st_mtime) 896 pax_warn(1, "File %s was modified during copy to %s", 897 arcn->org_name, arcn->name); 898 899 /* 900 * if the last block has a file hole (all zero), we must make sure this 901 * gets updated in the file. We force the last block of zeros to be | 803 * a hole at the end of the file. 804 */ 805 if (isem && (arcn->sb.st_size > 0L)) 806 file_flush(ofd, fnm, isem); 807 808 /* 809 * if we failed from archive read, we do not want to skip 810 */ --- 83 unchanged lines hidden (view full) --- 894 sys_warn(1, errno, "Failed stat of %s", arcn->org_name); 895 else if (arcn->sb.st_mtime != sb.st_mtime) 896 pax_warn(1, "File %s was modified during copy to %s", 897 arcn->org_name, arcn->name); 898 899 /* 900 * if the last block has a file hole (all zero), we must make sure this 901 * gets updated in the file. We force the last block of zeros to be |
902 * written. just closing with the file offset moved foward may not put | 902 * written. just closing with the file offset moved forward may not put |
903 * a hole at the end of the file. 904 */ 905 if (!no_hole && isem && (arcn->sb.st_size > 0L)) 906 file_flush(fd2, fnm, isem); 907 return; 908} 909 910/* --- 173 unchanged lines hidden --- | 903 * a hole at the end of the file. 904 */ 905 if (!no_hole && isem && (arcn->sb.st_size > 0L)) 906 file_flush(fd2, fnm, isem); 907 return; 908} 909 910/* --- 173 unchanged lines hidden --- |