Exemplo n.º 1
0
    def remove(self, dir_fh, name):
        dir_fil = self.get_fil(dir_fh)
        if dir_fil == None:  # XXX should raise error?
            return
        fh = dir_fil.get_dir().get(name, None)
        if fh == None:
            raise fsbase.NFSError(rfc1094.NFSERROR_NOENT)
        fil = self.get_fil(fh)

        if fil.type == rfc1094.NFDIR:
            if fil.dir <> {}:
                raise fsbase.NFSError(rfc1094.NFSERR_NOTEMPTY)
        del self._fils[fh]
        del dir_fil.get_dir()[name]
Exemplo n.º 2
0
 def _add_fil(self, dir_fh, name, new_fh):
     dir_fil = self.get_fil(dir_fh)
     assert (dir_fil <> None)
     dir = dir_fil.get_dir()
     if dir.has_key(name):
         raise fsbase.NFSError(rfc1094.NFSERR_EXIST)
     dir_fil.get_dir()[name] = new_fh
Exemplo n.º 3
0
 def change_val(self, *args):
     try:
         new_val = type(self.parent_dict[self.key])(*args)
     except (TypeError, ValueError):
         raise fsbase.NFSError(rfc1094.NFSERR_ACCES)
     self.parent_dict[self.key] = new_val
     self.data = self.get_data()
     self.set_size()
     # This is "rebind", not "mutate".
     self.mtime = fsbase.mk_now()
Exemplo n.º 4
0
 def NFSPROC_WRITE (self, wa):
     rv = rfc1094.attrstat ()
     try:
         fil = self.fs.get_fil (wa.file)
         if fil == None:
             raise fsbase.NFSError (rfc1094.NFSERR_STALE)
         fil.write (wa.offset, wa.data)
         rv.status = rfc1094.NFS_OK
         rv._data = fil
     except fsbase.NFSError, err:
         rv.status = err.err
Exemplo n.º 5
0
    def remove(self, dir_fh, name):
        dir_fil = self.get_fil(dir_fh)
        try:
            old_fh = dir_fil.get_dir()[name]
            old_fil = self.get_fil(old_fh)
            py_obj = old_fil.parent_dict[old_fil.key]
            if old_fil.type == rfc1094.NFDIR:
                if old_fil.dict != {}:
                    raise fsbase.NFSError(rfc1094.NFSERR_NOTEMPTY)
            del dir_fil[name]
        except TypeError:
            # NFSERR_ACCES isn't quite right, because it implies
            # that some user could delete this.
            raise fsbase.NFSError(rfc1094.NFSERR_ACCES)
        except KeyError:
            raise fsbase.NFSError(rfc1094.NFSERR_NOENT)

        del self._fils[old_fh]

        d = get_dict(py_obj)
        if d != None:
            del self._objs[id(py_obj)]