The Tar.Header.make function checks the size required for the file size, uid and gid and creates an extended header if needed. This could as well check the file name size and other fields.
|
(** Helper function to make a simple header *) |
|
let make ?(file_mode=0o400) ?(user_id=0) ?(group_id=0) ?(mod_time=0L) ?(link_indicator=Link.Normal) ?(link_name="") ?(uname="") ?(gname="") ?(devmajor=0) ?(devminor=0) file_name file_size = |
|
(* If some fields are too big, we must use a pax header *) |
|
let need_pax_header = |
|
Int64.unsigned_compare file_size 0o077777777777L > 0 |
|
|| user_id > 0x07777777 |
|
|| group_id > 0x07777777 in |
|
let extended = |
|
if need_pax_header |
|
then Some (Extended.make ~file_size ~user_id ~group_id ()) |
|
else None in |
|
{ file_name; |
|
file_mode; |
|
user_id; |
|
group_id; |
|
file_size; |
|
mod_time; |
|
link_indicator; |
|
link_name; |
|
uname; |
|
gname; |
|
devmajor; |
|
devminor; |
|
extended } |
A problem, though, is that the compatibility level is not considered, and in our writer we don't check the compatibility level before writing the extended header. This means we can set compatibility level to V7 but still get PAX extended headers. There is as well a discrepancy how we handle this for GNU compatibility level -- there we synthesize the GNU LongLink in the writer instead.
The
Tar.Header.makefunction checks the size required for the file size, uid and gid and creates an extended header if needed. This could as well check the file name size and other fields.ocaml-tar/lib/tar.ml
Lines 466 to 489 in ef66a98
A problem, though, is that the compatibility level is not considered, and in our writer we don't check the compatibility level before writing the extended header. This means we can set compatibility level to
V7but still get PAX extended headers. There is as well a discrepancy how we handle this forGNUcompatibility level -- there we synthesize the GNU LongLink in the writer instead.