Linux portability changes; add LA_PROCSTR
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Fri, 4 Mar 1994 00:35:14 +0000 (16:35 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Fri, 4 Mar 1994 00:35:14 +0000 (16:35 -0800)
SCCS-vsn: usr.sbin/sendmail/src/Makefiles/Makefile.Linux 8.2
SCCS-vsn: usr.sbin/sendmail/src/conf.h 8.94
SCCS-vsn: usr.sbin/sendmail/src/conf.c 8.79
SCCS-vsn: usr.sbin/sendmail/src/READ_ME 8.54

usr/src/usr.sbin/sendmail/src/Makefiles/Makefile.Linux
usr/src/usr.sbin/sendmail/src/READ_ME
usr/src/usr.sbin/sendmail/src/conf.c
usr/src/usr.sbin/sendmail/src/conf.h

index 4f78103..633cb6e 100644 (file)
@@ -7,7 +7,7 @@
 #
 #  This has been tested on Linux 0.99p10.
 #
 #
 #  This has been tested on Linux 0.99p10.
 #
-#      @(#)Makefile.Linux      8.1 (Berkeley) %G%
+#      @(#)Makefile.Linux      8.2 (Berkeley) %G%
 #
 
 # use O=-O (usual) or O=-g (debugging)
 #
 
 # use O=-O (usual) or O=-g (debugging)
@@ -23,18 +23,18 @@ O=  -O
 DBMDEF=        -DNDBM
 
 # environment definitions (e.g., -D_AIX3)
 DBMDEF=        -DNDBM
 
 # environment definitions (e.g., -D_AIX3)
-ENVDEF=        -D__USE_BSD
+ENVDEF=
 
 # see also conf.h for additional compilation flags
 
 # include directories
 
 # see also conf.h for additional compilation flags
 
 # include directories
-INCDIRS=-I/usr/include/bsd
+INCDIRS=-I/usr/LOCAL/include
 
 # library directories
 
 # library directories
-LIBDIRS=-L/usr/local/lib
+LIBDIRS=-L/usr/LOCAL/lib
 
 # libraries required on your system
 
 # libraries required on your system
-LIBS=  -lbsd -ldbm
+LIBS=  -lresolv
 
 # location of sendmail binary (usually /usr/sbin or /usr/lib)
 BINDIR=        ${DESTDIR}/usr/lib
 
 # location of sendmail binary (usually /usr/sbin or /usr/lib)
 BINDIR=        ${DESTDIR}/usr/lib
@@ -49,7 +49,7 @@ HFDIR=        ${DESTDIR}/usr/lib
 OBJADD=
 
 # additional pseudo-sources needed
 OBJADD=
 
 # additional pseudo-sources needed
-BEFORE=        features.h
+BEFORE=
 
 ###################  end of user configuration flags  ######################
 
 
 ###################  end of user configuration flags  ######################
 
@@ -80,9 +80,6 @@ dirent.h:
        echo "#include <sys/dir.h>" > dirent.h
        echo "#define dirent    direct" >> dirent.h
 
        echo "#include <sys/dir.h>" > dirent.h
        echo "#define dirent    direct" >> dirent.h
 
-features.h:
-       ln features.linux.h $@
-
 NROFF= nroff
 
 aliases.0: aliases.5
 NROFF= nroff
 
 aliases.0: aliases.5
index f158f63..c910604 100644 (file)
@@ -4,7 +4,7 @@
 #
 # %sccs.include.redist.sh%
 #
 #
 # %sccs.include.redist.sh%
 #
-#      @(#)READ_ME     8.53 (Berkeley) %G%
+#      @(#)READ_ME     8.54 (Berkeley) %G%
 #
 
 This directory contains the source files for sendmail.
 #
 
 This directory contains the source files for sendmail.
@@ -244,19 +244,25 @@ ARBPTR_T  The type of an arbitrary pointer -- defaults to "void *".
                If you are an very old compiler you may need to define
                this to be "char *".
 LA_TYPE                The type of load average your kernel supports.  These
                If you are an very old compiler you may need to define
                this to be "char *".
 LA_TYPE                The type of load average your kernel supports.  These
-               can be LA_SUBR (4) if you have the getloadavg(3) routine,
+               can be one of:
+               LA_ZERO (1) -- it always returns the load average as
+                       "zero" (and does so on all architectures).
+               LA_SUBR (4) if you have the getloadavg(3) routine,
                LA_MACH (5) to use MACH-style load averages (calls
                LA_MACH (5) to use MACH-style load averages (calls
-               processor_set_info()), LA_FLOAT (3) if you read kmem and
-               interpret the value as a floating point number, LA_INT (2)
-               to interpret as a long integer, or LA_SHORT (6) to
-               interpret as a short integer.  These last three have
-               several other parameters that they try to divine: the
-               name of your kernel, the name of the variable in the
-               kernel to examine, the number of bits of precision in
-               a fixed point load average, and so forth.  In desperation,
-               use LA_ZERO (1) -- it always returns the load average as
-               "zero" (and does so on all architectures).  The actual
-               code is in conf.c -- it can be tweaked if you are brave.
+                       processor_set_info()),
+               LA_PROCSTR (7) to read /proc/loadavg and interpret it
+                       as a string representing a floating-point
+                       number (Linux-style),
+               LA_FLOAT (3) if you read kmem and interpret the value
+                       as a floating point number,
+               LA_INT (2) to interpret as a long integer,
+               LA_SHORT (6) to interpret as a short integer.
+               These last three have several other parameters that they
+               try to divine: the name of your kernel, the name of the
+               variable in the kernel to examine, the number of bits of
+               precision in a fixed point load average, and so forth.
+               In desperation, use LA_ZERO.  The actual code is in
+               conf.c -- it can be tweaked if you are brave.
 SFS_TYPE       Encodes how your kernel can locate the amount of free
                space on a disk partition.  This can be set to SFS_NONE
                (0) if you have no way of getting this information,
 SFS_TYPE       Encodes how your kernel can locate the amount of free
                space on a disk partition.  This can be set to SFS_NONE
                (0) if you have no way of getting this information,
@@ -769,4 +775,4 @@ version.c   The version number and information about this
 
 Eric Allman
 
 
 Eric Allman
 
-(Version 8.53, last update %G% 09:44:04)
+(Version 8.54, last update %G% 08:35:14)
index 4ace13e..7543834 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)conf.c     8.78 (Berkeley) %G%";
+static char sccsid[] = "@(#)conf.c     8.79 (Berkeley) %G%";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -602,6 +602,7 @@ init_md(argc, argv)
 #define LA_SUBR                4       /* call getloadavg */
 #define LA_MACH                5       /* MACH load averages (as on NeXT boxes) */
 #define LA_SHORT       6       /* read kmem for avenrun; interpret as short */
 #define LA_SUBR                4       /* call getloadavg */
 #define LA_MACH                5       /* MACH load averages (as on NeXT boxes) */
 #define LA_SHORT       6       /* read kmem for avenrun; interpret as short */
