Ejemplo n.º 1
0
def inode2dir(inode):
    return py9p.Dir(dotu=1,
                    type=0,
                    dev=0,
                    qid=py9p.Qid((py9p.mode2plan(inode.mode) >> 24) &
                                 py9p.QTDIR,
                                 0, inode.path),
                    mode=py9p.mode2plan(inode.mode),
                    atime=inode.atime,
                    mtime=inode.mtime,
                    length=inode.length,
                    name=bytes(inode.name.encode('utf-8')),
                    uid=bytes(inode.uid.encode('utf-8')),
                    gid=bytes(inode.gid.encode('utf-8')),
                    muid=bytes(inode.muid.encode('utf-8')),
                    extension=inode.getvalue() if
                    inode.mode == stat.S_IFLNK else b'',
                    uidnum=inode.uidnum,
                    gidnum=inode.gidnum,
                    muidnum=inode.muidnum)
Ejemplo n.º 2
0
    def read(self, srv, req, inode):

        if req.ifcall.offset == 0:
            self.storage.sync(inode)

        if py9p.mode2plan(inode.mode) & py9p.DMDIR:
            req.ofcall.stat = []
            for (i, k) in list(inode.children.items()):
                if i not in (".", ".."):
                    self.storage.sync(k)
                    req.ofcall.stat.append(inode2dir(k))
        else:
            req.ofcall.data = self.storage.read(inode, req.ifcall.count,
                                                req.ifcall.offset)
            req.ofcall.count = len(req.ofcall.data)

        srv.respond(req, None)
Ejemplo n.º 3
0
    def walk(self, srv, req, fid=None):

        fd = fid or req.fid
        f = self.storage.checkout(fd.qid.path)
        self.storage.sync(f)

        for (i, k) in list(f.children.items()):
            if req.ifcall.wname[0] == i:
                qid = py9p.Qid((py9p.mode2plan(k.mode) >> 24) & py9p.QTDIR, 0,
                               hash(k))
                req.ofcall.wqid.append(qid)
                if len(req.ifcall.wname) > 1:
                    req.ifcall.wname.pop(0)
                    self.walk(srv, req, inode2dir(k))
                else:
                    srv.respond(req, None)
                return

        srv.respond(req, "file not found")
        return