diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-08-16 14:48:54 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-08-18 11:47:19 +0100 |
commit | 99cfc1f36ea88255a2b9497e983d57c1700dcc4c (patch) | |
tree | 83803a896aef143d7a74a9f20709daefc5ef12d6 /sysprep/utils.ml | |
parent | 99759da25c29a7376490074da3d2c22602a2acec (diff) | |
download | libguestfs-99cfc1f36ea88255a2b9497e983d57c1700dcc4c.tar.gz libguestfs-99cfc1f36ea88255a2b9497e983d57c1700dcc4c.tar.xz libguestfs-99cfc1f36ea88255a2b9497e983d57c1700dcc4c.zip |
sysprep: Add --firstboot functionality.
This allows you to add scripts that run in the context of
the guest the first time it boots.
Diffstat (limited to 'sysprep/utils.ml')
-rw-r--r-- | sysprep/utils.ml | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sysprep/utils.ml b/sysprep/utils.ml index 3b3ad8af..81877249 100644 --- a/sysprep/utils.ml +++ b/sysprep/utils.ml @@ -86,3 +86,19 @@ let skip_dashes str = let compare_command_line_args a b = compare (String.lowercase (skip_dashes a)) (String.lowercase (skip_dashes b)) + +let read_whole_file path = + let buf = Buffer.create 16384 in + let chan = open_in path in + let maxlen = 16384 in + let s = String.create maxlen in + let rec loop () = + let r = input chan s 0 maxlen in + if r > 0 then ( + Buffer.add_substring buf s 0 r; + loop () + ) + in + loop (); + close_in chan; + Buffer.contents buf |