interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / seed / host / tests / lstat.om

60 lines · 976 bytes Raw Blame History
1note stat follows the final symlink (size 4); lstat reports S_IFLNK in st_mode at byte 16.
2text a "ls1.tmp"
3text c "ls2.tmp"
4text body "abcd"
5fn main to int
6fd = int fopen a 0 len a 578 420
7if lt fd 0
8ret 1
9end
10w = write fd body 0 len body
11r = fclose fd
12list = new uchar 64 0
13put list 0 2
14put list 1 0
15put list 2 uchar len a
16put list 3 0
17i = ulong 0
18while lt i len a bound 64
19put list add 4 i get a i
20i = add i 1
21end
22off = add 4 len a
23put list off uchar len c
24put list add off 1 0
25i = ulong 0
26while lt i len c bound 64
27put list add add off 2 i get c i
28i = add i 1
29end
30total = add add off 2 len c
31r = symlnk list 0 total
32if ne r 0
33ret 2
34end
35st = new uchar 128 0
36r = stat c 0 len c st 0 128
37if ne r 0
38ret 3
39end
40if ne get st 48 4
41ret 4
42end
43r = lstat c 0 len c st 0 128
44if ne r 0
45ret 5
46end
47m = add ulong get st 16 shl ulong get st 17 ulong 8
48if ne and m ulong 61440 ulong 40960
49ret 6
50end
51r = unlink c 0 len c
52if ne r 0
53ret 7
54end
55r = unlink a 0 len a
56if ne r 0
57ret 8
58end
59ret 0
60end