Saturday, November 16, 2013

Why is "MobileSync" folder so large on my Mac??


This folder contains the iTunes backups of your devices. There should be a folder for each device with a long gibberish name. Do not mess with these folders in Finder.

You can manage this from inside iTunes. Go to the below screen in iTunes prefs and you will see an entry for each iDevice you are backing up to iTunes. You may have old devices in there from previous iPhones or iPads you can remove from the list. You do want to keep your current device in the list for iTunes backup though.

Tuesday, October 22, 2013

Vmware Linux Guest Add a New Hard Disk Without Rebooting Guest

As a system admin, I need to use additional hard drives for to provide more storage space or to separate system data from user data. This procedure, adding physical block devices to virtualized guests, describes how to add a hard drive on the host to a virtualized guest using VMWare software running Linux as guest.
It is possible to add or remove a SCSI device explicitly, or to re-scan an entire SCSI bus without rebooting a running Linux VM guest. This how to is tested under Vmware Server and Vmware Workstation v6.0 (but should work with older version too). All instructions are tested on RHEL, Fedora, CentOS and Ubuntu Linux guest / hosts operating systems.

Step # 1: Add a New Disk To Vm Guest

First, you need to add hard disk by visiting vmware hardware settings menu.
Click on VM > Settings
Fig.01: Vmware Virtual Machine Settings
Fig.01: Vmware Virtual Machine Settings
Alternatively you can press CTRL + D to bring settings dialog box.
Click on Add+ to add new hardware to guest:
Fig.02: VMWare adding a new hardware
Fig.02: VMWare adding a new hardware
Select hardware type Hard disk and click on Next
Fig.03 VMware Adding a new disk wizard
Fig.03 VMware Adding a new disk wizard
Select create a new virtual disk and click on Next
Fig.04: Vmware Wizard Disk
Fig.04: Vmware Wizard Disk
Set virtual disk type to SCSI and click on Next
Fig.05: Vmware Virtual Disk
Fig.05: Vmware Virtual Disk
Set maximum disk size as per your requirements and click on Next
Fig.06: Finalizing Disk Virtual Addition
Fig.06: Finalizing Disk Virtual Addition
Finally, set file location and click on Finish.

Step # 2: Rescan the SCSI Bus to Add a SCSI Device Without rebooting the VM

A rescan can be issued by typing the following command:
echo "- - -" > /sys/class/scsi_host/host#/scan
fdisk -l
tail -f /var/log/message

Sample outputs:
Linux Vmware Rescan New Scsi Disk Without Reboot
Fig.01:Linux Vmware Rescan New Scsi Disk Without Reboot

Replace host# with actual value such as host0. You can find scsi_host value using the following command:
# ls /sys/class/scsi_host
Output:
host0
Now type the following to send a rescan request:
echo "- - -" > /sys/class/scsi_host/host0/scan
fdisk -l
tail -f /var/log/message

Sample Outputs:
Jul 18 16:29:39 localhost kernel:   Vendor: VMware,   Model: VMware Virtual S  Rev: 1.0
Jul 18 16:29:39 localhost kernel:   Type:   Direct-Access                      ANSI SCSI revision: 02
Jul 18 16:29:39 localhost kernel:  target0:0:1: Beginning Domain Validation
Jul 18 16:29:39 localhost kernel:  target0:0:1: Domain Validation skipping write tests
Jul 18 16:29:39 localhost kernel:  target0:0:1: Ending Domain Validation
Jul 18 16:29:39 localhost kernel:  target0:0:1: FAST-40 WIDE SCSI 80.0 MB/s ST (25 ns, offset 127)
Jul 18 16:29:39 localhost kernel: SCSI device sdb: 2097152 512-byte hdwr sectors (1074 MB)
Jul 18 16:29:39 localhost kernel: sdb: Write Protect is off
Jul 18 16:29:39 localhost kernel: sdb: cache data unavailable
Jul 18 16:29:39 localhost kernel: sdb: assuming drive cache: write through
Jul 18 16:29:39 localhost kernel: SCSI device sdb: 2097152 512-byte hdwr sectors (1074 MB)
Jul 18 16:29:39 localhost kernel: sdb: Write Protect is off
Jul 18 16:29:39 localhost kernel: sdb: cache data unavailable
Jul 18 16:29:39 localhost kernel: sdb: assuming drive cache: write through
Jul 18 16:29:39 localhost kernel:  sdb: unknown partition table
Jul 18 16:29:39 localhost kernel: sd 0:0:1:0: Attached scsi disk sdb
Jul 18 16:29:39 localhost kernel: sd 0:0:1:0: Attached scsi generic sg1 type 0
Jul 18 16:29:39 localhost kernel:   Vendor: VMware,   Model: VMware Virtual S  Rev: 1.0
Jul 18 16:29:39 localhost kernel:   Type:   Direct-Access                      ANSI SCSI revision: 02
Jul 18 16:29:39 localhost kernel:  target0:0:2: Beginning Domain Validation
Jul 18 16:29:39 localhost kernel:  target0:0:2: Domain Validation skipping write tests
Jul 18 16:29:39 localhost kernel:  target0:0:2: Ending Domain Validation
Jul 18 16:29:39 localhost kernel:  target0:0:2: FAST-40 WIDE SCSI 80.0 MB/s ST (25 ns, offset 127)
Jul 18 16:29:39 localhost kernel: SCSI device sdc: 2097152 512-byte hdwr sectors (1074 MB)
Jul 18 16:29:39 localhost kernel: sdc: Write Protect is off
Jul 18 16:29:39 localhost kernel: sdc: cache data unavailable
Jul 18 16:29:39 localhost kernel: sdc: assuming drive cache: write through
Jul 18 16:29:39 localhost kernel: SCSI device sdc: 2097152 512-byte hdwr sectors (1074 MB)
Jul 18 16:29:39 localhost kernel: sdc: Write Protect is off
Jul 18 16:29:39 localhost kernel: sdc: cache data unavailable
Jul 18 16:29:39 localhost kernel: sdc: assuming drive cache: write through
Jul 18 16:29:39 localhost kernel:  sdc: unknown partition table
Jul 18 16:29:39 localhost kernel: sd 0:0:2:0: Attached scsi disk sdc
Jul 18 16:29:39 localhost kernel: sd 0:0:2:0: Attached scsi generic sg2 type 0

How Do I Delete a Single Device Called /dev/sdc?

In addition to re-scanning the entire bus, a specific device can be added or existing device deleted using the following command:
# echo 1 > /sys/block/devName/device/delete
# echo 1 > /sys/block/sdc/device/delete

How Do I Add a Single Device Called /dev/sdc?

To add a single device explicitly, use the following syntax:
# echo "scsi add-single-device <H> <B> <T> <L>" > /proc/scsi/scsi
Where,
  • <H> : Host
  • <B> : Bus (Channel)
  • <T> : Target (Id)
  • <L> : LUN numbers
For e.g. add /dev/sdc with host # 0, bus # 0, target # 2, and LUN # 0, enter:
# echo "scsi add-single-device 0 0 2 0">/proc/scsi/scsi
# fdisk -l
# cat /proc/scsi/scsi

Sample Outputs:
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: VMware,  Model: VMware Virtual S Rev: 1.0
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 01 Lun: 00
  Vendor: VMware,  Model: VMware Virtual S Rev: 1.0
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 02 Lun: 00
  Vendor: VMware,  Model: VMware Virtual S Rev: 1.0
  Type:   Direct-Access                    ANSI SCSI revision: 02

Step #3: Format a New Disk

Now, you can create partition using fdisk and format it using mkfs.ext3 command:
# fdisk /dev/sdc
# mkfs.ext3 /dev/sdc3

Step #4: Create a Mount Point And Update /etc/fstab

# mkdir /disk3
Open /etc/fstab file, enter:
# vi /etc/fstab
Append as follows:
/dev/sdc3               /disk3           ext3    defaults        1 2
Save and close the file.

Optional Task: Label the partition

You can label the partition using e2label. For example, if you want to label the new partition /backupDisk, enter
# e2label /dev/sdc1 /backupDisk

Conclusion

The VMware guest now has an additional virtualized storage device. The procedure works for all physical block devices, this includes CD-ROM, DVD and floppy devices. Next, time I will write about adding an additional virtualized storage device using XEN software.

AIX Frequently Asked Questions (Part 4 of 4)


Frequently Asked Questions about AIX and the IBM RS/6000 Section 4
__________________________________________________________________

2.07: Why does it take so long to compile "hello world" with xlc?

Some systems have experienced delays of more than 60 seconds in
compiling "#include <stdio.h> int main () {printf ("Hello world");}"
The problem is with the license manager contact IBM to make sure
you've got the latest PTF.


2.08: What's with malloc()?
 
malloc() uses a late allocation algorithm based on 4.3 BSD's malloc()
for speed.  This lets you allocate very large sparse memory spaces,
since the pages are not actually allocated until they are touched for
the first time.  Unfortunately, it doesn't die gracefully in the face of
loss of available memory.  See the "Paging Space Overview" under
InfoExplorer, and see the notes on the linker in this document for an
example of an ungraceful death.

If you want your program to get notified when running out of memory, you
should handle the SIGDANGER signal.  The default is to ignore it. 
SIGDANGER is sent to all processes when paging space gets low, and if
paging space gets even lower, processes with the highest paging space
usage are sent the SIGKILL signal.

malloc() is substantially different in 3.2, allocating memory more
tightly.  If you have problems running re-compiled programs on 3.2,
try running them with MALLOCTYPE=3.1.

Early Page Space Allocation (EPSA) added to AIX 3.2: see
/usr/lpp/bos/README.PSALLOC - IX38211 / U422496 Allows setting of
early allocation (vs. default late allocation) on a per-process basis.


2.09: does xlc complain about 'extern char *strcpy()'

The header <string.h> has a strcpy macro that expands strcpy(x,y) to
__strcpy(x,y), and the latter is then used by the compiler to generate
inline code for strcpy.  Because of the macro, your extern declaration
contains an invalid macro expansion.  The real cure is to remove your
extern declaration but adding -U__STR__ to your xlc will also do the trick.


2.10: Why do I get 'Parameter list cannot contain fewer ....'

This is the same as above.


2.11: Why does xlc complain about '(sometype *)somepointer = something'

Software that is developed using gcc may have this construct. However,
standard C does not permit casts to be lvalues, so you will need to
change the cast and move it to the right side of the assignment. If you
compile with 'cc', removing the cast completely will give you a warning,
'xlc' will give you an error (provided somepointer and something are of
different types - but else, why would the cast be there in the first place?)


2.12: Some more common errors

Here are a few other common errors with xlc:

305 |     switch((((np)->navigation_type) ? (*((np)->navigation_type)) :
      ((void *)0)))
      .a...........  
a - 1506-226: (S) The second and third operands of the conditional
operator must be of the same type.

The reason for this is that xlc defines NULL as (void *)0, and it does
not allow two different types as the second and third operand of ?:. 
The second argument above is not a pointer and the code used NULL
incorrectly as a scalar. NULL is a nil pointer constant in ANSI C and
in some traditional compilers.

You should change NULL in the third argument above to an integer 0.


2.13: Can the compiler generate assembler code?

Starting with version 1.3 of xlc and xlf the -S option will generate a
.s assembly code file prior to optimization. The option -qlist will
generate a human readable one in a .lst file.

There is also a disassembler in /usr/lpp/xlc/bin/dis include with the
1.3 version of xlc (and in /usr/lpp/xlC/bin/dis with the 2.1 version
of xlC) that will disassemble existing object or executable files.


2.14: Curses

Curses based applications should be linked with -lcurses and _not_ with
-ltermlib. It has also been reported that some problems with curses are
avoided if your application is compiled with -DNLS.

Peter Jeffe <peter@ski.austin.ibm.com> also notes:

>the escape sequences for cursor and function keys are *sometimes*
>treated as several characters: eg. the getch() - call does not return
>KEY_UP but 'ESC [ C.'

You're correct in your analysis: this has to do with the timing of the
escape sequence as it arrives from the net. There is an environment
variable called ESCDELAY that can change the fudge factor used to decide
when an escape is just an escape. The default value is 500; boosting
this a bit should solve your problems.

Christopher Carlyle O'Callaghan <asdfjkl@wam.umd.edu> has more comments
concerning extended curses:

1) The sample program in User Interface Programming Concepts, page 7-13
   is WRONG. Here is the correct use of panes and panels.

#include <cur01.h>
#include <cur05.h>

main()
{
PANE *A, *B, *C, *D, *E, *F, *G, *H;
PANEL *P;

initscr();

A = ecbpns (24, 79, NULL, NULL, 0, 2500, Pdivszp, Pbordry, NULL, NULL);
D = ecbpns (24, 79, NULL, NULL, 0, 0,    Pdivszf, Pbordry, NULL, NULL);
E = ecbpns (24, 79, D,    NULL, 0, 0,    Pdivszf, Pbordry, NULL, NULL);
B = ecbpns (24, 79, A, D, Pdivtyh, 3000, Pdivszp, Pbordry, NULL, NULL);
F = ecbpns (24, 79, NULL, NULL, 0, 0,    Pdivszf, Pbordry, NULL, NULL);
G = ecbpns (24, 79, F,    NULL, 0, 5000, Pdivszp, Pbordry, NULL, NULL);
H = ecbpns (24, 79, G,    NULL, 0, 3000, Pdivszp, Pbordry, NULL, NULL);
C = ecbpns (24, 79, B, F, Pdivtyh, 0, Pdivszf, Pbordry, NULL, NULL);
P = ecbpls (24, 79, 0, 0, "MAIN PANEL", Pdivtyv, Pbordry, A);

ecdvpl (P);
ecdfpl (P, FALSE);
ecshpl (P); 
ecrfpl (P);
endwin();
}

2) DO NOT include <curses.h> and any other <cur0x.h> file together.
   You will get a bunch of redefined statements.

3) There is CURSES and EXTENDED CURSES. Use only one or the other. If the
   manual says that they're backwards compatible or some other indication 
   that you can use CURSES routines with EXTENDED, don't believe it. To 
   use CURSES you need to include <curses.h> and you can't (see above).

4) If you use -lcur and -lcurses in the same link command, you will get
   Memory fault (core dump) error. You CANNOT use both of them at the same
   time. -lcur is for extended curses, -lcurses is for regular curses.

5) When creating PANEs, when you supply a value (other than 0) for the
   'ds' parameter and use Pdivszf value for the 'du' parameter, the 'ds'
   will be ignored (the sample program on page 7-13 in User Interface
   Programming Concepts is wrong.) For reasons as yet undetermined,
   Pdivszc doesn't seem to work (or at least I can't figure out how to
   use it.)

6) If you're running into bugs and can't figure out what is happening,
   try the following:
   include -qextchk -g in your compile line
 -qextchk will check to make sure you're passing the right number of
    parameters to the functions
 -g enables debug

7) Do not use 80 as the number of columns if you want to use the whole
   screen. The lower right corner will get erased.  Use 79 instead.

8) If you create a panel, you must create at least 1 pane, otherwise you
   will get a Memory fault (core dump).

9) When creating a panel, if you don't have a border around it, any title
   you want will not show up.

10) to make the screen scroll down:
    wmove (win, 0, 0);
    winsertln (win)

11) delwin(win) doesn't work in EXTENDED WINDOWS

    To make it appear as if a window is deleted, you need to do the following:
    for every window that you want to appear on the screen
 touchwin(win)
 wrefresh(win)

    you must make sure that you do it in the exact same order as you put
    them on the screen (i.e., if you called newwin with A, then C, then B,
    then you must do the loop with A, then C, then B, otherwise you won't
    get the same screen back).  The best thing to do is to put them into
    an array and keep track of the last window index.

12) mvwin(win, line, col) implies that it is only used for viewports and
    subwindows. It can also be used for the actual windows themselves.

13) If you specify the attribute of a window using wcolorout(win), any
    subsequent calls to chgat(numchars, mode) or any of its relatives
    will not work. (or at least they get very picky.)


2.15: How do I speed up linking

Please refer to sections 2.03 and 2.06 above.

From: losecco@undpdk.hep.nd.edu (John LoSecco) and
      hook@chaco.aix.dfw.ibm.com (Gary R. Hook)

>From oahu.cern.ch in /pub/aix3 you can get a wrapper for the existing
linker called tld which can reduce link times with large libraries by
factors of 3 to 4.


2.16: What is deadbeef?

