Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
    def match_write(self):
        dev = FreshSize('dev')
        bid = FreshSize('bid')
        block = FreshBlock('block')

        disk.assertion(ULT(dev, 2))

        yield (dev, bid, block)
Ejemplo n.º 3
0
 def inner(self):
     pid = os.fork()
     if pid:
         os.waitpid(pid, 0)
         disk.assertion(self)
         return True
     else:
         disk.assertion(Not(self))
         return False
Ejemplo n.º 4
0
    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]
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
 def write(self, bid, block):
     disk.assertion(self.valid(bid))
     self._disk.write(bid + self._start, block)
Ejemplo n.º 7
0
    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