34 static int strntoul(
const char *str,
char **endptr,
int base,
int num)
42 strncpy(buf, str, num);
45 ret = strtoul(buf, &end, base);
48 *endptr = ((
char *)str) + (end - buf);
50 *endptr = ((
char *)str) + strlen(buf);
56 #define GET_NUM_FIELD(phys, log) \
58 log = strntoul(phys, &end, 16, sizeof(phys)); \
60 if ( (end - phys) != sizeof(phys) ) return CPIOERR_BAD_HEADER;
61 #define SET_NUM_FIELD(phys, val, space) \
62 sprintf(space, "%8.8lx", (unsigned long) (val)); \
64 memcpy(phys, space, 8) \
76 memcpy(hdr->
nlink,
"00000001", 8);
77 memcpy(hdr->
namesize,
"0000000b", 8);
104 fprintf(stderr,
" %s(%p, %p)\n", __FUNCTION__, fsm, st);
121 memcpy(hdr->
checksum,
"00000000", 8);
134 if (!rc &&
S_ISLNK(st->st_mode)) {
135 assert(fsm->
lpath != NULL);
158 fprintf(stderr,
" %s(%p, %p)\n", __FUNCTION__, fsm, st);
184 st->st_dev =
makedev(major, minor);
190 st->st_rdev =
makedev(major, minor);
194 if (nameSize >= fsm->
wrsize)
197 {
char * t =
xmalloc(nameSize + 1);
198 fsm->
wrlen = nameSize;
217 fsm->
wrlen = st->st_size;
223 fsm->
wrbuf[st->st_size] =
'\0';
229 fprintf(stderr,
"\t %06o%3d (%4d,%4d)%10d %s\n\t-> %s\n",
230 (
unsigned)st->st_mode, (
int)st->st_nlink,
231 (
int)st->st_uid, (
int)st->st_gid, (
int)st->st_size,
239 static char msg[256];
241 int l, myerrno =
errno;
243 strcpy(msg,
"cpio: ");
247 s = msg + strlen(msg);
248 sprintf(s,
_(
"(error 0x%x)"), (
unsigned)rc);
285 l =
sizeof(msg) - strlen(msg) - 1;
287 if (l > 0) strncat(msg, s, l);
293 if (l > 0) strncat(msg, s, l);
295 if (l > 0) strncat(msg, strerror(myerrno), l);