def match_mknod(self): parent = BitVecVal(1, 64) name = FreshBitVec('name', 64) mode = FreshBitVec('mode', 64) mtime = FreshBitVec('mtime', 64) assertion(name != 0) yield (parent, name, mode, mtime)
def match_write(self): dev = FreshSize('dev') bid = FreshSize('bid') block = FreshBlock('block') disk.assertion(ULT(dev, 2)) yield (dev, bid, block)
def inner(self): pid = os.fork() if pid: os.waitpid(pid, 0) disk.assertion(self) return True else: disk.assertion(Not(self)) return False
def create_impl(self, mach): a1 = FreshDiskArray('impl-array') d1 = AsyncDisk(mach, a1) a = FreshSize('start') b = FreshSize('mid') c = FreshSize('end') disk.assertion(ULT(a, b)) disk.assertion(ULT(b, c)) p1 = Partition(d1, a, b) p2 = Partition(d1, b, c) return [p1, p2]
def mknod(self, parent, name, mode, mtime): if 0 < self.lookup(parent, name): return BitVecVal(-errno.EEXIST, 64) on = self._mach.create_on([]) ino = FreshBitVec('ino', 64) assertion(0 < ino) assertion(Not(0 < self._parentfn(ino))) self._dirfn = self._dirfn.update((parent, name), ino, guard=on) self._modefn = self._modefn.update(ino, mode, guard=on) self._mtimefn = self._mtimefn.update(ino, mtime, guard=on) self._parentfn = self._parentfn.update(ino, parent, guard=on) return ino
def write(self, bid, block): disk.assertion(self.valid(bid)) self._disk.write(bid + self._start, block)
def pre_post(self, spec, impl, **kwargs): name = FreshBitVec('name.pre', 64) parent = BitVecVal(1, 64) sb = impl._disk.read(0) imap = impl._disk.read(sb[2]) off = FreshBitVec('off', 9) pre = ForAll([name], Implies( name != 0, And( Implies( 0 < spec._dirfn(parent, name), parent == spec._parentfn( spec._dirfn(parent, name))), Implies( 0 < impl.lookup(parent, name), And( impl.lookup(parent, name) < sb[1], spec.get_attr(spec.lookup( parent, name)) == impl.get_attr( impl.lookup(parent, name)))), spec.lookup(parent, name) == impl.lookup(parent, name)))) pre = And( pre, ForAll([off], Implies( ZeroExt(64 - off.size(), off) < sb[1], And(0 < imap[off], imap[off] < sb[0])))) pre = And( pre, # allocated blocks are in range ]0..allocator[ 0 < sb[2], sb[2] < sb[0], 0 < imap[1], imap[1] < sb[0], # root dir inode has been allocated 1 < sb[1], ) (spec, impl, (_, name0, _, _), (sino, iino)) = yield pre self.show(pre) if iino < 0: iino = impl.lookup(parent, name0) if self._solve(sino == iino): assertion(sino == iino) sb = impl._disk.read(0) imap = impl._disk.read(sb[2]) post = ForAll([name], Implies( name != 0, And( Implies( 0 < spec._dirfn(parent, name), parent == spec._parentfn( spec._dirfn(parent, name))), Implies( 0 < impl.lookup(parent, name), And( impl.lookup(parent, name) < sb[1], spec.get_attr(spec.lookup( parent, name)) == impl.get_attr( impl.lookup(parent, name)))), spec.lookup(parent, name) == impl.lookup(parent, name)))) post = And( post, ForAll([off], Implies( ZeroExt(64 - off.size(), off) < sb[1], And(0 < imap[off], imap[off] < sb[0])))) post = And( post, # allocated blocks are in range ]0..allocator[ 0 < sb[2], sb[2] < sb[0], 0 < imap[1], imap[1] < sb[0], # root dir inode has been allocated 1 < sb[1], ) yield post