| files[ino] = mkfile(m, md0, # links(ino, dirs), content), buf-opt = none, inode = mkinode(ino, md1, false, # links(ino, dirs), 0, n), old_ino = 0, old_ino0 = 0, afs-cons(dirs, files), ino ∈ files ⊦ [afs_truncate_internal#(n, n / VFS_PAGE_SIZE; inode, buf-opt, old_ino0, old_ino, asynced0, err, dirs, files; asynced)] (err = ESUCCESS → files[ino].content.stream from n = σ⊥) |
files[ino] = mkfile(m, md0, # links(ino, dirs), content), buf-opt = none, inode = mkinode(ino, md1, false, # links(ino, dirs), 0, n), old_ino = 0, old_ino0 = 0, pageno = n / VFS_PAGE_SIZE, afs-cons(dirs, files), ino ∈ files ⊦ [ let ino = inode.ino, content = files[inode.ino].content, buf = ? in {old_ino0 := inode.size % VFS_PAGE_SIZE, old_ino := min(n, inode.size); asynced0 := inode.size ≤ n ∧ old_ino0 ≠ 0 ∧ (pageno ∈ content ∨ buf-opt.some?); if asynced0 then {if buf-opt.some? then buf := buf-opt.buf else buf := files[ino].content[pageno]; buf := fill(buf, zero, old_ino0, VFS_PAGE_SIZE - old_ino0); content[pageno] := buf; buf-opt := some(buf)}; files[ino].content := content upto old_ino; let new_inode = inode in {new_inode.size := n; afs_inode_sync#(new_inode; dirs, files)}; inode := getinode(inode.ino, dirs, files); err := ESUCCESS} or fail#(; ; err); asynced := ?] (err = ESUCCESS → files[ino].content.stream from n = σ⊥), VFS_PAGE_SIZE = 0
Used simplifier rules: afs_truncate_internal# (N, PAGENO ; INODE, PBUF-OPT, OFFSET, SIZE, MODIFIED, ERR, DIRS, FILES ; ASYNCED ) { let INO = INODE.ino, CONTENT = FILES[INODE.ino].content, PBUF = ? in {OFFSET := INODE.size % VFS_PAGE_SIZE, SIZE := min(N, INODE.size); MODIFIED := INODE.size ≤ N ∧ OFFSET ≠ 0 ∧ (PAGENO ∈ CONTENT ∨ PBUF-OPT.some?); if MODIFIED then {if PBUF-OPT.some? then PBUF := PBUF-OPT.buf else PBUF := FILES[INO].content[PAGENO]; PBUF := fill(PBUF, zero, OFFSET, VFS_PAGE_SIZE - OFFSET); CONTENT[PAGENO] := PBUF; PBUF-OPT := some(PBUF)}; FILES[INO].content := CONTENT upto SIZE; let NEW_INODE = INODE in {NEW_INODE.size := N; afs_inode_sync#(NEW_INODE; DIRS, FILES)}; INODE := getinode(INODE.ino, DIRS, FILES); ERR := ESUCCESS} or fail#(; ; ERR); ASYNCED := ? };