When running the debugger (dbx), you may have wondered what the
'deadbeef' is you occasionally see in registers.  Do note, that
0xdeadbeef is a hexadecimal number that also happens to be some kind
of word (the RS/6000 was built in Texas!), and this hexadecimal number
is simply put into unused registers at some time, probably during
program startup.


2.17: How do I make an export list from a library archive?
From: d.dennerline@bull.com (Dave Dennerline)

This script will only extract the "export"able names and should be
useful in starting the shared library creation process. The user must
determine which names should be included in the import and export lists.
It's only been tested on a few library archives.

#!/bin/ksh
#
# mkexps - make export list
# This program creates an export list by combining all the "." and normal names
# into one list. 
#
if [[ "$#" -ne 1 ]]
then
    print "Usage: mkexps ArchiveFile"
    exit -2
fi
if [[ ! -f $1 ]] 
then
    print "mkexps: Cannot open file \"$1\""
    exit -1
fi
dump -g $1 | awk '
BEGIN {
        top = 1
}    
/^[ ]*[0-9][0-9]*/ {
    if ( (n = index( $2, "." )) > 0 ) {
        export_array[ top++ ] = substr( $2, n+1, length( $2 ))
    }
    else {
 export_array[ top++ ] = $2
    }
}

END {
    for ( i = 1; i < top; i++ )
    {
 print export_array[ i ]
    }

}' | sort | uniq


2.19: Building imake, makedepend
From: crow@austin.ibm.com (David L. Crow)

    You need X11dev.src release 1.2.3.0 (ie the R5 release).  
     Unless you have an R5 release of AIXwindows, there is no xmkmf.
  These are the steps that I use to make imake, makedepend and all
  of it's config files, and then install them in the working tree
  (ie not the Xamples) for daily use:
  
      cd /usr/lpp/X11/Xamples
      make Makefile
      make SUBDIRS="config util" Makefiles
      make SUBDIRS="config util" linklibs
      make SUBDIRS="config util" depend
      make SUBDIRS="config util" 
      make SUBDIRS="config util" install
      
  Then redo the steps everytime you apply an X11 update.


2.20: How can tell what shared libraries a binary is linked with?

Use "dump -H <execfilename>" and see if anything other than /unix is
listed in the loader section (at the bottom).  The first example is
/bin/sh (statically linked) and the second example is
/usr/local/bin/bash (shared).

INDEX  PATH                          BASE                MEMBER              
0      /usr/lib:/lib                                                         
1      /                             unix                                    

INDEX  PATH                          BASE                MEMBER              
0      ./lib/readline/:./lib/glob/:/usr/lib:/lib               
1                                    libc.a              shr.o               
2                                    libcurses.a         shr.o               


2.21: Can I get a PTF for my C/C++ compiler from the net?

Unfortunately, the compiler group does not release PTFs.  You have to
call IBM and ask for the latest tape.


2.22: Why does "install"ing software I got from the net fail?

Note that the RS/6000 has two install programs, one with System V flavor
in the default PATH (/etc/install with links from /usr/bin and /usr/usg),
and one with BSD behavior in /usr/ucb/install.


2.23: What is Linker TOC overflow error 12?

There is a hard coded limit in the AIX 3.2.5 linker that is fixed in
AIX 4.1.  A kind soul donated the following information to help people
get the 3.2.5 fix

    The LPS (paperwork) 
      AIX TOC Data Binder/6000 #P91128
      Version 1.1
      Program Number 5799-QDY
      Reference No. GC23-2604-00, FC 5615
    Pre Reqs listed were AIX 3.2.5
      IBM C Set++ V2 (5765-186)

You could also put some of the application code into shared libraries
or, in the case of gcc, use -mminimal-toc.

----------------------------------------------------
3.00: Fortran and other compilers

This section covers all compilers other than C/C++.  On Fortran, there
seem to have been some problems with floating point handling, in
particular floating exceptions.


3.01: I have problems mixing Fortran and C code, why?

A few routines (such as getenv, signal, and system) exist in both the
Fortran and C libraries but with different parameters. In the recent
past, if you have a mixed program that calls getenv from both C and
Fortran code, you have to link them carefully by specifying the correct
library first on your command line. This is no longer needed starting
with version 1.5 of the compilers.


3.02: How do I statically bind Fortran libraries and dynamically
      bind C libraries?
From: amaranth@vela.acs.oakland.edu (Paul Amaranth)

[ Editor's note: Part of this is also discussed above under the C compiler
  section, but I felt it was so valuable that I have left it all in. 
  I've done some minor editing, mostly typographical. ]

The linker and binder are rather versatile programs, but it is not
always clear how to make them do what you want them to.  In particular,
there are times when you do not want to use shared libraries, but
rather, staticly bind the required routines into your object.  Or, you
may need to use two versions of the same routine (eg, Fortran & C).  Here
are the results of my recent experiments.  I would like to thank Daniel
Premer and Brad Hollowbush, my SE, for hints.  Any mistakes or omissions
are my own and I have tended to interchange the terms "linker" and
"binder".  These experiments were performed on AIX 3.1.2.  Most of this
should be applicable to later upgrades of 3.1.

1)  I have some C programs, I want to bind in the runtime routines.  How
    do I do this? [Mentioned in section 2.04 of this article as well, ed.]

    You can put the -bnso binder command on the link line.  You should
    also include the -bI:/lib/syscalls.exp control argument:
      
      $ cc *.o -bnso -bI:/lib/syscalls.exp -o foo

    This will magically do everything you need.  Note that this will bind
    _all_ required routines in.  The -bI argument tells the linker that
    these entry points will be resolved dynamically at runtime (these are
    system calls).  If you omit this you will get lots of unresolved 
    reference messages.

2)  I want to statically bind in the Fortran runtime so a) my customers 
    do not need to buy it and b) I don't have to worry about the runtime
    changing on a new release.  Can I use the two binder arguments in
    1) to do this?

    You should be able to do so, but, at least under 3002, if you do
    you will get a linker error referencing getenv.  In addition, there
    are a number of potential conflicts between Fortran and C routines.
    The easy way just does not work.  See the section on
    2 stage linking for C and Fortran on how to do this.  The getenv
    problem is a mess, see the section on Comments & Caveats for more.

3)  I have a mixture of C and Fortran routines, how can I make sure
    that the C routines reference the C getenv, while the Fortran routines
    reference the Fortran getenv (which has different parameters and, if
    called mistakenly by a C routine results in a segmentation fault)?

    From Mike Heath (mike@pencom.com):

    Use -brename:symbol1,symbol2 when pre-linking the modules from one
    of the languages. It does not matter which one you choose.

