| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: cpio.c,v 1.20 2009/02/14 08:10:06 lukem Exp $ */ | | 1 | /* $NetBSD: cpio.c,v 1.21 2011/03/26 12:01:06 martin Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1992 Keith Muller. | | 4 | * Copyright (c) 1992 Keith Muller. |
5 | * Copyright (c) 1992, 1993 | | 5 | * Copyright (c) 1992, 1993 |
6 | * The Regents of the University of California. All rights reserved. | | 6 | * The Regents of the University of California. All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to Berkeley by | | 8 | * This code is derived from software contributed to Berkeley by |
9 | * Keith Muller of the University of California, San Diego. | | 9 | * Keith Muller of the University of California, San Diego. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -32,27 +32,27 @@ | | | @@ -32,27 +32,27 @@ |
32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
33 | * SUCH DAMAGE. | | 33 | * SUCH DAMAGE. |
34 | */ | | 34 | */ |
35 | | | 35 | |
36 | #if HAVE_NBTOOL_CONFIG_H | | 36 | #if HAVE_NBTOOL_CONFIG_H |
37 | #include "nbtool_config.h" | | 37 | #include "nbtool_config.h" |
38 | #endif | | 38 | #endif |
39 | | | 39 | |
40 | #include <sys/cdefs.h> | | 40 | #include <sys/cdefs.h> |
41 | #if !defined(lint) | | 41 | #if !defined(lint) |
42 | #if 0 | | 42 | #if 0 |
43 | static char sccsid[] = "@(#)cpio.c 8.1 (Berkeley) 5/31/93"; | | 43 | static char sccsid[] = "@(#)cpio.c 8.1 (Berkeley) 5/31/93"; |
44 | #else | | 44 | #else |
45 | __RCSID("$NetBSD: cpio.c,v 1.20 2009/02/14 08:10:06 lukem Exp $"); | | 45 | __RCSID("$NetBSD: cpio.c,v 1.21 2011/03/26 12:01:06 martin Exp $"); |
46 | #endif | | 46 | #endif |
47 | #endif /* not lint */ | | 47 | #endif /* not lint */ |
48 | | | 48 | |
49 | #include <sys/types.h> | | 49 | #include <sys/types.h> |
50 | #include <sys/time.h> | | 50 | #include <sys/time.h> |
51 | #include <sys/stat.h> | | 51 | #include <sys/stat.h> |
52 | #include <sys/param.h> | | 52 | #include <sys/param.h> |
53 | #include <string.h> | | 53 | #include <string.h> |
54 | #include <ctype.h> | | 54 | #include <ctype.h> |
55 | #include <stdio.h> | | 55 | #include <stdio.h> |
56 | #include <unistd.h> | | 56 | #include <unistd.h> |
57 | #include <stdlib.h> | | 57 | #include <stdlib.h> |
58 | #include "pax.h" | | 58 | #include "pax.h" |
| @@ -639,28 +639,28 @@ vcpio_rd(ARCHD *arcn, char *buf) | | | @@ -639,28 +639,28 @@ vcpio_rd(ARCHD *arcn, char *buf) |
639 | return com_rd(arcn); | | 639 | return com_rd(arcn); |
640 | } | | 640 | } |
641 | | | 641 | |
642 | /* | | 642 | /* |
643 | * vcpio_endrd() | | 643 | * vcpio_endrd() |
644 | * no cleanup needed here, just return size of the trailer (for append) | | 644 | * no cleanup needed here, just return size of the trailer (for append) |
645 | * Return: | | 645 | * Return: |
646 | * size of trailer header in this format | | 646 | * size of trailer header in this format |
647 | */ | | 647 | */ |
648 | | | 648 | |
649 | off_t | | 649 | off_t |
650 | vcpio_endrd(void) | | 650 | vcpio_endrd(void) |
651 | { | | 651 | { |
652 | return (off_t)(sizeof(HD_VCPIO) + sizeof(TRAILER + | | 652 | return (off_t)(sizeof(HD_VCPIO) + sizeof(TRAILER) + |
653 | (VCPIO_PAD(sizeof(HD_VCPIO) + sizeof(TRAILER))))); | | 653 | (VCPIO_PAD(sizeof(HD_VCPIO) + sizeof(TRAILER)))); |
654 | } | | 654 | } |
655 | | | 655 | |
656 | /* | | 656 | /* |
657 | * crc_stwr() | | 657 | * crc_stwr() |
658 | * start up the device mapping table, enable crc file calculation | | 658 | * start up the device mapping table, enable crc file calculation |
659 | * Return: | | 659 | * Return: |
660 | * 0 if ok, -1 otherwise (what dev_start() returns) | | 660 | * 0 if ok, -1 otherwise (what dev_start() returns) |
661 | */ | | 661 | */ |
662 | | | 662 | |
663 | int | | 663 | int |
664 | crc_stwr(void) | | 664 | crc_stwr(void) |
665 | { | | 665 | { |
666 | docrc = 1; | | 666 | docrc = 1; |
| @@ -948,28 +948,28 @@ bcpio_rd(ARCHD *arcn, char *buf) | | | @@ -948,28 +948,28 @@ bcpio_rd(ARCHD *arcn, char *buf) |
948 | return com_rd(arcn); | | 948 | return com_rd(arcn); |
949 | } | | 949 | } |
950 | | | 950 | |
951 | /* | | 951 | /* |
952 | * bcpio_endrd() | | 952 | * bcpio_endrd() |
953 | * no cleanup needed here, just return size of the trailer (for append) | | 953 | * no cleanup needed here, just return size of the trailer (for append) |
954 | * Return: | | 954 | * Return: |
955 | * size of trailer header in this format | | 955 | * size of trailer header in this format |
956 | */ | | 956 | */ |
957 | | | 957 | |
958 | off_t | | 958 | off_t |
959 | bcpio_endrd(void) | | 959 | bcpio_endrd(void) |
960 | { | | 960 | { |
961 | return (off_t)(sizeof(HD_BCPIO) + sizeof(TRAILER + | | 961 | return (off_t)(sizeof(HD_BCPIO) + sizeof(TRAILER) + |
962 | (BCPIO_PAD(sizeof(HD_BCPIO) + sizeof(TRAILER))))); | | 962 | (BCPIO_PAD(sizeof(HD_BCPIO) + sizeof(TRAILER)))); |
963 | } | | 963 | } |
964 | | | 964 | |
965 | /* | | 965 | /* |
966 | * bcpio_wr() | | 966 | * bcpio_wr() |
967 | * copy the data in the ARCHD to buffer in old binary cpio format | | 967 | * copy the data in the ARCHD to buffer in old binary cpio format |
968 | * There is a real chance of field overflow with this critter. So we | | 968 | * There is a real chance of field overflow with this critter. So we |
969 | * always check the conversion is ok. nobody in their right mind | | 969 | * always check the conversion is ok. nobody in their right mind |
970 | * should write an archive in this format... | | 970 | * should write an archive in this format... |
971 | * Return | | 971 | * Return |
972 | * 0 if file has data to be written after the header, 1 if file has NO | | 972 | * 0 if file has data to be written after the header, 1 if file has NO |
973 | * data to write after the header, -1 if archive write failed | | 973 | * data to write after the header, -1 if archive write failed |
974 | */ | | 974 | */ |
975 | | | 975 | |