コード例 #1
0
ファイル: LockManager.py プロジェクト: moggen/amitools
  def r32_lock(self, addr):
    # find out associated file handle
    rel = int((addr - self.base_addr) / self.lock_size)
    lock_addr = self.base_addr + rel * self.lock_size
    b_addr = lock_addr >> 2
    lock = self.get_by_b_addr(b_addr, none_if_missing=True)
    if lock != None:
      # get addon text
      delta = addr - lock_addr
      name,off,val_type_name = self.lock_def.get_name_for_offset(delta, 2)
      type_name = self.lock_def.get_type_name()
      addon="%s+%d = %s(%s)+%d  %s" % (type_name, delta, name, val_type_name, off, lock)

      # get some special values
      val = 0
      # get DosList entry of associated volume
      if name == 'fl_Volume':
        ami_path = lock.ami_path
        volume_name = self.path_mgr.ami_volume_of_path(ami_path)
        log_lock.debug("fl_Volume: looking up volume '%s' of %s",volume_name,lock)
        volume = self.doslist_mgr.get_entry_by_name(volume_name)
        if volume == None:
          raise VamosInternalError("No DosList entry found for volume '%s'" % vol)
        val = volume.baddr
  
      self.trace_mem_int('R', 2, addr, val, text="LOCK", level=logging.INFO, addon=addon)
      return val
    else:
      # outside of locks
      addon = "lock=B%06x  cur_lock=B%06x" % (b_addr, self.cur_addr >> 2)
      self.trace_mem_int('R', 2, addr, 0, text="LOCK??", level=logging.WARN, addon=addon)
      return 0
コード例 #2
0
    def r32_lock(self, addr):
        # find out associated file handle
        rel = int((addr - self.base_addr) / self.lock_size)
        lock_addr = self.base_addr + rel * self.lock_size
        b_addr = lock_addr >> 2
        lock = self.get_by_b_addr(b_addr, none_if_missing=True)
        if lock != None:
            # get addon text
            delta = addr - lock_addr
            name, off, val_type_name = self.lock_def.get_name_for_offset(
                delta, 2)
            type_name = self.lock_def.get_type_name()
            addon = "%s+%d = %s(%s)+%d  %s" % (type_name, delta, name,
                                               val_type_name, off, lock)

            # get some special values
            val = 0
            # get DosList entry of associated volume
            if name == 'fl_Volume':
                ami_path = lock.ami_path
                volume_name = self.path_mgr.ami_volume_of_path(ami_path)
                log_lock.debug("fl_Volume: looking up volume '%s' of %s",
                               volume_name, lock)
                volume = self.doslist_mgr.get_entry_by_name(volume_name)
                if volume == None:
                    raise VamosInternalError(
                        "No DosList entry found for volume '%s'" % vol)
                val = volume.baddr

            self.trace_mem_int('R',
                               2,
                               addr,
                               val,
                               text="LOCK",
                               level=logging.INFO,
                               addon=addon)
            return val
        else:
            # outside of locks
            addon = "lock=B%06x  cur_lock=B%06x" % (b_addr, self.cur_addr >> 2)
            self.trace_mem_int('R',
                               2,
                               addr,
                               0,
                               text="LOCK??",
                               level=logging.WARN,
                               addon=addon)
            return 0
コード例 #3
0
ファイル: LockManager.py プロジェクト: moggen/amitools
  def examine_lock(self, lock, fib_mem):
    # name
    name_addr = fib_mem.s_get_addr('fib_FileName')
    fib_mem.w_cstr(name_addr, lock.name)
    # dummy key
    fib_mem.w_s('fib_DiskKey',0xcafebabe)
    # type
    if os.path.isdir(lock.sys_path):
      dirEntryType = 0x2 # dir
    else:
      dirEntryType = 0xfffffffd # file
    fib_mem.w_s('fib_DirEntryType', dirEntryType )
    # protection
    prot = DosProtection(0)
    try:
      os_stat = os.stat(lock.sys_path)
      mode = os_stat.st_mode
      if mode & stat.S_IXUSR == 0:
        prot.clr(DosProtection.FIBF_EXECUTE)
      if mode & stat.S_IRUSR == 0:
        prot.clr(DosProtection.FIBF_READ)
      if mode & stat.S_IWUSR == 0:
        prot.clr(DosProtection.FIBF_WRITE)
      log_lock.debug("examine lock: '%s' mode=%03o: prot=%s", lock, mode, prot)
    except OSError:
      return ERROR_OBJECT_IN_USE
    fib_mem.w_s('fib_Protection', prot.mask)
    # size
    if os.path.isfile(lock.sys_path):
      size = os.path.getsize(lock.sys_path)
      fib_mem.w_s('fib_Size', size)
    # date (use mtime here)
    date_addr = fib_mem.s_get_addr('fib_Date')
    date = AccessStruct(fib_mem.mem, DateStampDef, date_addr)
    t = os.path.getmtime(lock.sys_path)
    at = sys_to_ami_time(t)
    date.w_s('ds_Days', at.tday)
    date.w_s('ds_Minute', at.tmin)
    date.w_s('ds_Tick', at.tick)
    return NO_ERROR

    
    
コード例 #4
0
 def examine_lock(self, lock, fib_mem):
     # name
     name_addr = fib_mem.s_get_addr('fib_FileName')
     fib_mem.w_cstr(name_addr, lock.name)
     # dummy key
     fib_mem.w_s('fib_DiskKey', 0xcafebabe)
     # type
     if os.path.isdir(lock.sys_path):
         dirEntryType = 0x2  # dir
     else:
         dirEntryType = 0xfffffffd  # file
     fib_mem.w_s('fib_DirEntryType', dirEntryType)
     # protection
     prot = DosProtection(0)
     try:
         os_stat = os.stat(lock.sys_path)
         mode = os_stat.st_mode
         if mode & stat.S_IXUSR == 0:
             prot.clr(DosProtection.FIBF_EXECUTE)
         if mode & stat.S_IRUSR == 0:
             prot.clr(DosProtection.FIBF_READ)
         if mode & stat.S_IWUSR == 0:
             prot.clr(DosProtection.FIBF_WRITE)
         log_lock.debug("examine lock: '%s' mode=%03o: prot=%s", lock, mode,
                        prot)
     except OSError:
         return ERROR_OBJECT_IN_USE
     fib_mem.w_s('fib_Protection', prot.mask)
     # size
     if os.path.isfile(lock.sys_path):
         size = os.path.getsize(lock.sys_path)
         fib_mem.w_s('fib_Size', size)
     # date (use mtime here)
     date_addr = fib_mem.s_get_addr('fib_Date')
     date = AccessStruct(fib_mem.mem, DateStampDef, date_addr)
     t = os.path.getmtime(lock.sys_path)
     at = sys_to_ami_time(t)
     date.w_s('ds_Days', at.tday)
     date.w_s('ds_Minute', at.tmin)
     date.w_s('ds_Tick', at.tick)
     return NO_ERROR