4)  I have C and Fortran routines.  I want to bind in the xlf library, while
    letting the rest of the libraries be shared.  How do I do this?

    You need to do a 2 stage link.  In the first stage, you bind in the
    xlf library routines, creating an intermediate object file.  The
    second stage resolves the remaining references to the shared libraries.

    This is a general technique that allows you to bind in specific system
    routines, while still referencing the standard shared libraries.

    Specifically, use this command to bind the xlf libraries to the Fortran
    objects:

       $ ld -bh:4 -T512 -H512 <your objects> -o intermediat.o \
         -bnso -bI:/lib/syscalls.exp -berok -lxlf -bexport:/usr/lib/libg.exp \
         -lg -bexport:<your export file>

    The argument -bexport:<your export file> specifies a file with the
    name of all entry points that are to be visible outside the intermediate 
    module.  Put one entrypoint name on a line.  The -bI:/lib/libg.exp line 
    is required for proper functioning of the program.  The -berok argument 
    tells the binder that it is ok to have unresolved references, at least 
    at this time (you would think -r would work here, but it doesn't seem to).  
    The -bnso argument causes the required modules to be imported
    into the object.  The -lxlf, of course, is the xlf library.

    Then, bind the intermediate object with the other shared libraries in
    the normal fashion:

       $ ld -bh:4 -T512 -H512 <C or other modules> intermediate.o \
         /lib/crt0.o -lm -lc

    Note the absence of -berok.  After this link, all references should
    be resolved (unless you're doing a multistage link and making another
    intermediate).

    NOTE THE ORDER OF MODULES.  This is extremely important if, for example,
    you had a subroutine named "load" in your Fortran stuff.  Putting the
    C libraries before the intermediate module would make the C "load"
    the operable definition, rather than the Fortran version EVEN THOUGH 
    THE FORTRAN MODULE HAS ALREADY BEEN THROUGH A LINK AND ALL REFERENCES 
    TO THE SYMBOL ARE CONTAINED IN THE FORTRAN MODULE.  This can
    be extremely difficult to find (trust me on this one :-)  Is this
    a bug, a feature, or what?
    
    [As mentioned in section 2.03 of this article, it is a feature that you
    can replace individual objects in linked files, ed.]

    The result will be a slightly larger object than normal.  (I say slightly
    because mine went up 5%, but then it's a 2 MB object :-)


Comments & Caveats:

   From the documentation the -r argument to the linker should do what
   -berok does.  It does not.  Very strange results come from using the
   -r argument.  I have not been able to make -r work in a sensible manner
   (even for intermediate links which is what it is supposed to be for).

       Note from Mike Heath (mike@pencom.com):

       'ld -r' is essentially shorthand for 'ld -berok -bnogc -bnoglink'.
       Certainly, using -berok with an export file (so garbage collection
       can be done) is preferable to ld -r, but the latter is easier.

   When binding an intermediate module, use an export file to define the
   entry points you want visible in the later link.  If you don't do this,
   you'll get the dreaded "unresolved reference" error.  Import files name
   entry points that will be dynamically resolved (and possibly where).

   If you are in doubt about what parameters or libraries to link, use the
   -v arg when linking and modify the exec call that shows up into 
   an ld command.  Some thought about the libraries will usually yield an
   idea of when to use what.  If you don't know what an argument is for,
   leave it in.  It's there for a purpose (even if you don't understand it).

   Watch the order of external definitions (ie, libraries) when more than
   one version of a routine may show up, eg "load".  The first one defined
   on the ld command line is the winner.  

   The getenv (and system and signal) problem is a problem that started out
   minor, got somewhat worse in 3003 and, eventually will be correctly fixed.
   Basically, you should extract the 3002 version of these three routines
   from xlf.a before doing the update and save them away, then link these
   routines in if you use these Fortran system services.  


3.03: How do I check if a number is NaN?
From: sdl@glasnost.austin.ibm.com (Stephen Linam)

NaN is "Not a Number".  It arises because the RISC System/6000 uses
IEEE floating point arithmetic.

To determine if a variable is a NaN you can make use of the property
that a NaN does not compare equal to anything, including itself.
Thus, for real variable X, use

 IF (X .NE. X) THEN ! this will be true if X is NaN

Floating point operations which cause exceptions (such as an overflow)
cause status bits to be set in the Floating Point Status and Control
Register (FPSCR).  There is a Fortran interface to query the FPSCR, and
it is described in the XLF Fortran manuals -- I don't have the manuals
right here, but look for FPGETS and FPSETS.

The IBM manual "Risc System/6000 Hardware Technical Reference - General
Information" (SA23-2643) describes what floating point exceptions can
occur and which bits are set in the FPSCR as a result of those exceptions.


3.04: Some info sources on IEEE floating point

1. ANSI/IEEE STD 754-1985 (IEEE Standard for Binary Floating-Point
   Arithmetic) and ANSI/IEEE STD 854-1987 (IEEE Standard for
   Radix-Independent Floating-Point Arithmetic), both available from IEEE. 

2. David Goldberg, "What Every Computer Scientist Should Know About
   Floating-Point Arithmetic", ACM Computing Surveys, Vol. 23, No. 1,
   March 1991, pp. 5-48.


3.05: Why does it take so long to compile "hello world" with xlf? 

[read 2.07]


____________________________________________________________________________
4.00: GNU and Public Domain software

GNU software comes from the Free Software Foundation and various other
sources. A number of ftp sites archive them. Read the GNU license for 
rules on distributing their software.

Lots of useful public domain software have been and continue to be ported
to the RS/6000. See below for ftp or download information.


4.01: How do I find sources?
From: jik@GZA.COM (Jonathan Kamens)

There is a newsgroup devoted to posting about how to get a certain
source.  One is strongly urged to follow the guidelines in the article
How_to_find_sources(READ_THIS_BEFORE_POSTING), available via anonymous
ftp from rtfm.mit.edu

/pub/usenet/comp.sources.wanted/H_t_f_s_(R_T_B_P)

Note: You should try to use hostnames rather than ip addresses since
they are much less likely to change.

Also available from mail-server@rtfm.mit.edu by sending a mail
message containing:

send usenet/comp.sources.wanted/H_t_f_s_(R_T_B_P)

Send a message containing "help" to get general information about the
mail server.

If you don't find what you were looking for by following these
guidelines, you can post a message to comp.sources.wanted.


4.02: Are there any ftp sites?

Below are some ftp sites that are supposed to have RS/6000 specific
software.  I haven't verified all the entries.

US sites:
<aixpdslib.seas.ucla.edu:/pub/>  128.97.2.211">ftp://aixpdslib.seas.ucla.edu:/pub/>  128.97.2.211
<ftp://aix.boulder.ibm.com:/>
<">software.watson.ibm.com:/>">ftp://software.watson.ibm.com:/>

European sites:
<nic.funet.fi:/pub/unix/AIX/RS6000/>  128.214.6.100">ftp://nic.funet.fi:/pub/unix/AIX/RS6000/>  128.214.6.100
<iacrs1.unibe.ch:/pub/>   130.92.11.3">ftp://iacrs1.unibe.ch:/pub/>   130.92.11.3
<ftp.zrz.TU-Berlin.DE:/pub/aix/>  130.149.4.50">ftp://ftp.zrz.TU-Berlin.DE:/pub/aix/>  130.149.4.50
<ftp-aix.polytechnique.fr:/pub/binaries/rios/> 129.104.3.60">ftp://ftp-aix.polytechnique.fr:/pub/binaries/rios/> 129.104.3.60
<ftp.uni-stuttgart.de:/sw/rs_aix32/>  129.69.8.13">ftp://ftp.uni-stuttgart.de:/sw/rs_aix32/>  129.69.8.13

The first one is dedicated to software running on AIX.  It might not
always be the latest versions of the software, but it has been ported
to AIX (normally AIX version 3 only).  Please use the European sites
very sparingly.  They are primarily to serve people in Europe and most
of the software can be found in the US sites originally.

The remaining sites are simply ones that archie indicated contained
AIX related materials.

<ftp://ibminet.awdpa.ibm.com:/>#IBM announcements, oem hardware
<ftp://cac.toronto.ibm.com:/>#marketing-info
<">ftp.egr.duke.edu:/>">ftp://ftp.egr.duke.edu:/>
<">straylight.acs.ncsu.edu:/>">ftp://straylight.acs.ncsu.edu:/>
<">alpha.gnu.ai.mit.edu:/rs6000>">ftp://alpha.gnu.ai.mit.edu:/rs6000>
<">ftp.uni-stuttgart.de:/sw/rs_aix32/>">ftp://ftp.uni-stuttgart.de:/sw/rs_aix32/>
<">iacrs2.unibe.ch:/pub/aix/>">ftp://iacrs2.unibe.ch:/pub/aix/>
<">ftp.u.washington.edu:/pub/RS6000/>">ftp://ftp.u.washington.edu:/pub/RS6000/>
<">aixive.unb.ca:/>">ftp://aixive.unb.ca:/>
<">ftp.ans.net:/pub/misc/>">ftp://ftp.ans.net:/pub/misc/>
<">uvaarpa.virginia.edu:/pub/misc/>">ftp://uvaarpa.virginia.edu:/pub/misc/>
<">ux1.cts.eiu.edu:/pub/rs6000/>">ftp://ux1.cts.eiu.edu:/pub/rs6000/>
<ftp://ftp.bsc.nopub:/Src/>
<">ftp-aix.polytechnique.fr:/pub/binaries/rios/>">ftp://ftp-aix.polytechnique.fr:/pub/binaries/rios/>
<">aix1.segi.ulg.ac.be:/pub/aix/>">ftp://aix1.segi.ulg.ac.be:/pub/aix/>
<ftp://byron.u.washington.edu:/pub/aix/>
<">cunixf.cc.columbia.edu:/aix/>">ftp://cunixf.cc.columbia.edu:/aix/>
<">files1zrz.zrz.tu-berlin.de:/pub/aix/>">ftp://files1zrz.zrz.tu-berlin.de:/pub/aix/>
<">ftp.rz.uni-augsburg.de:/pub/aix/>">ftp://ftp.rz.uni-augsburg.de:/pub/aix/>
<">fyvie.cs.wisc.edu:/pub/aix/>">ftp://fyvie.cs.wisc.edu:/pub/aix/>
<">solaria.cc.gatech.edu:/pub/aix/>">ftp://solaria.cc.gatech.edu:/pub/aix/>
<">spot.colorado.edu:/aix/>">ftp://spot.colorado.edu:/aix/>
<ftp://swdsrv.edvz.univie.ac.at:/unix/systems/aix/>
<">switek.uni-muenster.de:/pub/aix/>">ftp://switek.uni-muenster.de:/pub/aix/>
<">wuarchive.wustl.edu:/systems/aix/>">ftp://wuarchive.wustl.edu:/systems/aix/>
<">cs.nyu.edu:/pub/AIX/>">ftp://cs.nyu.edu:/pub/AIX/>
<">karazm.math.uh.edu:/pub/AIX/>">ftp://karazm.math.uh.edu:/pub/AIX/>
<">minnie.zdv.uni-mainz.de:/pub0/pub/AIX/>">ftp://minnie.zdv.uni-mainz.de:/pub0/pub/AIX/>
<">oersted.ltf.dth.dk:/pub/AIX/>">ftp://oersted.ltf.dth.dk:/pub/AIX/>
<">rs3.hrz.th-darmstadt.de:/pub/incoming/AIX/>">ftp://rs3.hrz.th-darmstadt.de:/pub/incoming/AIX/>
<">aeneas.mit.edu:/pub/rs6000/>">ftp://aeneas.mit.edu:/pub/rs6000/>
<">cameron.egr.duke.edu:/rs6000/>">ftp://cameron.egr.duke.edu:/rs6000/>
<">ifi.informatik.uni-stuttgart.de:/pub/rs6000/>">ftp://ifi.informatik.uni-stuttgart.de:/pub/rs6000/>
<">metropolis.super.org:/pub/rs6000/>">ftp://metropolis.super.org:/pub/rs6000/>
<">ramses.cs.cornell.edu:/pub/rs6000/>">ftp://ramses.cs.cornell.edu:/pub/rs6000/>
<">server.uga.edu:/pub/rs6000/>">ftp://server.uga.edu:/pub/rs6000/>
<">uvaarpa.virginia.edu:/pub/rs6000/>">ftp://uvaarpa.virginia.edu:/pub/rs6000/>
<ftp://wayback.cs.cornell.edu:/pub/rs6000/>
<">alice.fmi.uni-passau.de:/pub/RS6000/>">ftp://alice.fmi.uni-passau.de:/pub/RS6000/>
<ftp://byron.u.washington.edu:/pub/aix/RS6000/>
<ftp://milton.u.washington.edu:/pub/RS6000/>
<">pascal.math.yale.edu:/pub/RS6000/>">ftp://pascal.math.yale.edu:/pub/RS6000/>
<">uxc.cso.uiuc.edu:/pub/RS6000/>">ftp://uxc.cso.uiuc.edu:/pub/RS6000/>

4.03: Why does "install"ing software I got from the net fail?

This answer was moved to section 2.22


4.04: GNU Emacs

If you get a segmentation fault in GNU EMACS 19.* during hilit19 use,
you can set locale to C (export LC_ALL=C) to get around the AIX bug.

Version 18.57 of GNU Emacs started to have RS/6000 support.  Use
s-aix3-2.h for AIX 3.2. Emacs is going through rapid changes recently.
Current release is 19.x.

Emacs will core-dump if it is stripped, so don't strip when you install
it.  You can edit a copy of the Makefile in src replacing all 'install -s' 
with /usr/ucb/install.


4.05: gcc/gdb

GNU C version 2.0 and later supports the RS/6000, and compiles straight
out of the box.  You may, however, experience that compiling it requires
large amounts of paging space.

Compiling gcc and gdb requires a patch to the 'as' assembler.  Call
IBM software support and request patch for apar IX26107 (U409205).

gcc has undergone many changes lately and the current version is 2.5.x.
gdb is at 4.1x.

If your machine crashed when trying to run gdb 4.7, call software support
and request ptf U412815.


4.06: GNU Ghostscript 

The PostScript interpreter GNU Ghostscript Version 2.3 and later supports
the RS/6000 and can be found on various ftp sites. Current version is 2.6.1.

Compile time problems:
  Compile idict.c and zstack.c _without_ optimization, add the following
  to the Makefile:

  idict.o: idict.c
        $(CC) -c idict.c

  zstack.o: zstack.c
        $(CC) -c zstack.c

Run time problems:
  Running ghostview-1.5 with ghostscript-2.6.1, I get 
   gs: Malformed ghostview color property.
  Solution: replace buggy version of ghostscript-2.6.1 X11 driver
  with at least 2.6.1pl4 

4.07  TeX - Document processing

TeX can be retrieved via ftp from ftp.uni-stuttgart.de.
Be sure to use a recent C compiler (01.02.0000.0013) and you can compile
with optimization.


4.08  Perl - Scripting language

Current version is 4.035 and compiling with cc should give no problems. 
If you use bsdcc, do not use perl's builtin malloc(), edit config.H to
'#define HAS_SYMLINK', and you should be on your way.  Bill Wohler tells
me that perl will run without editing config.H and with cc as well.  So
just say no to use perl's malloc().

Doug Sewell <DOUG@YSUB.YSU.EDU> adds:

In addition to not using the perl-provided malloc, when asked if you
want to edit config.sh, change 'cppstdin' from the wrapper-program
to '/lib/cpp'.

The perl wrapper name is compiled into perl, and requires that you keep
that file in the source directory, even if you blow away the rest of
the source.  /lib/cpp will do the job by itself.  I suspect this will
be fixed in perl 4.0pl11 Configure script.

Also, beware if you have gdbm installed per the instructions in the FAQ.
Gdbm is compiled with bsdcc; perl (as I installed it, anyway) was built
with cc, so I used the IBM-provided ndbm routines.


4.09: X-Windows

The base version has X11R4 and Motif 1.1 and the extended version has
X11R5 as AIXwindows 1.2.3.  See question 1.500 for more information
about determining your revision.

AIXwindows version 1.2.0 (X11rte 1.2.0) is X11R4 with Motif 1.1
AIXwindows version 1.2.3 (X11rte 1.2.3) is X11R5 with Motif 1.1
'lslpp -h X11rte.motif1.2.obj' should tell you if you are
running Motif 1.2.


4.10  Bash - /bin/ksh alternative from FSF

Bash is an alternative to ksh and is availible from prep.ai.mit.edu
and places that mirror the GNU software.  /etc/security/login.cfg
needs to be modified if this will be used as a default shell.


4.11: Elm

A very nice replacement for mail. Elm should be pretty straightforward,
the only thing to remember is to link with -lcurses as the only
curses/termlib library. You may also run into the problem listed under
point 2.13 above.


4.12: Oberon 2.2

From: afx@muc.ibm.de (Andreas Siegert)

Oberon is Wirth's follow on to Modula-2, but is not compatible. A free
version of Modula-3 is available from DEC/Olivetti at
gatekeeper.dec.com. This is not a Modula-2 replacement but a new
language. There are currently two M2 compilers for the 6000 that I
know of. One from Edinburgh Portable Compilers, +44 31 225 6262 (UK)
and the other from Gardens Point is availible through A+L in
Switzerland (+41 65 520311) or Real Time Associates in the UK
(info@rtal.demon.co.uk).

Oberon can be obtained via anonymous ftp from neptune.inf.ethz.ch
(129.132.101.33) under the directory Oberon/RS6000 or gatekeeper.dec.com
(16.1.0.2).


4.13  Kermit - Communications 

Get it from watsun.cc.columbia.edu (128.59.39.2), kermit/bin/cku189.tar.Z.
Uncompress, untar, and "make rs6000", and it works.


4.14: Gnu dbm
From: doug@cc.ysu.edu (Doug Sewell)

Here's the fixes for RS/6000's:

apply this to testgdbm.c:
158c158
<   char opt;
---
>   int opt;
166c166
<   while ((opt = getopt (argc, argv, "rn")) != -1)
---
>   while ((opt = getopt (argc, argv, "rn")) != EOF)

Apply this to systems.h:
111a112,114
> #ifdef RS6000
> #pragma alloca
> #else
112a116
> #endif

To compile, edit the Makefile.  Set CC to bsdcc (see /usr/lpp/bos/bsdport
if you don't have 'bsdcc' on your system) and set CFLAGS to -DRS6000 and
whatever options (-g, -O) you prefer.  Don't define SYSV.


4.15  tcsh - /bin/ksh alternative
From: cordes@athos.cs.ua.edu (David Cordes)

tcsh is available from tesla.ee.cornell.edu (pub/tcsh-6.00 directory)
Compiles with no problems. You must edit /etc/security/login.cfg to
permit users to change to this shell (chsh), adding the path where the
shell is installed (in my case, /usr/local/bin/tcsh).

From: "A. Bryan Curnutt" <bryan@Stoner.COM>

Under AIX 3.2.5, you need to modify the "config.h" file, changing
    #define BSDSIGS
to
    #undef BSDSIGS


4.16: Kyoto Common Lisp

The sources are available from cli.com. The kcl package is the needed
base; also retrieve the latest akcl distribution. akcl provides a
front-end that "ports" the original kcl to a number of different
platforms. The port to the 6000 worked with no problems. However, you
must be root for make to work properly with some memory protection
routines.


4.17  Tcl/Tk - X-Windows scripting

Current versions: Tcl 7.3, Tk 3.6. Available from sprite.berkeley.edu or
harbor.ecn.purdue.edu.


4.18: Expect
From: Doug Sewell <DOUG@YSUB.YSU.EDU>
   
To build the command-interpreter version, you must have the tcl library
built successfully. The expect library doesn't require tcl.  Note:
Expect and its library are built with bsdcc, so applications using
the library probably also need to be developed with bsdcc.

I ftp'd expect from ftp.cme.nist.gov.

You need to change several lines in the makefile.  First you need
to customize source and target directories and files:
#
TCLHDIR = /usr/include
TCLLIB = -ltcl
MANDIR = /usr/man/manl               (local man-pages)
MANEXT = l
BINDIR = /u/local/bin
LIBDIR = /usr/lib
HDIR = /usr/include
...
Next set the compiler, switches, and configuration options:
#
CC = bsdcc
CFLAGS = -O
...
PTY_TYPE = bsd
...
INTERACT_TYPE = select
...
Then you need to make these changes about line 90 or so:
comment out CFLAGS = $(CLFLAGS)
un-comment these lines:
CFLAGS = $(CLFLAGS) $(CPPFLAGS)
LFLAGS = ($CLFLAGS)

Then run 'make'.

You can't run some of the examples without modification (host name,
etc).  I don't remember if I ran all of them or not, but I ran enough
that I was satisfied it worked.


4.19: Public domain software on CD
From: mbeckman@mbeckman.mbeckman.com (Mel Beckman)

The Prime Time Freeware CD collection is a package of two CD's and docs
containing over THREE GIGABYTES of compressed Unix software. It costs $69
>from Prime Time Freeware, 415-112 N. Mary Ave., Suite 50, Sunnyvale, CA
94086. Phone 408-738-4832 voice, 408-738-2050 fax. No internet orders as
far as I can tell.

I've extracted and compiled a number of the packages, and all have worked
flawlessly so far on my 220. Everything from programming languages to 3D
solid modeling is in this bonanza!

Ed: The O'Reilly book, Unix Power Tools, also contains a CD-ROM with lots
of useful programs compiled for the RS/6000, among other platforms.


4.20: Andrew Toolkit

From: Gary Keim <gk5g+@andrew.cmu.edu>

The Andrew Toolkit Consortium of Carnegie Mellon University's School of
Computer Science has released new versions of the Andrew User
Environment, Andrew Toolkit, and Andrew Message System.

The Andrew User Environment (AUE) is an integrated set of applications
beginning with a 'generic object' editor, ez, a help system, a system
monitoring tool (console), an editor-based shell interface (typescript),
and support for printing multi-media documents. 

The Andrew Toolkit (ATK) is a portable user-interface toolkit that runs
under X11. It provides a dynamically-loadable object-oriented
environment wherein objects can be embedded in one another. Thus, one
could edit text that, in addition to containing multiple fonts, contains
embedded raster images, spreadsheets, drawing editors, equations, simple
animations, etc. These embedded objects can also be nested.

The Andrew Message System (AMS) provides a multi-media interface to mail
and bulletin-boards. AMS supports several mail management strategies
and implements many advanced features including authentication, return
receipts, automatic sorting of mail, vote collection and tabulation,
enclosures, audit trails of related messages, and subscription
management. It has interfaces that support ttys, personal computers, 
and workstations.

Release 5.1 of Andrew contains many bug fixes and updates. There is now
support for the new Internet MIME (Multipurpose Internet Mail Extensions)
standards for multipart, and multimedia mail. For more information on
MIME, please see the CHANGES files in the ftp directory on
emsworth.andrew.cmu.edu.

This release can be obtained as follows. The sources are available via
anonymous ftp from export.lcs.mit.edu (18.30.0.238) in the
./contrib/andrew tree. For details, see ./contrib/andrew/README.

PATCH for AIX3.2: A patch to the AUIS 5.1 sources can be ftp'ed from
emsworth.andrew.cmu.edu (128.2.45.40) in ./aixpatch. For those without
internet access, a 3.5" diskette can be ordered for a nominal fee of $10
by sending, or faxing, a purchase order to the Consortium address below.

Andrew, as well as a variety of other CMU software, can also be ftp'ed
>from emsworth.andrew.cmu.edu (128.2.30.62). Those with AFS access look
at /afs/andrew.cmu.edu/itc/sm/releases/X.V11R5/ftp.

Remote Andrew Demo Service 

This network service allows you to run Andrew Toolkit applications
without obtaining or compiling the Andrew software. You need a host
machine running X11 on the Internet. A simple "finger" command will let
you experience ATK applications firsthand. You'll be able to compose
multimedia documents, navigate through the interactive Andrew Tour, and
use the Andrew Message System to browse through CMU's three thousand
bulletin boards and newsgroups.

To use the Remote Andrew Demo service, run the following command:

    finger help@atk.itc.cmu.edu 

The service will give you further instructions.

Information Sources

Your bug reports are welcome; kindly send them to
info-andrew-bugs@andrew.cmu.edu and we will periodically post a status
report to the mailing list info-andrew@andrew.cmu.edu. To be added to
the mailing list or make other requests, send mail to
info-andrew-request@andrew.cmu.edu.

We also distribute the following related materials:

ATK and AMS sources and binaries on CDROM. Binaries are available
for the following system types: 

         IBM RiscSystem/6000 
  Sun SparcStation 
  HP 700 Series 
  DECstation 

ATK and AMS sources on QIC and Iotamat tapes Hardcopies of the
documentation for ATK and AMS. Introductory video tape: Welcome to
Andrew: An Overview of the Andrew System. Technical video tape: The
Andrew Project: A Session at the Winter 1988 Usenix Conference.

More information about these materials is available from:

    Information Requests
    Andrew Toolkit Consortium
    Carnegie Mellon University
    4910 Forbes Avenue, UCC 214
    Pittsburgh, PA 15213-3890
    USA
    phone: +1-412-268-6710
    fax: +1-412-621-8081
    info-andrew-request@andrew.cmu.edu

There is also a netnews distribution list, comp.soft-sys.andrew, which
is identical to the info-andrew list except that it does not support the
multi-media capabilities of info-andrew.


4.21: sudo

The most recent of sudo is cu-sudo v1.3.1 patchlevel 2
(cu-sudo.v1.3.1pl2.tar.Z).  It support AIX 3.x.  cu-sudo is maintained
by Todd Miller <millert@cs.colorado.edu>.


4.22: Flexfax/HylaFax and other fax software

From: Christian Zahl <czahl@cs.tu-berlin.de>

Sam Leffler has released a new version of FlexFax called HylaFax.  It
is availible from <">sgi.com:/sgi/fax/>">ftp://sgi.com:/sgi/fax/>. Version 2.2.1
supported many types of Class 1/2 fax modems and several UNIX systems
including AIX 3.2.3 or greater.  There is also a fax modem review
document at the same site as sgi.com:/pub/fax/bakeoff. The FlexFax
related files on sgi.com are replicated on ftp.bsc.no as well.

From: michael@hal6000.thp.Uni-Duisburg.DE (Michael Staats)

We're using mgetty+sendfax for the basic modem I/O, I wrote a printer
backend for the modem so that users can send faxes as easy as they print
postscript. I also wrote a little X interface composer to generate a
fax form that makes sending faxes very easy. You can find these
programs at hal6000.thp.Uni-Duisburg.DE under /pub/source.

program    comment

mgetty+sendfax-0.14.tar.gz basic modem I/O, needs hacking for AIX
X11/xform-1.1.tar.gz       small and simple X interface composer
    with an example fax form. Needs
    libxview.a incl. headers.
faxiobe.tar.gz   fax backend, needs configuring for
    your local site

If you need a binary version of libxview.a and the headers you'll find
them under /pub/binaries/AIX-3-2/lxview.tar.gz.


4.23  lsof - LiSt Open Files
From: abe@vic.cc.purdue.edu (Vic Abell)

Q. How can I determine the files that a process has opened?
Q. How can I locate the process that is using a specific network address?
Q. How can I locate the processes that have files open on a file system?

A. Use lsof (LiSt Open Files).

Lsof is available via anonymous ftp from vic.cc.purdue.edu
(128.210.15.16) in pub/lsofVVVtar.Z where VVV is the version number,
currently 229.


4.24  popper - POP3 mail daemon

The POP server is available via anonymous ftp from 
ftp.qualcomm.com:/quest/unix/servers/popper
  The makefile supports AIX
ftp.CC.Berkeley.EDU (128.32.136.9, 128.32.206.12).
  There are two versions in the pub directory: a compressed tar file
  popper-version.tar.Z and a Macintosh StuffIt archive in BinHex format
  called MacPOP.sit.hqx.

Problems building some versions of popper can sometimes be resolved by
compiling with bsdcc or -D_BSD.


4.26: mpeg link errors version 2.0
posted by (Nathan Lane) nathan@seldon.foundation.tricon.com 

.XShmCreateImage
.XShmDetach
.XShmAttach
.XShmGetEventBase
.XShmPutImage
.XShmQueryExtension

... are for the Shared Memory extension of the X server.
You can either choose to build it with shared memory or without.  I
always do it without the performance increase is not really
incredible, except on something like a 2x0 machine with the local bus
graphics adapter.  Just take out "DSH_MEM" in the CFLAGS in the
makefile for mpeg_play.  There is more information about shared memory
link errors in section 1.513.

Also, in the module "video.c" for mpeg_play it will complain about not
having enough memory to fully optimize one of the loops.  You can get
around that by specificying "qmaxmem=8000" in your cflags line, BUT,
the extra optimization does little good in my tests.


4.27: NNTP, INN

Link errors compiling nntp may occur because your machine lacks the
"patch" command.  Patch can be obtained from GNU repositories


4.28: Zmodem - File transfer

RZSZ is Chuck Forsberg's script for Z-modem. It is available by ftp at
<">oak.oakland.edu:/pub/unix-c/xyzmodem/rzsz9305.tar.Z>">ftp://oak.oakland.edu:/pub/unix-c/xyzmodem/rzsz9305.tar.Z> or
directly from Forsberg at Omen Technology BBS at 503-621-3746.

Hints:
0. Build with "make posix"
1. Use an 8-bit clean version of rlogin or telnet (Note: below)
2. Set the system to be transparent, I use "terminal download" 
3. Ensure hardware flow-control

Note, carlson@xylogics.com (James Carlson) suggests: Rlogin is
"slightly" unclean -- if an FF FF 73 73 appears in the datastream, it
can be ripped out by rlogind as a 'window size change' request.

[Ed note: The important part is using an 8-bit clean application,
since there are several implemenations of rlogin and telnet availible
you may need to try both and hunt down manuals to find the right flags
for your system]


4.29: Patch - automated file updates

AIX 3.2.5 does not ship with patch, a utility to apply the differences
between two files to make them identical.  This tool is often used to
update source code.

<">ftp.x.org:/pub/R6untarred/xc/util/patch/>">ftp://ftp.x.org:/pub/R6untarred/xc/util/patch/>
<">prep.ai.mit.edu:/pub/gnu/patch-2.1.tar.gz>">ftp://prep.ai.mit.edu:/pub/gnu/patch-2.1.tar.gz>


4.30: XNTP - network time protocol, synchronizes clocks

louie.udel.edu:/pub/ntp

______________________________________________________________________________
5.00: Third party products

[ Ed.: Entries in this section are edited to prevent them from looking
  like advertising. Prices given may be obsolete. Companies mentioned
  are for reference only and are not endorsed in any fashion. ]


5.02: Disk/Tape/SCSI
From: anonymous

- Most SCSI disk drives work (IBM resells Maxtor, tested Wren 6&7 myself);
  use osdisk when configuring (other SCSI disk).

- Exabyte: Unfortunately only the ones IBM sells are working.
  A few other tape drives will work; 
  use ostape when configuring (other SCSI tape).

- STK 3480 "Summit": Works with Microcode Version 5.2b


From: bell@hops.larc.nasa.gov (John Bell)
               
In summary, third party tape drives work fine with the RS/6000 unless 
you want to boot from them. This is because IBM drives have 'extended 
tape marks', which IBM claims are needed because the standard marks 
between files stored on the 8mm tape are unreliable. These extended 
marks are used when building boot tapes, so when the RS/6000 boots, it 
searches for an IBM tape drive and refuses to boot without it.

From: jrogers@wang.com (John Rogers)

On booting with non-IBM SCSI tape drives: I haven't tried it myself but
someone offered:

Turn machine on with key in secure position.
Wait until LED shows 200 and 8mm tape has stopped loading.
Turn key to service position.


From: amelcuk@gibbs.clarku.edu (Andrew Mel'cuk)

The IBM DAT is cheap and works.  If you get all the patches beforehand
(U407435, U410140) and remember to buy special "Media Recognition
System" tapes (Maxell, available from APS 800.443.4461 or IBM #21F8758)
the drive can even be a pleasure to use.  You can also flip a DIP switch
on the drive to enable using any computer grade DAT tapes (read the
hardware service manual).

Other DAT drives also work.  I have tried the Archive Python (works) and
experimented extensively with the Archive TurboDAT.  The TurboDAT is a
very fast compression unit, is not finicky with tapes and doesn't
require the many patches that the IBM 7206 does.  Works fine with the
base AIX 3.2 'ost' driver.


From: pack@acd.ucar.edu (Daniel Packman)

>>You can boot off of several different brands of non-IBM Exabytes.
>>At least TTI and Contemporary Cybernetics have done rather complete
>>jobs of emulating genuine IBM products.

A model that has worked for us from early AIX 3.1 through 3.2 is a TTI
CTS 8210.  This is the old low density drive.  The newer 8510 is dual
density (2.2gig and 5gig).  Twelve dip switches on the back control the
SCSI address and set up the emulation mode.  These drives have a very
useful set of lights for read-outs (eg, soft error rate, tape remaining,
tape motion, etc.).


5.03: Memory

Nordisk Computer Services (Portland 503-598-0111, Seattle
206-242-7777) is reputed to have memory for use on AIX platforms.

5xx machines have 8 memory slots, 3x0s have 2, and 3x5s have only one.
You need to add memory in pairs for the 5xx machines excepting the 520.

RS/6000 Models 220, 230 and 250 can use "PS/2" style SIMM memory.  All
have 8 SIMM sockets.  60ns or better is needed for the 250, 70ns
should be OK in the 220 and 230.  The 220 and 230 are limited to 64MB
of memory, the 250 is limited to 256MB.


5.04: Others
From: anonymous
       
IBM RISC System/6000 Interface Products

National Instruments Corporation markets a family of instrumentation
interface products for the IBM RISC System/6000 workstation family.  The
interface family consists of three products that give the RISC
System/6000 connectivity to the standards of VMEbus, VXIbus and GPIB. 
For more information, contact National Instruments Corporation,
512-794-0100 or 1-800-433-3488.


5.05: C++ compilers

Several C++ compilers are available. You can choose from Glockenspiel,
Greenhills, IBM's xlC (sold seperatly :), and GNU's g++. Glockenspiel
may now be part of Computer Associates. Comeau Computing
(718-945-0009) offers Comeau C++ 3.0 with Templates. For a full
development environment there's ObjectCenter's C++ (formerly Saber
C++).


5.06: Memory leak detectors

IBM's xlC comes with a product called the HeapView debugger that can
trace memory problems in C and C++ code.

SENTINEL has full memory access debugging capabilities including detection 
of memory leaks.  Contact info@vti.com (800) 296-3000 (703) 430-9247.

Insight from ParaSoft (818) 792-9941.
There is also a debug_malloc posted in one of the comp.sources groups.

Dave Dennerline mentioned that Purify (408) 720-1600 and TestCenter
(800) 669-2687 are not availible for the RS/6000 .

SevOne Software Inc. (info@tkg.com) has released their product to beta
testers.


5.07: PPP

PPP does not come with AIX 3.2.x (only SLIP).

David Crow caught the announcement of a ppp package that claims to
support AIX 4.x.  More information is availible from
<http://www.thoughtport.com:8080/PPP/> or
<ftp://dcssoft.anu.edu.au/pub/ppp/ppp-2.2b1.tar.gz>

A comercial PPP for AIX is availible from Morningstar
(sales@morningstar.com or marketing@morningstar.com) (800) 558-7872.


5.08: Graphics adapters

Abstract Technologies Inc. (Austin TX, 512-441-4040, info@abstract.com)
has several high performance graphics adapters for the RS/6000.
1600x1200, 24-bit true-color, and low cost 1024x768 adapters are
available.  Retail prices are between US$1000-2000.


5.09: Training Courses

Email training@skilldyn.com with "help" in the body of the message for
information about how to receive a list course descriptions for AIX*
and/or UNIX* courses offered by Skill Dynamics.

5.10: Hardware Vendors

New & Used RS6000s, peripherals
Core Systems Inc, 1605 12th Ave Seattle WA 98122 
(800) 329-2449  fax: (206) 329-3799
<http://www.corsys.com/homeworld>

______________________________________________________________________________
6.00: Miscellaneous other stuff

6.01: Can I get support by e-mail?

In general, no, <aixbugs@austin.ibm.com> and <services@austin.ibm.com>
are no longer supported.

IBM does maintain a fee based system, the AIX Support Family Services
at 1-800-CALL-AIX (1-800-225-5249) option 8.

In Canada:

Gary Tomic mentioned that Canadian customers can get support from their
BBS, cac.toronto.ibm.com at 142.77.253.16.

In Germany:

Thomas Braunbeck reported that German customers with ESS (extended
software service) contracts can get support by e-mail too. They can 
obtain information by sending mail with Subject: help to 
aixcall@aixserv.mainz.ibm.de.

Various flavors of service offerings are available. Contact your IBM rep
for details.


6.02: List of useful faxes

You can get some informative faxes by dialing IBM's Faxserver at
1-800-IBM-4FAX. If you're calling for the first time, push 3 then 2 to
request a list of RS/6000 related faxes.

document number                       Title
---------------  -----------------------------------------------------
     1453        Recovering from LED 518 in AIX 3.2
     1457        Recovering from LED 552 in AIX 3.1 and 3.2
     1461        Alternative Problem Reporting Methods
     1470        Recovering from LED 223/229, 225/229, 233/235, 221/229, or 221
     1537        How to Get AIX Support
     1719        Performance Analyzer/6000
     1721        Recovering from LED 553 in AIX 3.1 and 3.2
     1746        Recovering from LED 551 in AIX 3.1 and 3.2
     1755        Recovering Volume Groups
     1802        Repairing File Systems with fsck in AIX 3.1 and 3.2
     1803        How to Take a System Dump
     1804        Setting Up a Modem With the RS/6000
     1845        Using iptrace to Track Remote Print Jobs
     1867        Clearing the Queuing System
     1895        Removing/Replacing a Fixed Disk
     1896        Tape Drive Densities and Special Files
     1897        Tips on mksysb for AIX 3.2
     1909        UUCP (BNU) Helpful Information
     1910        Synchronizing Disk Names
     1988        Recovering from LED 201 in AIX 3.1 and 3.2
     1989        Recovering from LED 727 in AIX 3.2
     1991        Recovering from LED c31 in AIX 3.1 and 3.2
     2079        AIX 3.2.4
     2121        AIX 3.2.4 Installation Tips
     2267        How to reduce /usr in AIX 3.2
     2443        Man pages for AIX 3.2
     2446        How to set up sar
     2447        How to reduce /tmp
     2448        Installing a 5 GB tape drive
     2462        Bosboot diskettes
     2465        How to remove ptfs from the ODM

6.03: IBM's gopher, WWW, aftp presence (as of 6/10/94)
Thanks to Ronald S. Woan <woan@austin.ibm.com>

aix.boulder.ibm.com  (FixDist ptfs)
software.watson.ibm.com  (rlogin fixes & more)
gopher.ibmlink.ibm.com  (anonouncements & press releases)
www.austin.ibm.com  (software, hardware, service & support)

General IBM information like product announcements and press releases
are available through World Wide Web at <http://www.ibm.com/>

Specific information on the RISC System/6000 product line and AIX
(highlights include marketing information, technology White Papers and
the POWER 2 technology book online before it hits the presses,
searchable APAR database and AIX support FAX tips online so you don't
have to type in all those scripts) is available at
<http://www.austin.ibm.com/>


6.04: Some RS232 hints
From: graeme@ccu1.aukuni.ac.nz, sactoh0.SAC.CA.US!jak

Q: How do you connect a terminal to the RS232 tty ports when not using
   the standard IBM cable & terminal transposer?
A: 1- Connect pins 2->3, 3->2, 7->7 on the DB25's
   2- On the computer side, most of the time cross 6->20 (DSR, DTR).
      Some equipment may require connecting 6, 8, and 20 (DSR, DCD, DTR).

Also, pin 1 (FG) should be a bare metal wire and the cable should be
shielded with a connection all the way through. Most people don't run
pin 1 because pins 1 & 7 (SG) are jumpered on many equipment.

When booting from diskettes, the port speed is always 9600 baud.  If you
use SMIT to set a higher speed (38400 is nice) for normal use, remember
to reset your terminal before booting.

Q: How do you connect a printer to the RS232 tty ports
A: 1- Connect pins 2->3, 3->2, 7->7 on the DB25's
   2- On the computer side, loop pins 4->5 (CTS & RTS)


6.05  What publications are available for AIX and RS/6000?

The following are free just for the asking:

RS/Magazine
   P.O. Box 3272
   Lowell, MA 01853-9876
   e-mail: aknowles@expert.com (Anne Knowles, editor)

AIXpert
   IBM Corporation
   Mail Stop 36
   472 Wheelers Farms Road
   Milford, CT 06460
   FAX: (203) 783-7669

RiSc World
   P.O. Box 399
   Cedar Park, TX 78613
   FAX: (512) 331-3900
   Usenet: {cs.utexas.edu,execu,texbell}!pcinews!rsworld

These manuals should be available from your favorite IBM office.
 
SC23-2204-02  Problem Solving Guide
SC23-2365-01  Performance Monitoring and Tuning Guide for AIX 3.2
SA23-2629-07  Service Request Number Cross Reference, Ver 2.2
SA23-2631-05  Diagnostic Programs: Operator Guide
SA23-2632-05  Diagnostic Programs: Service Guide
SA23-2643-01  Hardware Technical Reference: General Information
SA23-2646-01  Hardware Technical Reference: Options and Devices

Computer bookstores often carry many of the following:

"Power RISC System/6000: Concepts, Facilities, Architecture", Chakravarty  
         McGraw-Hill ISBN 0070110476
"PowerPC: Concepts, Facilities, Architecture", Chakravarty/Cannon  
         McGraw-Hill ISBN 0070111928
"The Advanced Programmer's Guide to AIX 3.x", Colledge 
         McGraw-Hill ISBN 007707663X
"AIX Companion" , Cohn    
         Prentice-Hall ISBN 0132912201
"AIX for RS/6000: System & Administration Guide", DeRoest 
         McGraw-Hill ISBN 0070364397
"A Guide to AIX 3.2", Franklin
         Metro-Info Systems 05/1993
"IBM RS6000 AIX System Administration", Hollicker
         Prentice-Hall ISBN 0134526163
"IBM RISC SYSTEM/6000 - A Business Perspective", Hoskins
         John Wiley & Sons ISBN 0471599352
"The Advanced Programmer's Guide to AIX 3.x", Phil Colledge
 McGraw-Hill, 1994, ISBN: 0-07-707663-x


6.06: Some acronyms

APAR - authorized program analysis report
BOS  - Basic Operating System
DCR  - design change request
LPP  - Licensed Program Product
ODM  - Object Database Manager
PRPQ - programming request for price quotation
PTF  - Program Temporary Fix
SMIT - System Management Interface Tool


6.07: How do I get this by mailserver or ftp?

Since the articles are crossposted to news.answers, any archive
carrying that newsgroup will also have these articles.  In particular,
try ftp'ing to rtfm.mit.edu and checking the directory
pub/usenet/news.answers. This FAQ is archived as "aix-faq/part[123]".

The FAQ is also availible via email using the address
mail-server@rtfm.MIT.edu two examples of how you might use this from a
UNIX prompt follow:

echo help | mail mail-server@rtfm.MIT.edu
echo send usenet/news.answers/aix-faq/part1 | mail mail-server@rtfm.MIT.edu


6.08: Hypertext version of the FAQ

United States:
  <http://www.cis.ohio-state.edu/hypertext/faq/usenet/aix-faq/top.html>
  <http://www.chem.emory.edu/>
New Zeland:
  <http://www.abstract.co.nz/aix-faq/faq.html>
France:
  <http://www-resus.univ-mrs.fr/Us/CS/RS6k/>
Canada:
  <http://auk.uwaterloo.ca/aixgroup/aix-faq>


6.09: Where can I send suggestions for tools?

If you have any suggestions or comments about tools, whether currently or 
desirable to be in AIX, send a note to aix_tool_ideas@austin.ibm.com.


6.10: Comp.unix.aix archive availible on the WWW

Michael Staats & Fred Hucht have informed me that a 
searchable archive of comp.unix.aix is availible at: 
<http://www.thp.Uni-Duisburg.DE/cuaix/cuaix.html>

AIX Frequently Asked Questions (Part 3 of 4)


Frequently Asked Questions about AIX and the IBM RS/6000 Section 3
__________________________________________________________________

1.600: My named dies frequently, why?

Running on 3.2, named dies frequently on network's primary name server.

From: jpe@ee.egr.duke.edu (John P. Eisenmenger)

Try the following:

     stopsrc -s named  # stop running named
     setenv MALLOCTYPE 3.1 # use 3.1 memory allocation algorithm
     /etc/named ...  # don't use smit to start named

You might be able to use startsrc/smit after setting MALLOCTYPE and get
the same effect, but I'm not sure.

[According to John, the problem is malloc() in the named code. He
 also suggests using Berkeley's bind, which he has ported and can be
 ftp'ed from ftp.egr.duke.edu, /archives/network/bind-4.8.3.tar.Z. -ed]

Two ptfs should fix this problem. Get U412332 and U414752.

Christophe Wolfhugel <Christophe.Wolfhugel@grasp.insa-lyon.fr> reports
that bind 4.9 works fine on AIX 3.2 and without MALLOCTYPE=3.1.


1.601: How do I trace ethernet packets on an AIX system?
From: afx@muc.ibm.de (Andreas Siegert)

Do the following:

     iptrace -i en0 /tmp/ipt

The iptrace backgrounds.  Find its process id and kill it when you are
ready.  Then run

     ipreport -rns /tmp/ipt >/tmp/ipr

and look at the output.  The current version of Info does not document
the r, n and s options but they are quite useful for layering the output.


1.602 What is the authorized way of starting automount at boot time?
From: curt@ekhadafi.austin.ibm.com (Curt Finch)

I put this in my /etc/inittab:

automount:2:once:/usr/etc/automount -T -T -T -v >/tmp/au.se 2>&1

I hereby dub it authorized.


1.603: How do I set a tty port for both dial-in and dial-out?

Set the mode of the tty to be either 'shared' or 'delayed'. 


1.604: How to move or copy whole directory trees across a network

The following command will move an entire directory tree across a network 
while preserving permissions, uids and gids.

      $rsh RemoteHost "cd TargetDir; tar -cBf - ." | tar -xvBf -

Explanation:

The tar-create is rsh'd to the remote system and is written to
stdout (the pipe).

The local system is extracting the tar that is being read from
stdin (the pipe).


1.605: How can I send mail to hosts that cannot be pinged?
From: jupiter.sun.csd.unb.ca!dedourek (John DeDourek)

AIX 3.2 as shipped is configured to only send mail to mail addresses
which include a host name.  Many organizations use a mail address whose
"host name" part is not a host name (technically an MX name).  To change
the configuration of the AIX mailer, login as root.  Then edit the file
/etc/sendmail.cf to remove the comment marker ("# ") at the beginning of
the line which reads:
    # OK MX

Now rebuild the machine readable form of the configuration with
    sendmail -bz

and finally restart signal sendmail to load the new configuration by one
of the following:
     reboot
or
     stopsrc -s sendmail
     startsrc -s sendmail
or 
     kill -1 `cat /etc/sendmail.pid`


1.606: How to configure dialup SLIP

IBM's WWW page <URL:http://www.ibm.com/> can lead you to a helpful document
<URL:http://www.austin.ibm.com/pub/www/services/aix_service/faxes/SLIP.DOC.zap>

From: marvin@tornado.oche.de (Christian Bode)

If you don't have problems with slattach you should have PTF 
bos.obj 3.2.0.0.U411505 installed.  I assume that you did the right
ifconfig commands to setup your slip-device (for example sl0).

1. Create a group called slip.

2. Create a user slip with smit like this:
                                                     [Entry Fields]
* User NAME                                          [slip]
  ADMINISTRATIVE User?                                true
  User ID                                            []
  LOGIN user?                                         true
  PRIMARY group                                      [slip]
  Group SET                                          [slip]
  ADMINISTRATIVE groups                              [system]
  SU groups                                          [slip]
  HOME directory                                     [/home/slip]
  Initial PROGRAM                                    [/bin/sh]
  User INFORMATION                                   [SLIP-Dialup]
  Another user can SU to user?                        false
  User can RLOGIN?                                    true
  TRUSTED PATH?                                       nosak
  Valid TTYs                                         [/dev/tty1]
  AUDIT classes                                      []
  PRIMARY authentication method                      [SYSTEM]
  SECONDARY authentication method                    [NONE]
  Max FILE size                                      [2097151]
  Max CPU time                                       [-1]
  Max DATA segment                                   [262144]
  Max STACK size                                     [65536]
  Max CORE file size                                 [2048]
  Max physical MEMORY                                [65536]
  File creation UMASK                                [022]
  EXPIRATION date (MMDDhhmmyy)                       [0]

3. Create a tty with getty on it:
                                   Add a TTY
                                               [Entry Fields]
  TTY type                                     tty
  TTY interface                                rs232
  Description                                  Asynchronous Terminal
  Parent adapter                               sa0
* PORT number                                  [s1]
  BAUD rate                                    [38400]
  PARITY                                       [none]
  BITS per character                           [8]
  Number of STOP BITS                          [1]
  TERMINAL type                                [dumb]
  STATE to be configured at boot time          [available]
  DMA                                          on
  Read Trigger                                 0,1,2,3
  Transmit buffer count                        [16]
  Name of initial program to run               [/etc/getty]

  Note: The following attributes are only applicable if /etc/getty is
        specified as the initial program to run.

  Enable program?                              respawn
  Run level                                    2
  Enable LOGIN                                 share
  TIME before advancing to next port setting   [0]
  STTY attributes for RUN TIME                 [hupcl,cread,brkint>
  STTY attributes for LOGIN                    [hupcl,cread,echoe,>
  RUN shell activity manager                   no
  Optional LOGGER name                         []

4. Change the hardware characteristics so that it uses NO XON/XOFF handshake
   section 1.613 also talks about tty flow control.

5. Here is the the .profile for User slip to manage dialups

#!/bin/ksh
# SLIP login .profile
# Adapted from comp.unix.aix FAQ
# by Davide Migliavacca 
#    davide.migliavacca@inferentia.it,
#    100016.2335@compuserve.com
# Version 1.0 1995-05-16

# NOTE: script currently determines destination IP address from
# the DNS database (set the DNSDBFILE below). It should be
# possibile to work this out with lsdev/lsattr, so if someone
# manages to do it, please let me know.  Without device
# configuration support, you must have a DNS entry for each
# user (used as symbolic host address) and every user is tied
# to a particular port/address.  E.g: user fooslip is host
# fooslip (address 222.222.222.222). This script works on the
# line which has as destination address 222.222.222.222
# ONLY. If the user logins on a different line, it won't work
# (in part at least).

### SET THIS TO YOUR DNS DB FILE
DNSDBFILE='/usr/local/etc/db.inferentia'


PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:/usr/local/bin:.

export PATH ENV HISTSIZE
#
# Search for a LCK-File for our tty if there is one
#
TTYDEV=`tty`
TTYBASENAME=`basename $TTYDEV`

if [ -f /etc/locks/LCK..$TTYBASENAME ];
then SHPID=`cat /etc/locks/LCK..$TTYBASENAME`;
else {
/usr/bin/logger -t SLIP -p error "No LCK file for $TTYDEV"
 exit 64;
}
fi;

#
# Search for our own Shell to get the PID for checking against LCK-File
#

SH2PID=`ps -aef |
        sed -n -e "s/^ *$USER  *\([0-9][0-9]*\) .*-.*sh *$/\1/p`

#
# Is it the the same PID as in the LCK File so that we can start working ??
DEBUG=0
if [ $DEBUG -eq 1 ]
then
echo TTYDEV: $TTYDEV
echo TTYBASENAME: $TTYBASENAME
echo USER=$USER
echo SHPID: $SHPID
echo SH2PID: $SH2PID
fi
if [ $SHPID -eq $SH2PID ]
then
#  remove the LCK-File because slattach does not like it.
   rm -rf /etc/locks/LCK..$TTYBASENAME
#  Add RTS/CTS Handshakeing to our own tty:=20
#  note dm: Better do it in /etc/rc (once and for all)! using addrts
#  stty add rts
#  Startup slattach. Slattach has to have mode 4755 to be started up !!!
#  note dm: this is quite a kludge. If someone finds a way to get the
#  destination IP address from the device configuration data (it should be 
#  possible, just terribly tedious), PLEASE let me know!
   IPADDRESS=`cat $DNSDBFILE | grep $USER | awk '{print $4}'`
   echo SLIP starting. Your IP address is $IPADDRESS
   /usr/sbin/slattach $TTYBASENAME
# Get the pid of slattch so that we can kill him later on.
   SLPID=`ps -aef |
  sed -n -e "s/^ *$USER  *\([0-9][0-9]*\) .*-.*\/usr\/sbin\/slattach $TTYBASENAME *$/\1/p`
#  Just say that we are up.
   logger -t SLIP -p info "$USER: Starting up daemon (pid $SLPID) for [$IPADDRESS] on $TTYDEV"
else
# Something must be wrong with the LCK-File
  SH3PID=`ps -aef | awk ' {print $2}' | grep $SHPID`

  if [ ."$SH3PID" = ."" ]
  then
    SH3PID="NO_SUCH_PROCESS"
  fi

  if [ $SHPID = $SH3PID ]
    then
#  There is a living process which owns the LCK-File !!
 /usr/bin/logger -t SLIP -p error "$USER: Cannot remove LCK file for $TTYDEV (not owner)"
       exit 64
    else
#   Who the hell didn't remove the LCK-File (should never happen)
 /usr/bin/logger -t SLIP -p error "$USER: LCK file for $TTYDEV found with no owner"
       exit 64
    fi
fi

if [ $DEBUG -eq 1] 
then
 /usr/bin/logger -t SLIP -p debug "$USER: going to trap signals..."
fi
# Kill slattach if we get a signal 1 (Carrier Lost ? / Otherside-slattach
# terminated )
trap "kill $SLPID; /usr/bin/logger -t SLIP -p info \"$USER: Killing daemon (pid $SLPID) for $TTYDEV\"; exit 0" 1 

if [ $DEBUG -eq 1] 
then
 trap "/usr/bin/logger -t SLIP -p debug \"$USER: trap ERR\"" ERR
 trap "/usr/bin/logger -t SLIP -p debug \"$USER: trap 0\"" 0
 trap > /tmp/trap.$TTYBASENAME.log
 /usr/bin/logger -t SLIP -p debug "$USER: trap returns $?..."
fi

# We  will have a nice sleep and nice dreamings
if [ $DEBUG -eq 1] 
then
 /usr/bin/logger -t SLIP -p debug "$USER: going to sleep-loop..."
fi

while [ true ];
do
sleep 60;
done

# Sanity check (should never happen...)
/usr/bin/logger -t SLIP -p error "$USER: ERROR: .profile broken"


Here's another scenario:
From: oosten@angelo.ee.ualberta.ca (Brian Oostenbrink)

Operating System: IBM AIX 3.2.1 and 3.2.3

Configuring two RS6000s via a Serial Line Interface Protocol (SLIP) 
connection over two US Robotics Sportster 14,400 modems.

The AIX implementation of SLIP is slightly different from most others. 
The ifconfig command is used to bring up a serial interface, and the
slattach command is used to connect the interface to the serial port
used for the connection.  Dialer device commands can also be issued when
invoking the slattach command, using UUCP chat syntax.

The following describes a connection between two machines:

     local.j.k.l
         ethernet IP address 129.128.127.21
         slip interface IP address 129.1.2.1

     remote.a.b.c
         ethernet IP address 129.11.22.44
         slip interface address 129.11.22.1

1. Interface configuration

Each machine must have a separate IP address dedicated to the SLIP
interface. On remote.j.k.l, start the SLIP interface with:

         ifconfig sl0 129.11.22.1 129.128.127.1  up

and on local.a.b.c:

         ifconfig sl0 129.128.127.1 129.11.22.1  up

It is important in later versions of AIX 3.2.3+ to use the same SLIP
interface # as the ptty port #, ie. if you use tty12, use ifconfig sl12
instead of sl0.

At this point the interfaces are ready to be connected.

2. tty configuration
   The tty ports on both machines were configured in an identical manner
   using smit.
                                                 [Entry Fields]
 TTY type                                           tty
 TTY interface                                      rs232
 Description                                        Asynchronous Terminal
 Parent adapter                                     sa0
 PORT number                                        []                       +
 BAUD rate                                          [38400]                  +
 PARITY                                             [none]                   +
 BITS per character                                 [8]                      +
 Number of STOP BITS                                [1]                      +
 TERMINAL type                                      [dumb]
 STATE to be configured at boot time                [available]              +
 DMA                                                on                       +
 Read Trigger                                       0,1,2,3
 Transmit buffer count                              [16]                      #
 Name of initial program to run                     [etc/getty]

 Note: The following attributes are only applicable if /etc/getty is specified
 as the initial program to run.

 Enable program?                                    respawn
 Run level                                          2
 Enable LOGIN                                       disable                  +
 TIME before advancing to next port setting         [0]                      +#
 STTY attributes for RUN TIME                       [hupcl,cread,brkint,icr>
 STTY attributes for LOGIN                          [hupcl,cread,echoe,cs8,>
 RUN shell activity manager                         no                       +
 Optional LOGGER name                               []

On older versions of AIX, we encountered some problems disabling getty, and
resorted to changing the /etc/inittab file directly. For example, change

   tty0:2:respawn:/etc/getty /dev/tty0
to
   tty0:2:off:/etc/getty /dev/tty0

This will disable getty from running. After creating the SLIP tty device,
you will need to change its hardware configuration to disable Xon/Xoff
flow control. Software flow control should not be used for SLIP. Type
'smit chtty', and then select sub item 2: Hardware settings.

Most of the parameters in the tty configuration are the defaults.

3. Modem Configuration

   The modems were configured as follows:

   RTS/CTS flow control enabled.
   Xon/Xoff software flow control disabled. Usually this is automatic if
      RTS/CTS is enabled.
   Data rate, terminal to modem = fixed.
      This is the baud rate from the tty port to the modem. We used a
      fixed modem-port transfer rate, set to the fastest speed supported
      by both the tty port and the modem. Newer modems can use a higher
      transfer rate between the modem and serial port than the modem to
      modem rate, which is necessary to use data compression effectively.  
      In our setup, we used 14.4 kBaud modems with a port speed of 38.4
      kBaud. If your modem supports this feature, use it, otherwise set
      the port speed equal to the modem connection rate. On the USR
      Sportster at&b1 fixes the serial port rate to that of the last
      AT command. The speed parameter of the slattach command can be
      used to ensure that this rate is that set in the tty configuration.
   Error Correction enabled - not mandatory, but a good idea
   Data Compression - not required, but it helps, especially for text
      transfers.
   Auto Answer - If the SLIP connection is to be initiated from either
      machine, both modems should be set to auto answer, otherwise, just
      the answering modem.

   It is a good idea to configure the modem and then save the settings
   to NVRAM, so that the correct settings can always be restored by the
   slattach command.

4. UUCP configuration files

   /usr/lib/uucp/Devices
   /usr/lib/uucp/Dialers

   The Devices file must contain an entry with the tty and serial port
   speed used for the interface. In our example,
      Direct tty0 38400 slipdialer

   The keyword 'slipdialer' is merely an index into the Dialers file.
   For our purposes, the slipdialer entry in the Dialers file is simply:

      slipdialer

   This entry can also contain UUCP chat commands, or the chat commands
   can be included in the slattach command.

5. slattach invocation

   slattach connects the device on the tty port to the SLIP interface
   created by ifconfig, and sends any commands to the tty device if
   needed. For our example, remote.j.k.l would never initiate a call,
   only answer incoming calls. Therefore we execute:

         slattach tty0 38400 '"" ATZ OK ""'

   which connects the tty at 38400 baud. We could also simply run

         slattach tty0

   ie. without any modem commands, but the modem to port speed may not
   be correctly set this way. In addition, the ATZ command ensures the
   modem is set to the NVRAM settings.

   On local.a.b.c type:

         slattach tty0 38400 '"" ATZ OK \pATDT4925871 BIS ""' 4

   This establishes the link at 38400 baud, and executes the dial string
   as shown. The dial string is a UUCP chat string and are configured
   in an expect send expect send ... format. The string:

         '"" ATZ OK \pATDT4925871 BIS ""'

   is interpreted as:
   expect "" (null string) from modem
   send   ATZ              to modem
   expect OK               from modem
   send   \pATDT4925871    to modem
   expect BIS              from modem

   BIS is the end of the CONNECT STRING. You could use any portion of
   the string returned by the modem upon a connection as the expect
   string. It may be wiser to simply expect CONNECT since all
   connections should return this string.
   The null strings are necessary because the first parameter of the
   UUCP is an expected string from the modem, which can only be a null
   string until the modem has been given a command.

   The last parameter (4) of the slattach command is the debug level. 
   A debug level of 4 displays the UUCP chat strings, which is useful
   for checking the modem status.

6. Routing
   ifconfig is sufficient if all you want to do is talk between the
   two hosts.  If you are running SLIP so that you can talk to more
   than just that one other host you have to advertise your address.
   
   1) arp -s 802.5 iago 10:00:5a:b1:49:d8 pub
        where 802.5 is a token-ring network the hardware address can
        be obtained with `netstat -v` and iago was the SLIP client (My
        PC at home :)  pub is the important part it means "published"
        You may want to run this at boot time. 

   Routing through the SLIP link is similiar to routing of any gateway. 
   Invoking the ifconfig command automatically sets up a route between
   the two SLIP machines. An entry in /etc/hosts or the named database
   should be made, with the same machine name used for the SLIP address
   as the ethernet address on each machine. For example, in /etc/hosts
   on remote.a.b.c (and any other machine on remote.a.b.c ethernet):

     129.11.22.44 remote.a.b.c # ethernet address
     129.11.22.1  remote.a.b.c # slip address

   It is preferable to place the ethernet address in the hosts file
   before the SLIP address so remote.a.b.c will resolve to the
   ethernet address. When using named, it is important to have both
   addresses in the reverse file with the same name. We experienced
   difficulties with NFS mounting over the slip link, owing to some
   machine interpreting NFS requests from one of the two SLIP machines
   as coming from the SLIP address, while the SLIP machine believed it
   was sending the request from the ethernet address. This problem was
   eliminated by having both addresses reverse resolve to the same name.

7. Performance
   At a modem speed of 14.4 kBaud and a port speed of 38.4 kBaud, we
   realized a transfer rate through ftp of about 3.5 kB/s for text
   files, and 1.3 kB/s for compressed files.


1.607: Where is DCE discussed?

DCE is the Distributed Computing Environment, which is roughly a
flexible client-server architecture for heterogenous platforms.
For more information, take a look in comp.soft-sys.dce.


1.608: How do I make /var/spool/mail mountable?
From: petersen@pi1.physik.uni-stuttgart.de (Joerg Petersen)

In our cluster we share a /usr/local disk. We have a directory
/usr/local/spool/mail and /var/spool/mail is soft-linked to it.

From: fred@hal6000.thp.Uni-Duisburg.DE (Fred Hucht)

Several problems has been reported on sharing the mail directory via
NFS. The problems may occur when two or more sendmail daemons and/or
mail readers access a user's mail file simultanously, because of NFS'
file locking mechanism.

We use another method here: Every user has one line in his/her
$HOME/.forward file that reads

xxx@mainserver.domain.name

where xxx is the user node and mainserver.domain.name is the full
hostname of one of the machines. Then all incoming mail to all machines
is forwarded to mainserver, while mainserver ignores this line.


1.609: getty spawning too rapidly 
thanks to aslam@abaseen.lums.edu.pk (Sohail Aslam)

The problem can occur due a number of modem settings. The most
frequent is that the echo is not disabled on modems that are to
accept incoming calls. In hayes language, ATE0 disables echo.
If echo is enabled, the login prompt sent by the DTE (computer)
is echoed back to it. It then issues "password:" prompt which
the modem conveniently echoes back again. And the cycle goes on.

Another setting to check is the Q registers which controls the
modem's response to the DTE. The hayes command ATQ0 enables
results codes. The Q register in conjunction with the X and
the V registers, reports back to the DTE the status of the incoming
or outgoing call, and the type of connection established. For
outgoing calls, one would want to enable result codes but not
for incoming calls. If codes are enabled (via ATQ0), when a
call comes in, the modem will send strings (if ATV1 and ATX4 set)
"RINGING", "CONNECTED" etc. to the local DTE. The getty will think
some one is trying to login. It will send password prompt. Trouble
again. Telebit and other intelligent modems has ATQ2 setting
which says "reports codes only when calling out." For others,
you will need to disable it (ATQ1) and enable when calling out.

The DSR setting can be a source of problem. Ideally, modem should
raise DSR only when CD is detected and modem raises CTS. Computer,
such as the VAX, wait 30 seconds after the modem raises DSR. If
CD is not on by that time, the computer will drop DTR causing the
modem to reset. The DSR should be set to be raised only when
carrier has been detected. The hayes setting is AT&S1.

The DCD setting should be such that it reflects the true nature of
the carrier. The CD can be forced on at all times (AT&C0). This
is not good. Set it to AT&C1.

Most modems can reload saved settings from non-volatile memory
on a DTR transition. This is useful for resetting the modem
when a call drops. Use AT&D3 to get this effect. 

For dial in, thus, set AT E0 Q1 &C1 &D3 &S1 &W. The &W stores the
settings in memory. They will be reloaded due to &D3.


1.610: Does AIX support Compressed SLIP (CSLIP)?

No.  That means no VJ compression either :)  See PPP in section 5.07 
if you want more than standard SLIP.


1.611: How do I setup anonymous ftp on my AIX system?
(stolen from Peter Klee <klee@dhdibm1.bitnet> posting)

Have a look at '/usr/lpp/tcpip/samples/anon.ftp'. It is a shell script
and will set up a anonymous ftp site on your local RS/6000.  Note: the
ftpd that comes with AIX does not support the display messages every
time a user changes a directory or even when they login.

1.612: Talk, getting notification.

If you are not getting notification (that someone wants to talk to
you), use (swcons `tty` && mesg y) in one window.

There are many variations of 'talk' and finding compatible versions
for multiple operating systems can be tricky.

1.613: Disabling software flow control; using RTS/CTS.

Different versions of AIX 3.2.5 respond differently to attempts to
enable flow control (RTS/CTS signals).  This section is an attempt to
compile a list of different approaches.

The most straight forward is:
   chdev -l ttyxx -a rts=yes
   [ Note: ix40410 for AIX 3.2.5 should give you this functionality.  
   PTF U426113 and numerous other superceding ptfs should provide this.]

If carrier signal is high (its connected) you can try
   stty add rts </dev/ttyxx 

There is also a program that I first saw on the 800-IBM-4FAX number,
also found in INFO that will remedy the situation in some cases.  Note
that this code ignores the return code from ioctl (which on my machine
is <0 :)

/* This program is an adaptation of a program provided by IBM Defect Support.
   It is provided without warrantee, or support.

   The syntax of the command is:

 setrts tty [tty [tty [...]]]

   The program will loop through each tty provided on the command line, and 
   turn on the 'rts' line discipline.  The program does not require that
   the Carrier Detect signal be held high to keep the serial device from 
   blocking on the attempt to open it.  The program works for all valid ttys.

   BUGS: None that are known; however, using the program to set 'ptys' may
   cause the 'pty' to become unusable.

   This program was written by Robin D. Wilson, Pencom Software (with the
   specific 'ioctl()' call provided by the IBM Defect Support Center.

   I call it: "setrts"
   
   To compile:
   cc -O -o setrts setrts.c
   strip setrts
   
   (Funny, but if you strip with the compiler (i.e., cc -s), you end up with
   120 extra bytes in the executable...)
*/

#include <stdio.h>
#include <fcntl.h>
#include <termios.h>
#include <sys/tty.h>
#include <string.h>
#include <sys/param.h>
#include <unistd.h>

#define DEVDIR  "/dev/"
#define LINEDISP "rts"

main (argc, argv)
int argc;
char **argv;
{
 int tty;
 char ttyname[MAXPATHLEN];

/* Give a 'usage' recommendation if they don't provide an argument */
 if (argc < 2) {
    fprintf(stderr, "usage: %s <ttyn> [ttyn [ttyn [...]]]\n",argv[0]);
    exit(-1);
 }
 /* Otherwise, loop through all the arguments... */
 else while (--argc >= 1) {
  argv++;
 /* Check to see if they input the 'tty' names with the DEVDIR on them...
 * If not, put it on...
 */
  if (strncmp(DEVDIR, argv[0], strlen(DEVDIR)) != 0) {
   strcpy(ttyname, DEVDIR);
   strcat(ttyname, argv[0]);
  }
  else
   strcpy(ttyname, argv[0]);

/* Open the tty.  Use the non-blocking open (O_NDELAY) to open without a 
 * carrier (CD) present on the line...
 */
  if ((tty = open(ttyname, O_RDWR|O_NDELAY)) < 0) {
     fprintf(stderr, "%s: couldn't open tty device.\n",ttyname);
     exit (-2);
  }
 /* Add the 'rts' line discipline... */
  (void)ioctl(tty, TXADDCD, LINEDISP);
  (void)close(tty);
 }
}


1.614+ NIS security
Ole.H.Nielsen@fysik.dtu.dk (Ole Holm Nielsen)

SUMMARY: AIX 3.2.4 and above includes support for a more secure setup
of the ypserv NIS daemon.  You can prevent any random host on the
entire Internet from reading your NIS maps, as is possible with the
default AIX setup.
 
The details:
------------
After starting the ypserv daemon, I noticed in the syslog the following line:
Jan 17 12:01:18 zeise syslog: /usr/etc/ypserv: no /var/yp/securenets file 
This indicates that ypserv is looking for the mentioned configuration
file, but did not find it, and hence will deliver the NIS maps to
anyone on the net who can guess the NIS domainname.  I installed the
/var/yp/securenets file and restarted ypserv, and it works !  Any
illegal attempt to read NIS maps will result in the following getting
logged to syslog (example):
Jan 18 13:37:27 zeise syslog: ypserv: access denied for 129.142.6.79 

How to enable this NIS security option:  
Install the /var/yp/securenets file, for example:

# /var/yp/securenets file
#
# The format of this file is one of more lines of
# netmask netaddr
# Both netmask and netaddr must be dotted quads.
#
# Note that for a machine with two Ethernet interfaces (i.e. a gateway
# machine), the IP addresses of both have to be in /var/yp/securenets.
#
# for example:
#255.255.255.0 128.185.124.00
# Loopback interface
255.255.255.255 127.0.0.1

Uncommenting the last line would limit access to hosts on the
128.185.124.*  net, only.  The loopback interface must be included, as
shown above.

To log violations, have a /etc/syslog.conf file containing the proper
events.  We use this line:

*.err;kern.debug;auth.notice;user.none          /var/adm/messages

Caveat emptor:  This works for us, and you will have to verify it at
your own installation.  Don't complain to us if you have troubles.  
I do not know what PTF level our AIX 3.2.4 is at.  Our ypserv daemon 
looks like this:

zeise> strings /usr/lib/netsvc/yp/ypserv | head -2
@(#)16
1.12  com/cmd/usr.etc/yp/ypserv.c, cmdnfs, nfs325, 9334325a 5/4/93 19:44:41

If your AIX doesn't have securenets support, ask your support centre
for the PTF which includes APAR IX32328.  That seems to have included
the securenets support.


1.615: Why can't non-anonymous users login using WU-FTP?
From: swcxt@boco.co.gov (Shane Castle)

You must create a file named /etc/shells (this is the real /etc not a
subdirectory of your false root), that contains all the shells that
are defined on your system.  Get the list from
/etc/security/login.cfg.  Also, if having proper group authentication
is important to you, apply the following patch:

--- ftpd.c.dist Wed Apr 13 15:17:18 1994
+++ ftpd.c Tue Jan 17 13:29:58 1995
@@ -1153,7 +1153,13 @@
        setgroups(NULL, NULL);
        if (setpriv(PRIV_SET|PRIV_INHERITED|PRIV_EFFECTIVE|PRIV_BEQUEATH,
                    &priv, sizeof(priv_t)) < 0 ||
-           setuidx(ID_REAL|ID_EFFECTIVE, (uid_t)pw->pw_uid) < 0 ||
+           initgroups(pw->pw_name, (gid_t)pw->pw_gid) < 0 ||
+           setgidx(ID_REAL|ID_EFFECTIVE, (gid_t)pw->pw_gid) < 0 ||
+           setegid((gid_t)pw->pw_gid) < 0) {
+               reply(550, "Can't set gid (AIX3).");
+               goto bad;
+       }
+       if (setuidx(ID_REAL|ID_EFFECTIVE, (uid_t)pw->pw_uid) < 0 ||
            seteuid((uid_t)pw->pw_uid) < 0) {
                reply(550, "Can't set uid (AIX3).");
                goto bad;


1.616: NIS users can't login, do I need '*' in /etc/passwd?
From: ohnielse@fysik.dtu.dk (Ole Holm Nielsen)

Aparently at least one version of AIX InfoExplorer suggests
administrators use "+:*:0:0:::" as the last entry in the /etc/passwd
file of NIS clients for security reasons.  If the configuration SMIT
is done using SMIT it will actually append "+::0:0:::" which works and
does not compromise security.  Using the '*' in the passwd field
actaully prevents NIS users from logging in.

"+::0:0:::" should not allow you to login as user "+" and without a
password even when NIS is disabled, but it never hurts to double
check.

rbogue@entropy.phy.ilstu.edu (Ross Bogue) has suggested that
"+::-2:-2:::/bin/false" is even more secure.


1.617: HP JetDirect cards and virtual printers?  mkvirprt problems?
(stolen from many)

Since the release of AIX 3.2.5 adding a queue for JetDirect cards is
as easy as creating a virtual printer using "smit mkvirprt" or
/etc/mkvirprt.  If the command hangs make sure you are using an
HFT, aixterm or vt100 terminal.  The entire procedure is available
from the IBM FAX "Information Line" (800 IBM-4-FAX).


1.618: How can I hack libc.a to alter how hostnames are resolved?
(From: <mlarsen@ptdcs2.intel.com> "L. Mark Larsen")

[ 
  Editors note:  The implications of corrupting libc.a should not be
  understated.  While recovering from a corrupt libc.a should be a
  matter of booting from floppy I wouldn't wish that on anyone with a 
  supervisor or users to support :)

  enough of the weak kneed quivering...
]

Nate Itkin (a colleague) is the individual who did the initial work.
I suspect he would rather not be troubled with any questions you may
have in this area and I can probably answer them just as easily.  The
motivation for this was to use DNS for MX records (we are using IDA
sendmail) but NIS for most hostname lookups.

Secondly, warnings:  IBM has not given any sort of stamp of approval on what
we have done (though they appear to have integrated resolv+ into AIX 4 based
on some release notes I saw).  While we have been using it successfully for
about one year and have seen no problems, we can't and won't promise the same
for you.  This procedure plays around with libc.a which, as you probably know,
is an XCOFF shared library under AIX and hence a critical part of the running
system.  You assume all the risk if you try to install this.  All the usual
disclaimers about liability, etc. apply - there is no warranty associated with
any of this.

Furthermore, know that any PTF you subsequently install that updates/replaces
libc.a implies that you have to execute most of these procedures again.

To use resolv+ under AIX 3 (we've only done this under 3.2.5 but I would
think it should work for all point releases), here is what you have to do:

1. get the resolv+ source (I see a copy on ftp.uu.net in networking/ip/dns
   and there are likely copies elsewhere).  We are using version 2.1.1,
   which appears to be the latest available.  gethostnamadr.c needs a couple
   of additions:

 23a24,26
 > #ifdef _AIX
 > #include <sys/time.h>
 > #endif
 35a39,41
 > #ifdef _AIX
 > #include <sys/ioctl.h>         /* for SIOCGIFCONF */
 > #else
 36a43
 > #endif

2. Use the following instead of the supplied shlib/Makefile:

LIBP= gethostnamadr.o herror.o res_data.o res_query.o res_mkquery.o \
 sethostent.o res_send.o res_debug.o res_comp.o res_init.o
CFLAGS= -O -D_BSD=43 -D_NO_PROTO -DNIS -DDEBUG -U__STR__

all: shr.o 

shr.o: $(LIBP) setup 
 ld -o $@ /lib/syscalls.exp $(LIBP) tmp.o -bM:SRE -bE:shr.exp -bE:/lib/syscalls.exp -bI:crypt.imp -H512 -T512 -bh:4 -lc

setup:
 rm -f libc.a crypt.imp
 cp /lib/libc.a .
 chmod 755 libc.a
 ar xv libc.a shr.o
 /bin/dump -nv shr.o | grep EXP | awk '{print $$NF}' > shr.exp
 ld -o tmp.o -bnso shr.o -r
 @ echo '#!' > crypt.imp
 @ echo __crypt >> crypt.imp
 @ echo __setkey >> crypt.imp
 @ echo __encrypt >> crypt.imp
 
clean:
 rm -f shr.o tmp.o crypt.imp shr.exp $(LIBP) libc.a

install_libc: install_libc.c
 cc -o $@ install_libc.c -bnso -bI:/lib/syscalls.exp

herror.o: ../herror.c
 $(CC) $(CFLAGS) -c ../herror.c

res_comp.o: ../res_comp.c
 $(CC) $(CFLAGS) -c ../res_comp.c

res_debug.o: ../res_debug.c
 $(CC) $(CFLAGS) -c ../res_debug.c

res_data.o: ../res_data.c
 $(CC) $(CFLAGS) -c ../res_data.c

res_init.o: ../res_init.c
 $(CC) $(CFLAGS) -c ../res_init.c

res_mkquery.o: ../res_mkquery.c
 $(CC) $(CFLAGS) -c ../res_mkquery.c

res_query.o: ../res_query.c
 $(CC) $(CFLAGS) -c ../res_query.c

res_send.o: ../res_send.c
 $(CC) $(CFLAGS) -c ../res_send.c

gethostnamadr.o: ../gethostnamadr.c
 $(CC) $(CFLAGS) -c ../gethostnamadr.c

sethostent.o: ../sethostent.c
 $(CC) $(CFLAGS) -c ../sethostent.c

strpbrk.o: ../strpbrk.c
 $(CC) $(CFLAGS) -c ../strpbrk.c

strerror.o: ../strerror.c
 $(CC) $(CFLAGS) -c ../strerror.c

3. As shipped, IBM's /lib/syscalls.exp contains an entry for fork().  This
   needs to be removed as it will cause the new shr.o to use the system call
   entry point rather than the library wrapper and this can cause some rather
   odd behavior.  For example, I ran across one using the '!' command in vi
   where the error/informational messages were corrupted.

4. You can use "ar r libc.a shr.o" but that will leave a big hole in libc.a,
   since the new shr.o is slightly bigger than the original.  I always extract
   all the .o's from libc.a and build a brand new one - suit yourself.

5. Before the next step, you'll want to set up the two configuration files.
   The first is /etc/resolv.conf and it is basically the same as before
   except for the new keyword "search" - intended to replace the "domain".  See
   the resolver.5 manual page for details (included with the resolv+ source).
   The other file is /etc/host.conf, which is where you set the order of
   search.  See resolv+.8 for information on this.

6. Now, the only tricky part left is to get the new libc.a installed.  You'll
   note the Makefile has a target for install_libc.  Just put the following
   in install_lib.c and run "make install_libc" to build.

------------------------------- begin install_libc.c -------------------------
#include <stdio.h>

static char *nodns[] = { "/usr/ccs/lib/libc.a" , "/usr/ccs/lib/libc.a.ORIG" };
static char *hasdns[] = { "/usr/ccs/lib/libc.a.NEW" , "/usr/ccs/lib/libc.a" };

#define OLD     (0)
#define NEW     (1)

main()
{

 if(link(nodns[OLD],nodns[NEW])) {
  perror("link");
  exit(1);
 }

 if(unlink(nodns[OLD])) {
  perror("unlink");
  exit(1);
 }

 if(link(hasdns[OLD],hasdns[NEW])) {
  perror("link");
  exit(1);
 }

 if(unlink(hasdns[OLD])) {
  perror("unlink");
  exit(1);
 }

 exit(0);
}
------------------------------- end install_libc.c ---------------------------

7. You'll want to do this on a quiet machine.  Move the new libc.a to
   /usr/ccs/lib/libc.a.NEW, then run install_libc.  It is probably a good
   idea to reboot afterwords (though not strictly required).  We have a similar
   program called restore_libc (exercise for the reader) for backing out the
   change.

   Rather than do this on every machine (we have 170+ RS/6000's), I simply
   put this new libc.a into my network-installable image, which I blasted
   out over the year-end holiday break (I created a method for loading a new
   image onto machines without having to boot off of floppies and turn keys).

   Of course, for the really cautious, you can always make the change after
   booting off of the maintenance floppies...


1.619: What modem settings do I need?

ATQ2  - result codes in originate only
AT&C1 - CD follows state of carrier 
AT&D2 - hangup on DTR drop


1.620: NIS slave server config with master on different subnet?
From: msidler@metronet.com (Mike Sidler)

Assuming AIX 3.2.5,the master server up and running and the hosts file
has the master name defined. On slave do:

    1) domainname <domain_name that matches master>
    2) startsrv -s ypserv
    3) startsrv -s ypbind (ypwhich should return "loopback")
    4) (/usr/sbin/)ypset -d <domainname> <master_server_name>
       (ypwhich should return "<master_server_name>"
    5) (/usr/sbin/)ypinit -s <master_server_name>
    6) Put "+::0:0:::" in /etc/passwd after last local login. 
       Note: InfoExplorer has this entry INCORRECT in some versions.
    7) Other cfg files (group, etc) may need configuring but this will
       get ypserv and ypbind running on the slave looking at the right stuff.


______________________________________________________________________________
1.701: How do I shrink /usr?
From: mike@bria.UUCP (Michael Stefanik) and Richard Hasting

FOR AIX 3.1
-----------

 1) Make a backup of /usr

        find /usr -print | backup -ivf /dev/rmt0 (or appropriate device)

 2) shutdown to maintenance mode

        shutdown -Fm
 
 3) export LANG=C
 
 4) remove the filesystem and the logical volume
    ignore an error about the "dspmsg" command not found

        umount /usr
        rmfs /usr

 5) make a new logical volume hd2 and place it on rootvg with desired size

        mklv -yhd2 -a'e' rootvg NNN 

   where NNN is the number of 4 meg partitions

 6) create a filesystem on /dev/hd2

        crfs -vjfs -dhd2 -m'/usr' -Ayes -p'rw'

 7) mount the new /usr filesystem and check it

        /etc/mount /usr
        df -v

 8) restore from the tape; system won't reboot otherwise

        restore -xvf/dev/rmt0

 9) Sync and reboot the system; you now have a smaller /usr filesystem

FOR AIX 3.2
-----------

 0)  Experiences posted to comp.unix.aix lead me to suggest that
     many administrators find the following piece of information 
     useful after completing this procedure.  I thought some of you
     might like to read it BEFORE getting yourself into this
     predicament.  

     Call 1-800-IBM-4FAX and request document 2503 dated 1/26/94.  
     Title is "How to recover if all files are owned by root after
     restoration from a mksysb tape".

 1) Remove any unneeded files from /usr.

 2) Make sure all filesystems in the root volume group are mounted. If
    not, they will not be included in the re-installed system.

 3) Type mkszfile. This will create /.fs.size that contains a list of
    the active filesystems in the root volume group that will be
    included in the installation procedure.

 4) Edit .fs.size. Change the size of /usr to what you want.

    Example: This .fs.size file shows /usr to be 40MB.

 rootvg 4 hd2 /usr 10 40 jfs

    The 10 is the number of physical partitions for the filesystem and
    the 40 is 40 MB. Most systems have a physical partition size of 4 MB.
    Therefore, the second number (40) will always be 4 times the
    previous number (10). Note, however, that a model 320 with a 120 MB
    drive will have a physical partition size of only 2 MB, and the
    total MB is twice the number of physical partitions. The first
    number (4) in the .fs.size file represents the PP size.

    If you want to reduce the size of /usr from 40 MB to 32 MB, edit the
    /usr entry to:

        rootvg 4 hd2 /usr 8 32 jfs

    IMPORTANT: Make sure that you DO NOT enter a value which is less
    than the size of the filesystem required to contain the current
    data. Doing so will cause the re-installation procedure to fail.

 5) chdev -l rmt0 -a block=512 -T

 6) Unmount all filesystems that are NOT in the root volume group.
 
 7) Varyoff all user-defined volume groups, if any

        varyoffvg VGname

 8) Export the user-defined volume groups, if any

        exportvg VGname

 9) With a tape in the tape drive, type

        mksysb /dev/rmt0

     This will do a complete system backup, which will include
     information (in the .fs.size file) for the installation procedure
     on how large the filesystems are to be created.

 10) Follow the instructions in the Installation Kit under "How to
     Install and perform maintenance from Diskettes" (reportedly now 
     called "BOS Installation from a System Backup") using the
     diskettes and tape that you created in the previous steps.

     [ pre AIX 325: DO NOT select the option "Reinstall AIX with
     Current System Settings". Instead use "Install AIX with Current
     System Settings" for the logical volume size changes to take affect. ]

     [ w/ AIX 325: Select "Install from a mksysb image" ]

 11) When the installation is complete, you may then import any
     user-defined volume groups.

         importvg -y VGname PVname

     where "VGname" is the name of the volume group, and "PVname" is
     the name of any one of the physical volumes in the volume group.

 12) Varyon your user-defined volume groups

         varyonvg VGname

 The reduction of the filesystems is now complete.


1.702: How do I make a filesystem larger than 2Gb?

With AIX 4.1 IBM allows filesystems up to 64Gb (reference:
<URL:http://www.austin.ibm.com/announce.0725.html>).  Individual files are
still limited to 2Gb.

If you are having trouble creating a file greater than 1Mb it maybe
because that is the default limit for your account, see 'smit users'
or /etc/security/limit.

The largest filesystem under AIX is 2 Gigabytes because the largest
signed integer is 2**31 - 1.  This means that AIX 3.2.5 an versions
preceeding it are limited to 2Gb filesystems.  This obviously does not
include "non-filesystems"


1.703: Chlv warning.  Is the first 4k of a LV safe?

The first 4k of a raw LV are used to store control block.
Applications that write to the raw disk can overwrite this section
(common applications that do this are Oracle and Sybase).  Commands
that call getlvcb will generate a warning but succeed (since the
control block exists in ODM.  Don't run synclvodm unless you really
want to erase the first 4k and replace it with the info from the ODM.

shieh@austin.ibm.com (Johnny Shieh) has kindly provided the following
explanation:

The logical volume control block (lvcb) is the first 512
bytes of a logical volume.  This area holds important
information such as the creation date of the logical volume,
information about mirrored copies, and possible mount points
in a journaled filesystem.  Certain LVM commands are required
to update the lvcb, as part of completeness algorithms in
LVM.  The old lvcb area is first read and analyzed to see if
it is a valid lvcb.  If the information is verified as valid
lvcb information, then the lvcb is updated.  If the
information is not valid, then the lvcb update is not
performed and the user is given the warning message:

 Warning, cannot write lv control block data

Most of the time, this is a result of database programs
accessing the raw logical volumes (and thus bypassing the
journaled filesystem) as storage media.  When this occurs, the
information for the database is literally written over the lvcb.
Although this may seem fatal, it is not the case.  Once the
lvcb has been overwritten, the user can still:

 1) Extend a logical volume
 2) Create mirrored copies of a logical volume
 3) Remove the logical volume
 4) Create a journaled filesystem with which to mount
  the logical volume (note that this will destroy any
  data sitting in the lvcb area)

However, there is a limitation caused by this deletion of the
lvcb.  The logical volumes with deleted lvcb's face possible,
incomplete importation into other AIX systems.  During an
"importvg", the LVM command will scan the lvcb's of all defined
logical volumes in a volume group for information concerning the
logical volumes.  Surprisingly, if the lvcb is deleted, the
imported volume group will still define the logical volume to
the new AIX system which is accessing this volume group, and
the user can still access the raw logical volume.  However, any
journaled filesystem information is lost and the logical volume
and its associated mount point won't be imported into the new AIX
system.  The user must create new mount points and the availability
of previous data stored in the filesystem is NOT assured.  Also, during
this import of a logical volume with an erased LVCB, some non-jfs
information concerning the logical volume, which is displayed with
the "lslv" command, cannot be found.  When this occurs, the system uses
default logical volume information to populate the logical volume's
ODM information.  Thus, some output from the "lslv" will be inconsistent
with the real logical volume.  If logical volume copies still exist on
the original disks, this information will not be correctly reflected in
the ODM database.  The user should use "rmlvcopy" and "mklvcopy" to
rebuild any logical volume copies and synchronize the ODM.  Finally,
with an erased lvcb, the output from the "lslv" command might be
misleading or unreliable.


1.704: What's the limit on Physical Partitions Per Volume Group?
From: shieh@austin.ibm.com (Johnny Shieh)

In the design of LVM, each Logical Partition maps to one
Physical Partition.  And, each Physical Partition maps to a
number of disk sectors.  The design of LVM limits the number
of Physical Partitions that LVM can track per disk to 1016.
In most cases, not all the possible 1016 tracking partitions
are used by a disk.  The default size of each Physical
Partition during a "mkvg" command is 4 MB, which implies that
individual disks up to 4 GB can be included into a volume
group.

If a disk larger than 4 GB is added to a volume group (based
on usage of the default 4 MB size for Physical Partition) the
disk addition will fail with a warning message that the
Physical Partition size needs to be increased.* There are two
instances where this limitation will be enforced.  The first
case is when the user tries to use "mkvg" to create a volume
group where the number of physical partitions on one of the
disks in the volume group would exceed 1016.  In this case,
the user must pick from the available Physical Partition
ranges of:

1, 2, (4), 8, 16, 32, 64, 128, 256

Megabytes and use the "-s" option to "mkvg".  The second
case is where the disk which violates the 1016 limitation
is attempting to join a pre-existing volume group with
the "extendvg" command.  The user can either recreate the
volume group with a larger Physical Partition size (which
will allow the new disk to work with the 1016 limitation)
or the user can create a standalone volume group (consisting
of a larger Physical Partition size) for the new disk.

In AIX 4.1 and 3.2.5, if the install code detects that the
rootvg drive is larger than 4 GB, it will change the "mkvg
-s" value until the entire disk capacity can be mapped to the
available 1016 tracks.** This install change also implies
that all other disks added to rootvg, regardless of size,
will also be defined at that new Physical Partitions size.

For RAID systems, the /dev/hdiskX name used by LVM in AIX may
really consist of many non-4GB disks.  In this case, the 1016
limitation still exists.  LVM is unaware of the size of the
individual disks that may really make up /dev/hdiskX.  LVM bases
the 1016 limitation on the AIX recognized size of /dev/hdiskX,
and not the real independent physical disks that make up /dev/hdiskX.

* This bug was fixed in apar ix48926.  Current AIX 3.2.5 and
4.1.1, which do not have this fix on applied, will allow the
creation of volume groups with more than 1016 partitions.  The
implication of this bug allowing more than 1016 physical
partitions is that the user may access all portions of the logical
volume.  However during disk mirroring, the status of partitions
beyond the 1016 limit will not be tracked correctly.  If mirrors
beyond the 1016 range become "stale", LVM will not be aware of
their condition and data consistency may become an issue for
those partitions.  Additionally, the "migratepv" command creates
mirrors and deletes them as a method for moving logical volumes
around within/between disks.  If the 1016 limit is violated,
then the "migratepv" command may not behave correctly.
Additionally, the user should read the non-ptf documentation apar
ix50874 which is a companion to ix48926.

** This bug was fixed for AIX 3.2.5 rootvg install in apars
ix46862 and ix46863.  This bug does not exist in AIX 4.1.1.


1.705: Why am I having trouble adding another disk to my VG?
From: shieh@austin.ibm.com (Johnny Shieh)

In some instances, the user will experience a problem adding
a new disk to an existing volume group or in the creation of
a new volume group.  The warning message provided by LVM will
be:

 Not enough descriptor space left in this volume group.
 Either try adding a smaller PV or use another volume group.

On every disk in a volume group, there exists an area called the
Volume Group Descriptor Area (VGDA).  This space is what allows
the user to take a volume group to another AIX system and
"importvg" that volume group into that AIX system.  The VGDA
contains the names of disks that make up the volume group, their
physical sizes, partition mapping, logical volumes that exist in
the volume group, and other pertinent LVM management information.

When the user creates a volume group, the "mkvg" command
defaults to allowing the new volume group to have a maximum
of 32 disks in a volume group.  However, as bigger disks have
become more prevalent, this 32 disk limit is usually not
achieved because the space in the VGDA is used up faster, as
it accounts for the capacity on the bigger disks.  This
maximum VGDA space, for 32 disks, is a fixed size which is
part of the LVM design.  Large disks require more management
mapping space in the VGDA, which causes the number and size
of available disks to be added to the existing volume group
to shrink.  When a disk is added to a volume group, not only
does the new disk get a copy of the updated VGDA, but all
existing drives in the volume group must be able to accept
the new, updated VGDA.

The exception to this description of the maximum VGDA is
rootvg.  In order to provide AIX users more free space, when
rootvg is created, "mkvg" does not use the maximum limit of
32 disks that are allowed into a volume group.  Instead in
AIX 3.2, the number of disks picked in the install menu of
AIX is used as the reference number by "mkvg -d" during the
creation of rootvg.  For AIX 4.1, this "-d" number is 7 for
one disk and one more for each additional disk
picked. i.e. you pick two disks, the number is 8.  you pick
three disks, the number is 9, and so on.....  This limit does
not mean the user cannot add more disks to rootvg in the
post-install phase.  The amount of free space left in a VGDA,
and thus the number of size of the disks added to a volume
group, depends on the size and number of disks already
defined for a volume group.  However, this smaller size
during rootvg creation implies that the user will be able to
add fewer disks to rootvg than compared to a non-rootvg
volume group.

If the customer requires more VGDA space in the rootvg, then
they should use the "mksysb" and "migratepv" commands to
reconstruct and reorganize their rootvg (the only way to
change the "-d" limitation is recreation of the rootvg).

Note:  It is always strongly recommended that users do not place
user data onto rootvg disks.  This separation provides an extra
degree of system integrity.


1.706: What are the limits on a file, filesystem?

There are other limits but these come up most often.  Logical Volumes
do not _have_ to contain Journaled File Systems and therefore can be
larger than 2GB even in 3.2.5.

 File jfs-Filesystem
3.2.5 2GB 2GB
4.1.x 2GB 64GB


1.707  Hints for Segate 9 GB and other disks larger than 4 GB? 

[read 1.704]


1.708: How do I fix Volume Group Locked?
From /usr/lpp/bos/README (AIX 3.2.5) and 1.800.IBM.4FAX #2809

If you get '0516-266 publvodm: volume group rootvg is locked, try again'
or something similar, you can use (putlvodm -K`getlvodm -v <vgname>`)

______________________________________________________________________________

1.800: How do I control how hostnames are resolved?
From: AIX 4.1.2 Infoexplorer (posted by <kraem@ibm.de> Frank Kraemer)

The default order can be overwritten by creating the configuration file,
/etc/netsvc.conf and specifying the desired order. Both the default and
/etc/netsvc.conf can be overwritten with the environment variable,
NSORDER. If either the /etc/netsvc.conf file or environment variable,
NSORDER are defined, then at least one value must be specified along with
the option.

examples: 
    echo hosts = local,nis,bind >/etc/netsvc.conf
    NSORDER=local,bind; export NSORDER


______________________________________________________________________________
1.900: SCSI-1 and SCSI-2 "interoperability" got you confused?  

A.  SCSI-1 devices are supported on a SCSI-2 adapter.  This
    config will provide SCSI-1 performance.

B.  SCSI-2 devices are supported on a SCSI-1 adapter.  This
    config will provide SCSI-1 performance.

C.  A mix of SCSI-2 and SCSI-1 devices are supported on a SCSI-1
    adapter.  All devices will have SCSI-1 performance.

D.  A mix of SCSI-2 and SCSI-1 devices are supported on a SCSI-2
    adapter.  SCSI-2 devices will have SCSI-2 performance (10 MB/sec)
    and SCSI-1 devices will have SCSI-1 performance (4-5 MB/sec).


1.901: How to get your keyboard back after unplugging it from the 6000
From: Mickey Coggins and Anne Serre and L. Mark Larsen

When you unplug your keyboard from a running system, and plug it back
in, the key mapping is wrong.  For example, keys like Caps Lock and Ctrl
don't work as designed.

Solution: Type at the command line

        /usr/lpp/diagnostics/da/dkbd

Your screen goes black, you hear a few beeps, and your keyboard is reset.
It works with any environment, Xwindows, hft, NLS...

For Models 220, 230 and M20, use the following commands:

/usr/lpp/diagnostics/da/dkbd
/usr/lpp/diagnostics/da/dkbdsal   (for the 220)

After running the keyboard diagnostics to reset keyboard mappings, the
repeat rate is also reset to some slow value (11, according to the man
page).  If the user is in X, you need to open an hft window.  Do this
with "xopen /bin/csh".  Once you have an hft window, run "chhwkbd -r30".


1.902: How do I set up pcsim, the DOS emulator?

You must have a bootable DOS diskette to install pcsim. Either DOS 3.3, 
4.x, or 5.0 will work. IBM do not officially support DOS 5.0 for pcsim
but I have no problems with it. Just don't try to be fancy with the UMB 
and memory manager stuff.

With a bootable DOS disk in the drive, do:
$touch /u/dosdrive (this is the AIX file for DOS emulation)
$pcsim -Adiskette 3 -Cdrive /u/dosdrive
You would now get an A prompt. Type:
A> fdisk
Create the virtual C drive of whatever size you choose. Make it large 
enough for your needs since you cannot enlarge it later.
A> format c: /s (to format the virtual C drive)
Now exit from pcsim with ESCpcsim (Esc key followed by pcsim).

Now create a simprof file. Following is a starter:

Adiskette   : 3
Cdrive      :/u/dosdrive
lpt1        : name of printer queue
refresh     : 50
dmode       : V
mouse       : com1

You can now start pcsim anytime by typing pcsim. Make sure no floppies
are in the drive. For further information, refer to publication
SC23-2452, Personal Computer Simulator/6000 Guide and Reference.
       

1.903: How do I transfer files between AIX and DOS disks?

In one of the bos extensions are commands for transferring files between
DOS diskettes and AIX. The commands are dosread, doswrite, dosdir, dosdel,
and dosformat. Many users have mentioned that the mtools package from
prep.ai.mit.edu is better than the native AIX programs.


1.904: Where is the crypt program?

You can use PGP or crypt depending on your needs both require that you 
are a United States citizen and you reside in the United States.
Crypt is availible from your IBM marketing branch office.

The United States government classifies encryption technology as a
munition, meaning that you need an arms license to sell it overseas or
to non-US nationals.


1.905: How do I play audio CDs?
From: woan@austin.ibm.com (Ronald S. Woan)

Get xmcd by anonymous FTP from ftp.x.org in /contrib/applications/xmcd/
<URL:ftp://ftp.x.org/contrib/applications/xmcd/>


1.906: How can I get the mouse back after unplugging it?

/usr/lpp/diagnostics/da/dmousea


1.907: Where can I get source code to the operating system binary xxxxx?

AIX source code is not generally available.  Two other UNIX OS' do
make their source available, Linux & freeBSD.  Check
ftp://ftp.uu.net/systems/unix/[bsd-sources|linux]


_____________________________________________________
2.00: C/C++

Contrary to many people's belief, the C environment on the RS/6000 is
not very special.  The C compiler has quite a number of options that can
be used to control how it works, which "dialect" of C it compiles, how
it interprets certain language constructs, etc.  InfoExplorer includes a
Users Guide and a Reference Manual.

The compiler can be invoked with either xlc for strict ANSI mode and cc
for RT compatible mode (i.e. IBM 6150 with AIX 2).  The default options
for each mode are set in the /etc/xlc.cfg file, and you can actually add
another stanza and create a link to the /bin/xlc executable.

The file /usr/lpp/xlc/bin/README.xlc has information about the C
compiler, and the file /usr/lpp/bos/bsdport contains useful information,
in particular for users from a BSD background.

The file /etc/xlc.cfg also shows the symbol _IBMR2 that is predefined,
and therefore can be used for #ifdef'ing RS/6000 specific code.


2.01: I cannot make alloca work

A famous routine, in particular in GNU context, is the allocation
routine alloca().  Alloca allocates memory in such a way that it is
automatically free'd when the block is exited.  Most implementations
does this by adjusting the stack pointer.  Since not all C environments
can support it, its use is discouraged, but it is included in the xlc
compiler.  In order to make the compiler aware that you intend to use
alloca, you must put the line

#pragma alloca

before any other statements in the C source module(s) where alloca is
called.  If you don't do this, xlc will not recognize alloca as anything
special, and you will get errors during linking.

For AIX 3.2, it may be easier to use the -ma flag.


2.02: How do I compile my BSD programs?

The file /usr/lpp/bos/bsdport contains information on how to port
programs written for BSD to AIX 3.1.  This file may be very useful for
others as well.

A quick cc command for most "standard" BSD programs is:
  
  $ cc -D_BSD -D_BSD_INCLUDES  -o [loadfile] [sourcefile.c] -lbsd

If your software has system calls predefined with no prototype
parameters, also use the -D_NO_PROTO flag.


2.03: Isn't the linker different from what I am used to?

Yes.  It is not at all like what you are used to:

- The order of objects and libraries is normally _not_ important.  The
  linker reads _all_ objects including those from libraries into memory
  and does the actual linking in one go.  Even if you need to put a
  library of your own twice on the ld command line on other systems, it
  is not needed on the RS/6000 - doing so will even make your linking slower.

- One of the features of the linker is that it will replace an object in
  an executable with a new version of the same object:

  $ cc -o prog prog1.o prog2.o prog3.o  # make prog
  $ cc -c prog2.c    # recompile prog2.c
  $ cc -o prog.new prog2.o prog   # make prog.new from prog
      # by replacing prog2.o
  
- The standard C library /lib/libc.a is linked shared, which means that
  the actual code is not linked into your program, but is loaded only
  once and linked dynamically during loading of your program.

- The ld program actually calls the binder in /usr/lib/bind, and you can
  give ld special options to get details about the invocation of the
  binder.  These are found on the ld man page or in InfoExplorer.

- If your program normally links using a number of libraries (.a files),
  you can 'prelink' each of these into an object, which will make your
  final linking faster.  E.g. do:

  $ cc -c prog1.c prog2.c prog3.c
  $ ar cv libprog.a prog1.o prog2.o prog3.o
  $ ld -r -o libprog.o libprog.a
  $ cc -o someprog someprog.c libprog.o

This will solve all internal references between prog1.o, prog2.o and
prog3.o and save this in libprog.o Then using libprog.o to link your
program instead of libprog.a will increase linking speed, and even if
someprog.c only uses, say prog1.o and prog2.o, only those two modules
will be in your final program.  This is also due to the fact that the
binder can handle single objects inside one object module as noted above.

If you are using an -lprog option (for libprog.a) above, and still want
to be able to do so, you should name the prelinked object with a
standard library name, e.g. libprogP.a (P identifying a prelinked
object), that can be specified by -lprogP.  You cannot use the archiver
(ar) on such an object.

You should also have a look at section 3.01 of this article, in
particular if you have mixed Fortran/C programs.

Dave Dennerline (d.dennerline@bull.com) claims that his experiences
in prelinking on AIX does not save much time since most people have
separate libraries which do not have many dependencies between them,
thus not many symbols to resolve.


2.04: How do I statically link my program?

  cc -o prog -bnoso -bI:/lib/syscalls.exp obj1.o obj2.o obj3.o

will do that for a program consisting of the three objects obj1.o, etc.

From: Marc Pawliger (marc@sti.com)

As of AIX 3.2.5, you can install a speedup for AIXwindows called
Shared Memory Transport.  To static link an X application after the
SMT PTF has been installed, you must link with
-bI:/usr/lpp/X11/bin/smt.exp and the executable will NOT run on a
machine where SMT is not installed.  See /usr/lpp/X11/README.SMT


2.05: How do I make my own shared library?

To make your own shared object or library of shared objects, you should
know that a shared object cannot have undefined symbols.  Thus, if your
code uses any externals from /lib/libc.a, the latter MUST be linked with
your code to make a shared object.  Mike Heath (mike@pencom.com) said it
is possible to split code into more than one shared object when externals
in one object refer to another one.  You must be very good at
import/export files.  Perhaps he or someone can provide an example. 

Assume you have one file, sub1.c, containing a routine with no external
references, and another one, sub2.c, calling stuff in /lib/libc.a.  You
will also need two export files, sub1.exp, sub2.exp.  Read the example
below together with the examples on the ld man page. 

---- sub1.c ----
    int addint(int a, int b)
    {
      return a + b;
    }
---- sub2.c ----
    #include <stdio.h>

    void printint(int a)
    {
      printf("The integer is: %d\n", a);
    }
---- sub1.exp ----
    #!
    addint
---- sub2.exp ----
    #!
    printint
---- usesub.c ----
    main()
    {
      printint( addint(5,8) );
    }

The following commands will build your libshr.a, and compile/link the
program usesub to use it.  Note that you need the ld option -lc for
sub2shr.o since it calls printf from /lib/libc.a.

  $ cc  -c sub1.c
  $ ld -o sub1shr.o sub1.o -bE:sub1.exp -bM:SRE -T512 -H512 
  $ cc  -c sub2.c
  $ ld -o sub2shr.o sub2.o -bE:sub2.exp -bM:SRE -T512 -H512  -lc
  $ ar r libshr.a sub1shr.o sub2shr.o
  $ cc -o usesub usesub.c -L: libshr.a
  $ usesub
  The integer is: 13
  $


2.06: Linking my program fails with strange errors.  Why?

Very simple, the linker (actually called the binder), cannot get the
memory it needs, either because your ulimits are too low or because you
don't have sufficient paging space.  Since the linker is quite different
>from normal Unix linkers and actually does much more than these, it also
uses a lot of virtual memory.  It is not unusual to need 10000 pages (of
4k) or more to execute a fairly complex linking.

If you get 'BUMP error', either ulimits or paging is too low, if you get
'Binder killed by signal 9' your paging is too low.

First, check your memory and data ulimits; in korn shell 'ulimit -a' will
show all limits and 'ulimit -m 99999' and 'ulimit -d 99999' will
increase the maximum memory and data respectively to some high values. 
If this was not your problem, you don't have enough paging space.

If you will or can not increase your paging space, you could try this:

- Do you duplicate libraries on the ld command line? That is never
  necessary.

- Do more users link simultaneously? Try having only one linking going
  on at any time.

- Do a partwise linking, i.e. you link some objects/libraries with the
  -r option to allow the temporary output to have unresolved references,
  then link with the rest of your objects/libraries.  This can be split
  up as much as you want, and will make each step use less virtual memory.

  If you follow this scheme, only adding one object or archive at a
  time, you will actually emulate the behavior of other Unix linkers.

If you decide to add more paging space, you should consider adding a new
paging space on a second hard disk, as opposed to just increasing the
existing one.  Doing the latter could make you run out of free space on
your first harddisk. It is more involved to shrink a paging space
but easier to delete one.