/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)cpio:cpio.c 1.30.1.11"
/* /sccs/src/cmd/s.cpio.c
cpio.c 1.30.1.11 1/11/86 13:46:48
Reworked cpio which uses getopt(3) to interpret flag arguments and
changes reels to the save file name.
Performance and size improvements.
/* cpio COMPILE: cc -O cpio.c -s -i -o cpio -lgen -lerr
cpio -- copy file collections
#define EQ(x,y) (strcmp(x,y)==0)
/* MKSHORT: for VAX, Interdata, ... */
/* Take a 4-byte long, lv, and turn it */
/* into an array of two 2-byte shorts, v*/
#define MKSHORT(v,lv) {U.l=1L;if(U.c[0]) U.l=lv,v[0]=U.s[1],v[1]=U.s[0]; else U.l=lv,v[0]=U.s[0],v[1]=U.s[1];}
#define MAGIC 070707 /* cpio magic number */
#define BSMAGIC 0143561 /* byte-swapped cpio magic number */
#define IN 'i' /* copy in */
#define OUT 'o' /* copy out */
#define PASS 'p' /* direct copy */
#define HDRSIZE (Hdr.h_name - (char *)&Hdr) /* header size minus filename field */
#define LINKS 500 /* no. of links allocated per bunch */
#define CHARS 76 /* ASCII header size minus filename field */
#define BUFSIZE 512 /* In u370, can't use BUFSIZ or BSIZE */
#define CPIOBSZ 4096 /* file read/write */
#define MK_USHORT(a) (a & 00000177777) /* Make unsigned shorts for portable */
/* header. Hardware may only know */
/* integer operations and sign extend */
/* the large unsigned short resulting */
/* in 8 rather than 6 octal char in */
static struct stat Statb
, Xstatb
;
char Symlbuf
[MAXPATHLEN
+ 1]; /* target of symbolic link */
static unsigned Bufsize
= BUFSIZE
; /* default record size */
static char Buf
[CPIOBSZ
], *Cbuf
;
/* sBlocks: short Blocks. Cumulative character */
/* count for short reads in bread(). Encountered */
/* with communication lines and pipes as in: */
/* split -100 cpio_archive; cat xa* | cpio -icd */
char *eommsg
= "Change to part %d and press RETURN key. [q] ";
char ttyname
[] = _PATH_TTY
;
/* for VAX, Interdata, ... */
U
.s
[0] = v
[1], U
.s
[1] = v
[0];
U
.s
[0] = v
[0], U
.s
[1] = v
[1];
static usage(), chkswfile(), getname(), bintochar(), chkhdr(), gethdr();
static ckname(), openout(), breread(), bread(), bwrite(), eomchgreel();
static postml(), pentry(), nmatch(), gmatch(), umatch(), set_time();
static chgreel(), missdir(), pwd(), fperr(), fperrno();
short select
; /* set when files are selected */
if(argc
<= 1 || *argv
[1] != '-')
while( (ans
= getopt( argc
, argv
, "aBC:ifopcdlmrSsbtuvM:6eI:O:")) != EOF
) {
case 'a': /* reset access time */
case 'B': /* change record size to 5120 bytes */
case 'C': /* reset buffer size to arbitrary valu
Bufsize
= atoi( optarg
);
fperr("Illegal argument to -%c, '%s'",
case 'f': /* copy files not matched by patterns */
case 'c': /* ASCII header */
case 'd': /* create directories when needed */
case 'l': /* link files, when necessary */
case 'm': /* retain mod time */
case 'r': /* rename files interactively */
Rtty
= fopen(ttyname
, "r");
Wtty
= fopen(ttyname
, "w");
if(Rtty
==NULL
|| Wtty
==NULL
) {
fperrno("Cannot rename (%s missing)",
case 'S': /* swap halfwords */
case 's': /* swap bytes */
case 'b': /* swap both bytes and halfwords */
case 't': /* table of contents */
case 'u': /* copy unconditionally */
case 'v': /* verbose - print out file names */
case 'M': /* alternate message for end-of-media */
case '6': /* for old, sixth-edition files */
chkswfile( swfile
, ans
, Option
);
if( (i
= open( optarg
, O_RDONLY
) ) < 0) {
fperrno("Cannot open <%s> for input", optarg
);
if( dup2(i
, Input
) < 0 ) {
fperrno("Cannot dup to standard input");
chkswfile( swfile
, ans
, Option
);
if( (i
= open( optarg
, O_WRONLY
| O_CREAT
| O_TRUNC
,
fperrno("Cannot open <%s> for output", optarg
);
if( dup2(i
, Output
) < 0 ) {
fperrno("Cannot dup to standard output");
"Options must include one of -o, -i, or -p\n");
"Pass and Rename cannot be used together\n");
if( Bufsize
!= BUFSIZE
) {
fprintf( stderr
, "`B' or `C' option is irrelevant with the '-p' option\n");
Cp
= Cbuf
= (char *)malloc(Bufsize
);
/* get filename, copy header and file out */
if( mklong(Hdr
.h_filesize
) == 0L) {
bwrite(Chdr
,CHARS
+Hdr
.h_namesize
);
bwrite(&Hdr
, HDRSIZE
+Hdr
.h_namesize
);
(void) fprintf(stderr
, "%s\n",
symlsz
= (int) mklong(Hdr
.h_filesize
);
if (readlink(Hdr
.h_name
, Symlbuf
, symlsz
) < 0) {
fperrno("Cannot read symbolic link <%s>",
bwrite(&Hdr
, HDRSIZE
+Hdr
.h_namesize
);
(void) fprintf(stderr
, "%s\n",
if((Ifile
= open(Hdr
.h_name
, 0)) < 0) {
fperrno("Cannot open <%s>", Hdr
.h_name
);
bwrite(Chdr
,CHARS
+Hdr
.h_namesize
);
bwrite(&Hdr
, HDRSIZE
+Hdr
.h_namesize
);
for(filesz
=mklong(Hdr
.h_filesize
); filesz
>0; filesz
-= CPIOBSZ
){
ct
= filesz
>CPIOBSZ
? CPIOBSZ
: filesz
;
if(read(Ifile
, Buf
, ct
) < 0) {
fperrno("Cannot read %s", Hdr
.h_name
);
utb
.actime
= Statb
.st_atime
;
utb
.modtime
= Statb
.st_mtime
;
(void)utime(Hdr
.h_name
, &utb
);
(void) fprintf(stderr
, "%s\n", Hdr
.h_name
);
/* copy trailer, after all files have been copied */
strcpy(Hdr
.h_name
, "TRAILER!!!");
MKSHORT(Hdr
.h_filesize
, 0L);
Hdr
.h_namesize
= strlen("TRAILER!!!") + 1;
bwrite(Chdr
, CHARS
+Hdr
.h_namesize
);
bwrite(&Hdr
, HDRSIZE
+Hdr
.h_namesize
);
if(argc
> 0 ) { /* save patterns, if any */
symlsz
= (int) mklong(Hdr
.h_filesize
);
if( ckname(Hdr
.h_name
) && !Toc
)
(void)openout(Hdr
.h_name
, Symlbuf
);
if( (select
= ckname(Hdr
.h_name
)) && !Toc
)
Ofile
= openout(Hdr
.h_name
, (char *)0);
for(filesz
=mklong(Hdr
.h_filesize
); filesz
>0; filesz
-= CPIOBSZ
){
ct
= filesz
>CPIOBSZ
? CPIOBSZ
: filesz
;
swap(Buf
,ct
,byteswap
,halfswap
);
if(write(Ofile
, Buf
, ct
) < 0) {
fperrno("Cannot write %s", Hdr
.h_name
);
if(chmod(Hdr
.h_name
, Hdr
.h_mode
) < 0)
fperrno("Cannot change mode of <%s>",
set_time(Hdr
.h_name
, mklong(Hdr
.h_mtime
), mklong(Hdr
.h_mtime
));
case PASS
: /* move files around */
if(access(argv
[0], 2) == -1) {
(void) fperrno("Cannot write in <%s>", argv
[0]);
strcpy(Fullname
, argv
[0]); /* destination directory */
if(stat(Fullname
, &Xstatb
) < 0) {
fperrno("Cannot stat <%s>", Fullname
);
if((Xstatb
.st_mode
&S_IFMT
) != S_IFDIR
) {
(void) fprintf(stderr
, "<%s> is not a directory",
if( Fullname
[ strlen(Fullname
) - 1 ] != '/' )
fullp
= Fullname
+ strlen(Fullname
);
fperr("Use `-d' option to copy <%s>",
while(Hdr
.h_name
[i
] == '/')
strcpy(fullp
, &(Hdr
.h_name
[i
]));
if( PassLink
&& !A_directory
&& Dev
== Statb
.st_dev
) {
if(link(Hdr
.h_name
, Fullname
) < 0) {
if(missdir(Fullname
) != 0) {
fperrno("Cannot create directory for <%s>",
if(unlink(Fullname
) < 0) {
fperrno("Cannot unlink <%s>",
fperrno("Cannot link <%s> to <%s>",
if(link(Hdr
.h_name
, Fullname
) < 0) {
fperrno("Cannot link <%s> to <%s>",
symlsz
= (int) mklong(Hdr
.h_filesize
);
if (readlink(Hdr
.h_name
, Symlbuf
, symlsz
) < 0) {
fperrno("Cannot read symbolic link <%s>",
if(!openout(Fullname
, Symlbuf
))
Blocks
+= ((symlsz
+ (BUFSIZE
- 1)) / BUFSIZE
);
if(!(Ofile
= openout(Fullname
, (char *)0)))
if((Ifile
= open(Hdr
.h_name
, 0)) < 0) {
fperrno("Cannot open <%s>", Hdr
.h_name
);
for(; filesz
> 0; filesz
-= CPIOBSZ
) {
ct
= filesz
>CPIOBSZ
? CPIOBSZ
: filesz
;
if(read(Ifile
, Buf
, ct
) < 0) {
fperrno("Cannot read %s", Hdr
.h_name
);
if(write(Ofile
, Buf
, ct
) < 0) {
fperrno("Cannot write %s", Hdr
.h_name
);
/* Removed u370 ifdef which caused cpio */
/* to report blocks in terms of 4096 bytes. */
Blocks
+= ((ct
+ (BUFSIZE
- 1)) / BUFSIZE
);
utb
.actime
= Statb
.st_atime
;
utb
.modtime
= Statb
.st_mtime
;
(void)utime(Hdr
.h_name
, &utb
);
if(chmod(Fullname
, Hdr
.h_mode
) < 0)
fperrno("Cannot change mode of <%s>",
set_time(Fullname
, Statb
.st_atime
, mklong(Hdr
.h_mtime
));
/* print number of blocks actually copied */
Blocks
+= ((sBlocks
+ (BUFSIZE
- 1)) / BUFSIZE
);
(void) fprintf(stderr
, "%ld blocks\n", Blocks
* (Bufsize
>>9));
"Usage: %s\n %s\n %s\n %s\n %s\n",
"cpio -o[acvB] <name-list >collection",
"cpio -o[acvB] -Ocollection <name-list",
"cpio -i[cdmrstuvfB6] [ pattern ... ] <collection",
"cpio -i[cdmrstuvfB6] -Icollection [ pattern ... ]",
"cpio -p[adlmruv] directory <name-list");
chkswfile( sp
, c
, option
)
fperr( "-%c must be specified before -%c option",
c
== 'I' ? 'i' : 'o', c
);
if( (c
== 'I' && option
!= IN
) || (c
== 'O' && option
!= OUT
) ) {
fperr( "-%c option not permitted with -%c option", c
,
fperr("No more than one -I or -O flag permitted");
getname() /* get file name, get info for header */
register char *namep
= Name
;
while(*namep
== '.' && namep
[1] == '/') {
while(*namep
== '/') namep
++;
strcpy(Hdr
.h_name
, namep
);
if(lstat(namep
, &Statb
) < 0) {
fperrno("Cannot stat <%s>", Hdr
.h_name
);
ftype
= Statb
.st_mode
& Filetype
;
A_directory
= (ftype
== S_IFDIR
);
A_special
= (ftype
== S_IFBLK
)
A_symlink
= (ftype
== S_IFLNK
);
Hdr
.h_namesize
= strlen(Hdr
.h_name
) + 1;
Hdr
.h_uid
= Statb
.st_uid
;
Hdr
.h_gid
= Statb
.st_gid
;
Hdr
.h_dev
= Statb
.st_dev
;
Hdr
.h_ino
= Statb
.st_ino
;
Hdr
.h_mode
= Statb
.st_mode
;
MKSHORT(Hdr
.h_mtime
, Statb
.st_mtime
);
Hdr
.h_nlink
= Statb
.st_nlink
;
tlong
= ((Hdr
.h_mode
&S_IFMT
) == S_IFREG
||
(Hdr
.h_mode
&S_IFMT
) == S_IFLNK
)? Statb
.st_size
: 0L;
MKSHORT(Hdr
.h_filesize
, tlong
);
Hdr
.h_rdev
= Statb
.st_rdev
;
bintochar(t
) /* ASCII header write */
sprintf(Chdr
,"%.6o%.6ho%.6ho%.6ho%.6ho%.6ho%.6ho%.6ho%.11lo%.6ho%.11lo%s",
MAGIC
, MK_USHORT(Statb
.st_dev
), MK_USHORT(Statb
.st_ino
), Statb
.st_mode
, Statb
.st_uid
,
Statb
.st_gid
, Statb
.st_nlink
, MK_USHORT(Statb
.st_rdev
),
Statb
.st_mtime
, (short)strlen(Hdr
.h_name
)+1, t
, Hdr
.h_name
);
chartobin() /* ASCII header read */
sscanf(Chdr
, "%6ho%6ho%6ho%6ho%6ho%6ho%6ho%6ho%11lo%6ho%11lo",
&Hdr
.h_magic
, &Hdr
.h_dev
, &Hdr
.h_ino
, &Hdr
.h_mode
, &Hdr
.h_uid
,
&Hdr
.h_gid
, &Hdr
.h_nlink
, &Hdr
.h_rdev
, &Longtime
,
&Hdr
.h_namesize
, &Longfile
);
MKSHORT(Hdr
.h_filesize
, Longfile
);
MKSHORT(Hdr
.h_mtime
, Longtime
);
/* Check the header for the magic number. Switch modes automatically to
match the type of header found.
if( Hdr
.h_magic
== MAGIC
)
breread(&Hdr
.h_magic
, sizeof Hdr
.h_magic
);
if( Hdr
.h_magic
== MAGIC
|| Hdr
.h_magic
== (short)BSMAGIC
)
fperr("This is not a cpio file. Bad magic number.");
gethdr() /* get file headers */
if(Hdr
.h_magic
== (short)BSMAGIC
)
swap((char *)&Hdr
, HDRSIZE
, 1, 0);
else if( Hdr
.h_magic
!= MAGIC
) {
fperr("Out of phase--get help");
bread(Hdr
.h_name
, Hdr
.h_namesize
);
if(EQ(Hdr
.h_name
, "TRAILER!!!"))
ftype
= Hdr
.h_mode
& Filetype
;
A_directory
= (ftype
== S_IFDIR
);
A_special
= (ftype
== S_IFBLK
)
A_symlink
= (ftype
== S_IFLNK
);
ckname(namep
) /* check filenames with patterns given on cmd line */
char buf
[sizeof Hdr
.h_name
];
if(fflag
^ !nmatch(namep
, Pattern
)) {
if(Rename
&& !A_directory
) { /* rename interactively */
fprintf(Wtty
, "Rename <%s>\n", namep
);
fgets(buf
, sizeof buf
, Rtty
);
buf
[strlen(buf
) - 1] = '\0';
openout(namep
, symlname
) /* open files for writing, set all necessary info */
if(!strncmp(namep
, "./", 2))
if( !Dir
|| Rename
|| EQ(namep
, ".") || EQ(namep
, "..") )
/* do not consider . or .. files */
if(stat(namep
, &Xstatb
) == -1) {
/* try creating (only twice) */
if(mkdir(namep
, Hdr
.h_mode
) != 0) {
}while(ans
< 2 && missdir(namep
) == 0);
fperrno("Cannot create directory for <%s>",
fperrno("Cannot create directory <%s>", namep
);
if(chmod(namep
, Hdr
.h_mode
) < 0)
fperrno("Cannot change mode of <%s>", namep
);
if(chown(namep
, Hdr
.h_uid
, Hdr
.h_gid
) < 0)
fperrno("Cannot change ownership of <%s>",
set_time(namep
, mklong(Hdr
.h_mtime
), mklong(Hdr
.h_mtime
));
if(lstat(namep
, &Xstatb
) == 0) {
if(Uncond
&& !((!(Xstatb
.st_mode
& S_IWRITE
) || A_special
) && (Uid
!= 0))) {
fperrno("cannot unlink current <%s>", namep
);
if(!Uncond
&& (mklong(Hdr
.h_mtime
) <= Xstatb
.st_mtime
)) {
/* There's a newer or same aged version of file on destination */
fperr("current <%s> newer or same age", np
);
&& Hdr
.h_ino
== Xstatb
.st_ino
&& Hdr
.h_dev
== Xstatb
.st_dev
) {
fperr("Attempt to pass file to self!");
/* try symlinking (only twice) */
}while(ans
< 2 && missdir(np
) == 0);
fperrno("Cannot create directory for <%s>", namep
);
fperrno("Cannot symlink <%s> and <%s>", namep
, symlname
);
if((Hdr
.h_mode
& Filetype
) == S_IFIFO
)
/* try creating (only twice) */
if(mknod(namep
, Hdr
.h_mode
, Hdr
.h_rdev
) < 0) {
}while(ans
< 2 && missdir(np
) == 0);
fperrno("Cannot create directory for <%s>", namep
);
fperrno("Cannot mknod <%s>", namep
);
/* try creating (only twice) */
if((f
= creat(namep
, Hdr
.h_mode
)) < 0) {
}while(ans
< 2 && missdir(np
) == 0);
fperrno("Cannot create directory for <%s>", namep
);
fperrno("Cannot create <%s>", namep
);
if(chown(namep
, Hdr
.h_uid
, Hdr
.h_gid
) < 0)
fperrno("Cannot change ownership of <%s>", namep
);
/* Shared by bread() and breread()
static int nleft
= 0; /* unread chars left in Cbuf */
static char *ip
; /* pointer to next char to be read from Cbuf */
/* Reread the current buffer Cbuf.
A character count, c, of 0 simply resets the pointer so next bread gets
/* round c up to an even number */
while( (rv
= read(Input
, Cbuf
, Bufsize
)) == 0 ) {
Input
= chgreel(0, Input
, rv
);
fperrno("Read error on archive");
else if( rv
< Bufsize
) { /* short read */
smemcpy( &Cbuf
[ Bufsize
- rv
], Cbuf
, rv
);
p
= &Cbuf
[ Bufsize
- rv
];
static unsigned Ccnt
= 0;
/* round c up to an even number */
if( (Cleft
= Bufsize
- Ccnt
) <= c
) {
rv
= write(Output
, Cbuf
, Bufsize
);
if( rv
== 0 || ( rv
== -1 && errno
== ENXIO
) ) {
fperrno("Write error on archive");
else if( rv
< Bufsize
) {
Output
= chgreel(1, Output
, 0);
smemcpy( Cbuf
, &Cbuf
[ Bufsize
- rv
], rv
);
static int reelcount
= 1; /* used below and in chgreel() */
/* Change reel due to reaching end-of-media.
Keep trying to get a successful write before considering the
change-of-reel as successful.
Output
= chgreel(1, Output
, 0);
rv
= write(Output
, Cbuf
, Bufsize
);
fperrno( "Unable to write this medium" );
fperr( "Unable to write this medium: Premature EOF" );
(void) fprintf(stderr
, "Try again.\n");
postml(namep
, np
) /* linking funtion: Postml() is called after */
register char *namep
, *np
; /* namep is created. Postml() checks to see */
{ /* if namep should be linked to np. If so, */
/* postml() removes the independent instance */
register i
; /* of namep and links namep to np. */
static unsigned mlsize
= 0;
static unsigned mlinks
= 0;
ml
= (struct ml
**) malloc(mlsize
* sizeof(struct ml
));
else if( mlinks
== mlsize
) {
ml
= (struct ml
**) realloc((char *) ml
,
mlsize
* sizeof(struct ml
));
fperr("Out of memory for links");
for(i
= 0; i
< mlinks
; ++i
) {
if(mlp
->m_ino
==Hdr
.h_ino
&& mlp
->m_dev
==Hdr
.h_dev
) {
printf("%s linked to %s\n", ml
[i
]->m_name
,
if(Option
== IN
&& *(mlp
->m_name
) != '/') {
Fullname
[Pathend
] = '\0';
strcat(Fullname
, mlp
->m_name
);
/* try linking (only twice) */
if(link(lnamep
, namep
) < 0) {
}while(ans
< 2 && missdir(np
) == 0);
fperrno("Cannot create directory for <%s>", np
);
fperrno("Cannot link <%s> & <%s>", lnamep
, np
);
set_time(namep
, mklong(Hdr
.h_mtime
), mklong(Hdr
.h_mtime
));
if( !(ml
[mlinks
] = (struct ml
*)malloc(strlen(np
) + 2 + sizeof(struct ml
)))) {
fperr("Out of memory for links");
ml
[mlinks
]->m_dev
= Hdr
.h_dev
;
ml
[mlinks
]->m_ino
= Hdr
.h_ino
;
strcpy(ml
[mlinks
]->m_name
, np
);
pentry(namep
) /* print verbose table of contents */
static short lastid
= -1;
static struct passwd
*pw
;
printf("%-7o", MK_USHORT(Hdr
.h_mode
));
printf("%-6s", pw
->pw_name
);
if(pw
= getpwuid((int)Hdr
.h_uid
)) {
printf("%-6s", pw
->pw_name
);
printf("%-6d", Hdr
.h_uid
);
printf("%7ld ", mklong(Hdr
.h_filesize
));
U
.l
= mklong(Hdr
.h_mtime
);
strcpy(tbuf
, ctime((long *)&U
.l
));
printf(" %s %s", &tbuf
[4], namep
);
printf(" -> %s", Symlbuf
);
/* pattern matching functions */
if((**pat
== '!' && !gmatch(s
, *pat
+1))
register cc
, ok
, lc
, scc
;
return(gmatch(++s
, ++p
));
ok
|= ((lc
<= scc
) && (scc
<= (cc
=p
[1])));
if(scc
) return(gmatch(++s
, ++p
));
if (gmatch(s
++,p
)) return(1);
swap(buf
, bytecount
, bytes
, halfwords
) /* swap halfwords, bytes or both */
register union swpbytes
{
pbuf
= (union swpbytes
*)buf
;
if (count
% sizeof(union swpbytes
))
count
= (count
+ (sizeof(union swpbytes
) - 1)) / sizeof(union swpbytes
);
pbuf
->charv
[0] = pbuf
->charv
[1];
pbuf
= (union swphalf
*)buf
;
if (n
= count
% sizeof(union swphalf
))
for(i
= count
+ 1; i
<= count
+ (sizeof(union swphalf
) - n
); i
++)
for (i
= count
; i
< count
+ (sizeof(union swphalf
) - n
); i
++)
count
= (count
+ (sizeof(union swphalf
) - 1)) / sizeof(union swphalf
);
pbuf
->shortv
[0] = pbuf
->shortv
[1];
set_time(namep
, atime
, mtime
) /* set access and modification times */
static struct utimbuf timevec
;
(void)utime(namep
, &timevec
);
if((statb
.st_mode
&S_IFMT
) != S_IFCHR
) {
fperrno("Can't %s: ", x
? "write output": "read input");
( rv
== -1 && ( errno
== ENOSPC
|| errno
== ENXIO
) ) )
fperr( "\007Reached end of medium on %s",
fperrno( "\007Encountered an error on %s",
Rtty
= fopen(ttyname
, "r");
fperrno("Cannot prompt (can't open %s)", ttyname
);
fperr( eommsg
, reelcount
);
fgets(str
, sizeof str
, Rtty
);
fperr("If you want to go on, type device/file name when ready.");
fgets(str
, sizeof str
, Rtty
);
str
[strlen(str
) - 1] = '\0';
if((f
= open(str
, x
? 1: 0)) < 0) {
fperrno("Can't open <%s>", str
);
for(np
= namep
; *np
; ++np
)
if(np
== namep
) continue; /* skip over 'root slash' */
if(stat(namep
, &Xstatb
) == -1) {
if((ct
= mkdir(namep
, 0777)) != 0) {
fperr("missing 'd' option");
if (ct
== 2) ct
= 0; /* the file already exists */
pwd() /* get working directory */
if (getwd(Fullname
) == 0) {
(void)fprintf(stderr
, "cpio: %s\n",
Pathend
= strlen(Fullname
);
Fullname
[Pathend
++] = '/';
Fullname
[Pathend
] = '\0';
print message on the stderr
fprintf( stderr
, "cpio: ");
fmt
= va_arg( args
, char * );
vfprintf( stderr
, fmt
, args
);
print message on the stderr followed by error number and meaning.
fprintf( stderr
, "cpio: ");
fmt
= va_arg( args
, char * );
vfprintf( stderr
, fmt
, args
);
Fast if the to and from strings do not overlap,
slower but safe if they do.
smemcpy( to
, from
, count
)
register char *to
, *from
;
if( &to
[ count
] <= from
|| &from
[ count
] <= to
)
return memcpy( to
, from
, count
);