| 1 |
/** $MirOS: src/bin/pax/ar_subs.c,v 1.5 2007/02/17 04:52:39 tg Exp $ */ |
/* $OpenBSD: ar_subs.c,v 1.31 2006/11/17 08:38:04 otto Exp $ */ |
|
/* $OpenBSD: ar_subs.c,v 1.29 2006/01/25 17:42:08 markus Exp $ */ |
|
| 2 |
/* $NetBSD: ar_subs.c,v 1.5 1995/03/21 09:07:06 cgd Exp $ */ |
/* $NetBSD: ar_subs.c,v 1.5 1995/03/21 09:07:06 cgd Exp $ */ |
| 3 |
|
|
| 4 |
/*- |
/*- |
| 5 |
|
* Copyright (c) 2008 |
| 6 |
|
* Thorsten Glaser <tg@mirbsd.de> |
| 7 |
* Copyright (c) 1992 Keith Muller. |
* Copyright (c) 1992 Keith Muller. |
| 8 |
* Copyright (c) 1992, 1993 |
* Copyright (c) 1992, 1993 |
| 9 |
* The Regents of the University of California. All rights reserved. |
* The Regents of the University of California. All rights reserved. |
| 51 |
#include "options.h" |
#include "options.h" |
| 52 |
|
|
| 53 |
__SCCSID("@(#)ar_subs.c 8.2 (Berkeley) 4/18/94"); |
__SCCSID("@(#)ar_subs.c 8.2 (Berkeley) 4/18/94"); |
| 54 |
__RCSID("$MirOS: src/bin/pax/ar_subs.c,v 1.5 2007/02/17 04:52:39 tg Exp $"); |
__RCSID("$MirOS: src/bin/pax/ar_subs.c,v 1.7 2008/10/29 17:34:48 tg Exp $"); |
| 55 |
|
|
| 56 |
static void wr_archive(ARCHD *, int is_app); |
static void wr_archive(ARCHD *, int is_app); |
| 57 |
static int get_arc(void); |
static int get_arc(void); |
| 312 |
* header (as determined by the format). |
* header (as determined by the format). |
| 313 |
*/ |
*/ |
| 314 |
if (!to_stdout) { |
if (!to_stdout) { |
| 315 |
if ((arcn->type == PAX_HLK) || (arcn->type == PAX_HRG)) |
if ((arcn->type == PAX_HLK) || (arcn->type == PAX_HRG)) { |
| 316 |
res = lnk_creat(arcn); |
res = lnk_creat(arcn, &fd); |
| 317 |
else |
if (fd != -1) |
| 318 |
|
goto extdata; |
| 319 |
|
} else |
| 320 |
res = node_creat(arcn); |
res = node_creat(arcn); |
| 321 |
} |
} |
| 322 |
|
|
| 328 |
(void)putc('\n', listf); |
(void)putc('\n', listf); |
| 329 |
vfpart = 0; |
vfpart = 0; |
| 330 |
} |
} |
| 331 |
continue; |
goto popd; |
| 332 |
} |
} |
| 333 |
/* |
/* |
| 334 |
* we have a file with data here. If we can not create it, skip |
* we have a file with data here. If we can not create it, skip |
| 339 |
else if ((fd = file_creat(arcn)) < 0) { |
else if ((fd = file_creat(arcn)) < 0) { |
| 340 |
(void)rd_skip(arcn->skip + arcn->pad); |
(void)rd_skip(arcn->skip + arcn->pad); |
| 341 |
purg_lnk(arcn); |
purg_lnk(arcn); |
| 342 |
continue; |
goto popd; |
| 343 |
} |
} |
| 344 |
/* |
/* |
| 345 |
* extract the file from the archive and skip over padding and |
* extract the file from the archive and skip over padding and |
| 346 |
* any unprocessed data |
* any unprocessed data |
| 347 |
*/ |
*/ |
| 348 |
|
extdata: |
| 349 |
res = (*frmt->rd_data)(arcn, fd, &cnt); |
res = (*frmt->rd_data)(arcn, fd, &cnt); |
| 350 |
if (fd != STDOUT_FILENO) |
if (fd != STDOUT_FILENO) |
| 351 |
file_close(arcn, fd); |
file_close(arcn, fd); |
| 356 |
if (!res) |
if (!res) |
| 357 |
(void)rd_skip(cnt + arcn->pad); |
(void)rd_skip(cnt + arcn->pad); |
| 358 |
|
|
| 359 |
|
popd: |
| 360 |
/* |
/* |
| 361 |
* if required, chdir around. |
* if required, chdir around. |
| 362 |
*/ |
*/ |
| 414 |
if (ftree_start() < 0) { |
if (ftree_start() < 0) { |
| 415 |
if (is_app) |
if (is_app) |
| 416 |
goto trailer; |
goto trailer; |
|
else |
|
|
return; |
|
|
} |
|
|
if (((*frmt->st_wr)() < 0)) |
|
| 417 |
return; |
return; |
| 418 |
|
} else if (((*frmt->st_wr)() < 0)) |
| 419 |
|
return; |
| 420 |
|
|
| 421 |
wrf = frmt->wr; |
wrf = frmt->wr; |
| 422 |
|
|
| 423 |
/* |
/* |
| 932 |
* create a link or special file |
* create a link or special file |
| 933 |
*/ |
*/ |
| 934 |
if ((arcn->type == PAX_HLK) || (arcn->type == PAX_HRG)) |
if ((arcn->type == PAX_HLK) || (arcn->type == PAX_HRG)) |
| 935 |
res = lnk_creat(arcn); |
res = lnk_creat(arcn, NULL); |
| 936 |
else |
else |
| 937 |
res = node_creat(arcn); |
res = node_creat(arcn); |
| 938 |
if (res < 0) |
if (res < 0) |