Permalink
Browse files

Fix #212; third argument to open was not provided, thus files were ge…

…tting created without appropriate permissions
  • Loading branch information...
1 parent 70a015f commit 4ab1cbe712b9243ac5f0ff4e6232b85e72873a6e @dizzyd dizzyd committed Jun 7, 2010
Showing with 9 additions and 1 deletion.
  1. +1 −1 c_src/bitcask_nifs.c
  2. +8 −0 src/bitcask.erl
@@ -768,7 +768,7 @@ ERL_NIF_TERM bitcask_nifs_lock_acquire(ErlNifEnv* env, int argc, const ERL_NIF_T
}
// Try to open the lock file -- allocate a resource if all goes well.
- int fd = open(filename, flags);
+ int fd = open(filename, flags, 0600);
if (fd > -1)
{
// Successfully opened the file -- setup a resource to track the FD.
View
@@ -41,6 +41,7 @@
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
+-include_lib("kernel/include/file.hrl").
-endif.
%% @type bc_state().
@@ -844,6 +845,13 @@ roundtrip_test() ->
{ok, <<"v3">>} = bitcask:get(B, <<"k">>),
close(B).
+write_lock_perms_test() ->
+ os:cmd("rm -rf /tmp/bc.test.writelockperms"),
+ B = bitcask:open("/tmp/bc.test.writelockperms", [read_write]),
+ ok = bitcask:put(B, <<"k">>, <<"v">>),
+ {ok, Info} = file:read_file_info("/tmp/bc.test.writelockperms/bitcask.write.lock"),
+ ?assertEqual(8#00600, Info#file_info.mode band 8#00600).
+
list_data_files_test() ->
os:cmd("rm -rf /tmp/bc.test.list; mkdir -p /tmp/bc.test.list"),

0 comments on commit 4ab1cbe

Please sign in to comment.