Package: monotone
Version: 1.0-2
Severity: important
Tags: patch
User: debian-h...@lists.debian.org
Usertags: hurd

Hi,

currently[1] monotone fails to build on hurd-i386.
The problem is due to the usage of MAXPATHLEN, which is not defined on Hurd
(as there is no length contraint for paths).
The attached patch does the following fixes:
- src/netxx/serverbase.cxx, Netxx::ServerBase::bind_to():
  use glibc's get_current_dir_name() if no PATH_MAX (the correct define to
  eventually use) is defined, or use the current getcwd() way; in both the
  cases, the cwd read is done just once at the beginning of the function,
  instead of being done everytime in the for loop
  (also, couldn't this file eventually use get_current_working_dir() from fs?)
- src/unix/fs.cc, get_current_working_dir():
  use the same working patters as above, making use of PATH_MAX instead of
  hardcoding 4096 as size

Also, after the (log!) test suite run I got just three failures:
 60 automate_certs                                FAIL (line 2) 0:09, 0:00 on 
CPU
177 database_dump_load                            FAIL (line 25) 1:08, 0:00 on 
CPU
  2 bash_completion                               FAIL (line 43) 0:49, 0:00 on 
CPU
I haven't investigated them yet, but I guess they don't sound something that
would make monotone unusable (especially as the other 600+ test cases pass).

[1] 
https://buildd.debian.org/status/fetch.php?pkg=monotone&arch=hurd-i386&ver=1.0-2&stamp=1304200144

Thanks,
-- 
Pino
--- a/src/netxx/serverbase.cxx
+++ b/src/netxx/serverbase.cxx
@@ -89,6 +89,20 @@
     sockets_size_ = addr.size();
     sockets_ = new Socket[sockets_size_];
 
+    std::string cwd;
+#   if !defined(PATH_MAX) && defined(__GLIBC__)
+    char *buffer = ::get_current_dir_name();
+    if (buffer) {
+	cwd = buffer;
+	free(buffer);
+    }
+#   else
+    char buffer[PATH_MAX];
+    if (getcwd(buffer, sizeof(buffer))) {
+        cwd = buffer;
+    }
+#   endif
+
     /*
      * now that we have an array of sockets we need to walk through each one
      * and set it up. We will use a temporay socket and make it call
@@ -167,10 +181,8 @@
 		if (saun->sun_path[0] == '/') {
 		    files_.push_back(saun->sun_path);
 		} else {
-		    char buffer[MAXPATHLEN];
-
-		    if (getcwd(buffer, sizeof(buffer))) {
- 			std::string fullpath = buffer; fullpath += '/'; fullpath += saun->sun_path;
+		    if (!cwd.empty()) {
+ 			std::string fullpath = cwd; fullpath += '/'; fullpath += saun->sun_path;
 			files_.push_back(fullpath);
 		    } else {
 			files_.push_back(saun->sun_path);
--- a/src/unix/fs.cc
+++ b/src/unix/fs.cc
@@ -41,14 +41,28 @@
 string
 get_current_working_dir()
 {
-  char buffer[4096];
-  if (!getcwd(buffer, 4096))
+#if !defined(PATH_MAX) && defined(__GLIBC__)
+  std::string cwd;
+  char *buffer = ::get_current_dir_name();
+  if (!buffer)
+    {
+      const int err = errno;
+      E(false, origin::system,
+        F("cannot get working directory: %s") % os_strerror(err));
+    }
+  cwd = buffer;
+  free(buffer);
+  return cwd;
+#else
+  char buffer[PATH_MAX + 1];
+  if (!getcwd(buffer, sizeof(buffer) - 1))
     {
       const int err = errno;
       E(false, origin::system,
         F("cannot get working directory: %s") % os_strerror(err));
     }
   return string(buffer);
+#endif
 }
 
 void

Reply via email to