1 /* $Source: /u/mark/src/pax/RCS/pass.c,v $
5 * pass.c - handle the pass option of cpio
9 * These functions implement the pass options in PAX. The pass option
10 * copies files from one directory hierarchy to another.
14 * Mark H. Colburn, NAPS International (mark@jhereg.mn.org)
16 * Sponsored by The USENIX Association for public distribution.
18 * Copyright (c) 1989 Mark H. Colburn.
19 * All rights reserved.
21 * Redistribution and use in source and binary forms are permitted
22 * provided that the above copyright notice is duplicated in all such
23 * forms and that any documentation, advertising materials, and other
24 * materials related to such distribution and use acknowledge that the
25 * software was developed * by Mark H. Colburn and sponsored by The
28 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
29 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
30 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
33 * Revision 1.3 89/02/12 10:29:51 mark
34 * Fixed misspelling of Replstr
36 * Revision 1.2 89/02/12 10:05:09 mark
39 * Revision 1.1 88/12/23 18:02:20 mark
45 static char *ident = "$Id: pass.c,v 1.3 89/02/12 10:29:51 mark Exp $";
46 static char *copyright = "Copyright (c) 1989 Mark H. Colburn.\nAll rights reserved.\n";
55 /* pass - copy within the filesystem
59 * Pass copies the named files from the current directory hierarchy to
60 * the directory pointed to by dirname.
64 * char *dirname - name of directory to copy named files to.
70 int pass(char *dirname)
79 char name[PATH_MAX + 1];
83 while (name_next(name, &sb) >= 0 && (fd = openin(name, &sb)) >= 0) {
85 if (rplhead != (Replstr *)NULL) {
88 if (get_disposition("pass", name) || get_newname(name, sizeof(name))) {
96 if (passitem(name, &sb, fd, dirname)) {
100 fprintf(stderr, "%s/%s\n", dirname, name);
106 /* passitem - copy one file
110 * Passitem copies a specific file to the named directory
114 * char *from - the name of the file to open
115 * Stat *asb - the stat block associated with the file to copy
116 * int ifd - the input file descriptor for the file to copy
117 * char *dir - the directory to copy it to
121 * Returns given input file descriptor or -1 if an error occurs.
128 int passitem(char *from, Stat *asb, int ifd, char *dir)
132 int passitem(from, asb, ifd, dir)
142 char to[PATH_MAX + 1];
144 if (nameopt(strcat(strcat(strcpy(to, dir), "/"), from)) < 0) {
147 if (asb->sb_nlink > 1) {
150 if (f_link && islink(from, asb) == (Link *)NULL) {
153 if ((ofd = openout(to, asb, islink(to, asb), 1)) < 0) {
157 passdata(from, ifd, to, ofd);
159 tstamp[0] = asb->sb_atime;
160 tstamp[1] = f_mtime ? asb->sb_mtime : time((time_t *) 0);