A Concurrent Specification for POSIX File Systems
Gian Ntzik, Pedro da Rocha Pinto and Philippa Gardner
Imperial College London gian.ntzik08@imperial.ac.uk pedro.da-rocha-pinto09@imperial.ac.uk p.gardner@imperial.ac.uk
Dagstuhl 2016
1/22
A Concurrent Specification for POSIX File Systems Gian Ntzik, Pedro - - PowerPoint PPT Presentation
A Concurrent Specification for POSIX File Systems Gian Ntzik, Pedro da Rocha Pinto and Philippa Gardner Imperial College London gian.ntzik08@imperial.ac.uk pedro.da-rocha-pinto09@imperial.ac.uk p.gardner@imperial.ac.uk Dagstuhl 2016 1/22
1/22
2/22
3/22
◮ Z Notation: specification language with refinement to
◮ Forest: Haskell DSL for type-safe file-system interactions
◮ SSL [ESOP’14], Fusion Logic [OOPSLA’15]
4/22
5/22
6/22
7/22
usr bin git
8/22
9/22
10/22
C ⊑ A x1 ∈ X1.
A x2 ∈ X2.
A xn−1 ∈ Xn−1.
11/22
11/22
11/22
11/22
11/22
12/22
13/22
14/22
// rename file, if target exists it must be a file and it is replaced let rename file(r1, r2, a, b) ∃ιa, ιb. A FS ∈ FS. fs(FS) ∧ r1, r2 ∈ dom(FS) , fs(FS[r1 → S][r2 → (FS(r2) \ {(b, −)}) ∪ {(b, ιa)}]) ∧ FS(r1) = S ∪ {(a, ιa} ∧ isfile(FS, ιa) ∧ (∃ιb. (b, ιb) ∈ FS(r2) = ⇒ isfile(FS, ιb)) = ⇒ ret = 0
14/22
// rename file, if target exists it must be a file and it is replaced let rename file(r1, r2, a, b) ∃ιa, ιb. A FS ∈ FS. fs(FS) ∧ r1, r2 ∈ dom(FS) , fs(FS[r1 → S][r2 → (FS(r2) \ {(b, −)}) ∪ {(b, ιa)}]) ∧ FS(r1) = S ∪ {(a, ιa} ∧ isfile(FS, ιa) ∧ (∃ιb. (b, ιb) ∈ FS(r2) = ⇒ isfile(FS, ιb)) = ⇒ ret = 0
let rename dir(r1, r2, a, b) ∃S, ιa, ιb. A FS ∈ FS. fs(FS) ∧ r1, r2 ∈ dom(FS) , fs(FS[r1 → S][r2 → (FS(r2) \ {(b, −)}) ∪ {(b, ιa)}]) ∧ FS(r1) = S ∪ {a, ιa} ∧ isdir(FS, ιa) ∧ r2 ∈ descendants(FS, r1) ∧ (∃ιb. (b, ιb) ∈ FS(r2) = ⇒ isempdir(FS, ιb)) = ⇒ ret = 0
14/22
// rename file, if target exists it must be a file and it is replaced let rename file(r1, r2, a, b) ∃ιa, ιb. A FS ∈ FS. fs(FS) ∧ r1, r2 ∈ dom(FS) , fs(FS[r1 → S][r2 → (FS(r2) \ {(b, −)}) ∪ {(b, ιa)}]) ∧ FS(r1) = S ∪ {(a, ιa} ∧ isfile(FS, ιa) ∧ (∃ιb. (b, ιb) ∈ FS(r2) = ⇒ isfile(FS, ιb)) = ⇒ ret = 0
let rename dir(r1, r2, a, b) ∃S, ιa, ιb. A FS ∈ FS. fs(FS) ∧ r1, r2 ∈ dom(FS) , fs(FS[r1 → S][r2 → (FS(r2) \ {(b, −)}) ∪ {(b, ιa)}]) ∧ FS(r1) = S ∪ {a, ιa} ∧ isdir(FS, ιa) ∧ r2 ∈ descendants(FS, r1) ∧ (∃ιb. (b, ιb) ∈ FS(r2) = ⇒ isempdir(FS, ιb)) = ⇒ ret = 0
source is file, target is an existing directory let err file and dir(r1, r2, a, b) ∃ιa, ιb. A FS ∈ FS. fs(FS) ∧ r1, r2 ∈ dom(FS) , fs(FS) ∧ (a, ιa) ∈ FS(r1) ∧ isfile(FS, ιa) ∧ (b, ιb) ∈ FS(r2) ∧ isdir(FS, ιb) = ⇒ ret = −1 ∗ errno = EISDIR
15/22
16/22
17/22
◮ open(path, O CREAT|O EXCL) to try to lock ◮ unlink to unlock
18/22
19/22
◮ We want clients to observe lock and unlock operations as single atomic
◮ This specification cannot be guaranteed only by the module ◮ The file system is globally shared ◮ The module cannot enforce ownership of the path ◮ The module and the environment must agree a priori on a protocol for the use
20/22
21/22
◮ The path /p is not changed ◮ Only the module creates /p/a (locks the lock) ◮ Only the module removes /p/a (unlocks the lock)
22/22