]>
git.saurik.com Git - apple/file_cmds.git/blob - pax/file_subs.c
1 /* $OpenBSD: file_subs.c,v 1.13 1997/09/01 18:29:48 deraadt Exp $ */
2 /* $NetBSD: file_subs.c,v 1.4 1995/03/21 09:07:18 cgd Exp $ */
5 * Copyright (c) 1992 Keith Muller.
6 * Copyright (c) 1992, 1993
7 * The Regents of the University of California. All rights reserved.
9 * This code is derived from software contributed to Berkeley by
10 * Keith Muller of the University of California, San Diego.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by the University of
23 * California, Berkeley and its contributors.
24 * 4. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 static char sccsid
[] = "@(#)file_subs.c 8.1 (Berkeley) 5/31/93";
45 static char rcsid
[] __attribute__((__unused__
)) = "$OpenBSD: file_subs.c,v 1.13 1997/09/01 18:29:48 deraadt Exp $";
49 #include <sys/types.h>
53 #include <sys/param.h>
65 mk_link
__P((register char *,register struct stat
*,register char *, int));
68 * routines that deal with file operations such as: creating, removing;
69 * and setting access modes, uid/gid and times of files
72 #define FILEBITS (S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
73 #define SETBITS (S_ISUID | S_ISGID)
74 #define ABITS (FILEBITS | SETBITS)
78 * Create and open a file.
80 * file descriptor or -1 for failure
85 file_creat(register ARCHD
*arcn
)
97 * assume file doesn't exist, so just try to create it, most times this
98 * works. We have to take special handling when the file does exist. To
99 * detect this, we use O_EXCL. For example when trying to create a
100 * file and a character device or fifo exists with the same name, we
101 * can accidently open the device by mistake (or block waiting to open)
102 * If we find that the open has failed, then figure spend the effore to
103 * figure out why. This strategy was found to have better average
104 * performance in common use than checking the file (and the path)
107 file_mode
= arcn
->sb
.st_mode
& FILEBITS
;
108 if ((fd
= open(arcn
->name
, O_WRONLY
| O_CREAT
| O_TRUNC
| O_EXCL
,
113 * the file seems to exist. First we try to get rid of it (found to be
114 * the second most common failure when traced). If this fails, only
115 * then we go to the expense to check and create the path to the file
117 if (unlnk_exist(arcn
->name
, arcn
->type
) != 0)
122 * try to open it again, if this fails, check all the nodes in
123 * the path and give it a final try. if chk_path() finds that
124 * it cannot fix anything, we will skip the last attempt
126 if ((fd
= open(arcn
->name
, O_WRONLY
| O_CREAT
| O_TRUNC
,
130 if (nodirs
|| chk_path(arcn
->name
,arcn
->sb
.st_uid
,arcn
->sb
.st_gid
) < 0) {
131 syswarn(1, oerrno
, "Unable to create %s", arcn
->name
);
140 * Close file descriptor to a file just created by pax. Sets modes,
141 * ownership and times as required.
143 * 0 for success, -1 for failure
148 file_close(register ARCHD
*arcn
, int fd
)
152 register ARCHD
*arcn
;
161 syswarn(0, errno
, "Unable to close file descriptor on %s",
165 * set owner/groups first as this may strip off mode bits we want
166 * then set file permission modes. Then set file access and
167 * modification times.
170 res
= set_ids(arcn
->name
, arcn
->sb
.st_uid
, arcn
->sb
.st_gid
);
173 * IMPORTANT SECURITY NOTE:
174 * if not preserving mode or we cannot set uid/gid, then PROHIBIT
178 arcn
->sb
.st_mode
&= ~(SETBITS
);
180 set_pmode(arcn
->name
, arcn
->sb
.st_mode
);
181 if (patime
|| pmtime
)
182 set_ftime(arcn
->name
, arcn
->sb
.st_mtime
, arcn
->sb
.st_atime
, 0);
187 * Create a hard link to arcn->ln_name from arcn->name. arcn->ln_name
190 * 0 if ok, -1 otherwise
195 lnk_creat(register ARCHD
*arcn
)
199 register ARCHD
*arcn
;
205 * we may be running as root, so we have to be sure that link target
206 * is not a directory, so we lstat and check
208 if (lstat(arcn
->ln_name
, &sb
) < 0) {
209 syswarn(1,errno
,"Unable to link to %s from %s", arcn
->ln_name
,
214 if (S_ISDIR(sb
.st_mode
)) {
215 paxwarn(1, "A hard link to the directory %s is not allowed",
220 return(mk_link(arcn
->ln_name
, &sb
, arcn
->name
, 0));
225 * Create a hard link to arcn->org_name from arcn->name. Only used in copy
226 * with the -l flag. No warning or error if this does not succeed (we will
227 * then just create the file)
229 * 1 if copy() should try to create this file node
230 * 0 if cross_lnk() ok, -1 for fatal flaw (like linking to self).
235 cross_lnk(register ARCHD
*arcn
)
239 register ARCHD
*arcn
;
243 * try to make a link to orginal file (-l flag in copy mode). make sure
244 * we do not try to link to directories in case we are running as root
245 * (and it might succeed).
247 if (arcn
->type
== PAX_DIR
)
249 return(mk_link(arcn
->org_name
, &(arcn
->sb
), arcn
->name
, 1));
254 * In copy mode if we are not trying to make hard links between the src
255 * and destinations, make sure we are not going to overwrite ourselves by
256 * accident. This slows things down a little, but we have to protect all
257 * those people who make typing errors.
259 * 1 the target does not exist, go ahead and copy
260 * 0 skip it file exists (-k) or may be the same as source file
265 chk_same(register ARCHD
*arcn
)
269 register ARCHD
*arcn
;
275 * if file does not exist, return. if file exists and -k, skip it
278 if (lstat(arcn
->name
, &sb
) < 0)
284 * better make sure the user does not have src == dest by mistake
286 if ((arcn
->sb
.st_dev
== sb
.st_dev
) && (arcn
->sb
.st_ino
== sb
.st_ino
)) {
287 paxwarn(1, "Unable to copy %s, file would overwrite itself",
296 * try to make a hard link between two files. if ign set, we do not
299 * 0 if successful (or we are done with this file but no error, such as
300 * finding the from file exists and the user has set -k).
301 * 1 when ign was set to indicates we could not make the link but we
302 * should try to copy/extract the file as that might work (and is an
303 * allowed option). -1 an error occurred.
308 mk_link(register char *to
, register struct stat
*to_sb
, register char *from
,
312 mk_link(to
, to_sb
, from
, ign
)
314 register struct stat
*to_sb
;
323 * if from file exists, it has to be unlinked to make the link. If the
324 * file exists and -k is set, skip it quietly
326 if (lstat(from
, &sb
) == 0) {
331 * make sure it is not the same file, protect the user
333 if ((to_sb
->st_dev
==sb
.st_dev
)&&(to_sb
->st_ino
== sb
.st_ino
)) {
334 paxwarn(1, "Unable to link file %s to itself", to
);
339 * try to get rid of the file, based on the type
341 if (S_ISDIR(sb
.st_mode
)) {
342 if (rmdir(from
) < 0) {
343 syswarn(1, errno
, "Unable to remove %s", from
);
346 } else if (unlink(from
) < 0) {
348 syswarn(1, errno
, "Unable to remove %s", from
);
356 * from file is gone (or did not exist), try to make the hard link.
357 * if it fails, check the path and try it again (if chk_path() says to
361 if (link(to
, from
) == 0)
364 if (!nodirs
&& chk_path(from
, to_sb
->st_uid
, to_sb
->st_gid
) == 0)
367 syswarn(1, oerrno
, "Could not link to %s from %s", to
,
375 * all right the link was made
382 * create an entry in the file system (other than a file or hard link).
383 * If successful, sets uid/gid modes and times as required.
385 * 0 if ok, -1 otherwise
390 node_creat(register ARCHD
*arcn
)
394 register ARCHD
*arcn
;
398 register int ign
= 0;
400 register int pass
= 0;
405 * create node based on type, if that fails try to unlink the node and
406 * try again. finally check the path and try again. As noted in the
407 * file and link creation routines, this method seems to exhibit the
408 * best performance in general use workloads.
410 file_mode
= arcn
->sb
.st_mode
& FILEBITS
;
415 res
= mkdir(arcn
->name
, file_mode
);
420 file_mode
|= S_IFCHR
;
421 res
= mknod(arcn
->name
, file_mode
, arcn
->sb
.st_rdev
);
424 file_mode
|= S_IFBLK
;
425 res
= mknod(arcn
->name
, file_mode
, arcn
->sb
.st_rdev
);
428 res
= mkfifo(arcn
->name
, file_mode
);
432 * Skip sockets, operation has no meaning under BSD
435 "%s skipped. Sockets cannot be copied or extracted",
439 res
= symlink(arcn
->ln_name
, arcn
->name
);
447 * we should never get here
449 paxwarn(0, "%s has an unknown file type, skipping",
455 * if we were able to create the node break out of the loop,
456 * otherwise try to unlink the node and try again. if that
457 * fails check the full path and try a final time.
463 * we failed to make the node
466 if ((ign
= unlnk_exist(arcn
->name
, arcn
->type
)) < 0)
472 if (nodirs
|| chk_path(arcn
->name
,arcn
->sb
.st_uid
,arcn
->sb
.st_gid
) < 0) {
473 syswarn(1, oerrno
, "Could not create: %s", arcn
->name
);
479 * we were able to create the node. set uid/gid, modes and times
482 res
= ((arcn
->type
== PAX_SLK
) ?
483 #if defined(__APPLE__)
484 /* Mac OS X doesn't have lchown, so don't bother */
487 set_lids(arcn
->name
, arcn
->sb
.st_uid
, arcn
->sb
.st_gid
) :
489 set_ids(arcn
->name
, arcn
->sb
.st_uid
, arcn
->sb
.st_gid
));
494 * symlinks are done now.
496 if (arcn
->type
== PAX_SLK
)
500 * IMPORTANT SECURITY NOTE:
501 * if not preserving mode or we cannot set uid/gid, then PROHIBIT any
505 arcn
->sb
.st_mode
&= ~(SETBITS
);
507 set_pmode(arcn
->name
, arcn
->sb
.st_mode
);
509 if (arcn
->type
== PAX_DIR
&& strcmp(NM_CPIO
, argv0
) != 0) {
511 * Dirs must be processed again at end of extract to set times
512 * and modes to agree with those stored in the archive. However
513 * to allow extract to continue, we may have to also set owner
514 * rights. This allows nodes in the archive that are children
515 * of this directory to be extracted without failure. Both time
516 * and modes will be fixed after the entire archive is read and
519 if (access(arcn
->name
, R_OK
| W_OK
| X_OK
) < 0) {
520 if (lstat(arcn
->name
, &sb
) < 0) {
521 syswarn(0, errno
,"Could not access %s (stat)",
523 set_pmode(arcn
->name
,file_mode
| S_IRWXU
);
526 * We have to add rights to the dir, so we make
527 * sure to restore the mode. The mode must be
528 * restored AS CREATED and not as stored if
531 set_pmode(arcn
->name
,
532 ((sb
.st_mode
& FILEBITS
) | S_IRWXU
));
534 arcn
->sb
.st_mode
= sb
.st_mode
;
538 * we have to force the mode to what was set here,
539 * since we changed it from the default as created.
541 add_dir(arcn
->name
, arcn
->nlen
, &(arcn
->sb
), 1);
542 } else if (pmode
|| patime
|| pmtime
)
543 add_dir(arcn
->name
, arcn
->nlen
, &(arcn
->sb
), 0);
546 if (patime
|| pmtime
)
547 set_ftime(arcn
->name
, arcn
->sb
.st_mtime
, arcn
->sb
.st_atime
, 0);
553 * Remove node from file system with the specified name. We pass the type
554 * of the node that is going to replace it. When we try to create a
555 * directory and find that it already exists, we allow processing to
556 * continue as proper modes etc will always be set for it later on.
558 * 0 is ok to proceed, no file with the specified name exists
559 * -1 we were unable to remove the node, or we should not remove it (-k)
560 * 1 we found a directory and we were going to create a directory.
565 unlnk_exist(register char *name
, register int type
)
568 unlnk_exist(name
, type
)
576 * the file does not exist, or -k we are done
578 if (lstat(name
, &sb
) < 0)
583 if (S_ISDIR(sb
.st_mode
)) {
585 * try to remove a directory, if it fails and we were going to
586 * create a directory anyway, tell the caller (return a 1)
588 if (rmdir(name
) < 0) {
591 syswarn(1,errno
,"Unable to remove directory %s", name
);
598 * try to get rid of all non-directory type nodes
600 if (unlink(name
) < 0) {
601 syswarn(1, errno
, "Could not unlink %s", name
);
609 * We were trying to create some kind of node in the file system and it
610 * failed. chk_path() makes sure the path up to the node exists and is
611 * writeable. When we have to create a directory that is missing along the
612 * path somewhere, the directory we create will be set to the same
613 * uid/gid as the file has (when uid and gid are being preserved).
614 * NOTE: this routine is a real performance loss. It is only used as a
615 * last resort when trying to create entries in the file system.
617 * -1 when it could find nothing it is allowed to fix.
623 chk_path( register char *name
, uid_t st_uid
, gid_t st_gid
)
626 chk_path(name
, st_uid
, st_gid
)
632 register char *spt
= name
;
637 * watch out for paths with nodes stored directly in / (e.g. /bozo)
644 * work foward from the first / and check each part of the path
646 spt
= strchr(spt
, '/');
652 * if it exists we assume it is a directory, it is not within
653 * the spec (at least it seems to read that way) to alter the
654 * file system for nodes NOT EXPLICITLY stored on the archive.
655 * If that assumption is changed, you would test the node here
656 * and figure out how to get rid of it (probably like some
657 * recursive unlink()) or fix up the directory permissions if
658 * required (do an access()).
660 if (lstat(name
, &sb
) == 0) {
666 * the path fails at this point, see if we can create the
667 * needed directory and continue on
669 if (mkdir(name
, S_IRWXU
| S_IRWXG
| S_IRWXO
) < 0) {
676 * we were able to create the directory. We will tell the
677 * caller that we found something to fix, and it is ok to try
678 * and create the node again.
682 (void)set_ids(name
, st_uid
, st_gid
);
685 * make sure the user doen't have some strange umask that
686 * causes this newly created directory to be unusable. We fix
687 * the modes and restore them back to the creation default at
690 if ((access(name
, R_OK
| W_OK
| X_OK
) < 0) &&
691 (lstat(name
, &sb
) == 0)) {
692 set_pmode(name
, ((sb
.st_mode
& FILEBITS
) | S_IRWXU
));
693 add_dir(name
, spt
- name
, &sb
, 1);
703 * Set the access time and modification time for a named file. If frc is
704 * non-zero we force these times to be set even if the user did not
705 * request access and/or modification time preservation (this is also
706 * used by -t to reset access times).
707 * When ign is zero, only those times the user has asked for are set, the
708 * other ones are left alone. We do not assume the un-documented feature
709 * of many utimes() implementations that consider a 0 time value as a do
715 set_ftime(char *fnm
, time_t mtime
, time_t atime
, int frc
)
718 set_ftime(fnm
, mtime
, atime
, frc
)
725 static struct timeval tv
[2] = {{0L, 0L}, {0L, 0L}};
728 tv
[0].tv_sec
= (long)atime
;
729 tv
[1].tv_sec
= (long)mtime
;
730 if (!frc
&& (!patime
|| !pmtime
)) {
732 * if we are not forcing, only set those times the user wants
733 * set. We get the current values of the times if we need them.
735 if (lstat(fnm
, &sb
) == 0) {
737 tv
[0].tv_sec
= (long)sb
.st_atime
;
739 tv
[1].tv_sec
= (long)sb
.st_mtime
;
741 syswarn(0,errno
,"Unable to obtain file stats %s", fnm
);
747 if (utimes(fnm
, tv
) < 0)
748 syswarn(1, errno
, "Access/modification time set failed on: %s",
755 * set the uid and gid of a file system node
757 * 0 when set, -1 on failure
762 set_ids(char *fnm
, uid_t uid
, gid_t gid
)
765 set_ids(fnm
, uid
, gid
)
771 if (chown(fnm
, uid
, gid
) < 0) {
773 * ignore EPERM unless in verbose mode or being run by root.
774 * if running as pax, POSIX requires a warning.
776 if (strcmp(NM_PAX
, argv0
) == 0 || errno
!= EPERM
|| vflag
||
778 syswarn(1, errno
, "Unable to set file uid/gid of %s",
785 #if !defined(__APPLE__)
786 /* Mac OS X doesn't have lchown */
790 * set the uid and gid of a file system node
792 * 0 when set, -1 on failure
797 set_lids(char *fnm
, uid_t uid
, gid_t gid
)
800 set_lids(fnm
, uid
, gid
)
806 if (lchown(fnm
, uid
, gid
) < 0) {
808 * ignore EPERM unless in verbose mode or being run by root.
809 * if running as pax, POSIX requires a warning.
811 if (strcmp(NM_PAX
, argv0
) == 0 || errno
!= EPERM
|| vflag
||
813 syswarn(1, errno
, "Unable to set file uid/gid of %s",
823 * Set file access mode
828 set_pmode(char *fnm
, mode_t mode
)
837 if (chmod(fnm
, mode
) < 0)
838 syswarn(1, errno
, "Could not set permissions on %s", fnm
);
844 * Write/copy a file (during copy or archive extract). This routine knows
845 * how to copy files with lseek holes in it. (Which are read as file
846 * blocks containing all 0's but do not have any file blocks associated
847 * with the data). Typical examples of these are files created by dbm
848 * variants (.pag files). While the file size of these files are huge, the
849 * actual storage is quite small (the files are sparse). The problem is
850 * the holes read as all zeros so are probably stored on the archive that
851 * way (there is no way to determine if the file block is really a hole,
852 * we only know that a file block of all zero's can be a hole).
853 * At this writing, no major archive format knows how to archive files
854 * with holes. However, on extraction (or during copy, -rw) we have to
855 * deal with these files. Without detecting the holes, the files can
856 * consume a lot of file space if just written to disk. This replacement
857 * for write when passed the basic allocation size of a file system block,
858 * uses lseek whenever it detects the input data is all 0 within that
859 * file block. In more detail, the strategy is as follows:
860 * While the input is all zero keep doing an lseek. Keep track of when we
861 * pass over file block boundries. Only write when we hit a non zero
862 * input. once we have written a file block, we continue to write it to
863 * the end (we stop looking at the input). When we reach the start of the
864 * next file block, start checking for zero blocks again. Working on file
865 * block boundries significantly reduces the overhead when copying files
866 * that are NOT very sparse. This overhead (when compared to a write) is
867 * almost below the measurement resolution on many systems. Without it,
868 * files with holes cannot be safely copied. It does has a side effect as
869 * it can put holes into files that did not have them before, but that is
870 * not a problem since the file contents are unchanged (in fact it saves
871 * file space). (Except on paging files for diskless clients. But since we
872 * cannot determine one of those file from here, we ignore them). If this
873 * ever ends up on a system where CTG files are supported and the holes
874 * are not desired, just do a conditional test in those routines that
875 * call file_write() and have it call write() instead. BEFORE CLOSING THE
876 * FILE, make sure to call file_flush() when the last write finishes with
877 * an empty block. A lot of file systems will not create an lseek hole at
878 * the end. In this case we drop a single 0 at the end to force the
879 * trailing 0's in the file.
881 * rem: how many bytes left in this file system block
882 * isempt: have we written to the file block yet (is it empty)
883 * sz: basic file block allocation size
884 * cnt: number of bytes on this write
885 * str: buffer to write
887 * number of bytes written, -1 on write (or lseek) error.
892 file_write(int fd
, char *str
, register int cnt
, int *rem
, int *isempt
, int sz
,
896 file_write(fd
, str
, cnt
, rem
, isempt
, sz
, name
)
909 register char *st
= str
;
912 * while we have data to process
917 * We are now at the start of file system block again
918 * (or what we think one is...). start looking for
926 * only examine up to the end of the current file block or
927 * remaining characters to write, whatever is smaller
929 wcnt
= MIN(cnt
, *rem
);
934 * have not written to this block yet, so we keep
941 * look for a zero filled buffer
943 while ((pt
< end
) && (*pt
== '\0'))
948 * skip, buf is empty so far
950 if (lseek(fd
, (off_t
)wcnt
, SEEK_CUR
) < 0) {
951 syswarn(1,errno
,"File seek on %s",
959 * drat, the buf is not zero filled
965 * have non-zero data in this file system block, have to write
967 if (write(fd
, st
, wcnt
) != wcnt
) {
968 syswarn(1, errno
, "Failed write to file %s", name
);
978 * when the last file block in a file is zero, many file systems will not
979 * let us create a hole at the end. To get the last block with zeros, we
980 * write the last BYTE with a zero (back up one byte and write a zero).
985 file_flush(int fd
, char *fname
, int isempt
)
988 file_flush(fd
, fname
, isempt
)
994 static char blnk
[] = "\0";
997 * silly test, but make sure we are only called when the last block is
998 * filled with all zeros.
1004 * move back one byte and write a zero
1006 if (lseek(fd
, (off_t
)-1, SEEK_CUR
) < 0) {
1007 syswarn(1, errno
, "Failed seek on file %s", fname
);
1011 if (write(fd
, blnk
, 1) < 0)
1012 syswarn(1, errno
, "Failed write to file %s", fname
);
1018 * close a file we have beed reading (to copy or archive). If we have to
1019 * reset access time (tflag) do so (the times are stored in arcn).
1024 rdfile_close(register ARCHD
*arcn
, register int *fd
)
1027 rdfile_close(arcn
, fd
)
1028 register ARCHD
*arcn
;
1033 * make sure the file is open
1044 * user wants last access time reset
1046 set_ftime(arcn
->org_name
, arcn
->sb
.st_mtime
, arcn
->sb
.st_atime
, 1);
1052 * read a file to calculate its crc. This is a real drag. Archive formats
1053 * that have this, end up reading the file twice (we have to write the
1054 * header WITH the crc before writing the file contents. Oh well...
1056 * 0 if was able to calculate the crc, -1 otherwise
1061 set_crc(register ARCHD
*arcn
, register int fd
)
1065 register ARCHD
*arcn
;
1073 unsigned long crc
= 0L;
1079 * hmm, no fd, should never happen. well no crc then.
1085 if ((size
= (u_long
)arcn
->sb
.st_blksize
) > (u_long
)sizeof(tbuf
))
1086 size
= (u_long
)sizeof(tbuf
);
1089 * read all the bytes we think that there are in the file. If the user
1090 * is trying to archive an active file, forget this file.
1093 if ((res
= read(fd
, tbuf
, size
)) <= 0)
1096 for (i
= 0; i
< res
; ++i
)
1097 crc
+= (tbuf
[i
] & 0xff);
1101 * safety check. we want to avoid archiving files that are active as
1102 * they can create inconsistant archive copies.
1104 if (cpcnt
!= arcn
->sb
.st_size
)
1105 paxwarn(1, "File changed size %s", arcn
->org_name
);
1106 else if (fstat(fd
, &sb
) < 0)
1107 syswarn(1, errno
, "Failed stat on %s", arcn
->org_name
);
1108 else if (arcn
->sb
.st_mtime
!= sb
.st_mtime
)
1109 paxwarn(1, "File %s was modified during read", arcn
->org_name
);
1110 else if (lseek(fd
, (off_t
)0L, SEEK_SET
) < 0)
1111 syswarn(1, errno
, "File rewind failed on: %s", arcn
->org_name
);