···220220 sb_export_table_start : int64;
221221}
222222223223-let make_superblock sb_magic sb_inode_count sb_modification_time sb_block_size
223223+let superblock sb_magic sb_inode_count sb_modification_time sb_block_size
224224 sb_fragment_entry_count sb_compression_id sb_block_log sb_flags sb_id_count
225225 sb_version_major sb_version_minor sb_root_inode_ref sb_bytes_used
226226 sb_id_table_start sb_xattr_table_start sb_inode_table_start
···249249250250let superblock_codec =
251251 let open Wire.Codec in
252252- record "SquashfsSuperblock" make_superblock
252252+ record "SquashfsSuperblock" superblock
253253 |+ field "magic" Wire.uint32 (fun t -> t.sb_magic)
254254 |+ field "inode_count" Wire.uint32 (fun t -> t.sb_inode_count)
255255 |+ field "modification_time" Wire.uint32 (fun t -> t.sb_modification_time)
+8-11
lib/squashfs_writer.ml
···261261 sb_export_table_start : int64;
262262}
263263264264-let make_superblock sb_magic sb_inode_count sb_modification_time sb_block_size
264264+let superblock sb_magic sb_inode_count sb_modification_time sb_block_size
265265 sb_fragment_entry_count sb_compression_id sb_block_log sb_flags sb_id_count
266266 sb_version_major sb_version_minor sb_root_inode_ref sb_bytes_used
267267 sb_id_table_start sb_xattr_table_start sb_inode_table_start
···290290291291let superblock_codec =
292292 let open Wire.Codec in
293293- record "SquashfsSuperblock" make_superblock
293293+ record "SquashfsSuperblock" superblock
294294 |+ field "magic" Wire.uint32 (fun t -> t.sb_magic)
295295 |+ field "inode_count" Wire.uint32 (fun t -> t.sb_inode_count)
296296 |+ field "modification_time" Wire.uint32 (fun t -> t.sb_modification_time)
···580580 | _ -> None
581581582582(* Encode an inode header + body into a fresh buffer *)
583583-let make_inode_buf t inode_type mode inode_number body_size encode_body =
583583+let inode_buf t inode_type mode inode_number body_size encode_body =
584584 let buf = Bytes.create (inode_header_size + body_size) in
585585 encode_inode_header buf 0 inode_type mode 0 0 t.mtime inode_number;
586586 encode_body buf inode_header_size;
···592592 List.fold_left (fun acc (n, _) -> acc + 8 + String.length n) 3 children
593593 in
594594 let buf =
595595- make_inode_buf t Basic_directory mode inode_number dir_body_size
596596- (fun buf off ->
595595+ inode_buf t Basic_directory mode inode_number dir_body_size (fun buf off ->
597596 Wire.Codec.encode dir_body_codec
598597 {
599598 db_start_block = 0;
···609608let write_file_inode_buf t inode_table inode_number mode data =
610609 let fragment_unsigned = 0xFFFFFFFF in
611610 let buf =
612612- make_inode_buf t Basic_file mode inode_number file_body_size (fun buf off ->
611611+ inode_buf t Basic_file mode inode_number file_body_size (fun buf off ->
613612 Wire.Codec.encode file_body_codec
614613 {
615614 fb_start_block = 0;
···637636 minor =
638637 let rdev = (major lsl 8) lor minor in
639638 let buf =
640640- make_inode_buf t inode_type mode inode_number device_body_size
641641- (fun buf off ->
639639+ inode_buf t inode_type mode inode_number device_body_size (fun buf off ->
642640 Wire.Codec.encode device_body_codec
643641 { devb_nlink = 1; devb_rdev = rdev }
644642 buf off)
···647645648646let write_ipc_inode_buf t inode_table inode_number inode_type mode =
649647 let buf =
650650- make_inode_buf t inode_type mode inode_number ipc_body_size (fun buf off ->
648648+ inode_buf t inode_type mode inode_number ipc_body_size (fun buf off ->
651649 Wire.Codec.encode ipc_body_codec { ipcb_nlink = 1 } buf off)
652650 in
653651 Buffer.add_bytes inode_table buf
···700698 List.fold_left (fun acc (n, _) -> acc + 8 + String.length n) 3 t.root
701699 in
702700 let buf =
703703- make_inode_buf t Basic_directory 0o755 inode_number dir_body_size
704704- (fun buf off ->
701701+ inode_buf t Basic_directory 0o755 inode_number dir_body_size (fun buf off ->
705702 Wire.Codec.encode dir_body_codec
706703 {
707704 db_start_block = 0;
+6-11
test/test_squashfs.ml
···271271(* ---- xattr tests ---- *)
272272273273(* Helper: build a minimal SquashFS image using the writer *)
274274-let make_image f =
274274+let image f =
275275 let fs = Squashfs.Writer.v () in
276276 f fs;
277277 match Squashfs.of_string (Squashfs.Writer.finalize fs) with
···281281(* has_xattrs returns false for a plain image (no xattr table) *)
282282let test_has_xattrs_false () =
283283 let t =
284284- make_image (fun fs ->
285285- Squashfs.Writer.add_file fs "hello.txt" ~mode:0o644 "hi")
284284+ image (fun fs -> Squashfs.Writer.add_file fs "hello.txt" ~mode:0o644 "hi")
286285 in
287286 Alcotest.(check bool) "no xattrs" false (Squashfs.has_xattrs t)
288287289288(* xattr returns Ok None for inode with no xattrs (xattr_id = 0xFFFFFFFF) *)
290289let test_xattr_no_xattr_table () =
291290 let t =
292292- make_image (fun fs -> Squashfs.Writer.add_file fs "f" ~mode:0o644 "data")
291291+ image (fun fs -> Squashfs.Writer.add_file fs "f" ~mode:0o644 "data")
293292 in
294293 let root = Squashfs.root t in
295294 match Squashfs.xattr t root "user.foo" with
···299298300299(* list_xattrs returns Ok [] for inode with no xattrs *)
301300let test_list_xattrs_empty () =
302302- let t =
303303- make_image (fun fs -> Squashfs.Writer.add_directory fs "d" ~mode:0o755)
304304- in
301301+ let t = image (fun fs -> Squashfs.Writer.add_directory fs "d" ~mode:0o755) in
305302 let root = Squashfs.root t in
306303 match Squashfs.list_xattrs t root with
307304 | Ok [] -> ()
···311308(* xattr on a symlink inode with no xattrs returns Ok None *)
312309let test_xattr_symlink_no_xattrs () =
313310 let t =
314314- make_image (fun fs ->
311311+ image (fun fs ->
315312 Squashfs.Writer.add_file fs "target" ~mode:0o644 "x";
316313 Squashfs.Writer.add_symlink fs "link" "target")
317314 in
···494491let test_xattr_bad_table_start () =
495492 (* A valid image normally has xattr_table_start = 0xFFFFFFFFFFFFFFFF (no xattrs).
496493 We can't easily craft one with a bad table, but we can test the has_xattrs path. *)
497497- let t =
498498- make_image (fun fs -> Squashfs.Writer.add_file fs "f" ~mode:0o644 "x")
499499- in
494494+ let t = image (fun fs -> Squashfs.Writer.add_file fs "f" ~mode:0o644 "x") in
500495 (* has_xattrs is false for writer-generated images *)
501496 Alcotest.(check bool) "has_xattrs false" false (Squashfs.has_xattrs t);
502497 (* xattr on root (no xattr_id) is Ok None *)