Download raw body.
Change pax(1) default write format
On Mon, Apr 15, 2024 at 06:33:15PM +0200, Jeremie Courreges-Anglas wrote:
> On Mon, Apr 15, 2024 at 06:30:29PM +0200, Mark Kettenis wrote:
> > > From: "Theo de Raadt" <deraadt@openbsd.org>
> > > Date: Mon, 15 Apr 2024 10:22:25 -0600
> > >
> > > I am absolutely unworried about this size increase.
> > > We must do this.
> > >
> > > But why this? What is this for?
> > >
> > > +#ifdef SMALL
> > > +# define DEFLT 5 /* format when called as pax: ustar */
> >
> > Well the pax on ramdisks only supports a limited number of formats to
> > make the binary smaller...
>
> pax/tar on the ramdisks include read support for the 'pax' format,
> they don't include write support.
>
> I can unifdef, but I will only be able to test ramdisks on amd64 and
> i386.
For reference, the diff below unifdefs the write support.
Before/after:
ritchie /usr/src/distrib/special/pax$ size tar.o obj/tar.o
text data bss dec hex
7003 0 40 7043 1b83 tar.o
8724 0 40 8764 223c obj/tar.o
We could go this way but I don't care much about it right now.
I'd rather move towards changing the defaults, so please go back to
the initial diff. ;)
Index: options.c
===================================================================
RCS file: /cvs/src/bin/pax/options.c,v
diff -u -p -r1.107 options.c
--- options.c 9 Dec 2023 23:00:11 -0000 1.107
+++ options.c 15 Apr 2024 16:47:36 -0000
@@ -216,8 +216,6 @@ FSUB fsub[] = {
{ },
/* 9: gzip, to detect failure to use -z */
{ },
-/* 10: POSIX PAX */
- { },
#else
/* 6: compress, to detect failure to use -Z */
{NULL, 0, 4, 0, 0, 0, 0, compress_id},
@@ -227,11 +225,11 @@ FSUB fsub[] = {
{NULL, 0, 4, 0, 0, 0, 0, bzip2_id},
/* 9: gzip, to detect failure to use -z */
{NULL, 0, 4, 0, 0, 0, 0, gzip_id},
+#endif
/* 10: POSIX PAX */
{"pax", 5120, BLKMULT, 0, 1, BLKMULT, 0, ustar_id, no_op,
ustar_rd, tar_endrd, no_op, pax_wr, tar_endwr, tar_trail,
tar_opt},
-#endif
};
#define F_OCPIO 0 /* format when called as cpio -6 */
#define F_ACPIO 1 /* format when called as cpio -c */
Index: tar.c
===================================================================
RCS file: /cvs/src/bin/pax/tar.c,v
diff -u -p -r1.79 tar.c
--- tar.c 20 Jan 2024 17:34:50 -0000 1.79
+++ tar.c 15 Apr 2024 16:39:14 -0000
@@ -75,9 +75,7 @@ static char *name_split(char *, int);
static int ul_oct(u_long, char *, int, int);
static int ull_oct(unsigned long long, char *, int, int);
static int rd_xheader(ARCHD *arcn, int, off_t);
-#ifndef SMALL
static int wr_xheader(ARCHD *, struct xheader *);
-#endif
static uid_t uid_nobody;
static uid_t uid_warn;
@@ -913,7 +911,6 @@ reset:
return(0);
}
-#ifndef SMALL
static int
xheader_add(struct xheader *xhdr, const char *keyword,
const char *value)
@@ -1097,7 +1094,6 @@ wr_xheader(ARCHD *arcn, struct xheader *
return 0;
}
-#endif
static int
wr_ustar_or_pax(ARCHD *arcn, int ustar)
@@ -1105,9 +1101,7 @@ wr_ustar_or_pax(ARCHD *arcn, int ustar)
HD_USTAR *hd;
const char *name;
char *pt, hdblk[sizeof(HD_USTAR)];
-#ifndef SMALL
struct xheader xhdr = SLIST_HEAD_INITIALIZER(xhdr);
-#endif
int bad_mtime;
/*
@@ -1133,15 +1127,12 @@ wr_ustar_or_pax(ARCHD *arcn, int ustar)
paxwarn(1, "Link name too long for ustar %s",
arcn->ln_name);
return(1);
- }
-#ifndef SMALL
- else if (xheader_add(&xhdr, "linkpath", arcn->name) == -1) {
+ } else if (xheader_add(&xhdr, "linkpath", arcn->name) == -1) {
paxwarn(1, "Link name too long for pax %s",
arcn->ln_name);
xheader_free(&xhdr);
return(1);
}
-#endif
}
/*
@@ -1153,9 +1144,7 @@ wr_ustar_or_pax(ARCHD *arcn, int ustar)
paxwarn(1, "File name too long for ustar %s",
arcn->name);
return(1);
- }
-#ifndef SMALL
- else if (xheader_add(&xhdr, "path", arcn->name) == -1) {
+ } else if (xheader_add(&xhdr, "path", arcn->name) == -1) {
paxwarn(1, "File name too long for pax %s",
arcn->name);
xheader_free(&xhdr);
@@ -1163,7 +1152,6 @@ wr_ustar_or_pax(ARCHD *arcn, int ustar)
}
/* PAX format, we don't need to split the path */
pt = arcn->name;
-#endif
}
/*
@@ -1249,16 +1237,13 @@ wr_ustar_or_pax(ARCHD *arcn, int ustar)
paxwarn(1, "File is too long for ustar %s",
arcn->org_name);
return(1);
- }
-#ifndef SMALL
- else if (xheader_add_ull(&xhdr, "size",
+ } else if (xheader_add_ull(&xhdr, "size",
arcn->sb.st_size) == -1) {
paxwarn(1, "File is too long for pax %s",
arcn->org_name);
xheader_free(&xhdr);
return(1);
}
-#endif
}
break;
}
@@ -1302,7 +1287,6 @@ wr_ustar_or_pax(ARCHD *arcn, int ustar)
hd->mtime, sizeof(hd->mtime), 3);
if (bad_mtime && ustar)
goto out;
-#ifndef SMALL
if (!ustar) {
/*
* The pax format can preserve atime and store
@@ -1325,7 +1309,6 @@ wr_ustar_or_pax(ARCHD *arcn, int ustar)
return (1);
}
}
-#endif
if (ul_oct(arcn->sb.st_mode, hd->mode, sizeof(hd->mode), 3))
goto out;
if (!Nflag) {
@@ -1335,7 +1318,6 @@ wr_ustar_or_pax(ARCHD *arcn, int ustar)
strncpy(hd->gname, name, sizeof(hd->gname));
}
-#ifndef SMALL
/* write out a pax extended header if needed */
if (!SLIST_EMPTY(&xhdr)) {
int ret;
@@ -1345,7 +1327,6 @@ wr_ustar_or_pax(ARCHD *arcn, int ustar)
if (ret == -1)
return(-1);
}
-#endif
/*
* calculate and store the checksum write the header to the archive
@@ -1364,9 +1345,7 @@ wr_ustar_or_pax(ARCHD *arcn, int ustar)
return(1);
out:
-#ifndef SMALL
xheader_free(&xhdr);
-#endif
/*
* header field is out of range
*/
@@ -1402,13 +1381,11 @@ ustar_wr(ARCHD *arcn)
* 0 if file has data to be written after the header, 1 if file has NO
* data to write after the header, -1 if archive write failed
*/
-#ifndef SMALL
int
pax_wr(ARCHD *arcn)
{
return wr_ustar_or_pax(arcn, 0);
}
-#endif
/*
* name_split()
--
jca
Change pax(1) default write format