(dev.[5] = 'h' || dev.[5] = 's' || dev.[5] = 'v') &&
dev.[6] = 'd' &&
dev.[7] >= 'a' && dev.[7] <= 'z' then (
- let dev = String.copy dev in
- dev.[5] <- 's';
- dev
+ let dev = Bytes.of_string dev in
+ Bytes.set dev 5 's';
+ Bytes.to_string dev
)
else
dev
let suid = is_suid mode in
let sgid = is_sgid mode in
let svtx = is_svtx mode in
- if suid then str.[3] <- 's';
- if sgid then str.[6] <- 's';
- if svtx then str.[9] <- 't';
+ let str = Bytes.of_string str in
+ if suid then Bytes.set str 3 's';
+ if sgid then Bytes.set str 6 's';
+ if svtx then Bytes.set str 9 't';
- str
+ Bytes.to_string str
let tmpdir () =
let chan = open_in "/dev/urandom" in
- let data = String.create 16 in
- really_input chan data 0 (String.length data);
+ let data = Bytes.create 16 in
+ really_input chan data 0 (Bytes.length data);
close_in chan;
- let data = Digest.to_hex (Digest.string data) in
+ let data = Digest.to_hex (Digest.bytes data) in
(* Note this is secure, because if the name already exists, even as a
* symlink, mkdir(2) will fail.
*)
- let tmpdir = Filename.temp_dir_name // sprintf "guestfsbrowser%s.tmp" data in
+ let tmpdir =
+ Filename.get_temp_dir_name () // sprintf "guestfsbrowser%s.tmp" data in
Unix.mkdir tmpdir 0o700;
at_exit
(fun () ->