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 = Directfifowatcher.mkentry fqp abspath realperm slice_name in
27 Directfifowatcher.openentry root_dir fqp (abspath,slice_name)
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
47 with Unix.Unix_error(_,_,_) ->
49 Directfifowatcher.add_dir_watch fqp
51 (** Functions corresponding to file deletion/directory removal *)
55 match rp with Relpath(rel) ->
56 let fqp = String.concat "/" [root_dir;rel] in
57 let fqp_in = String.concat "." [fqp;"in"] in
58 let fqp_out = String.concat "." [fqp;"out"] in
59 Directfifowatcher.closeentry fqp;
64 logprint "Hm. %s disappeared. Looks like slice %s shot itself in the foot\n" fqp (this#get_slice_name ())
67 match rp with Relpath(rel) ->
68 let fqp = String.concat "/" [root_dir;rel] in
69 Directfifowatcher.del_dir_watch fqp;
73 logprint "Hm. %s disappeared or not empty. Looks like slice %s shot itself in the foot\n" fqp (this#get_slice_name ())
78 let s = Unix.stat root_dir in
79 if (s.st_kind<>S_DIR) then
82 Unix.mkdir root_dir 0o700
84 else if (s.st_perm <> 0o700) then
87 Unix.mkdir root_dir 0o700
89 with Unix.Unix_error(_,_,_) ->
92 Unix.mkdir root_dir 0o700;
95 Directfifowatcher.add_dir_watch root_dir