]> git.saurik.com Git - apple/file_cmds.git/commitdiff
file_cmds-272.201.1.tar.gz macos-1014 macos-10141 macos-10142 macos-10143 v272.201.1 v272.220.1
authorApple <opensource@apple.com>
Tue, 7 Aug 2018 04:24:15 +0000 (04:24 +0000)
committerApple <opensource@apple.com>
Tue, 7 Aug 2018 04:24:15 +0000 (04:24 +0000)
compress/compress.1
compress/compress.c
ln/ln.c
pax/gen_subs.c
pax/pax_format.c

index a353c19a5752dd441b7edcdd8a20e008187523cf..963cd7a48c1a0bf30205a6b6e685e2907889cefb 100644 (file)
 .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
index 0732fa46238a8bf42a265d51e1d49955bf3d3cc2..17d100f4109e9c008c95dffff5e423978c49fd93 100644 (file)
@@ -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 5e61d21c3c8b8ec97273ae442cd04a7fbbff5d31..183800e31ee4e334442bb931e1ccca220491b7e0 100644 (file)
--- 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));
        }
 
index d3b4c16766651f334df698702bc24cb1e50e3427..0b75b0d83b9d297449b9120b6763f34ac60bc01b 100644 (file)
@@ -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
        }
 
index 3ac97ed41068311520863b890096fe7d6790bf3e..fbacdff01cd6ec4df181eefd5dccb6284c0cacb9 100644 (file)
@@ -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=<arcn->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;
        }