[erlang-questions] Newbie questions about file module
Ville Silventoinen
ville.silventoinen@REDACTED
Thu Feb 12 12:35:20 CET 2009
Hi,
I've written a small Erlang program that copies directory trees. I cannot
figure out how to set the owner (Unix UID and GID) for symbolic links,
because file:write_file_info/2 modifies the target file, not the symlink.
Unix command chown has -h option for this purpose. Is there any way of doing
this in Erlang? Why isn't there file:write_link_info/2? Perhaps I've missed
something, is there a way to copy the symlink as it is? (I do use read_link
and read_link_info.)
My second question relates to eprof. I analysed the execution of my program
(copying /usr/local/lib to NFS directory). The eprof:total_analyse/0 results
are below ("mirror11" is my module). It shows that 82% of the time goes in
file_name_1/1, which "Generates a flat file name from a deep list of atoms
and characters (integers)". Does this really mean that 82% of time is spent
here, instead of doing disk I/O? I would have expected file:copy/2 to be on
the top of the list. (There are 481 directories and 6744 files in my
/usr/local/lib.)
Any comments would be appreciated!
Thanks,
Ville
7> eprof:total_analyse().
FUNCTION CALLS TIME
file:file_name_1/1 3086234 82 %
gen:do_call/4 29869 2 %
file:check_args/1 93941 2 %
gen:wait_resp_mon/3 29869 1 %
mirror11:get_file_info/2 21195 1 %
file:check_and_call/2 29869 1 %
file:call/2 29869 1 %
gen:call/4 29869 1 %
file:file_name/1 36615 1 %
gen_server:call/3 29869 1 %
mirror11:do_file/4 6744 1 %
erlang:'++'/2 21680 0 %
erlang:monitor/2 29869 0 %
file:read_link_info/1 14451 0 %
file:copy_int/3 13488 0 %
erlang:whereis/1 29869 0 %
erlang:demonitor/1 29869 0 %
erlang:list_to_tuple/1 29869 0 %
erlang:list_to_binary/1 21195 0 %
mirror11:by_type/6 7707 0 %
lists:foreach/2 7708 0 %
ets:lookup/2 21195 0 %
mirror11:log_debug/2 6748 0 %
file:write_file_info/2 7225 0 %
ets:insert/2 7707 0 %
mirror11:do_dir/3 481 0 %
mirror11:'-do_dir/3-fun-5-'/4 6744 0 %
file:copy/2 6744 0 %
mirror11:start_dir_workers/5 963 0 %
ets:delete/1 481 0 %
file:list_dir/1 962 0 %
mirror11:rendezvous/1 963 0 %
erlang:apply/2 481 0 %
erlang:spawn/3 481 0 %
file:make_dir/1 481 0 %
ets:new/2 481 0 %
erlang:spawn/1 481 0 %
mirror11:'-start_dir_workers/5-fun-0-'/3 481 0 %
mirror11:do_symlink/4 2 0 %
mirror11:master_loop/0 1 0 %
file:read_link/1 4 0 %
file:make_symlink/2 2 0 %
mirror11:'-do_dir/3-fun-6-'/4 2 0 %
Total time: 51.30
Measurement overhead: 13.48
ok
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090212/6289f1c1/attachment.htm>
More information about the erlang-questions
mailing list