Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/seed/host/tests/fchdir.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / host / tests / fchdir.om` 53 lines ยท 784 bytes Raw Blame History 1 note fchdir/getppid/umask: directory fd, mask 0 with a 0777 file, parent id. 2 text subd "subdir" 3 text inside "inside" 4 text p "mode2.tmp" 5 fn main to int 6 pp = getppid 7 if le pp long 0 8 ret 1 9 end 10 me = getpid 11 if eq pp long me 12 ret 2 13 end 14 old = umask 0 15 fd = int fopen p 0 len p 578 511 16 if lt fd 0 17 ret 3 18 end 19 r = fclose fd 20 st = new uchar 128 0 21 r = stat p 0 len p st 0 128 22 if ne r 0 23 ret 4 24 end 25 m = add ulong get st 16 shl ulong get st 17 ulong 8 26 if ne and m ulong 4095 ulong 511 27 ret 5 28 end 29 z = umask int old 30 r = unlink p 0 len p 31 if ne r 0 32 ret 6 33 end 34 r = makedir subd 0 len subd 448 35 if ne r 0 36 ret 7 37 end 38 dfd = int fopen subd 0 len subd 16384 0 39 if lt dfd 0 40 ret 8 41 end 42 r = fchdir dfd 43 if ne r 0 44 ret 9 45 end 46 f = int fopen inside 0 len inside 578 511 47 if lt f 0 48 ret 10 49 end 50 z = fclose f 51 z = fclose dfd 52 ret 0 53 end