Skip to content

Commit 169ec8f

Browse files
committed
initial commit with linux constants
0 parents  commit 169ec8f

File tree

7 files changed

+147
-0
lines changed

7 files changed

+147
-0
lines changed

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.rebar3
2+
_*
3+
.eunit
4+
*.o
5+
*.beam
6+
*.plt
7+
*.swp
8+
*.swo
9+
.erlang.cookie
10+
ebin
11+
log
12+
erl_crash.dump
13+
.rebar
14+
logs
15+
_build
16+
.idea

LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Copyright (c) 2016, Emir Ozer <[email protected]>.
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are
6+
met:
7+
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above copyright
12+
notice, this list of conditions and the following disclaimer in the
13+
documentation and/or other materials provided with the distribution.
14+
15+
* The names of its contributors may not be used to endorse or promote
16+
products derived from this software without specific prior written
17+
permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
beamwhale
2+
=====
3+
4+
An OTP library
5+
6+
Build
7+
-----
8+
9+
$ rebar3 compile

rebar.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{erl_opts, [debug_info]}.
2+
{deps, []}.

src/beamwhale.app.src

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{application, beamwhale,
2+
[{description, "An OTP library"},
3+
{vsn, "0.1.0"},
4+
{registered, []},
5+
{applications,
6+
[kernel,
7+
stdlib
8+
]},
9+
{env,[]},
10+
{modules, []},
11+
12+
{maintainers, []},
13+
{licenses, []},
14+
{links, []}
15+
]}.

src/beamwhale.erl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-module(beamwhale).
2+
3+
%% API exports
4+
-export([]).
5+
6+
%%====================================================================
7+
%% API functions
8+
%%====================================================================
9+
10+
11+
%%====================================================================
12+
%% Internal functions
13+
%%====================================================================

src/linux.erl

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
-module(linux).
2+
3+
-compile(export_all).
4+
5+
sys_unshare() -> % kernel/fork.c
6+
272.
7+
8+
9+
%% linux/sched.h
10+
clone_vm() -> hex_to_int(<<"0x00000100">>). % set if VM shared between processes
11+
clone_fs() -> hex_to_int(<<"0x00000200">>). % set if fs info shared between processes
12+
clone_files() -> hex_to_int(<<"0x00000400">>). % set if open files shared between processes
13+
clone_sighand() -> hex_to_int(<<"0x00000800">>). % set if signal handlers and blocked signals shared
14+
clone_ptrace() -> hex_to_int(<<"0x00002000">>). % set if we want to let tracing continue on the child too
15+
clone_vfork() -> hex_to_int(<<"0x00004000">>). % set if the parent wants the child to wake it up on mm_release
16+
clone_parent() -> hex_to_int(<<"0x00008000">>). % set if we want to have the same parent as the cloner
17+
clone_thread() -> hex_to_int(<<"0x00010000">>). % Same thread group?
18+
clone_newns() -> hex_to_int(<<"0x00020000">>). % New mount namespace group
19+
clone_sysvsem() -> hex_to_int(<<"0x00040000">>). % share system V SEM_UNDO semantics
20+
clone_settls() -> hex_to_int(<<"0x00080000">>). % create a new TLS for the child
21+
clone_parent_settid() -> hex_to_int(<<"0x00100000">>). % set the TID in the parent
22+
clone_child_cleartid() -> hex_to_int(<<"0x00200000">>). % clear the TID in the child
23+
clone_detached() -> hex_to_int(<<"0x00400000">>). % Unused, ignored
24+
clone_untraced() -> hex_to_int(<<"0x00800000">>). % set if the tracing process can't force CLONE_PTRACE on this clone
25+
clone_child_settid() -> hex_to_int(<<"0x01000000">>). % set the TID in the child
26+
clone_newcgroup() -> hex_to_int(<<"0x02000000">>). % New cgroup namespace
27+
clone_newuts() -> hex_to_int(<<"0x04000000">>). % New utsname namespace
28+
clone_newipc() -> hex_to_int(<<"0x08000000">>). % New ipc namespace
29+
clone_newuser() -> hex_to_int(<<"0x10000000">>). % New user namespace
30+
clone_newpid() -> hex_to_int(<<"0x20000000">>). % New pid namespace
31+
clone_newnet() -> hex_to_int(<<"0x40000000">>). % New network namespace
32+
clone_io() -> hex_to_int(<<"0x80000000">>). % Clone io context
33+
34+
35+
%% linux/fs.h
36+
ms_rdonly() -> 1. % Mount read-only
37+
ms_nosuid() -> 2. % Ignore suid and sgid bits
38+
ms_nodev() -> 4. % Disallow access to device special files
39+
ms_noexec() -> 8. % Disallow program execution
40+
ms_synchronous() -> 16. % Writes are synced at once
41+
ms_remount() -> 32. % Alter flags of a mounted FS
42+
ms_mandlock() -> 64. % Allow mandatory locks on an FS
43+
ms_dirsync() -> 128. % Directory modifications are synchronous
44+
ms_noatime() -> 1024.% Do not update access times.
45+
ms_nodiratime() -> 2048.% Do not update directory access times
46+
ms_bind() -> 4096.
47+
ms_move() -> 8192.
48+
ms_rec() -> 16384.
49+
ms_silent() -> 32768.
50+
ms_posixacl() -> (1 bsl 16). % VFS does not apply the umask
51+
ms_unbindable() -> (1 bsl 17). % change to unbindable
52+
ms_private() -> (1 bsl 18). % change to private
53+
ms_strictatime() -> (1 bsl 24). % Always perform atime updates
54+
ms_mgc_val() -> hex_to_int(<<"0xC0ED0000">>).% Old magic mount flag
55+
56+
mnt_force() -> hex_to_int(<<"0x00000001">>).% Attempt to forcibily umount
57+
mnt_detach() -> hex_to_int(<<"0x00000002">>).% Just detach from the tree
58+
mnt_expire() -> hex_to_int(<<"0x00000004">>).% Mark for expiry
59+
umount_nofollow() -> hex_to_int(<<"0x00000008">>).% Don't follow symlink on umount
60+
umount_unused() -> hex_to_int(<<"0x80000000">>).% Flag guaranteed to be unused
61+
62+
hex_to_int(Hex) ->
63+
erlang:binary_to_integer(erlang:list_to_binary(lists:subtract(erlang:binary_to_list(Hex),"0x")), 16).

0 commit comments

Comments
 (0)