diff --git a/osc/util/ar.py b/osc/util/ar.py index 00bd4b60..51834b30 100644 --- a/osc/util/ar.py +++ b/osc/util/ar.py @@ -160,9 +160,9 @@ class Ar: self.__file = open(self.filename, 'rb') try: if sys.platform[:3] != 'win': - self.__file = mmap.mmap(self.__file.fileno(), 0, prot=mmap.PROT_READ) + self.__file = mmap.mmap(self.__file.fileno(), os.path.getsize(self.__file.name), prot=mmap.PROT_READ) else: - self.__file = mmap.mmap(self.__file.fileno(), 0) + self.__file = mmap.mmap(self.__file.fileno(), os.path.getsize(self.__file.name)) except EnvironmentError, e: if e.errno == 19 or ( hasattr(e, 'winerror') and e.winerror == 5 ): print >>sys.stderr, 'cannot use mmap to read the file, falling back to the default io' diff --git a/osc/util/cpio.py b/osc/util/cpio.py index a486942c..35cae47c 100644 --- a/osc/util/cpio.py +++ b/osc/util/cpio.py @@ -145,9 +145,9 @@ class CpioRead: self.__file = open(self.filename, 'rb') try: if sys.platform[:3] != 'win': - self.__file = mmap.mmap(self.__file.fileno(), 0, prot = mmap.PROT_READ) + self.__file = mmap.mmap(self.__file.fileno(), os.path.getsize(self.__file.name), prot = mmap.PROT_READ) else: - self.__file = mmap.mmap(self.__file.fileno(), 0) + self.__file = mmap.mmap(self.__file.fileno(), os.path.getsize(self.__file.name)) except EnvironmentError, e: if e.errno == 19 or ( hasattr(e, 'winerror') and e.winerror == 5 ): print >>sys.stderr, 'cannot use mmap to read the file, failing back to default'