+#define LA_PROCSTR     7       /* read string ("1.17") from /proc/loadavg */
 
 /* do guesses based on general OS type */
 #ifndef LA_TYPE
 
 /* do guesses based on general OS type */
 #ifndef LA_TYPE
@@ -800,6 +801,57 @@ getla()
 }
 
 
 }
 
 
+#else
+#if LA_TYPE == LA_PROC
+
+/*
+**  Read /proc/loadavg for the load average.  This is assumed to be
+**  in a format like "0.15 0.12 0.06".
+**
+**     Initially intended for Linux.  This has been in the kernel
+**     since at least 0.99.15.
+*/
+
+# ifndef _PATH_LOADAVG
+#  define _PATH_LOADAVG        "/proc/loadavg"
+# endif
+
+int
+getla()
+{
+       register double avenrun;
+       register int result;
+       static FILE *fp = NULL;
+
+       *avenrun = 0.0;
+
+       if (fp == NULL)
+       {
+               fp = fopen(_PATH_LOADAVG, "r");
+               if (fp == NULL) 
+               {
+                       if (tTd(3, 2))
+                               printf("getla: fopen(%s): %s\n",
+                                       _PATH_LOADAVG, errstring(errno));
+                       return -1;
+               }
+       }
+       (void) rewind(fp);
+       result = fscanf(fp, "%lf", &avenrun);
+       if (result != 1)
+       {
+               if (tTd(3, 2))
+                       printf("getla: fscanf() = %d: %s\n",
+                               result, errstring(errno));
+               return -1;
+       }
+
+       if (tTd(3, 1))
+               printf("getla(): %.2f\n", avenrun);
+
+       return ((int) (avenrun + 0.5));
+}
+
 #else
 
 getla()
 #else
 
 getla()
@@ -812,6 +864,7 @@ getla()
 #endif
 #endif
 #endif
 #endif
 #endif
 #endif
+#endif
 
 
 /*
 
 
 /*
index 7ddfdaa..3b246e9 100644 (file)
@@ -5,7 +5,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)conf.h      8.93 (Berkeley) %G%
+ *     @(#)conf.h      8.94 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -573,7 +573,7 @@ extern void         *malloc();
 # define ERRLIST_PREDEFINED    /* don't declare sys_errlist */
 # define GIDSET_T      gid_t   /* from <linux/types.h> */
 # ifndef LA_TYPE
 # define ERRLIST_PREDEFINED    /* don't declare sys_errlist */
 # define GIDSET_T      gid_t   /* from <linux/types.h> */
 # ifndef LA_TYPE
-#  define LA_TYPE      LA_PROC
+#  define LA_TYPE      LA_PROCSTR
 # endif
 # define SFS_TYPE      SFS_VFS         /* use <sys/vfs.h> statfs() impl */
 # include <sys/sysmacros.h>
 # endif
 # define SFS_TYPE      SFS_VFS         /* use <sys/vfs.h> statfs() impl */
 # include <sys/sysmacros.h>