diff options
author | bde <bde@FreeBSD.org> | 1999-08-11 08:03:39 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1999-08-11 08:03:39 +0000 |
commit | d3695c1d0371e1f02895f7217864a7634ec907ba (patch) | |
tree | a543750bdf394a4b03b710990b9cb92776a9b7e2 | |
parent | 87155c158cde253c8b9fc613526a6a06ca6f4b98 (diff) | |
download | FreeBSD-src-d3695c1d0371e1f02895f7217864a7634ec907ba.zip FreeBSD-src-d3695c1d0371e1f02895f7217864a7634ec907ba.tar.gz |
Support 21-bit minor numbers. Avoid wasting a byte in their octal
representation by generating the same format as tar-1.13 (use a single
space as the terminator for 7-digit octal numbers). This is POSIX.1
conformant (2-byte terminators are just a bug or historical wart in
old versions of gnu tar). All devices created by `MAKEDEV all' except
rsa0.ctl can now be handled by tar(1).
-rw-r--r-- | gnu/usr.bin/tar/create.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/gnu/usr.bin/tar/create.c b/gnu/usr.bin/tar/create.c index d01d166..3f667a7 100644 --- a/gnu/usr.bin/tar/create.c +++ b/gnu/usr.bin/tar/create.c @@ -873,6 +873,8 @@ dump_file (p, curdev, toplevel) #if defined(S_IFBLK) || defined(S_IFCHR) if (type != LF_FIFO) { + char minorbuf[8 + 1]; + if (checked_to_oct ((long) major (hstat.st_rdev), 8, header->header.devmajor)) { @@ -880,13 +882,24 @@ dump_file (p, curdev, toplevel) critical_error = 1; goto badfile; } - if (checked_to_oct ((long) minor (hstat.st_rdev), 8, - header->header.devminor)) + + /* + * Try harder than usual to fit the minor number. to_oct() wastes + * one byte by adding 2 terminating bytes (a space and a NUL) where + * only 1 (either a space or a NUL) is required by POSIX.1. We + * will discard the NUL if that is necessary and sufficient for the + * minor number to fit. This is compatible with tar-1.13. + */ + if (checked_to_oct ((long) minor (hstat.st_rdev), 8 + 1, minorbuf)) { msg ("%s: minor number too large; not dumped", p); critical_error = 1; goto badfile; } + if (minorbuf[0] == ' ') + bcopy(minorbuf + 1, header->header.devminor, 8); + else + bcopy(minorbuf, header->header.devminor, 8); } #endif |