git.annexia.org
/
virt-p2v.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Version 0.9.5 for release.
[virt-p2v.git]
/
iso-attach
diff --git
a/iso-attach
b/iso-attach
index
55bcd3e
..
a6aad26
100755
(executable)
--- a/
iso-attach
+++ b/
iso-attach
@@
-1,6
+1,6
@@
#!/usr/bin/ocamlrun /usr/bin/ocaml
(* -*- tuareg -*- *)
#!/usr/bin/ocamlrun /usr/bin/ocaml
(* -*- tuareg -*- *)
-(* iso-attach attaches an updated 'virt-p2v
.ml
' file to the end of
+(* iso-attach attaches an updated 'virt-p2v' file to the end of
* an ISO image. This is just for quick developer builds because it
* takes ages to rebuild a full ISO.
*
* an ISO image. This is just for quick developer builds because it
* takes ages to rebuild a full ISO.
*
@@
-50,7
+50,7
@@
open Unix
* stuff them into a tarball or ZIP file and attach that.
*)
* stuff them into a tarball or ZIP file and attach that.
*)
-let magic = "ISOATTACHMENT00
2
"
+let magic = "ISOATTACHMENT00
3
"
let magiclen = String.length magic (* = 16 bytes *)
let trailerlen = magiclen + 8 + 8 (* magic + file start + true size *)
let magiclen = String.length magic (* = 16 bytes *)
let trailerlen = magiclen + 8 + 8 (* magic + file start + true size *)
@@
-113,7
+113,7
@@
SYNOPSIS
DESCRIPTION
DESCRIPTION
-iso-attach attaches an updated 'virt-p2v
.ml
' file to the end of
+iso-attach attaches an updated 'virt-p2v' file to the end of
an ISO image. This is just for quick developer builds because it
takes ages to rebuild a full ISO.
an ISO image. This is just for quick developer builds because it
takes ages to rebuild a full ISO.
@@
-169,7
+169,8
@@
and do_add isoname attachment =
let size = file_size + trailerlen in
let over = size land 2047 in
if over > 0 then 2048-over else 0 in
let size = file_size + trailerlen in
let over = size land 2047 in
if over > 0 then 2048-over else 0 in
- assert ((padding_size + file_size + trailerlen) land 2047 = 0);
+ let attachment_size = padding_size + file_size + trailerlen in
+ assert (attachment_size land 2047 = 0);
(* Write the padding. *)
ignore (write fd (String.make padding_size 'x') 0 padding_size);
(* Write the padding. *)
ignore (write fd (String.make padding_size 'x') 0 padding_size);
@@
-177,8
+178,8
@@
and do_add isoname attachment =
(* Write the magic. *)
ignore (write fd magic 0 magiclen);
(* Write the magic. *)
ignore (write fd magic 0 magiclen);
- (* Write the
file start and tru
e size. *)
- let buffer = string_of_int64
iso_size
in
+ (* Write the
attachment size and true fil
e size. *)
+ let buffer = string_of_int64
(Int64.of_int attachment_size)
in
ignore (write fd buffer 0 8);
let buffer = string_of_int64 (Int64.of_int file_size) in
ignore (write fd buffer 0 8);
ignore (write fd buffer 0 8);
let buffer = string_of_int64 (Int64.of_int file_size) in
ignore (write fd buffer 0 8);
@@
-192,14
+193,16
@@
and do_delete isoname =
if read fd buf 0 magiclen <> magiclen || buf <> magic then
failwith "no attachment found";
if read fd buf 0 magiclen <> magiclen || buf <> magic then
failwith "no attachment found";
- (* Read the s
tart offset of the file.
*)
+ (* Read the s
ize of the attachment
*)
let buf = String.create 8 in
if read fd buf 0 8 <> 8 then
failwith "cannot read attachment size";
let buf = String.create 8 in
if read fd buf 0 8 <> 8 then
failwith "cannot read attachment size";
- let offset = int64_of_string buf in
+ let attachment_size = int64_of_string buf in
+
+ let orig_size = LargeFile.lseek fd (Int64.neg attachment_size) SEEK_END in
(* Truncate to start of the file. *)
(* Truncate to start of the file. *)
- LargeFile.ftruncate fd o
ffset
;
+ LargeFile.ftruncate fd o
rig_size
;
close fd
close fd
@@
-210,18
+213,18
@@
and do_get isoname output =
if read fd buf 0 magiclen <> magiclen || buf <> magic then
failwith "no attachment found";
if read fd buf 0 magiclen <> magiclen || buf <> magic then
failwith "no attachment found";
- (* Read the
start and
size. *)
+ (* Read the
attachment size and true
size. *)
let buf = String.create 8 in
if read fd buf 0 8 <> 8 then
let buf = String.create 8 in
if read fd buf 0 8 <> 8 then
- failwith "cannot read attachment
offset
";
- let
offset
= int64_of_string buf in
+ failwith "cannot read attachment
size
";
+ let
attachment_size
= int64_of_string buf in
let buf = String.create 8 in
if read fd buf 0 8 <> 8 then
let buf = String.create 8 in
if read fd buf 0 8 <> 8 then
- failwith "cannot read
attachment
size";
+ failwith "cannot read
file true
size";
let size = Int64.to_int (int64_of_string buf) in
(* Seek to beginning of the attachment. *)
let size = Int64.to_int (int64_of_string buf) in
(* Seek to beginning of the attachment. *)
- ignore (LargeFile.lseek fd
offset SEEK_SET
);
+ ignore (LargeFile.lseek fd
(Int64.neg attachment_size) SEEK_END
);
(* Copy out the attachment. *)
let fd2 = openfile output [O_WRONLY; O_CREAT; O_TRUNC] 0o644 in
(* Copy out the attachment. *)
let fd2 = openfile output [O_WRONLY; O_CREAT; O_TRUNC] 0o644 in
@@
-242,3
+245,5
@@
and do_get isoname output =
close fd
let () = main ()
close fd
let () = main ()
+
+(* This file must end with a newline. *)