diff options
author | Patrik Nyblom <[email protected]> | 2012-02-13 20:13:37 +0100 |
---|---|---|
committer | Patrik Nyblom <[email protected]> | 2012-03-22 18:16:14 +0100 |
commit | c15f94e7922040b63f3abf8680cd77d5548fecf3 (patch) | |
tree | 498dd289cf85393a70d4f34ff20c59338fd24066 /lib | |
parent | 0fd4e39abeea3fc87b78eec8495109f9245b5ac8 (diff) | |
download | otp-c15f94e7922040b63f3abf8680cd77d5548fecf3.tar.gz otp-c15f94e7922040b63f3abf8680cd77d5548fecf3.tar.bz2 otp-c15f94e7922040b63f3abf8680cd77d5548fecf3.zip |
Add user tag spreading functionality to VM and use in file
User tags in a dynamic trace enabled VM are spread throughout the system
in the same way as seq_trace tokens. This is used by the file module
and various other modules to get hold of the tag from the user process
without changing the protocol.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dtrace/c_src/Makefile.in | 10 | ||||
-rw-r--r-- | lib/dtrace/examples/efile_drv.d | 3 | ||||
-rw-r--r-- | lib/dtrace/src/dtrace.erl | 41 | ||||
-rw-r--r-- | lib/hipe/cerl/erl_bif_types.erl | 35 | ||||
-rw-r--r-- | lib/kernel/src/file.erl | 160 | ||||
-rw-r--r-- | lib/kernel/src/file_io_server.erl | 15 | ||||
-rw-r--r-- | lib/kernel/src/file_server.erl | 106 | ||||
-rw-r--r-- | lib/kernel/test/prim_file_SUITE.erl | 108 |
8 files changed, 235 insertions, 243 deletions
diff --git a/lib/dtrace/c_src/Makefile.in b/lib/dtrace/c_src/Makefile.in index 831ce5ce75..4d5f59a63d 100644 --- a/lib/dtrace/c_src/Makefile.in +++ b/lib/dtrace/c_src/Makefile.in @@ -76,7 +76,7 @@ before_DTrace_OBJS = $(OBJDIR)/dtrace$(TYPEMARKER).o ## NIF_MAKEFILE = $(PRIVDIR)/Makefile # Higher-level makefiles says that we can only compile on UNIX flavors -NIF_LIB = $(LIBDIR)/dtrace$(TYPEMARKER).so +NIF_LIB = $(LIBDIR)/dtrace$(TYPEMARKER).@DED_EXT@ ifeq ($(HOST_OS),) HOST_OS := $(shell $(ERL_TOP)/erts/autoconf/config.guess) @@ -121,14 +121,14 @@ $(OBJDIR)/%$(TYPEMARKER).o: %.c $(DTRACE_USER_HEADER) $(INSTALL_DIR) $(OBJDIR) $(CC) -c -o $@ $(ALL_CFLAGS) $< -$(LIBDIR)/dtrace$(TYPEMARKER).so: $(OBJS) +$(NIF_LIB): $(OBJS) $(INSTALL_DIR) $(LIBDIR) $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS) clean: - rm -f $(LIBDIR)/dtrace.so - rm -f $(LIBDIR)/dtrace.debug.so - rm -f $(LIBDIR)/dtrace.valgrind.so + rm -f $(LIBDIR)/dtrace.@DED_EXT@ + rm -f $(LIBDIR)/dtrace.debug.@DED_EXT@ + rm -f $(LIBDIR)/dtrace.valgrind.@DED_EXT@ rm -f $(OBJDIR)/dtrace.o rm -f $(OBJDIR)/dtrace.debug.o rm -f $(OBJDIR)/dtrace.valgrind.o diff --git a/lib/dtrace/examples/efile_drv.d b/lib/dtrace/examples/efile_drv.d index c9c8080dba..085995ce58 100644 --- a/lib/dtrace/examples/efile_drv.d +++ b/lib/dtrace/examples/efile_drv.d @@ -71,7 +71,8 @@ erlang*:::efile_drv-entry arg4 == NULL ? "" : copyinstr(arg4), arg5 == NULL ? "" : copyinstr(arg5), arg6, arg7, /* NOTE: port name in args[10] is experimental */ - copyinstr((user_addr_t) args[10])) + (args[10] == NULL) ? + "?" : copyinstr((user_addr_t) args[10])); } erlang*:::efile_drv-int* diff --git a/lib/dtrace/src/dtrace.erl b/lib/dtrace/src/dtrace.erl index 6951c03215..71a1a3480e 100644 --- a/lib/dtrace/src/dtrace.erl +++ b/lib/dtrace/src/dtrace.erl @@ -35,12 +35,10 @@ %%% then the driver will ignore the user's input and use a default %%% value of 0 or NULL, respectively. --define(DTRACE_UT_KEY, '_dtrace_utag_@_@'). % Match prim_file:get_dtrace_utag()! - -export([init/0, available/0, user_trace_s1/1, % TODO: unify with pid & tag args like user_trace_i4s4 p/0, p/1, p/2, p/3, p/4, p/5, p/6, p/7, p/8]). --export([put_utag/1, get_utag/0]). +-export([put_utag/1, get_utag/0, get_utag_data/0, spread_utag/1, restore_utag/1]). -export([scaff/0]). % Development only -export([user_trace_i4s4/9]). % Know what you're doing! @@ -188,24 +186,29 @@ user_trace_int(I1, I2, I3, I4, S1, S2, S3, S4) -> false end. --spec put_utag(undefined | iolist()) -> ok. - -put_utag(undefined) -> - put_utag(<<>>); -put_utag(T) when is_binary(T) -> - put(?DTRACE_UT_KEY, T), - ok; -put_utag(T) when is_list(T) -> - put(?DTRACE_UT_KEY, list_to_binary(T)), - ok. +-spec put_utag(undefined | iodata()) -> binary() | undefined. +put_utag(Data) -> + erlang:put_utag(unicode:characters_to_binary(Data)). +-spec get_utag() -> binary() | undefined. get_utag() -> - case get(?DTRACE_UT_KEY) of - undefined -> - <<>>; - X -> - X - end. + erlang:get_utag(). + +-spec get_utag_data() -> binary() | undefined. +%% Gets utag if set, otherwise the spread utag data from last incoming message +get_utag_data() -> + erlang:get_utag_data(). + +-spec spread_utag(boolean()) -> true | {non_neg_integer(), binary() | []}. +%% Makes the utag behave as a sequential trace token, will spread with messages to be picked up by someone using +%% get_utag_data or get_drv_utag_data. +spread_utag(B) -> + erlang:spread_utag(B). + +-spec restore_utag(true | {non_neg_integer(), binary() | []}) -> true. +restore_utag(T) -> + erlang:restore_utag(T). + %% Scaffolding to write tedious code: quick brute force and not 100% correct. diff --git a/lib/hipe/cerl/erl_bif_types.erl b/lib/hipe/cerl/erl_bif_types.erl index a7ce17eb53..260f216725 100644 --- a/lib/hipe/cerl/erl_bif_types.erl +++ b/lib/hipe/cerl/erl_bif_types.erl @@ -614,6 +614,10 @@ type(erlang, adler32_combine, 3, Xs) -> type(erlang, append, 2, Xs) -> type(erlang, '++', 2, Xs); % alias type(erlang, append_element, 2, Xs) -> strict(arg_types(erlang, append_element, 2), Xs, fun (_) -> t_tuple() end); +type(erlang, append_vm_utag_data, 1, Xs) -> + strict(arg_types(erlang, append_vm_utag_data, 1), + Xs, + fun(_) -> t_iodata() end); type(erlang, apply, 2, Xs) -> Fun = fun ([X, _Y]) -> case t_is_fun(X) of @@ -800,6 +804,10 @@ type(erlang, get_module_info, 2, Xs) -> type(erlang, get_stacktrace, 0, _) -> t_list(t_tuple([t_atom(), t_atom(), t_sup([t_arity(), t_list()]), t_list()])); +type(erlang, get_utag, 0, _) -> + t_sup(t_binary(), t_atom('undefined')); +type(erlang, get_utag_data, 0, _) -> + t_sup(t_binary(), t_atom('undefined')); type(erlang, group_leader, 0, _) -> t_pid(); type(erlang, group_leader, 2, Xs) -> strict(arg_types(erlang, group_leader, 2), Xs, @@ -1186,6 +1194,10 @@ type(erlang, port_set_data, 2, Xs) -> strict(arg_types(erlang, port_set_data, 2), Xs, fun (_) -> t_atom('true') end); type(erlang, pre_loaded, 0, _) -> t_list(t_atom()); +type(erlang, prepend_vm_utag_data, 1, Xs) -> + strict(arg_types(erlang, prepend_vm_utag_data, 1), + Xs, + fun(_) -> t_iodata() end); type(erlang, process_display, 2, _) -> t_atom('true'); type(erlang, process_flag, 2, Xs) -> T_process_flag_returns = t_sup([t_boolean(), t_atom(), t_non_neg_integer()]), @@ -1303,6 +1315,9 @@ type(erlang, purge_module, 1, Xs) -> fun (_) -> t_atom('true') end); type(erlang, put, 2, Xs) -> strict(arg_types(erlang, put, 2), Xs, fun (_) -> t_any() end); +type(erlang, put_utag, 1, Xs) -> + strict(arg_types(erlang, put_utag, 1), Xs, + fun(_) -> t_sup(t_binary(), t_atom('undefined')) end); type(erlang, raise, 3, _) -> t_none(); type(erlang, read_timer, 1, Xs) -> strict(arg_types(erlang, read_timer, 1), Xs, @@ -1312,6 +1327,8 @@ type(erlang, ref_to_list, 1, Xs) -> type(erlang, register, 2, Xs) -> strict(arg_types(erlang, register, 2), Xs, fun (_) -> t_atom('true') end); type(erlang, registered, 0, _) -> t_list(t_atom()); +type(erlang, restore_utag, 1, Xs) -> + strict(arg_types(erlang, restore_utag, 1), Xs, fun(_) -> t_atom('true') end); type(erlang, resume_process, 1, Xs) -> strict(arg_types(erlang, resume_process, 1), Xs, fun (_) -> t_any() end); %% TODO: overapproximation -- fix this @@ -1426,6 +1443,10 @@ type(erlang, spawn_opt, 4, Xs) -> type(erlang, split_binary, 2, Xs) -> strict(arg_types(erlang, split_binary, 2), Xs, fun (_) -> t_tuple([t_binary(), t_binary()]) end); +type(erlang, spread_utag, 1, Xs) -> + strict(arg_types(erlang, spread_utag, 1), Xs, + fun(_) -> t_sup(t_tuple([t_non_neg_integer(), t_sup(t_binary(), t_nil())]), + t_atom('true')) end); type(erlang, start_timer, 3, Xs) -> strict(arg_types(erlang, start_timer, 3), Xs, fun (_) -> t_reference() end); type(erlang, statistics, 1, Xs) -> @@ -3422,6 +3443,8 @@ arg_types(erlang, append, 2) -> arg_types(erlang, '++', 2); arg_types(erlang, append_element, 2) -> [t_tuple(), t_any()]; +arg_types(erlang, append_vm_utag_data, 1) -> + [t_iodata()]; arg_types(erlang, apply, 2) -> [t_sup(t_tuple([t_module(), t_atom()]), @@ -3547,6 +3570,10 @@ arg_types(erlang, get_module_info, 1) -> [t_atom()]; arg_types(erlang, get_module_info, 2) -> [t_atom(), t_module_info_2()]; +arg_types(erlang, get_utag, 0) -> + []; +arg_types(erlang, get_utag_data, 0) -> + []; arg_types(erlang, group_leader, 0) -> []; arg_types(erlang, group_leader, 2) -> @@ -3763,6 +3790,8 @@ arg_types(erlang, port_set_data, 2) -> [t_sup(t_port(), t_atom()), t_any()]; arg_types(erlang, pre_loaded, 0) -> []; +arg_types(erlang, prepend_vm_utag_data, 1) -> + [t_iodata()]; arg_types(erlang, process_display, 2) -> [t_pid(), t_atom('backtrace')]; arg_types(erlang, process_flag, 2) -> @@ -3789,6 +3818,8 @@ arg_types(erlang, purge_module, 1) -> [t_atom()]; arg_types(erlang, put, 2) -> [t_any(), t_any()]; +arg_types(erlang, put_utag, 1) -> + [t_sup(t_binary(), t_atom('undefined'))]; arg_types(erlang, raise, 3) -> OldStyleType = t_list(t_tuple([t_atom(), t_atom(), t_sup([t_arity(), t_list()])])), @@ -3802,6 +3833,8 @@ arg_types(erlang, register, 2) -> [t_atom(), t_sup(t_port(), t_pid())]; arg_types(erlang, registered, 0) -> []; +arg_types(erlang, restore_utag, 1) -> + [t_sup(t_tuple([t_non_neg_integer(), t_sup(t_binary(), t_nil())]), t_atom('true'))]; arg_types(erlang, resume_process, 1) -> [t_pid()]; % intended for debugging only arg_types(erlang, round, 1) -> @@ -3860,6 +3893,8 @@ arg_types(erlang, spawn_opt, 4) -> [t_node(), t_atom(), t_list(), t_list(t_spawn_options())]; arg_types(erlang, split_binary, 2) -> [t_binary(), t_non_neg_integer()]; +arg_types(erlang, spread_utag, 1) -> + [t_boolean()]; arg_types(erlang, start_timer, 3) -> [t_non_neg_integer(), t_sup(t_pid(), t_atom()), t_any()]; arg_types(erlang, statistics, 1) -> diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl index aecb9f7923..3a618976f5 100644 --- a/lib/kernel/src/file.erl +++ b/lib/kernel/src/file.erl @@ -39,7 +39,7 @@ -export([ipread_s32bu_p32bu/3]). %% Generic file contents. -export([open/2, close/1, advise/4, - read/2, write/2, + read/2, write/2, pread/2, pread/3, pwrite/2, pwrite/3, read_line/1, position/2, truncate/1, datasync/1, sync/1, @@ -62,7 +62,7 @@ %% Internal export to prim_file and ram_file until they implement %% an efficient copy themselves. --export([copy_opened/4]). +-export([copy_opened/3]). -export([ipread_s32bu_p32bu_int/3]). @@ -166,7 +166,7 @@ pid2name(Pid) when is_pid(Pid) -> Reason :: posix(). get_cwd() -> - call(get_cwd, [no_drive, get_dtrace_utag()]). + call(get_cwd, []). -spec get_cwd(Drive) -> {ok, Dir} | {error, Reason} when Drive :: string(), @@ -174,21 +174,21 @@ get_cwd() -> Reason :: posix() | badarg. get_cwd(Drive) -> - check_and_call(get_cwd, [file_name(Drive), get_dtrace_utag()]). + check_and_call(get_cwd, [file_name(Drive)]). -spec set_cwd(Dir) -> ok | {error, Reason} when Dir :: name(), Reason :: posix() | badarg. set_cwd(Dirname) -> - check_and_call(set_cwd, [file_name(Dirname), get_dtrace_utag()]). + check_and_call(set_cwd, [file_name(Dirname)]). -spec delete(Filename) -> ok | {error, Reason} when Filename :: name(), Reason :: posix() | badarg. delete(Name) -> - check_and_call(delete, [file_name(Name), get_dtrace_utag()]). + check_and_call(delete, [file_name(Name)]). -spec rename(Source, Destination) -> ok | {error, Reason} when Source :: name(), @@ -196,21 +196,21 @@ delete(Name) -> Reason :: posix() | badarg. rename(From, To) -> - check_and_call(rename, [file_name(From), file_name(To), get_dtrace_utag()]). + check_and_call(rename, [file_name(From), file_name(To)]). -spec make_dir(Dir) -> ok | {error, Reason} when Dir :: name(), Reason :: posix() | badarg. make_dir(Name) -> - check_and_call(make_dir, [file_name(Name), get_dtrace_utag()]). + check_and_call(make_dir, [file_name(Name)]). -spec del_dir(Dir) -> ok | {error, Reason} when Dir :: name(), Reason :: posix() | badarg. del_dir(Name) -> - check_and_call(del_dir, [file_name(Name), get_dtrace_utag()]). + check_and_call(del_dir, [file_name(Name)]). -spec read_file_info(Filename) -> {ok, FileInfo} | {error, Reason} when Filename :: name(), @@ -218,7 +218,7 @@ del_dir(Name) -> Reason :: posix() | badarg. read_file_info(Name) -> - check_and_call(read_file_info, [file_name(Name), get_dtrace_utag()]). + check_and_call(read_file_info, [file_name(Name)]). -spec read_file_info(Filename, Opts) -> {ok, FileInfo} | {error, Reason} when Filename :: name(), @@ -227,12 +227,12 @@ read_file_info(Name) -> Reason :: posix() | badarg. read_file_info(Name, Opts) when is_list(Opts) -> - check_and_call(read_file_info, [file_name(Name), Opts, get_dtrace_utag()]). + check_and_call(read_file_info, [file_name(Name), Opts]). -spec altname(Name :: name()) -> any(). altname(Name) -> - check_and_call(altname, [file_name(Name), get_dtrace_utag()]). + check_and_call(altname, [file_name(Name)]). -spec read_link_info(Name) -> {ok, FileInfo} | {error, Reason} when Name :: name(), @@ -240,7 +240,7 @@ altname(Name) -> Reason :: posix() | badarg. read_link_info(Name) -> - check_and_call(read_link_info, [file_name(Name), get_dtrace_utag()]). + check_and_call(read_link_info, [file_name(Name)]). -spec read_link_info(Name, Opts) -> {ok, FileInfo} | {error, Reason} when Name :: name(), @@ -249,7 +249,7 @@ read_link_info(Name) -> Reason :: posix() | badarg. read_link_info(Name, Opts) when is_list(Opts) -> - check_and_call(read_link_info, [file_name(Name),Opts, get_dtrace_utag()]). + check_and_call(read_link_info, [file_name(Name),Opts]). -spec read_link(Name) -> {ok, Filename} | {error, Reason} when @@ -258,7 +258,7 @@ read_link_info(Name, Opts) when is_list(Opts) -> Reason :: posix() | badarg. read_link(Name) -> - check_and_call(read_link, [file_name(Name), get_dtrace_utag()]). + check_and_call(read_link, [file_name(Name)]). -spec write_file_info(Filename, FileInfo) -> ok | {error, Reason} when Filename :: name(), @@ -266,7 +266,7 @@ read_link(Name) -> Reason :: posix() | badarg. write_file_info(Name, Info = #file_info{}) -> - check_and_call(write_file_info, [file_name(Name), Info, get_dtrace_utag()]). + check_and_call(write_file_info, [file_name(Name), Info]). -spec write_file_info(Filename, FileInfo, Opts) -> ok | {error, Reason} when Filename :: name(), @@ -275,7 +275,7 @@ write_file_info(Name, Info = #file_info{}) -> Reason :: posix() | badarg. write_file_info(Name, Info = #file_info{}, Opts) when is_list(Opts) -> - check_and_call(write_file_info, [file_name(Name), Info, Opts, get_dtrace_utag()]). + check_and_call(write_file_info, [file_name(Name), Info, Opts]). -spec list_dir(Dir) -> {ok, Filenames} | {error, Reason} when Dir :: name(), @@ -283,7 +283,7 @@ write_file_info(Name, Info = #file_info{}, Opts) when is_list(Opts) -> Reason :: posix() | badarg. list_dir(Name) -> - check_and_call(list_dir, [file_name(Name), get_dtrace_utag()]). + check_and_call(list_dir, [file_name(Name)]). -spec read_file(Filename) -> {ok, Binary} | {error, Reason} when Filename :: name(), @@ -291,7 +291,7 @@ list_dir(Name) -> Reason :: posix() | badarg | terminated | system_limit. read_file(Name) -> - check_and_call(read_file, [file_name(Name), get_dtrace_utag()]). + check_and_call(read_file, [file_name(Name)]). -spec make_link(Existing, New) -> ok | {error, Reason} when Existing :: name(), @@ -299,7 +299,7 @@ read_file(Name) -> Reason :: posix() | badarg. make_link(Old, New) -> - check_and_call(make_link, [file_name(Old), file_name(New), get_dtrace_utag()]). + check_and_call(make_link, [file_name(Old), file_name(New)]). -spec make_symlink(Existing, New) -> ok | {error, Reason} when Existing :: name(), @@ -307,7 +307,7 @@ make_link(Old, New) -> Reason :: posix() | badarg. make_symlink(Old, New) -> - check_and_call(make_symlink, [file_name(Old), file_name(New), get_dtrace_utag()]). + check_and_call(make_symlink, [file_name(Old), file_name(New)]). -spec write_file(Filename, Bytes) -> ok | {error, Reason} when Filename :: name(), @@ -315,7 +315,7 @@ make_symlink(Old, New) -> Reason :: posix() | badarg | terminated | system_limit. write_file(Name, Bin) -> - check_and_call(write_file, [file_name(Name), make_binary(Bin), get_dtrace_utag()]). + check_and_call(write_file, [file_name(Name), make_binary(Bin)]). %% This whole operation should be moved to the file_server and prim_file %% when it is time to change file server protocol again. @@ -367,7 +367,7 @@ raw_write_file_info(Name, #file_info{} = Info) -> case check_args(Args) of ok -> [FileName] = Args, - ?PRIM_FILE:write_file_info(FileName, Info, get_dtrace_utag()); + ?PRIM_FILE:write_file_info(FileName, Info); Error -> Error end. @@ -400,7 +400,7 @@ open(Item, ModeList) when is_list(ModeList) -> [FileName | _] = Args, %% We rely on the returned Handle (in {ok, Handle}) %% being a pid() or a #file_descriptor{} - ?PRIM_FILE:open(FileName, ModeList, get_dtrace_utag()); + ?PRIM_FILE:open(FileName, ModeList); Error -> Error end @@ -421,7 +421,7 @@ open(Item, ModeList) when is_list(ModeList) -> case check_args(Args) of ok -> [FileName | _] = Args, - call(open, [FileName, ModeList, get_dtrace_utag()]); + call(open, [FileName, ModeList]); Error -> Error end @@ -466,10 +466,7 @@ close(_) -> advise(File, Offset, Length, Advise) when is_pid(File) -> R = file_request(File, {advise, Offset, Length, Advise}), wait_file_reply(File, R); -advise(#file_descriptor{module = prim_file = Module} = Handle, Offset, Length, Advise) -> - Module:advise(Handle, Offset, Length, Advise, get_dtrace_utag()); advise(#file_descriptor{module = Module} = Handle, Offset, Length, Advise) -> - %% DTrace TODO: ram_file and other file drivers not yet DTrace'ified. Module:advise(Handle, Offset, Length, Advise); advise(_, _, _, _) -> {error, badarg}. @@ -480,25 +477,17 @@ advise(_, _, _, _) -> Data :: string() | binary(), Reason :: posix() | badarg | terminated. -read(File, Sz) -> - read(File, Sz, get_dtrace_utag()). - -read(File, Sz, _DTraceUtag) - when (is_pid(File) orelse is_atom(File)), is_integer(Sz), Sz >= 0 -> +read(File, Sz) when (is_pid(File) orelse is_atom(File)), is_integer(Sz), Sz >= 0 -> case io:request(File, {get_chars, '', Sz}) of Data when is_list(Data); is_binary(Data) -> {ok, Data}; Other -> Other end; -read(#file_descriptor{module = prim_file = Module} = Handle, Sz, DTraceUtag) - when is_integer(Sz), Sz >= 0 -> - Module:read(Handle, Sz, DTraceUtag); -read(#file_descriptor{module = Module} = Handle, Sz, _DTraceUtag) +read(#file_descriptor{module = Module} = Handle, Sz) when is_integer(Sz), Sz >= 0 -> - %% DTrace TODO: ram_file and other file drivers not yet DTrace'ified. Module:read(Handle, Sz); -read(_, _, _) -> +read(_, _) -> {error, badarg}. -spec read_line(IoDevice) -> {ok, Data} | eof | {error, Reason} when @@ -513,10 +502,7 @@ read_line(File) when (is_pid(File) orelse is_atom(File)) -> Other -> Other end; -read_line(#file_descriptor{module = prim_file = Module} = Handle) -> - Module:read_line(Handle, get_dtrace_utag()); read_line(#file_descriptor{module = Module} = Handle) -> - %% DTrace TODO: ram_file and other file drivers not yet DTrace'ified. Module:read_line(Handle); read_line(_) -> {error, badarg}. @@ -530,10 +516,7 @@ read_line(_) -> pread(File, L) when is_pid(File), is_list(L) -> pread_int(File, L, []); -pread(#file_descriptor{module = prim_file = Module} = Handle, L) when is_list(L) -> - Module:pread(Handle, L, get_dtrace_utag()); pread(#file_descriptor{module = Module} = Handle, L) when is_list(L) -> - %% DTrace TODO: ram_file and other file drivers not yet DTrace'ified. Module:pread(Handle, L); pread(_, _) -> {error, badarg}. @@ -565,7 +548,6 @@ pread(File, At, Sz) when is_pid(File), is_integer(Sz), Sz >= 0 -> wait_file_reply(File, R); pread(#file_descriptor{module = Module} = Handle, Offs, Sz) when is_integer(Sz), Sz >= 0 -> - %% DTrace TODO: ram_file and other file drivers not yet DTrace'ified. Module:pread(Handle, Offs, Sz); pread(_, _, _) -> {error, badarg}. @@ -575,22 +557,16 @@ pread(_, _, _) -> Bytes :: iodata(), Reason :: posix() | badarg | terminated. -write(File, Bytes) -> - write(File, Bytes, get_dtrace_utag()). - -write(File, Bytes, _DTraceUtag) when (is_pid(File) orelse is_atom(File)) -> +write(File, Bytes) when (is_pid(File) orelse is_atom(File)) -> case make_binary(Bytes) of Bin when is_binary(Bin) -> io:request(File, {put_chars,Bin}); Error -> Error end; -write(#file_descriptor{module = prim_file = Module} = Handle, Bytes, DTraceUtag) -> - Module:write(Handle, Bytes, DTraceUtag); -write(#file_descriptor{module = Module} = Handle, Bytes, _DTraceUtag) -> - %% DTrace TODO: ram_file and other file drivers not yet DTrace'ified. +write(#file_descriptor{module = Module} = Handle, Bytes) -> Module:write(Handle, Bytes); -write(_, _, _) -> +write(_, _) -> {error, badarg}. -spec pwrite(IoDevice, LocBytes) -> ok | {error, {N, Reason}} when @@ -601,10 +577,7 @@ write(_, _, _) -> pwrite(File, L) when is_pid(File), is_list(L) -> pwrite_int(File, L, 0); -pwrite(#file_descriptor{module = prim_file = Module} = Handle, L) when is_list(L) -> - Module:pwrite(Handle, L, get_dtrace_utag()); pwrite(#file_descriptor{module = Module} = Handle, L) when is_list(L) -> - %% DTrace TODO: ram_file and other file drivers not yet DTrace'ified. Module:pwrite(Handle, L); pwrite(_, _) -> {error, badarg}. @@ -631,7 +604,6 @@ pwrite(File, At, Bytes) when is_pid(File) -> R = file_request(File, {pwrite, At, Bytes}), wait_file_reply(File, R); pwrite(#file_descriptor{module = Module} = Handle, Offs, Bytes) -> - %% DTrace TODO: ram_file and other file drivers not yet DTrace'ified. Module:pwrite(Handle, Offs, Bytes); pwrite(_, _, _) -> {error, badarg}. @@ -643,10 +615,7 @@ pwrite(_, _, _) -> datasync(File) when is_pid(File) -> R = file_request(File, datasync), wait_file_reply(File, R); -datasync(#file_descriptor{module = prim_file = Module} = Handle) -> - Module:datasync(Handle, get_dtrace_utag()); datasync(#file_descriptor{module = Module} = Handle) -> - %% DTrace TODO: ram_file and other file drivers not yet DTrace'ified. Module:datasync(Handle); datasync(_) -> {error, badarg}. @@ -658,10 +627,7 @@ datasync(_) -> sync(File) when is_pid(File) -> R = file_request(File, sync), wait_file_reply(File, R); -sync(#file_descriptor{module = prim_file = Module} = Handle) -> - Module:sync(Handle, get_dtrace_utag()); sync(#file_descriptor{module = Module} = Handle) -> - %% DTrace TODO: ram_file and other file drivers not yet DTrace'ified. Module:sync(Handle); sync(_) -> {error, badarg}. @@ -675,10 +641,7 @@ sync(_) -> position(File, At) when is_pid(File) -> R = file_request(File, {position,At}), wait_file_reply(File, R); -position(#file_descriptor{module = prim_file = Module} = Handle, At) -> - Module:position(Handle, At, get_dtrace_utag()); position(#file_descriptor{module = Module} = Handle, At) -> - %% DTrace TODO: ram_file and other file drivers not yet DTrace'ified. Module:position(Handle, At); position(_, _) -> {error, badarg}. @@ -690,10 +653,7 @@ position(_, _) -> truncate(File) when is_pid(File) -> R = file_request(File, truncate), wait_file_reply(File, R); -truncate(#file_descriptor{module = prim_file = Module} = Handle) -> - Module:truncate(Handle, get_dtrace_utag()); truncate(#file_descriptor{module = Module} = Handle) -> - %% DTrace TODO: ram_file and other file drivers not yet DTrace'ified. Module:truncate(Handle); truncate(_) -> {error, badarg}. @@ -734,7 +694,7 @@ copy_int(Source, Dest, Length) when is_pid(Source), is_pid(Dest); is_pid(Source), is_record(Dest, file_descriptor); is_record(Source, file_descriptor), is_pid(Dest) -> - copy_opened_int(Source, Dest, Length, get_dtrace_utag()); + copy_opened_int(Source, Dest, Length, 0); %% Copy between open raw files, both handled by the same module copy_int(#file_descriptor{module = Module} = Source, #file_descriptor{module = Module} = Dest, @@ -743,14 +703,14 @@ copy_int(#file_descriptor{module = Module} = Source, %% Copy between open raw files of different modules copy_int(#file_descriptor{} = Source, #file_descriptor{} = Dest, Length) -> - copy_opened_int(Source, Dest, Length, get_dtrace_utag()); + copy_opened_int(Source, Dest, Length, 0); %% Copy between filenames, let the server do the copy copy_int({SourceName, SourceOpts}, {DestName, DestOpts}, Length) when is_list(SourceOpts), is_list(DestOpts) -> check_and_call(copy, [file_name(SourceName), SourceOpts, file_name(DestName), DestOpts, - Length, get_dtrace_utag()]); + Length]); %% Filename -> open file; must open Source and do client copy copy_int({SourceName, SourceOpts}, Dest, Length) when is_list(SourceOpts), is_pid(Dest); @@ -761,8 +721,7 @@ copy_int({SourceName, SourceOpts}, Dest, Length) Source -> case open(Source, [read | SourceOpts]) of {ok, Handle} -> - Result = copy_opened_int(Handle, Dest, Length, - get_dtrace_utag()), + Result = copy_opened_int(Handle, Dest, Length, 0), close(Handle), Result; {error, _} = Error -> @@ -779,8 +738,7 @@ copy_int(Source, {DestName, DestOpts}, Length) Dest -> case open(Dest, [write | DestOpts]) of {ok, Handle} -> - Result = copy_opened_int(Source, Handle, Length, - get_dtrace_utag()), + Result = copy_opened_int(Source, Handle, Length, 0), close(Handle), Result; {error, _} = Error -> @@ -815,46 +773,45 @@ copy_int(Source, Dest, Length) -> -copy_opened(Source, Dest, Length, DTraceUtag) +copy_opened(Source, Dest, Length) when is_integer(Length), Length >= 0; is_atom(Length) -> - copy_opened_int(Source, Dest, Length, DTraceUtag); -copy_opened(_, _, _, _) -> + copy_opened_int(Source, Dest, Length); +copy_opened(_, _, _) -> {error, badarg}. %% Here we know that Length is either an atom or an integer >= 0 %% (by the way, atoms > integers) -copy_opened_int(Source, Dest, Length, DTraceUtag) +copy_opened_int(Source, Dest, Length) when is_pid(Source), is_pid(Dest) -> - copy_opened_int(Source, Dest, Length, 0, DTraceUtag); -copy_opened_int(Source, Dest, Length, DTraceUtag) + copy_opened_int(Source, Dest, Length, 0); +copy_opened_int(Source, Dest, Length) when is_pid(Source), is_record(Dest, file_descriptor) -> - copy_opened_int(Source, Dest, Length, 0, DTraceUtag); -copy_opened_int(Source, Dest, Length, DTraceUtag) + copy_opened_int(Source, Dest, Length, 0); +copy_opened_int(Source, Dest, Length) when is_record(Source, file_descriptor), is_pid(Dest) -> - copy_opened_int(Source, Dest, Length, 0, DTraceUtag); -copy_opened_int(Source, Dest, Length, DTraceUtag) + copy_opened_int(Source, Dest, Length, 0); +copy_opened_int(Source, Dest, Length) when is_record(Source, file_descriptor), is_record(Dest, file_descriptor) -> - copy_opened_int(Source, Dest, Length, 0, DTraceUtag); -copy_opened_int(_, _, _, _) -> + copy_opened_int(Source, Dest, Length, 0); +copy_opened_int(_, _, _) -> {error, badarg}. %% Here we know that Source and Dest are handles to open files, Length is %% as above, and Copied is an integer >= 0 %% Copy loop in client process -copy_opened_int(_, _, Length, Copied, _DTraceUtag) - when Length =< 0 -> % atom() > integer() +copy_opened_int(_, _, Length, Copied) when Length =< 0 -> % atom() > integer() {ok, Copied}; -copy_opened_int(Source, Dest, Length, Copied, DTraceUtag) -> +copy_opened_int(Source, Dest, Length, Copied) -> N = if Length > 65536 -> 65536; true -> Length end, % atom() > integer() ! - case read(Source, N, DTraceUtag) of + case read(Source, N) of {ok, Data} -> M = if is_binary(Data) -> byte_size(Data); is_list(Data) -> length(Data) end, - case write(Dest, Data, DTraceUtag) of + case write(Dest, Data) of ok -> if M < N -> %% Got less than asked for - must be end of file @@ -864,8 +821,7 @@ copy_opened_int(Source, Dest, Length, Copied, DTraceUtag) -> NewLength = if is_atom(Length) -> Length; true -> Length-M end, - copy_opened_int(Source, Dest, NewLength, Copied+M, - DTraceUtag) + copy_opened_int(Source, Dest, NewLength, Copied+M) end; {error, _} = Error -> Error @@ -885,8 +841,6 @@ copy_opened_int(Source, Dest, Length, Copied, DTraceUtag) -> ipread_s32bu_p32bu(File, Pos, MaxSize) when is_pid(File) -> ipread_s32bu_p32bu_int(File, Pos, MaxSize); -ipread_s32bu_p32bu(#file_descriptor{module = prim_file = Module} = Handle, Pos, MaxSize) -> - Module:ipread_s32bu_p32bu(Handle, Pos, MaxSize, get_dtrace_utag()); ipread_s32bu_p32bu(#file_descriptor{module = Module} = Handle, Pos, MaxSize) -> Module:ipread_s32bu_p32bu(Handle, Pos, MaxSize); ipread_s32bu_p32bu(_, _, _) -> @@ -1467,7 +1421,10 @@ call(Command, Args) when is_list(Args) -> check_and_call(Command, Args) when is_list(Args) -> case check_args(Args) of ok -> - call(Command, Args); + X = erlang:spread_utag(true), + Y = call(Command, Args), + erlang:restore_utag(X), + Y; Error -> Error end. @@ -1502,6 +1459,3 @@ wait_file_reply(From, Ref) -> %% receive {'EXIT', From, _} -> ok after 0 -> ok end, {error, terminated} end. - -get_dtrace_utag() -> - dtrace:get_utag(). diff --git a/lib/kernel/src/file_io_server.erl b/lib/kernel/src/file_io_server.erl index cc0343031b..14da9c1a55 100644 --- a/lib/kernel/src/file_io_server.erl +++ b/lib/kernel/src/file_io_server.erl @@ -21,7 +21,7 @@ %% A simple file server for io to one file instance per server instance. -export([format_error/1]). --export([start/4, start_link/4]). +-export([start/3, start_link/3]). -export([count_and_find/3]). @@ -43,18 +43,18 @@ format_error({_Line, Mod, Reason}) -> format_error(ErrorId) -> erl_posix_msg:message(ErrorId). -start(Owner, FileName, ModeList, DTraceUtag) +start(Owner, FileName, ModeList) when is_pid(Owner), (is_list(FileName) orelse is_binary(FileName)), is_list(ModeList) -> - do_start(spawn, Owner, FileName, ModeList, DTraceUtag). + do_start(spawn, Owner, FileName, ModeList). -start_link(Owner, FileName, ModeList, DTraceUtag) +start_link(Owner, FileName, ModeList) when is_pid(Owner), (is_list(FileName) orelse is_binary(FileName)), is_list(ModeList) -> - do_start(spawn_link, Owner, FileName, ModeList, DTraceUtag). + do_start(spawn_link, Owner, FileName, ModeList). %%%----------------------------------------------------------------- %%% Server starter, dispatcher and helpers -do_start(Spawn, Owner, FileName, ModeList, DTraceUtag) -> +do_start(Spawn, Owner, FileName, ModeList) -> Self = self(), Ref = make_ref(), Pid = @@ -63,12 +63,11 @@ do_start(Spawn, Owner, FileName, ModeList, DTraceUtag) -> %% process_flag(trap_exit, true), case parse_options(ModeList) of {ReadMode, UnicodeMode, Opts} -> - case ?PRIM_FILE:open(FileName, Opts, DTraceUtag) of + case ?PRIM_FILE:open(FileName, Opts) of {error, Reason} = Error -> Self ! {Ref, Error}, exit(Reason); {ok, Handle} -> - put(dtrace_utag, DTraceUtag), % TODO: API? %% XXX must I handle R6 nodes here? M = erlang:monitor(process, Owner), Self ! {Ref, ok}, diff --git a/lib/kernel/src/file_server.erl b/lib/kernel/src/file_server.erl index 82adc45795..fc6cd823c9 100644 --- a/lib/kernel/src/file_server.erl +++ b/lib/kernel/src/file_server.erl @@ -76,7 +76,6 @@ stop() -> init([]) -> process_flag(trap_exit, true), - put(dtrace_utag, atom_to_list(?FILE_SERVER)), case ?PRIM_FILE:start() of {ok, Handle} -> ets:new(?FILE_IO_SERVER_TABLE, [named_table]), @@ -100,9 +99,9 @@ init([]) -> {'reply', 'eof' | 'ok' | {'error', term()} | {'ok', term()}, state()} | {'stop', 'normal', 'stopped', state()}. -handle_call({open, Name, ModeList, DTraceUtag}, {Pid, _Tag} = _From, Handle) +handle_call({open, Name, ModeList}, {Pid, _Tag} = _From, Handle) when is_list(ModeList) -> - Child = ?FILE_IO_SERVER:start_link(Pid, Name, ModeList, DTraceUtag), + Child = ?FILE_IO_SERVER:start_link(Pid, Name, ModeList), case Child of {ok, P} when is_pid(P) -> ets:insert(?FILE_IO_SERVER_TABLE, {P, Name}); @@ -111,86 +110,87 @@ handle_call({open, Name, ModeList, DTraceUtag}, {Pid, _Tag} = _From, Handle) end, {reply, Child, Handle}; -handle_call({open, _Name, _Mode, _DTraceUtag}, _From, Handle) -> +handle_call({open, _Name, _Mode}, _From, Handle) -> {reply, {error, einval}, Handle}; -handle_call({read_file, Name, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:read_file(Name, DTraceUtag), Handle}; +handle_call({read_file, Name}, _From, Handle) -> + {reply, ?PRIM_FILE:read_file(Name), Handle}; -handle_call({write_file, Name, Bin, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:write_file(Name, Bin, DTraceUtag), Handle}; +handle_call({write_file, Name, Bin}, _From, Handle) -> + {reply, ?PRIM_FILE:write_file(Name, Bin), Handle}; -handle_call({set_cwd, Name, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:set_cwd(Handle, Name, DTraceUtag), Handle}; +handle_call({set_cwd, Name}, _From, Handle) -> + {reply, ?PRIM_FILE:set_cwd(Handle, Name), Handle}; -handle_call({delete, Name, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:delete(Handle, Name, DTraceUtag), Handle}; +handle_call({delete, Name}, _From, Handle) -> + {reply, ?PRIM_FILE:delete(Handle, Name), Handle}; -handle_call({rename, Fr, To, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:rename(Handle, Fr, To, DTraceUtag), Handle}; +handle_call({rename, Fr, To}, _From, Handle) -> + {reply, ?PRIM_FILE:rename(Handle, Fr, To), Handle}; -handle_call({make_dir, Name, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:make_dir(Handle, Name, DTraceUtag), Handle}; +handle_call({make_dir, Name}, _From, Handle) -> + {reply, ?PRIM_FILE:make_dir(Handle, Name), Handle}; -handle_call({del_dir, Name, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:del_dir(Handle, Name, DTraceUtag), Handle}; +handle_call({del_dir, Name}, _From, Handle) -> + {reply, ?PRIM_FILE:del_dir(Handle, Name), Handle}; -handle_call({list_dir, Name, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:list_dir(Handle, Name, DTraceUtag), Handle}; +handle_call({list_dir, Name}, _From, Handle) -> + {reply, ?PRIM_FILE:list_dir(Handle, Name), Handle}; handle_call(get_cwd, _From, Handle) -> - {reply, ?PRIM_FILE:get_cwd(Handle, no_drive, "TODO-fixme"), Handle}; -handle_call({get_cwd, no_drive, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:get_cwd(Handle, no_drive, DTraceUtag), Handle}; -handle_call({get_cwd, Name, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:get_cwd(Handle, Name, DTraceUtag), Handle}; + {reply, ?PRIM_FILE:get_cwd(Handle), Handle}; +handle_call({get_cwd}, _From, Handle) -> + {reply, ?PRIM_FILE:get_cwd(Handle), Handle}; +handle_call({get_cwd, Name}, _From, Handle) -> + {reply, ?PRIM_FILE:get_cwd(Handle, Name), Handle}; -handle_call({read_file_info, Name, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:read_file_info(Handle, Name, [], DTraceUtag), Handle}; -handle_call({read_file_info, Name, Opts, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:read_file_info(Handle, Name, Opts, DTraceUtag), Handle}; +handle_call({read_file_info, Name}, _From, Handle) -> + {reply, ?PRIM_FILE:read_file_info(Handle, Name), Handle}; -handle_call({altname, Name, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:altname(Handle, Name, DTraceUtag), Handle}; +handle_call({read_file_info, Name, Opts}, _From, Handle) -> + {reply, ?PRIM_FILE:read_file_info(Handle, Name, Opts), Handle}; -handle_call({write_file_info, Name, Info, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:write_file_info(Handle, Name, Info, [], DTraceUtag), Handle}; -handle_call({write_file_info, Name, Info, Opts, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:write_file_info(Handle, Name, Info, Opts, DTraceUtag), Handle}; +handle_call({altname, Name}, _From, Handle) -> + {reply, ?PRIM_FILE:altname(Handle, Name), Handle}; -handle_call({read_link_info, Name, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:read_link_info(Handle, Name, [], DTraceUtag), Handle}; -handle_call({read_link_info, Name, Opts, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:read_link_info(Handle, Name, Opts, DTraceUtag), Handle}; +handle_call({write_file_info, Name, Info}, _From, Handle) -> + {reply, ?PRIM_FILE:write_file_info(Handle, Name, Info), Handle}; -handle_call({read_link, Name, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:read_link(Handle, Name, DTraceUtag), Handle}; +handle_call({write_file_info, Name, Info, Opts}, _From, Handle) -> + {reply, ?PRIM_FILE:write_file_info(Handle, Name, Info, Opts), Handle}; -handle_call({make_link, Old, New, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:make_link(Handle, Old, New, DTraceUtag), Handle}; +handle_call({read_link_info, Name}, _From, Handle) -> + {reply, ?PRIM_FILE:read_link_info(Handle, Name), Handle}; -handle_call({make_symlink, Old, New, DTraceUtag}, _From, Handle) -> - {reply, ?PRIM_FILE:make_symlink(Handle, Old, New, DTraceUtag), Handle}; +handle_call({read_link_info, Name, Opts}, _From, Handle) -> + {reply, ?PRIM_FILE:read_link_info(Handle, Name, Opts), Handle}; -handle_call({copy, SourceName, SourceOpts, DestName, DestOpts, Length, DTraceUtag}, +handle_call({read_link, Name}, _From, Handle) -> + {reply, ?PRIM_FILE:read_link(Handle, Name), Handle}; + +handle_call({make_link, Old, New}, _From, Handle) -> + {reply, ?PRIM_FILE:make_link(Handle, Old, New), Handle}; + +handle_call({make_symlink, Old, New}, _From, Handle) -> + {reply, ?PRIM_FILE:make_symlink(Handle, Old, New), Handle}; + +handle_call({copy, SourceName, SourceOpts, DestName, DestOpts, Length}, _From, Handle) -> Reply = - case ?PRIM_FILE:open(SourceName, [read, binary | SourceOpts], - DTraceUtag) of + case ?PRIM_FILE:open(SourceName, [read, binary | SourceOpts]) of {ok, Source} -> SourceReply = case ?PRIM_FILE:open(DestName, - [write, binary | DestOpts], - DTraceUtag) of + [write, binary | DestOpts]) of {ok, Dest} -> DestReply = - ?PRIM_FILE:copy(Source, Dest, Length, DTraceUtag), - ?PRIM_FILE:close(Dest, DTraceUtag), + ?PRIM_FILE:copy(Source, Dest, Length), + ?PRIM_FILE:close(Dest), DestReply; {error, _} = Error -> Error end, - ?PRIM_FILE:close(Source, DTraceUtag), + ?PRIM_FILE:close(Source), SourceReply; {error, _} = Error -> Error diff --git a/lib/kernel/test/prim_file_SUITE.erl b/lib/kernel/test/prim_file_SUITE.erl index 9575762b12..3e2202922c 100644 --- a/lib/kernel/test/prim_file_SUITE.erl +++ b/lib/kernel/test/prim_file_SUITE.erl @@ -70,7 +70,7 @@ %% compile time. -define(PRIM_FILE_call(F, H, A), case H of - [] -> apply(?PRIM_FILE, F, A -- ["utag"]); + [] -> apply(?PRIM_FILE, F, A); _ -> apply(?PRIM_FILE, F, [H | A]) end). @@ -255,31 +255,31 @@ make_del_dir(Config, Handle, Suffix) -> ?line NewDir = filename:join(RootDir, atom_to_list(?MODULE) ++"_mk-dir"++Suffix), - ?line ok = ?PRIM_FILE_call(make_dir, Handle, [NewDir, "utag"]), - ?line {error, eexist} = ?PRIM_FILE_call(make_dir, Handle, [NewDir, "utag"]), - ?line ok = ?PRIM_FILE_call(del_dir, Handle, [NewDir, "utag"]), - ?line {error, enoent} = ?PRIM_FILE_call(del_dir, Handle, [NewDir, "utag"]), + ?line ok = ?PRIM_FILE_call(make_dir, Handle, [NewDir]), + ?line {error, eexist} = ?PRIM_FILE_call(make_dir, Handle, [NewDir]), + ?line ok = ?PRIM_FILE_call(del_dir, Handle, [NewDir]), + ?line {error, enoent} = ?PRIM_FILE_call(del_dir, Handle, [NewDir]), % Make sure we are not in a directory directly under test_server % as that would result in eacess errors when trying to delere '..', % because there are processes having that directory as current. - ?line ok = ?PRIM_FILE_call(make_dir, Handle, [NewDir, "utag"]), + ?line ok = ?PRIM_FILE_call(make_dir, Handle, [NewDir]), ?line {ok, CurrentDir} = ?PRIM_FILE_call(get_cwd, Handle, []), - ?line ok = ?PRIM_FILE_call(set_cwd, Handle, [NewDir, "utag"]), + ?line ok = ?PRIM_FILE_call(set_cwd, Handle, [NewDir]), try %% Check that we get an error when trying to create... %% a deep directory ?line NewDir2 = filename:join(RootDir, atom_to_list(?MODULE) ++"_mk-dir-noexist/foo"), - ?line {error, enoent} = ?PRIM_FILE_call(make_dir, Handle, [NewDir2, "utag"]), + ?line {error, enoent} = ?PRIM_FILE_call(make_dir, Handle, [NewDir2]), %% a nameless directory - ?line {error, enoent} = ?PRIM_FILE_call(make_dir, Handle, ["", "utag"]), + ?line {error, enoent} = ?PRIM_FILE_call(make_dir, Handle, [""]), %% a directory with illegal name - ?line {error, badarg} = ?PRIM_FILE_call(make_dir, Handle, ['mk-dir', "utag"]), + ?line {error, badarg} = ?PRIM_FILE_call(make_dir, Handle, ['mk-dir']), %% a directory with illegal name, even if it's a (bad) list - ?line {error, badarg} = ?PRIM_FILE_call(make_dir, Handle, [[1,2,3,{}], "utag"]), + ?line {error, badarg} = ?PRIM_FILE_call(make_dir, Handle, [[1,2,3,{}]]), %% Maybe this isn't an error, exactly, but worth mentioning anyway: %% ok = ?PRIM_FILE:make_dir([$f,$o,$o,0,$b,$a,$r])), @@ -292,17 +292,17 @@ make_del_dir(Config, Handle, Suffix) -> %% Try deleting some bad directories %% Deleting the parent directory to the current, sounds dangerous, huh? %% Don't worry ;-) the parent directory should never be empty, right? - ?line case ?PRIM_FILE_call(del_dir, Handle, ["..", "utag"]) of + ?line case ?PRIM_FILE_call(del_dir, Handle, [".."]) of {error, eexist} -> ok; {error, eacces} -> ok; %OpenBSD {error, einval} -> ok %FreeBSD end, - ?line {error, enoent} = ?PRIM_FILE_call(del_dir, Handle, ["", "utag"]), - ?line {error, badarg} = ?PRIM_FILE_call(del_dir, Handle, [[3,2,1,{}], "utag"]), + ?line {error, enoent} = ?PRIM_FILE_call(del_dir, Handle, [""]), + ?line {error, badarg} = ?PRIM_FILE_call(del_dir, Handle, [[3,2,1,{}]]), ?line test_server:timetrap_cancel(Dog) after - ?line ok = ?PRIM_FILE_call(set_cwd, Handle, [CurrentDir, "utag"]) + ?line ok = ?PRIM_FILE_call(set_cwd, Handle, [CurrentDir]) end, ok. @@ -324,7 +324,7 @@ cur_dir_0(Config, Handle) -> %% Find out the current dir, and cd to it ;-) ?line {ok,BaseDir} = ?PRIM_FILE_call(get_cwd, Handle, []), ?line Dir1 = BaseDir ++ "", %% Check that it's a string - ?line ok = ?PRIM_FILE_call(set_cwd, Handle, [Dir1, "utag"]), + ?line ok = ?PRIM_FILE_call(set_cwd, Handle, [Dir1]), ?line DirName = atom_to_list(?MODULE) ++ case Handle of [] -> @@ -336,40 +336,40 @@ cur_dir_0(Config, Handle) -> %% Make a new dir, and cd to that ?line RootDir = ?config(priv_dir,Config), ?line NewDir = filename:join(RootDir, DirName), - ?line ok = ?PRIM_FILE_call(make_dir, Handle, [NewDir, "utag"]), + ?line ok = ?PRIM_FILE_call(make_dir, Handle, [NewDir]), ?line io:format("cd to ~s",[NewDir]), - ?line ok = ?PRIM_FILE_call(set_cwd, Handle, [NewDir, "utag"]), + ?line ok = ?PRIM_FILE_call(set_cwd, Handle, [NewDir]), %% Create a file in the new current directory, and check that it %% really is created there ?line UncommonName = "uncommon.fil", ?line {ok,Fd} = ?PRIM_FILE:open(UncommonName, [read, write]), ?line ok = ?PRIM_FILE:close(Fd), - ?line {ok,NewDirFiles} = ?PRIM_FILE_call(list_dir, Handle, [".", "utag"]), + ?line {ok,NewDirFiles} = ?PRIM_FILE_call(list_dir, Handle, ["."]), ?line true = lists:member(UncommonName,NewDirFiles), %% Delete the directory and return to the old current directory %% and check that the created file isn't there (too!) ?line expect({error, einval}, {error, eacces}, {error, eexist}, - ?PRIM_FILE_call(del_dir, Handle, [NewDir, "utag"])), - ?line ?PRIM_FILE_call(delete, Handle, [UncommonName, "utag"]), - ?line {ok,[]} = ?PRIM_FILE_call(list_dir, Handle, [".", "utag"]), - ?line ok = ?PRIM_FILE_call(set_cwd, Handle, [Dir1, "utag"]), + ?PRIM_FILE_call(del_dir, Handle, [NewDir])), + ?line ?PRIM_FILE_call(delete, Handle, [UncommonName]), + ?line {ok,[]} = ?PRIM_FILE_call(list_dir, Handle, ["."]), + ?line ok = ?PRIM_FILE_call(set_cwd, Handle, [Dir1]), ?line io:format("cd back to ~s",[Dir1]), - ?line ok = ?PRIM_FILE_call(del_dir, Handle, [NewDir, "utag"]), - ?line {error, enoent} = ?PRIM_FILE_call(set_cwd, Handle, [NewDir, "utag"]), - ?line ok = ?PRIM_FILE_call(set_cwd, Handle, [Dir1, "utag"]), + ?line ok = ?PRIM_FILE_call(del_dir, Handle, [NewDir]), + ?line {error, enoent} = ?PRIM_FILE_call(set_cwd, Handle, [NewDir]), + ?line ok = ?PRIM_FILE_call(set_cwd, Handle, [Dir1]), ?line io:format("cd back to ~s",[Dir1]), - ?line {ok,OldDirFiles} = ?PRIM_FILE_call(list_dir, Handle, [".", "utag"]), + ?line {ok,OldDirFiles} = ?PRIM_FILE_call(list_dir, Handle, ["."]), ?line false = lists:member(UncommonName,OldDirFiles), %% Try doing some bad things ?line {error, badarg} = - ?PRIM_FILE_call(set_cwd, Handle, [{foo,bar}, "utag"]), + ?PRIM_FILE_call(set_cwd, Handle, [{foo,bar}]), ?line {error, enoent} = - ?PRIM_FILE_call(set_cwd, Handle, ["", "utag"]), + ?PRIM_FILE_call(set_cwd, Handle, [""]), ?line {error, enoent} = - ?PRIM_FILE_call(set_cwd, Handle, [".......a......", "utag"]), + ?PRIM_FILE_call(set_cwd, Handle, [".......a......"]), ?line {ok,BaseDir} = ?PRIM_FILE_call(get_cwd, Handle, []), %% Still there? @@ -405,10 +405,10 @@ cur_dir_1(Config, Handle) -> ?line case os:type() of {unix, _} -> ?line {error, enotsup} = - ?PRIM_FILE_call(get_cwd, Handle, ["d:", "utag"]); + ?PRIM_FILE_call(get_cwd, Handle, ["d:"]); vxworks -> ?line {error, enotsup} = - ?PRIM_FILE_call(get_cwd, Handle, ["d:", "utag"]); + ?PRIM_FILE_call(get_cwd, Handle, ["d:"]); {win32, _} -> win_cur_dir_1(Config, Handle) end, @@ -422,7 +422,7 @@ win_cur_dir_1(_Config, Handle) -> %% and try to get current directory for that drive. ?line [Drive, $:|_] = BaseDir, - ?line {ok, BaseDir} = ?PRIM_FILE_call(get_cwd, Handle, [[Drive, $:], "utag"]), + ?line {ok, BaseDir} = ?PRIM_FILE_call(get_cwd, Handle, [[Drive, $:]]), io:format("BaseDir = ~s\n", [BaseDir]), %% Unfortunately, there is no way to move away from the @@ -1027,7 +1027,7 @@ file_write_file_info(Config, Handle, Suffix) -> ?line ok = ?PRIM_FILE:write_file(Name, "hello"), ?line Time = {{1997, 01, 02}, {12, 35, 42}}, ?line Info = #file_info{mode=8#400, atime=Time, mtime=Time, ctime=Time}, - ?line ok = ?PRIM_FILE_call(write_file_info, Handle, [Name, Info, "utag"]), + ?line ok = ?PRIM_FILE_call(write_file_info, Handle, [Name, Info]), %% Read back the times. @@ -1050,12 +1050,12 @@ file_write_file_info(Config, Handle, Suffix) -> %% Make the file writable again. ?line ?PRIM_FILE_call(write_file_info, Handle, - [Name, #file_info{mode=8#600}, "utag"]), + [Name, #file_info{mode=8#600}]), ?line ok = ?PRIM_FILE:write_file(Name, "hello again"), %% And unwritable. ?line ?PRIM_FILE_call(write_file_info, Handle, - [Name, #file_info{mode=8#400}, "utag"]), + [Name, #file_info{mode=8#400}]), ?line {error, eacces} = ?PRIM_FILE:write_file(Name, "hello again"), %% Write the times again. @@ -1063,7 +1063,7 @@ file_write_file_info(Config, Handle, Suffix) -> ?line NewTime = {{1997, 02, 15}, {13, 18, 20}}, ?line NewInfo = #file_info{atime=NewTime, mtime=NewTime, ctime=NewTime}, - ?line ok = ?PRIM_FILE_call(write_file_info, Handle, [Name, NewInfo, "utag"]), + ?line ok = ?PRIM_FILE_call(write_file_info, Handle, [Name, NewInfo]), ?line {ok, ActualInfo2} = ?PRIM_FILE_call(read_file_info, Handle, [Name]), ?line #file_info{atime=NewActAtime, mtime=NewTime, @@ -1081,7 +1081,7 @@ file_write_file_info(Config, Handle, Suffix) -> %% Make the file writeable again, so that we can remove the %% test suites ... :-) ?line ?PRIM_FILE_call(write_file_info, Handle, - [Name, #file_info{mode=8#600}, "utag"]), + [Name, #file_info{mode=8#600}]), ?line test_server:timetrap_cancel(Dog), ok. @@ -1390,11 +1390,11 @@ delete(Config, Handle, Suffix) -> %% Check that the file is readable ?line {ok, Fd2} = ?PRIM_FILE:open(Name, [read]), ?line ok = ?PRIM_FILE:close(Fd2), - ?line ok = ?PRIM_FILE_call(delete, Handle, [Name, "utag"]), + ?line ok = ?PRIM_FILE_call(delete, Handle, [Name]), %% Check that the file is not readable anymore ?line {error, _} = ?PRIM_FILE:open(Name, [read]), %% Try deleting a nonexistent file - ?line {error, enoent} = ?PRIM_FILE_call(delete, Handle, [Name, "utag"]), + ?line {error, enoent} = ?PRIM_FILE_call(delete, Handle, [Name]), ?line test_server:timetrap_cancel(Dog), ok. @@ -1895,14 +1895,14 @@ make_link(Config, Handle, Suffix) -> ?line NewDir = filename:join(RootDir, atom_to_list(?MODULE) ++"_make_link"++Suffix), - ?line ok = ?PRIM_FILE_call(make_dir, Handle, [NewDir, "utag"]), + ?line ok = ?PRIM_FILE_call(make_dir, Handle, [NewDir]), ?line Name = filename:join(NewDir, "a_file"), ?line ok = ?PRIM_FILE:write_file(Name, "some contents\n"), ?line Alias = filename:join(NewDir, "an_alias"), ?line Result = - case ?PRIM_FILE_call(make_link, Handle, [Name, Alias, "utag"]) of + case ?PRIM_FILE_call(make_link, Handle, [Name, Alias]) of {error, enotsup} -> {skipped, "Links not supported on this platform"}; ok -> @@ -1913,12 +1913,12 @@ make_link(Config, Handle, Suffix) -> %% since they are not used on symbolic links. ?line {ok, Info} = - ?PRIM_FILE_call(read_link_info, Handle, [Name, "utag"]), + ?PRIM_FILE_call(read_link_info, Handle, [Name]), ?line {ok, Info} = - ?PRIM_FILE_call(read_link_info, Handle, [Alias, "utag"]), + ?PRIM_FILE_call(read_link_info, Handle, [Alias]), ?line #file_info{links = 2, type = regular} = Info, ?line {error, eexist} = - ?PRIM_FILE_call(make_link, Handle, [Name, Alias, "utag"]), + ?PRIM_FILE_call(make_link, Handle, [Name, Alias]), ok end, @@ -1956,30 +1956,30 @@ symlinks(Config, Handle, Suffix) -> ?line NewDir = filename:join(RootDir, atom_to_list(?MODULE) ++"_make_symlink"++Suffix), - ?line ok = ?PRIM_FILE_call(make_dir, Handle, [NewDir, "utag"]), + ?line ok = ?PRIM_FILE_call(make_dir, Handle, [NewDir]), ?line Name = filename:join(NewDir, "a_plain_file"), ?line ok = ?PRIM_FILE:write_file(Name, "some stupid content\n"), ?line Alias = filename:join(NewDir, "a_symlink_alias"), ?line Result = - case ?PRIM_FILE_call(make_symlink, Handle, [Name, Alias, "utag"]) of + case ?PRIM_FILE_call(make_symlink, Handle, [Name, Alias]) of {error, enotsup} -> {skipped, "Links not supported on this platform"}; ok -> ?line {ok, Info1} = - ?PRIM_FILE_call(read_file_info, Handle, [Name, "utag"]), + ?PRIM_FILE_call(read_file_info, Handle, [Name]), ?line {ok, Info1} = - ?PRIM_FILE_call(read_file_info, Handle, [Alias, "utag"]), + ?PRIM_FILE_call(read_file_info, Handle, [Alias]), ?line {ok, Info1} = - ?PRIM_FILE_call(read_link_info, Handle, [Name, "utag"]), + ?PRIM_FILE_call(read_link_info, Handle, [Name]), ?line #file_info{links = 1, type = regular} = Info1, ?line {ok, Info2} = - ?PRIM_FILE_call(read_link_info, Handle, [Alias, "utag"]), + ?PRIM_FILE_call(read_link_info, Handle, [Alias]), ?line #file_info{links=1, type=symlink} = Info2, ?line {ok, Name} = - ?PRIM_FILE_call(read_link, Handle, [Alias, "utag"]), + ?PRIM_FILE_call(read_link, Handle, [Alias]), ok end, @@ -2003,7 +2003,7 @@ list_dir_limit(Config) when is_list(Config) -> ?line NewDir = filename:join(RootDir, atom_to_list(?MODULE)++"_list_dir_limit"), ?line {ok, Handle1} = ?PRIM_FILE:start(), - ?line ok = ?PRIM_FILE_call(make_dir, Handle1, [NewDir, "utag"]), + ?line ok = ?PRIM_FILE_call(make_dir, Handle1, [NewDir]), Ref = erlang:start_timer(MaxTime*1000, self(), []), ?line Result = list_dir_limit_loop(NewDir, Handle1, Ref, MaxNumber, 0), ?line Time = case erlang:cancel_timer(Ref) of @@ -2054,7 +2054,7 @@ list_dir_limit_loop(Dir, Handle, Ref, N, Cnt) -> end. list_dir_check(Dir, Handle, Cnt) -> - case ?PRIM_FILE:list_dir(Handle, Dir, "utag") of + case ?PRIM_FILE:list_dir(Handle, Dir) of {ok, ListDir} -> case length(ListDir) of Cnt -> |