From 74e6a095cde8426176ac056299a621da2e5f847f Mon Sep 17 00:00:00 2001 From: Apple Date: Tue, 7 Aug 2018 04:24:15 +0000 Subject: [PATCH] file_cmds-272.201.1.tar.gz --- compress/compress.1 | 4 ++-- compress/compress.c | 7 ++++--- ln/ln.c | 9 +++++++++ pax/gen_subs.c | 14 ++++++++++++-- pax/pax_format.c | 24 ++++++++++++++++++++++-- 5 files changed, 49 insertions(+), 9 deletions(-) diff --git a/compress/compress.1 b/compress/compress.1 index a353c19..963cd7a 100644 --- a/compress/compress.1 +++ b/compress/compress.1 @@ -47,13 +47,13 @@ .Nm .Fl c .Op Fl b Ar bits -.Op Ar file +.Op Ar .Nm uncompress .Op Fl fv .Op Ar .Nm uncompress .Fl c -.Op Ar file +.Op Ar .Sh DESCRIPTION The .Nm diff --git a/compress/compress.c b/compress/compress.c index 0732fa4..17d100f 100644 --- a/compress/compress.c +++ b/compress/compress.c @@ -132,8 +132,9 @@ main(int argc, char *argv[]) exit (eval); } - if (cat == 1 && argc > 1) - errx(1, "the -c option permits only a single file argument"); + /* + * The UNIX standard requires that `uncompress -c` be able to have multiple file parameters given. + */ for (; *argv; ++argv) switch(style) { @@ -429,7 +430,7 @@ usage(int iscompress) "usage: compress [-cfv] [-b bits] [file ...]\n"); else (void)fprintf(stderr, - "usage: uncompress [-cfv] [-b bits] [file ...]\n"); + "usage: uncompress [-cfv] [file ...]\n"); exit(1); } diff --git a/ln/ln.c b/ln/ln.c index 5e61d21..183800e 100644 --- a/ln/ln.c +++ b/ln/ln.c @@ -92,6 +92,15 @@ main(int argc, char *argv[]) if (argc != 2) usage(); linkf = link; + /* UNIX conformance requires that both operands be NOT a dir */ + for (int i = 0; i < 2; i++) { + if (stat(argv[i], &sb) == 0 && S_ISDIR(sb.st_mode)){ + errno = EISDIR; + warn("%s", argv[0]); + return 1; + } + } + exit(linkit(argv[0], argv[1], 0)); } diff --git a/pax/gen_subs.c b/pax/gen_subs.c index d3b4c16..0b75b0d 100644 --- a/pax/gen_subs.c +++ b/pax/gen_subs.c @@ -147,10 +147,20 @@ ls_list(ARCHD *arcn, time_t now, FILE *fp) # endif (unsigned long)MINOR(sbp->st_rdev)); else { + /* + * UNIX compliance fix: printing filename length for soft links + * from arcn->ln_nlen instead of sbp->st_size, which is 0. + */ + off_t nlen; + if (arcn->type == PAX_SLK) { + nlen = arcn->ln_nlen; + } else { + nlen = sbp->st_size; + } # ifdef LONG_OFF_T - (void)fprintf(fp, "%9lu ", sbp->st_size); + (void)fprintf(fp, "%9lu ", nlen); # else - (void)fprintf(fp, "%9qu ", sbp->st_size); + (void)fprintf(fp, "%9qu ", nlen); # endif } diff --git a/pax/pax_format.c b/pax/pax_format.c index 3ac97ed..fbacdff 100644 --- a/pax/pax_format.c +++ b/pax/pax_format.c @@ -944,6 +944,10 @@ pax_rd(ARCHD *arcn, char *buf) arcn->sb.st_size = (off_t)asc_ul(hd->size, sizeof(hd->size), OCT); #else arcn->sb.st_size = (off_t)asc_uqd(hd->size, sizeof(hd->size), OCT); + /* When we have extended header for size, prefer it over hd->size */ + if (size_x_current) { + sscanf(size_x_current, "%lld", &arcn->sb.st_size); + } #endif arcn->sb.st_mtime = (time_t)asc_ul(hd->mtime, sizeof(hd->mtime), OCT); if (arcn->sb.st_atimespec.tv_sec == 0) { // Can be set from header @@ -1315,6 +1319,9 @@ pax_wr(ARCHD *arcn) mode_t mode12only; int term_char=3; /* orignal setting */ term_char=1; /* To pass conformance tests 274, 301 */ + const char *size_header_name = "size"; + char size_value[100]; + bzero(size_value, sizeof(size_value)); /* * check for those file system types pax cannot store @@ -1444,8 +1451,21 @@ pax_wr(ARCHD *arcn) if (uqd_oct((u_quad_t)arcn->sb.st_size, hd->size, sizeof(hd->size), term_char)) { # endif - paxwarn(1,"File is too long for pax %s",arcn->org_name); - return(1); + /* + * Insert an extended header for size=sb.st_size> since + * octal range of 12 byte string cannot fit > 8GiB files in header. + * This fixes Conformance test pax.343 + */ + int i; + snprintf(size_value, sizeof(size_value), "%lld", arcn->sb.st_size); + for (i = 0; i < sizeof(o_option_table)/sizeof(O_OPTION_TYPE); i++) { + if (strncasecmp(size_header_name, o_option_table[i].name, o_option_table[i].len) == 0) { + size_x = size_value; + ext_header_entry[ext_header_inx++] = i; + } + } + generate_pax_ext_header_and_data(arcn, ext_header_inx, &ext_header_entry[0], + PAXXTYPE, header_name_x, header_name_x_requested); } break; } -- 2.7.4