1 (* frontend.ml: Routines that implement frontend actions, such as creating directories in a slice, creating pipes etc. *)
8 (** frontendhandler class: Methods to create and unlink pipes and directories
9 @param root_dir vsys directory inside a slice
10 @param slice_name actual slice name - set with care, since the acl functionality refers to these names *)
11 class frontendHandler (root_dir,slice_name) =
13 method get_slice_name () = slice_name
15 (** A new script was copied into the backend, make a corresponding entry in
17 @param rp Relative path of the entry in the backend
18 @param abspath Absolute path of the entry
19 @param perm Permissions of the entry at the frontend *)
20 method mkentry (rp:relpath) abspath perm =
21 let realperm = perm land (lnot 0o111) in
22 match rp with Relpath(rel) ->
23 let fqp = String.concat "/" [root_dir;rel] in
24 let res = Fifowatcher.mkentry fqp abspath realperm slice_name in
27 Fifowatcher.openentry fqp (abspath,slice_name) realperm
30 (** A new directory was created at the backend, make a corresponding directory
31 at the frontend. Refer to mkentry for parameters *)
32 method mkdir rp perm =
33 match rp with Relpath(rel) ->
34 let fqp = String.concat "/" [root_dir;rel] in
36 let s = Unix.stat fqp in
37 if (s.st_kind<>S_DIR) then
42 else if (s.st_perm <> perm) then
44 fprintf logfd "Removing directory %s\n" fqp;
49 with Unix.Unix_error(_,_,_) ->
52 (** Functions corresponding to file deletion/directory removal *)
56 match rp with Relpath(rel) ->
57 let fqp1 = String.concat "/" [root_dir;rel;".in"] in
58 let fqp2 = String.concat "/" [root_dir;rel;".out"] in
63 fprintf logfd "Hm. %s disappeared. Looks like slice %s shot itself in the foot\n" fqp1 (this#get_slice_name ());flush logfd
66 match rp with Relpath(rel) ->
67 let fqp = String.concat "/" [root_dir;rel] in
71 fprintf logfd "Hm. %s disappeared. Looks like slice %s shot itself in the foot\n" fqp (this#get_slice_name ());flush logfd