Skip to content

Commit 79e3d2e

Browse files
committed
Add various debug helpers.
Build with -g, start fuse in the foreground with tracing output, document MALLOC_CHECK_ .
1 parent ba6dde1 commit 79e3d2e

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

Diff for: OMakefile

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ section
55
vmount(-l, src, build)
66
.SUBDIRS: build
77

8+
section
9+
vmount(-l, src, debug)
10+
OCAMLOPTFLAGS += -g
11+
.SUBDIRS: debug
12+
813
if false
914

1015
section

Diff for: README

+6
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,10 @@ Or use a few special commands
8484
git fs umount
8585
git fs help
8686

87+
Debugging
88+
---------
89+
90+
MALLOC_CHECK_=3 debug/git-fs debug 2>&1 |tee -a debug.log
91+
92+
8793

Diff for: debug/.keep

Whitespace-only changes.

Diff for: src/git_fs.ml

+8-6
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ let is_mounted () =
861861
git_dir_quoted = fsname)
862862
(mtab_lines ())
863863

864-
let cmd_mount () =
864+
let cmd_mount ?(debug=false) () =
865865
let lazy mountpoint = mountpoint_lazy in
866866
let lazy fsname = fsname_lazy in
867867
(*log fsname;*)
@@ -872,15 +872,16 @@ let cmd_mount () =
872872
begin try Unix.mkdir mountpoint 0o755
873873
with Unix.Unix_error (Unix.EEXIST, _, _) -> () end;
874874
prerr_endline (Printf.sprintf "Mounting on %S" mountpoint);
875-
let fuse_args = [|
876-
fs_subtype; (*"-f";*)
875+
let fuse_args = [
877876
"-o"; "ro";
878877
(* fuse doesn't guess the subtype anymore, if we give it fsname *)
879878
"-osubtype=" ^ fs_subtype;
880879
"-ofsname=" ^ fsname;
881880
mountpoint;
882-
|] in
883-
Fuse.main fuse_args fuse_ops
881+
] in
882+
let fuse_args = if debug then "-s"::"-d"::fuse_args else fuse_args in
883+
let fuse_args = fs_subtype::fuse_args in
884+
Fuse.main (Array.of_list fuse_args) fuse_ops
884885
end
885886

886887
let cmd_umount () =
@@ -915,7 +916,8 @@ let cmd_fuse_help () =
915916
let _ =
916917
match Sys.argv with
917918
|[| _ |] -> cmd_mount ()
918-
|[| _; "mount" |] -> cmd_mount ()
919+
|[| _; "mount" |] -> cmd_mount ~debug:false ()
920+
|[| _; "debug" |] -> cmd_mount ~debug:true ()
919921
|[| _; "umount" |] -> cmd_umount ()
920922
|[| _; "show-mountpoint" |] -> cmd_show_mountpoint ()
921923
|[| _; "is-mounted" |] -> cmd_is_mounted ()

0 commit comments

Comments
 (0)