[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#683354: apt unusable on hurd



tag 683354 + patch
thanks

Hi,

Alle martedì 31 luglio 2012, Gabriele Giacone ha scritto:
> Upgrade to 0.9.7.3 then run apt-get update:
> [...]
> Reading package lists... Done
> E: The package cache file is corrupted
> 
> You won't be able to install/remove any package.
> Downgrading apt and libapt-pkg4.12 to 0.9.7.2 fixes that.

This happens in 0.9.7.3 because this version was fixed to properly use 
the fallback code (i.e. not using mremap()) in any occasion on non-Linux 
OSes. This means that in MMap::Map() mmap() is not used, but SyncToFd + 
buffer is; when synchronizing this (in the two MMap::Sync()), the write 
of the buffer to SyncToFd or the msync() call is done inside 
preprocessor blocks "#ifdef _POSIX_SYNCHRONIZED_IO"... and that symbol 
is not defined by glibc on Hurd, as msync() is not implemented (and 
returns ENOSYS). OTOH, you don't need the POSIX synchronized I/O to just 
write to the file, so the _POSIX_SYNCHRONIZED_IO blocks can be reduced 
to the actual msync() calls.
Attached there is a patch implementing what said above; it makes apt 
working again on Hurd.

Thanks,
-- 
Pino Toscano
--- a/apt-pkg/contrib/mmap.cc
+++ b/apt-pkg/contrib/mmap.cc
@@ -160,7 +160,6 @@
    if ((Flags & UnMapped) == UnMapped)
       return true;
    
-#ifdef _POSIX_SYNCHRONIZED_IO   
    if ((Flags & ReadOnly) != ReadOnly)
    {
       if (SyncToFd != NULL)
@@ -170,11 +169,12 @@
       }
       else
       {
+#ifdef _POSIX_SYNCHRONIZED_IO   
 	 if (msync((char *)Base, iSize, MS_SYNC) < 0)
 	    return _error->Errno("msync", _("Unable to synchronize mmap"));
+#endif   
       }
    }
-#endif   
    return true;
 }
 									/*}}}*/
@@ -186,7 +186,6 @@
    if ((Flags & UnMapped) == UnMapped)
       return true;
    
-#ifdef _POSIX_SYNCHRONIZED_IO
    unsigned long long PSize = sysconf(_SC_PAGESIZE);
    if ((Flags & ReadOnly) != ReadOnly)
    {
@@ -198,11 +197,12 @@
       }
       else
       {
+#ifdef _POSIX_SYNCHRONIZED_IO
 	 if (msync((char *)Base+(unsigned long long)(Start/PSize)*PSize,Stop - Start,MS_SYNC) < 0)
 	    return _error->Errno("msync", _("Unable to synchronize mmap"));
+#endif   
       }
    }
-#endif   
    return true;
 }
 									/*}}}*/

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: