Commit 5353464e authored by gerd's avatar gerd

Fixes for MacOS X


git-svn-id: https://gps.dynxs.de/private/svn/app-plasma/trunk@624 55289a75-7b90-4627-9e07-ffb4263930b2
parent 030eedc3
......@@ -15,13 +15,18 @@ usage () {
inst=""
passwd="/etc/passwd"
group="/etc/group"
apple=0
case `uname` in
Darwin) apple=1 ;;
esac
while [ $# -gt 0 ]; do
case "$1" in
-passwd)
passwd="$2"; shift 2 ;;
passwd="$2"; apple=0; shift 2 ;;
-group)
group="$2"; shift 2 ;;
group="$2"; apple=0; shift 2 ;;
-*)
usage ;;
*)
......@@ -67,8 +72,15 @@ else
fi
echo "Setting passwd and group"
cat "$passwd" | $plasma admin_table $nn -auth proot -put passwd
cat "$group" | $plasma admin_table $nn -auth proot -put group
if [ $apple -gt 0 ]; then
dscl -url . -readall /Users |
$plasma admin_table $nn -auth proot -apple -put passwd
dscl -url . -readall /Groups |
$plasma admin_table $nn -auth proot -apple -put group
else
cat "$passwd" | $plasma admin_table $nn -auth proot -put passwd
cat "$group" | $plasma admin_table $nn -auth proot -put group
fi
echo "ok"
echo "Done"
......@@ -15,9 +15,13 @@ conf="$prefix/etc/authnode.conf"
status() {
pid=`cat "$sockdir/pid" 2>/dev/null`
if kill -0 $pid 2>/dev/null; then
exe=`readlink /proc/$pid/exe | sed -e 's/ (deleted)$//'`
exe=`basename "$exe"`
if [ "X$exe" = "X$progname" ]; then
if [ -d /proc/$pid ]; then
exe=`readlink /proc/$pid/exe | sed -e 's/ (deleted)$//'`
exe=`basename "$exe"`
if [ "X$exe" = "X$progname" ]; then
return 0
fi
else
return 0
fi
fi
......
......@@ -15,9 +15,13 @@ conf="$prefix/etc/datanode.conf"
status() {
pid=`cat "$sockdir/pid" 2>/dev/null`
if kill -0 $pid 2>/dev/null; then
exe=`readlink /proc/$pid/exe | sed -e 's/ (deleted)$//'`
exe=`basename "$exe"`
if [ "X$exe" = "X$progname" ]; then
if [ -d /proc/$pid ]; then
exe=`readlink /proc/$pid/exe | sed -e 's/ (deleted)$//'`
exe=`basename "$exe"`
if [ "X$exe" = "X$progname" ]; then
return 0
fi
else
return 0
fi
fi
......
......@@ -15,9 +15,13 @@ conf="$prefix/etc/nfsnode.conf"
status() {
pid=`cat "$sockdir/pid" 2>/dev/null`
if kill -0 $pid 2>/dev/null; then
exe=`readlink /proc/$pid/exe | sed -e 's/ (deleted)$//'`
exe=`basename "$exe"`
if [ "X$exe" = "X$progname" ]; then
if [ -d /proc/$pid ]; then
exe=`readlink /proc/$pid/exe | sed -e 's/ (deleted)$//'`
exe=`basename "$exe"`
if [ "X$exe" = "X$progname" ]; then
return 0
fi
else
return 0
fi
fi
......
......@@ -15,9 +15,13 @@ conf="$prefix/etc/namenode.conf"
status() {
pid=`cat "$sockdir/pid" 2>/dev/null`
if kill -0 $pid 2>/dev/null; then
exe=`readlink /proc/$pid/exe | sed -e 's/ (deleted)$//'`
exe=`basename "$exe"`
if [ "X$exe" = "X$progname" ]; then
if [ -d /proc/$pid ]; then
exe=`readlink /proc/$pid/exe | sed -e 's/ (deleted)$//'`
exe=`basename "$exe"`
if [ "X$exe" = "X$progname" ]; then
return 0
fi
else
return 0
fi
fi
......
......@@ -44,6 +44,8 @@ let main () =
(fun s -> raise (Arg.Bad ("Don't know what to do with: " ^ s)))
(sprintf "usage: %s [options]" (Filename.basename Sys.argv.(0)));
Printexc.record_backtrace true;
let parallelizer =
Netplex_mp.mp ~keep_fd_open:true () in
......
......@@ -206,7 +206,13 @@ let factory() =
*)
( match Unix.getsockname fd with
| Unix.ADDR_UNIX path ->
Unix.chmod path 0o666
( try
Unix.chmod path 0o666
with
| _ ->
Printf.eprintf
"Cannot chmod %S" path
)
| _ ->
()
)
......
......@@ -1197,63 +1197,71 @@ let factory() =
[shm_name]
method post_start_hook cont =
let store =
Dn_store.open_store (conf :> Dn_store.dn_store_config) in
let shm =
Dn_shm.openshm
(conf :> Dn_shm.dn_shm_config)
shm_name in
let udsocket =
Netplex_cenv.lookup "Dn_manager" "RPC" in
(* Start the special server for [Dn_discover]: *)
let dsrv = create_dn_discover_server conf cont in
let m =
{ shm = shm;
shm_name = shm_name;
slot_used = Array.make conf#dn_shm_queue_length false;
wrequests = Queue.create();
drequests = Queue.create();
io_mset = create_io_mset conf;
safetrans = Hashtbl.create 17;
last_sync = 0L;
syncing = false;
slow_syncing = false;
wsync = Queue.create();
user_shm = Hashtbl.create 5;
udsocket = udsocket;
store = store;
discover_server = dsrv;
stats = new_stats()
} in
Manager_var.set "current_manager" m;
(** Publish the name of the shm object: *)
ignore(Netplex_sharedvar.create_var
"plasma.datanode.shm.name");
ignore(Netplex_sharedvar.set_value
"plasma.datanode.shm.name" shm_name);
(** Establish the timer calling [sync] periodically: *)
let _tm =
Netplex_cenv.create_timer
(fun tm -> sync_cycle m; true)
conf#dn_sync_period in
(** Establish a timer for [maybe_timeout_safetrans] *)
let _tm =
Netplex_cenv.create_timer
(fun tm -> maybe_timeout_safetrans m; true)
60.0 in
(** Establish a timer for printing statistics *)
let _tm =
Netplex_cenv.create_timer
(fun tm -> print_stats m; true)
stats_period in
();
try
let store =
Dn_store.open_store (conf :> Dn_store.dn_store_config) in
let shm =
Dn_shm.openshm
(conf :> Dn_shm.dn_shm_config)
shm_name in
let udsocket =
Netplex_cenv.lookup "Dn_manager" "RPC" in
(* Start the special server for [Dn_discover]: *)
let dsrv = create_dn_discover_server conf cont in
let m =
{ shm = shm;
shm_name = shm_name;
slot_used = Array.make conf#dn_shm_queue_length false;
wrequests = Queue.create();
drequests = Queue.create();
io_mset = create_io_mset conf;
safetrans = Hashtbl.create 17;
last_sync = 0L;
syncing = false;
slow_syncing = false;
wsync = Queue.create();
user_shm = Hashtbl.create 5;
udsocket = udsocket;
store = store;
discover_server = dsrv;
stats = new_stats()
} in
Manager_var.set "current_manager" m;
(** Publish the name of the shm object: *)
ignore(Netplex_sharedvar.create_var
"plasma.datanode.shm.name");
ignore(Netplex_sharedvar.set_value
"plasma.datanode.shm.name" shm_name);
(** Establish the timer calling [sync] periodically: *)
let _tm =
Netplex_cenv.create_timer
(fun tm -> sync_cycle m; true)
conf#dn_sync_period in
(** Establish a timer for [maybe_timeout_safetrans] *)
let _tm =
Netplex_cenv.create_timer
(fun tm -> maybe_timeout_safetrans m; true)
60.0 in
(** Establish a timer for printing statistics *)
let _tm =
Netplex_cenv.create_timer
(fun tm -> print_stats m; true)
stats_period in
()
with
| error ->
let bt = Printexc.get_backtrace() in
cont#log `Crit ("Exception: " ^
(Netexn.to_string error));
cont#log `Crit ("Backtrace: " ^ bt);
method system_shutdown() =
let m = current_manager() in
......
......@@ -1050,9 +1050,10 @@ let fixup_ii ii =
let proc_allocate_inode sess (tid,ii) emit =
(* sec *)
dlogr (fun () -> sprintf "proc_allocate_inode tid=%Ld" tid);
(get_shared()) # incr_count `RPC_filesystem;
let module A = Pfs_rpcapi_aux in
dlogr
(fun () -> sprintf "proc_allocate_inode tid=%Ld seqno=%Ld" tid ii.A.seqno);
(get_shared()) # incr_count `RPC_filesystem;
with_transaction
"allocate_inode" sess emit tid
(fun trans ->
......
This diff is collapsed.
......@@ -58,6 +58,7 @@ FILES[] =
plasma_filebuf
plasma_client
plasma_netfs
plasma_opendir
OCAMLINCLUDES = ../plasmasupport
......
......@@ -1406,6 +1406,7 @@ let admin_table() =
let esys = Unixqueue.create_unix_event_system() in
let ac = access_cluster esys in
let mode = ref None in
let apple = ref false in
Arg.parse
(ac#args @
......@@ -1414,6 +1415,9 @@ let admin_table() =
"-put", Arg.String (fun key -> mode := Some(`Put key)),
"<name> Set the admin table <name> from stdin";
"-apple", Arg.Set apple,
" For -put: accept input in 'dscl -url -readall' format"
]
)
(fun s ->
......@@ -1431,8 +1435,17 @@ let admin_table() =
| Some(`Put key) ->
let c = ac#open_cluster () in
let data =
Netchannels.string_of_in_obj_channel
(new Netchannels.input_channel stdin) in
if !apple then
let f =
match key with
| "passwd" -> Plasma_opendir.to_passwd
| "group" -> Plasma_opendir.to_group
| _ -> failwith "unsupported key" in
let ch = new Netchannels.input_channel stdin in
f ch
else
Netchannels.string_of_in_obj_channel
(new Netchannels.input_channel stdin) in
Plasma_client.write_admin_table c key data
......
(* $Id$ *)
(* Functions for converting the output of MacOSX
- dscl -url . -readall /Users, and
- dscl -url . -readall /Groups
to the /etc/passwd and /etc/group formats, resp
*)
open Printf
type passwd_entry =
{ mutable uid : int option;
mutable name : string option;
mutable real_name : string option;
mutable gid : int option;
mutable home : string option;
mutable shell : string option
}
let empty_entry =
{ uid = None;
name = None;
real_name = None;
gid = None;
home = None;
shell = None
}
type group_entry =
{ mutable g_id : int option;
mutable g_name : string option;
mutable g_members : string list
}
let empty_group =
{ g_id = None;
g_name = None;
g_members = []
}
let re = Netstring_str.regexp "[ \t\r\n]+"
let decode s =
let words = Netstring_str.split re s in
List.map
(fun w ->
try Netencoding.Url.decode ~plus:false w
with _ -> w
)
words
let to_passwd (ch : Netchannels.in_obj_channel) =
let entry = ref empty_entry in
let cur_att = ref None in
let out = ref [] in
let process_cur_att() =
match !cur_att with
| None -> ()
| Some(name,value) ->
let values = decode value in
( try
( match name with
| "UniqueID" ->
!entry.uid <- Some (int_of_string (List.hd values))
| "RecordName" ->
!entry.name <- Some (List.hd values)
| "RealName" ->
!entry.real_name <- Some (String.concat " " values)
| "PrimaryGroupID" ->
!entry.gid <- Some (int_of_string (List.hd values))
| "NFSHomeDirectory" ->
!entry.home <- Some (List.hd values)
| "UserShell" ->
!entry.shell <- Some (List.hd values)
| _ ->
()
);
cur_att := None
with _ ->
prerr_endline ("Cannot parse attribute: " ^ name)
) in
let output_entry() =
let get =
function
| None -> raise Not_found
| Some x -> x in
try
let uid = get !entry.uid in
let gid = get !entry.gid in
let name = get !entry.name in
let real_name = get !entry.real_name in
let home = get !entry.home in
let shell = get !entry.shell in
let passwd_line =
sprintf "%s:*:%d:%d:%s:%s:%s"
name uid gid real_name home shell in
out := passwd_line :: !out
with Not_found -> () (* incomplete *) in
try
while true do
let line = ch # input_line () in
if line = "" then ()
else if line = "-" then ( (* end of user entry *)
process_cur_att();
output_entry();
entry := empty_entry
)
else if line.[0] = ' ' then ( (* continuation line *)
match !cur_att with
| None -> ()
| Some(name,value) ->
cur_att := Some(name,value ^ line)
)
else (
try
let colon = String.index line ':' in
process_cur_att();
let name = String.sub line 0 colon in
let value =
String.sub line (colon+1) (String.length line - colon - 1) in
cur_att := Some(name,value)
with
| Not_found -> ()
)
done;
assert false
with
| End_of_file ->
process_cur_att();
output_entry();
String.concat "\n" (List.rev !out)
let to_group (ch : Netchannels.in_obj_channel) =
let entry = ref empty_group in
let cur_att = ref None in
let out = ref [] in
let process_cur_att() =
match !cur_att with
| None -> ()
| Some(name,value) ->
let values = decode value in
( try
( match name with
| "PrimaryGroupID" ->
!entry.g_id <- Some (int_of_string (List.hd values))
| "RecordName" ->
!entry.g_name <- Some (List.hd values)
| "GroupMembership" ->
!entry.g_members <- values
| _ ->
()
);
cur_att := None
with _ ->
prerr_endline ("Cannot parse attribute: " ^ name)
) in
let output_entry() =
let get =
function
| None -> raise Not_found
| Some x -> x in
try
let gid = get !entry.g_id in
let name = get !entry.g_name in
let group_line =
sprintf "%s:*:%d:%s"
name gid (String.concat "," !entry.g_members) in
out := group_line :: !out
with Not_found -> () (* incomplete *) in
try
while true do
let line = ch # input_line () in
if line = "" then ()
else if line = "-" then ( (* end of user entry *)
process_cur_att();
output_entry();
entry := empty_group
)
else if line.[0] = ' ' then ( (* continuation line *)
match !cur_att with
| None -> ()
| Some(name,value) ->
cur_att := Some(name,value ^ line)
)
else (
try
let colon = String.index line ':' in
process_cur_att();
let name = String.sub line 0 colon in
let value =
String.sub line (colon+1) (String.length line - colon - 1) in
cur_att := Some(name,value)
with
| Not_found -> ()
)
done;
assert false
with
| End_of_file ->
process_cur_att();
output_entry();
String.concat "\n" (List.rev !out)
(* $Id$ *)
(* Functions for converting the output of MacOSX
- dscl -url . -readall /Users, and
- dscl -url . -readall /Groups
to the /etc/passwd and /etc/group formats, resp
*)
val to_passwd : Netchannels.in_obj_channel -> string
val to_group : Netchannels.in_obj_channel -> string
......@@ -359,7 +359,7 @@ let node_list ?(port_param="port") ?(node_param="node") ?(empty_ok=false)
exception Out_of_shared_memory
let rec get_shm_fd prefix n =
let r = Digest.to_hex(Plasma_rng.random_bytes 16) in
let r = String.sub (Digest.to_hex(Plasma_rng.random_bytes 16)) 0 8 in
let name = Printf.sprintf "/%s_%s_%d" prefix r n in
try
(Netsys_posix.shm_open
......@@ -392,6 +392,8 @@ let enlarge_shm fd size =
| Unix.Unix_error(Unix.ENOSPC,_,_) ->
( try Unix.LargeFile.ftruncate fd old_size with _ -> ());
raise Out_of_shared_memory
| Unix.Unix_error(Unix.ESPIPE,_,_) ->
()
)
let map_shm fd pos len =
......@@ -402,9 +404,14 @@ let map_shm fd pos len =
*)
if pos < 0L || len < 0 then
invalid_arg "Plasma_util.map_shm";
let eof = Unix.LargeFile.lseek fd 0L Unix.SEEK_END in
if Int64.sub eof (Int64.of_int len) < pos then
failwith "Plasma_util.map_shm: shm file not large enough";
( try
let eof = Unix.LargeFile.lseek fd 0L Unix.SEEK_END in
if Int64.sub eof (Int64.of_int len) < pos then
failwith "Plasma_util.map_shm: shm file not large enough";
with
| Unix.Unix_error(Unix.ESPIPE,_,_) ->
() (* this check is unavailable on some OS *)
);
Bigarray.Array1.map_file
fd ~pos Bigarray.char Bigarray.c_layout true len
......@@ -413,9 +420,14 @@ let map_shm_int64 fd pos len =
(* len: in bytes *)
if pos < 0L || len < 0 then
invalid_arg "Plasma_util.map_shm_int64";
let eof = Unix.LargeFile.lseek fd 0L Unix.SEEK_END in
if Int64.sub eof (Int64.of_int len) < pos then
failwith "Plasma_util.map_shm_int64: shm file not large enough";
( try
let eof = Unix.LargeFile.lseek fd 0L Unix.SEEK_END in
if Int64.sub eof (Int64.of_int len) < pos then
failwith "Plasma_util.map_shm_int64: shm file not large enough";
with
| Unix.Unix_error(Unix.ESPIPE,_,_) ->
() (* this check is unavailable on some OS *)
);
Bigarray.Array1.map_file
fd ~pos Bigarray.int64 Bigarray.c_layout true (len / 8)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment