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
omega-mv / seed / host / tests / chmod.om
| 1 | note chmod: path permissions through fchmodat; mode 0600 is 384, checked in st_mode at byte 16. |
| 2 | text p "mode.tmp" |
| 3 | text miss "no.such.file" |
| 4 | fn main to int |
| 5 | fd = int fopen p 0 len p 578 420 |
| 6 | if lt fd 0 |
| 7 | ret 1 |
| 8 | end |
| 9 | r = fclose fd |
| 10 | if ne r 0 |
| 11 | ret 2 |
| 12 | end |
| 13 | r = chmod p 0 len p 384 |
| 14 | if ne r 0 |
| 15 | ret 3 |
| 16 | end |
| 17 | buf = new uchar 128 0 |
| 18 | r = stat p 0 len p buf 0 128 |
| 19 | if ne r 0 |
| 20 | ret 4 |
| 21 | end |
| 22 | m = add ulong get buf 16 shl ulong get buf 17 ulong 8 |
| 23 | m = add m shl ulong get buf 18 ulong 16 |
| 24 | m = add m shl ulong get buf 19 ulong 24 |
| 25 | if ne and m ulong 4095 ulong 384 |
| 26 | ret 5 |
| 27 | end |
| 28 | r = chmod miss 0 len miss 384 |
| 29 | if ge r 0 |
| 30 | ret 6 |
| 31 | end |
| 32 | r = unlink p 0 len p |
| 33 | if ne r 0 |
| 34 | ret 7 |
| 35 | end |
| 36 | ret 0 |
| 37 | end |