Re: Compile error with AIX 3.2.5

1999-07-14 Thread Jos Backus

On Wed, Jul 14, 1999 at 12:58:27PM +1100, Brian Salter-Duke wrote:
 AIX 3.2.5 doesn't have fchdir(2).
 
 Try replacing
 
  if (fchdir(fdsourcedir) == -1)
 
 with
   if (chdir(".") == -1)

Looks like my (broken) suggestion a few years back (mine was a 3.2.4 system).

Please try the following patch and let me know whether it works for you.

# diff -u install.c.orig install.c
--- install.c.orig  Wed Jul 14 11:02:55 1999
+++ install.c   Wed Jul 14 11:08:15 1999
@@ -1,3 +1,5 @@
+#include sys/param.h
+
 #include "substdio.h"
 #include "strerr.h"
 #include "error.h"
@@ -10,6 +12,7 @@
 #define FATAL "install: fatal: "

 int fdsourcedir = -1;
+char sourcedir[MAXPATHLEN+1];

 void h(home,uid,gid,mode)
 char *home;
@@ -78,7 +81,7 @@
   int fdin;
   int fdout;

-  if (fchdir(fdsourcedir) == -1)
+  if (chdir(sourcedir) == -1)
 strerr_die2sys(111,FATAL,"unable to switch back to source directory: ");

   fdin = open_read(file);
@@ -157,6 +160,11 @@
   fdsourcedir = open_read(".");
   if (fdsourcedir == -1)
 strerr_die2sys(111,FATAL,"unable to open current directory: ");
+
+  getcwd(sourcedir,MAXPATHLEN);
+  if (sourcedir == (char *)0)
+strerr_die2sys(111,FATAL,"unable to open current directory: ");
+

   umask(077);
   hier();


Btw, the FreeBSD getcwd(3) manpage says:

 These routines have traditionally been used by programs to save the name
 of a working directory for the purpose of returning to it.  A much faster
 and less error-prone method of accomplishing this is to open the current
 directory (`.') and use the fchdir(2) function to return.

AIX 4.x does have fchdir(2).

Cheers,
-- 
Jos Backus  _/ _/_/_/  "Reliability means never
   _/ _/   _/   having to say you're sorry."
  _/ _/_/_/ -- D. J. Bernstein
 _/  _/ _/_/
[EMAIL PROTECTED]  _/_/  _/_/_/  use Std::Disclaimer;



Compile error with AIX 3.2.5

1999-07-13 Thread Brian Salter-Duke

I have just tried to compile qmail on AIX 3.2.5 and it failed. I
searched the archives and found some one who had the identical
error. There was a reply that suggested a fix and then a reply
from Bruno Wolff III on 26 August 1998 that suggested this 
would not work. Here is that reply that contains the original
error and the first suggestion:-
---

This solution won't work. fchdir is being used because it is an efficient
way to reset the cwd after it has been changed. I think it may have also
been done to simplify indicating where to install stuff (by cd'ing
to the install directory rather than building full filename paths).

What I did for install for rblstmpd and qmail-1.03, was create a static
buffer of size PATHNAMELEN+1 (defined in sys/param.h) and used getwd
to get the name of the cwd and then used chdir to the saved name to
return to it.

 .fchdir
 The OS is AIX 3.2.5

AIX 3.2.5 doesn't have fchdir(2).

Try replacing

 if (fchdir(fdsourcedir) == -1)

with
  if (chdir(".") == -1)

---

I have two questions:-

Is Bruno correct that the simple line change just above does not work?

If so, how do his suggestions translate into changes in the code?

Cheers, Brian.
-- 
Associate Professor Brian Salter-Duke (Brian Duke)
Chemistry, Faculty of Science, IT and Education, Northern Territory University,
  Darwin, NT 0909, Australia.  Phone 08-89466702. Fax 08-89466847
[EMAIL PROTECTED]  http://www.smps.ntu.edu.au/chemistry/compchem.html