CHAPTER 5: INCORPORATING AFS INTO THE KERNEL
. . . . . . . . . . Assumptions
5.1 . . . . Loading the Files Needed for a Kernel Build
5.1.1 . . . . . . Loading Files from a Local Tape Drive
5.1.2 . . . . . . Loading Files from a Remote Machine
5.2 . . . . Building Kernels on Digital UNIX 2.0 Systems
5.3 . . . . Building Kernels on Digital UNIX 3.0 Systems
5.4 . . . . Building Kernels on HP 9000 Series 700 Systems Running HP-UX 9.0
5.5 . . . . Building Kernels on HP 9000 Series 800 Systems Running HP-UX 9.0
5.6 . . . . Building Kernels on IRIX Systems
5.7 . . . . Building Kernels on NCR UNIX Systems
5.8 . . . . Building Kernels on SunOS Systems
5.9 . . . . Building Kernels on Ultrix Systems
5.10 . . . Invoking dkload in a Machine's Initialization File
5.11 . . . . . . Invoking Kernel Extensions in a Machine's Initialization File
5.12 . . . Invoking modload in a SunOS Machine's Initialization File


 5. INCORPORATING AFS INTO THE KERNEL

All AFS file server and client machines must run a kernel that incorporates AFS
modifications.  This chapter provides detailed instructions for building AFS
into the UNIX kernel of an AFS file server or client machine.  The preferred
method for incorporating AFS into a machine's kernel is dynamic loading, which
is possible on most system types.  Chapters 2, 3, and 4 include dynamic loading
instructions for each system type. 

The final sections of this chapter are provided for reference. They present the
text of the files that Transarc provides for inclusion in the initialization
file on machines using a dynamic loader.  Text is presented for Transarc's
dkload, IBM's kernel extension facility and Sun's modload for SunOS systems.
Other system types that can run a dynamic loader use an initialization file
provided by the operating system provider. 

Before you can build a kernel, the build-related AFS libraries and other files
from the Binary Distribution Tape must reside on the local disk of the machine
where you are performing the build. Follow the instructions in Section 5.1
unless you are installing your cell's first file server machine, and have
already followed the instructions in Section 2.3 for loading kernel building
files. 

After you have loaded the needed files, follow the kernel building instructions
for your system type, listed as follows.  Note that these instructions explain
only how to build a kernel with AFS modifications in it.  Procedures for
installing the modified kernel on individual machines appear in Chapters 2, 3,
and 4. 

 - For Digital UNIX Version 2, see Section 5.2, page 5-7.

 - For Digital UNIX Version 3, see Section 5.3, page 5-11.

 - For HP-UX on HP 9000 Series 700 machines, see Section 5.4, page 5-16.

 - For HP-UX for HP 9000 Series 800 machines, see Section 5.5, page 5-20.

 - For IRIX, see Section 5.6, page 5-23.

 - For NCR UNIX see Section 5.7, page 5-26.

 - For SunOS, see Section 5.8, page 5-28.

 - For Ultrix, if you have an Ultrix source license, see Section 5.9, page 5-35.

Assumptions

Compiling a kernel is a complicated and system-specific process.  The following
assumptions are made throughout the instructions:

 - The kernel system distribution directory is /usr/sys.  Adjust the
pathname in the following procedures if your system distribution
directory is different.

 - The person building the kernel has a basic knowledge of kernel
building and the system type upon which the kernel is being built.
This section explains how to incorporate AFS into the kernel, but
does not explain the kernel-build process.

 5.1. LOADING THE FILES NEEDED FOR A KERNEL BUILD

Before you can build a kernel, the build-related AFS libraries and other files
from the Binary Distribution Tape must reside on the local disk of the machine
where you are performing the build.

Perform the steps in this section unless you are installing your cell's first
file server machine (and have already followed the instructions in Section 2.3
for loading kernel build files).

You can load files from the tape into the UNIX file system on either

 - the local machine (where you are performing the build), if it has a
   tape drive attached.  See Section 5.1.1.

 - a remote machine with a tape drive attached.  You then copy the files
   to the local machine's disk using ftp, NFS, or another network
   transfer method.  See Section 5.1.2.

 5.1.1. LOADING FILES FROM A LOCAL TAPE DRIVE

The second tar set on the Binary Distribution Tape contains the /usr/afs/sys
directory, which houses the library files needed to build AFS into the kernel
(for most system types, libafs.a and libafs.nonfs.a).

Follow the instructions to create the /usr/afs/sys directory and load the
appropriate files from the tape into it.

Step 1: Create the /usr/afs/sys directory.

	------------------------
	# mkdir /usr/afs     
	# mkdir /usr/afs/sys 
	------------------------

Step 2: Mount the Binary Distribution Tape and load the second tar set
into /usr/afs/sys.

----------------------------------------------------------------------------------
On HP-UX systems: Substitute mt -t for mt -f.                                  

On all system types:  For , substitute the name of the tape device for 
your system that does not rewind after each operation.                         

	# cd /usr/afs/sys                                                              
	# mt -f /dev/ rewind                                                   
	# mt -f /dev/ fsf 1                                                    
	# tar xvf /dev/                                                        
----------------------------------------------------------------------------------

 5.1.2. LOADING FILES FROM A REMOTE MACHINE

If the local machine does not have a tape drive, you must transfer the needed
files onto the local disk from a remote machine.  This section assumes you have
already loaded the fifth tar set from the Binary Distribution Tape to the
directory /usr/afsws on the remote machine.  The /usr/afsws/root.client/bin
directory contains the needed library files.

Step 1: Create /usr/afs/sys on the local disk (of the machine where you
are building the kernel).

	------------------------
	# mkdir /usr/afs     
	# mkdir /usr/afs/sys 
	------------------------

Step 2: Using ftp, NFS, or another network file transfer method, copy the
files from the remote machine's /usr/afsws/root.client/bin directory
to the /usr/afs/sys directory on the local machine.

Step 3: Verify that /usr/afs/sys contains libafs.a and libafs.nonfs.a.

	---------------------
	# ls /usr/afs/sys 
	---------------------

 5.2. BUILDING KERNELS ON DEC AXP MACHINES RUNNING OSF/1 VERSION 2

This section explains how to add AFS into the kernel on DEC AXP machines
running DIGITAL UNIX Version 2.

Step 1: Copy the basic configuration file in /usr/sys/conf to a new name.

Copy the basic configuration file to a new, AFS-specific name. 

	----------------------
	# cd  /usr/sys/conf                                            
	# cp  AFS 
	----------------------

Step 2: Add AFS as an option to the configuration file created in the
previous step.

Add AFS to the list of options in the configuration file you created
in Step 1, so that the result looks like the following:

.                    .                                             
.                    .                                             
options               UFS                                             
options               NFS                                             
options               AFS 
.                    .                                             
.                    .                                             
--------------------------------------------------------------------------------

Step 3: Add entries for AFS to /usr/sys/conf/files.
--------------------------------------------------------------
Make these changes to /usr/sys/conf/files:                 

Add a line for AFS to the list of OPTIONS:                 

	OPTIONS/afs             optional afs define_dynamic

Add a line for AFS near the end of the file:               

	afs/libafs.c 		optional afs if_dynamic afs Binary 
--------------------------------------------------------------
Step 4: Add entries for AFS to /usr/sys/vfs/vfs_conf.c, which contains a
table listing all supported file systems.

----------------------------------------------------------------------------
To /usr/sys/vfs/vfs_conf.c, add AFS to the list of defined file systems, 
so that the result looks like                                            

	.       .              .                                        
	extern  struct vfsops cdfs_vfsops;                                 
	#endif                                                             

	#include                                                    
	#if defined(AFS)                                                   
	      extern        struct vfsops afs_vfsops;                        
	#endif                                                             

	#include                                                   
	#if     MSFS && !MSFS_DYNAMIC                                      
	      extern  struct vfsops msfs_vfsops;                                 
	.       .              .                                        

Add an entry for AFS to the end of the vfssw structure so the            
result looks like:                                                       

	.       .              .                                        
	      &fdfs_vfsops,           /* 12 = MOUNT_FDFS */                
	#if defined(AFS && AFS 
	      &afs_vfsops,            /* 13 = MOUNT_DFS */                 
	#else                                                              
	      (struct vfsops *)       /* 13 = MOUNT_ADDON */               
	#endif                                                             
	.       .              .                                        
	.       .              .                                        
----------------------------------------------------------------------------

Step 5: If you followed the loading instructions in Section 5.1 (or
Section 2.3 if you are building a kernel on your cell's first file
server machine), the AFS kernel modules reside in /usr/afs/sys; they
are also accessible in /usr/afsws/root.client/bin.  Copy the
appropriate AFS kernel module from /usr/afs/sys to the indicated
kernel binary object directory.

-------------------------------------------------------------------------------
In each case below, read "does not support NFS" to mean the kernel does not 
include support for NFS server functionality.                               

	# cd  /usr/afs/sys

For a kernel that supports NFS:                                             

	# cp libafs.o  /usr/sys/BINARY/libafs.o

For a kernel that does not support NFS:                                     

	# cp libafs.nonfs.o  /usr/sys/BINARY/libafs.o
-------------------------------------------------------------------------------

Step 6: Configure the kernel.  Respond to any prompts by pressing
. The resulting kernel will reside in /usr/sys/AFS.

	-------------------------------------------------
	# doconfig  -c  AFS for another configuration 
	-------------------------------------------------

If you are installing your cell's first machine, return to Section 2.5.1 (page 2-19).

If you are installing an additional file server machine, return to Section 3.1.2.2 (page 3-13).

If you are installing an additional client machine, return to Section 4.2.2 (page 4-11). 

 5.3. BUILDING KERNELS ON Digital UNIX MACHINES RUNNING OSF/1 VERSION 3

This section explains how to add AFS into the kernel on Digital UNIX machines
running OSF/1 Version 3.

Step 1: Copy the basic configuration file in /usr/sys/conf to a new name.

Copy the basic configuration file to a new, AFS-specific name. 

	---------------------------
	# cd  /usr/sys/conf                                            
	# cp    AFS 
	---------------------------

Step 2: Add AFS as an option to the configuration file created in the
previous step.

Add AFS to the list of options in the configuration file you created in Step 1,
so that the result looks like the following:                                 
.                    .                                             
.                    .                                             
options               UFS                                             
options               NFS                                             
options               AFS 
.                    .                                             
.                    .                                             
--------------------------

Step 3: Add entries for AFS to /usr/sys/conf/files.

Make the following changes to /usr/sys/conf/files:                       

First, add a line for AFS to the list of OPTIONS, so that the result     
looks like                                                               

	.                    .
	OPTIONS/nfs	optional nfs define_dynamic
	OPTIONS/afs	optional afs define_dynamic
	OPTIONS/cdfs	optional cdfs define_dynamic
	.                    .

Second, add a line to the end of the file, so that the result looks
like
	.                    	.
	net/pfilt_bpf.c		optional packetfilter Binary
	data/xti_data.c		optional xtiso Notbinary
	afs/libafs.c		optional afs if_dynamic afs Binary
----------------------------------------------------------------------------

Step 4: Add entries for AFS to /usr/sys/vfs/vfs_conf.c, which contains a
table listing all supported file systems.

----------------------------------------------------------------------------
To /usr/sys/vfs/vfs_conf.c, add AFS to the list of defined file systems, 
so that the result looks like                                            

	.       .              .                                        
	.       .              .                                        
	#include                                                 
	#if defined(DCEEFS) && DCEEFS                                      
	      extern        struct vfsops efs_vfsops;                        
	#endif                                                             

	#include                                                    
	#if defined(AFS)                                                   
	      extern  struct vfsops afs_vfsops;                              
	#endif                                                             

	#include                                                 
	#if FFM_FS && !FFM_FS_DYNAMIC                                      
	      extern struct vfsops ffm_vfsops;                               
	#endif                                                             
	.       .              .                                        
	.       .              .                                        

Using the MOUNT_ADDON slot in the vfssw[] table replace the existing
single line: 

	.       .              .                                        
	     (struct vfsops *)0,     /* 13 = MOUNT_ADDON */               
	.       .		.                                        

with the following group of lines for AFS:
	.	.		.

	#if   defined(AFS)                                                 
	     &afs_vfsops,                                                 
	#else                                                              
	     (struct vfsops *)0,    /*  13 = MOUNT_ADDON */               
	#endif                                                             
	.       .              .                                        
	.       .              .                                        
----------------------------------------------------------------------------


Step 5: If you followed the loading instructions in Section 5.1 (or
Section 2.3 if you are building a kernel on your cell's first file
server machine), the AFS kernel modules reside in /usr/afs/sys; they
are also accessible in /usr/afsws/root.client/bin.  Copy the
appropriate AFS kernel module from /usr/afs/sys to the indicated
kernel binary object directory.

-------------------------------------------------------------------------------
In each case below, read "does not support NFS" to mean the kernel does not 
include support for NFS server functionality.                               

	# cd  /usr/afs/sys                                                          

For a kernel that supports NFS:                                             
	# cp libafs.o  /usr/sys/BINARY/libafs.o                                     

For a kernel that does not support NFS:                                     
	# cp libafs.nonfs.o /usr/sys/BINARY/libafs.o                                

-------------------------------------------------------------------------------

Step 6: Configure the kernel.  Respond to any prompts by pressing
. The resulting kernel will reside in /usr/sys/AFS or
/usr/sys/AFS.rt as appropriate.

	-----------------------
	# doconfig  -c  AFS 
	-----------------------

If you are installing your cell's first machine, return to Section
2.5.1 (page 2-19).

If you are installing an additional file server machine, return to
 Section 3.1.2.2 (page 3-13).

If you are installing an additional client machine, return to
Section 4.2.2 (page 4-11).


 5.4. BUILDING KERNELS ON HP 9000 SERIES 700 SYSTEMS RUNNING HP-UX 9.0

This section explains how to add AFS into the kernel on HP 9000 Series 700
systems running HP-UX 9.0.

Step 1: Copy the AFS kernel modules libafs.a and libafs.nonfs.a from the
distribution directory to /etc/conf.  If you followed the loading
instructions in Section 5.1 (or Section 2.3 if you are building a
kernel on your cell's first file server machine), the AFS kernel
modules reside in /usr/afs/sys; they are also accessible in
/usr/afsws/root.client/bin.

	--------------------------------------------
	Copy the AFS library files to /etc/conf. 

	# cd /etc/conf                           
	# cp /usr/afs/sys/libafs.a  .            
	# cp /usr/afs/sys/libafs.nonfs.a  .      
	--------------------------------------------

Step 2: Add entries for AFS to /etc/conf/conf.c.

------------------------------------------------------------------------------------
To /etc/conf/conf.c, add the following AFS declarations in the indicated places. 

Add an "extern" declaration for afsc_link() right after the one for              
nfsc_link(), so that the result looks like the following:                        
.                                                                        
extern nipc_link();                                                              
extern nfsc_link();                                                              
extern afsc_link();                                                              
extern cdfs_link();                                                              
.                                                                        

Add an afsc_link entry to the int (*driver_link[]) ()=                           
declaration, so that the result looks like the following:                        

.                                                                            
nipc.link                                                                        
nfsc_link,                                                                       
afsc_link,                                                                       
ite_ink,,                                                                       
------------------------------------------------------------------------------------

Step 3: Edit /etc/conf/config.mk, adding an AFS entry to the list of
libraries defined as LIBS.

--------------------------------------------------------------------------
Edit /etc/conf/config.mk, adding an AFS entry to the list of libraries 
defined as LIBS:                                                       

 - if the kernel includes support for NFS server functionality,     
 - add an entry for $(ROOT)/libafs.a                                
 - if the kernel does not include support for NFS,                  
add an entry for $(ROOT)/libafs.nonfs.a                             

The file should look something like:                                   

LIBS= \                                                                
	$(ROOT)/libuipc.a \                                            
	.                                                     
	.                                                     
	$(ROOT)/libnfs.a \                                             
	$(ROOT)/libafs.a \                                             
	$(ROOT)/libcdfs.a \                                            
	.                                                     
	.                                                     
--------------------------------------------------------------------------

Step 4: Working in /etc/conf, compile the kernel.  The resulting kernel
is suitable for (and must run on) both AFS clients and file server
machines of this system type.  It is created /etc/conf/hp-ux.

------------------------------------------------------------------------
If the working directory is not still /etc/conf, change directories. 

	# cd /etc/conf                                                       

Compile the kernel.                                                  

	# make  -f  config.mk                                                
------------------------------------------------------------------------

If you are installing your cell's first machine, return to Section
2.6.2 (page 2-25).

If you are installing an additional file server machine, return to
Section 3.1.2.3 (page 3-17).

If you are installing an additional client machine, return to
Section 4.2.3.2 (page 4-14).

 5.5. BUILDING KERNELS ON HP 9000 SERIES 800 SYSTEMS RUNNING HP-UX 9.0

This section explains how to add AFS into the kernel on HP 9000 Series 800
systems running HP-UX 9.0.

Step 1: Copy the AFS kernel modules libafs.a and libafs.nonfs.a from the
distribution directory to /etc/conf.  If you followed the loading
instructions in Section 5.1 (or Section 2.3 if you are building a
kernel on your cell's first file server machine), the AFS kernel
modules reside in /usr/afs/sys; they are also accessible in
/usr/afsws/root.client/bin.

------------------------------------------------
Copy the AFS library files to /etc/conf/lib. 

	# cd /etc/conf/lib                           
	# cp /usr/afs/sys/libafs.a  .                
	# cp /usr/afs/sys/libafs.nonfs.a  .          
------------------------------------------------

Step 2: Add entries for the AFS library to /etc/master, in both the list
of file systems and in the "loadorder" section.

-----------------------------------------------------------------------------------

In /etc/master, add an entry for AFS to the list of file systems.  If the       
kernel includes support for NFS server functionality,                           
add the AFS entry just after its entry so that the file looks like              

.          .            .                                                  
.          .            .                                                  
filesystem     nfs     lib libnfs.a;                                            
filesystem     afs     lib libafs.a;                                            
.          .            .                                                  
.          .            .                                                  

If the kernel does not include support for NFS server functionality, substitute 
libafs.nonfs.a for libafs.a and place the AFS entry after the                   
entry for UFS.                                                                  

Also add libafs.a (or libafs.nonfs.a) to the list of libraries                  
in the "loadorder" section (the list appears on a single line in the            
file and appears here on multiple lines for space reasons only).

	libsixq.a libpvc.a libsixtr.a libpsi.a libotsam.a \
	libxtisys.a libufs.a libnfs.a libafs.a 
-----------------------------------------------------------------------------------

Step 3: Make a copy of /etc/conf/gen/S800 as /etc/conf/gen/SAFS, and add
an entry for AFS to the copy.

--------------------------------------------------------------------------------------

# cd  /etc/conf/gen                                                                
# cp S800  SAFS 

Now edit SAFS to include an entry for AFS right after the one for NFS, so that the 
file looks like                                                                    

.                                                                           
.                                                                           
include switch;    /*include modules*/                                             
include disc1;                                                                     
include nfs;                                                                       
include afs;                                                                       
include lan1;                                                                      
include lan3;                                                                      
.                                                                           
.                                                                           
--------------------------------------------------------------------------------------

Step 4: Working in /etc/conf/gen (you changed directory there in the
previous step), compile the kernel.  The resulting kernel, created
as /etc/conf/SAFS/hp-ux, is suitable for (and must run on) both AFS
clients and file server machines of this system type.

	-----------------------
	Compile the kernel. 

	# /etc/uxgen  SAFS 
	-----------------------

If you are installing your cell's first machine, return to Section
2.6.2 (page 2-25).

If you are installing an additional file server machine, return to
Section 3.1.2.3 (page 3-17).

If you are installing an additional client machine, return to
Section 4.2.3.2 (page 4-14).

 5.6. BUILDING KERNELS ON IRIX SYSTEMS

This section explains how to add AFS into the kernel on Silicon Graphics, Inc.
machines running IRIX.

Step 1: Create /var/sysgen/system/afs.sm as a symbolic link to the AFS
initialization file.  If you followed the loading instructions in
Section 5.1 (or Section 2.3 if you are building a kernel on your
cell's first file server machine), the AFS kernel libraries and
initialization file reside in /usr/afs/sys; they are also accessible
in /usr/afsws/root.client/bin.

---------------------------------------------------------------------------------------
Create /var/sysgen/system/afs.sm as a symbolic link to the AFS initialization file. 

	# cd  /var/sysgen/system
	# ln  -s  /usr/afs/sys/afs.sm  afs.sm
---------------------------------------------------------------------------------------

Step 2: Create the master file /var/sysgen/master.d/afs.

-----------------------------------------------------------------------------------
Create /var/sysgen/master.d/afs as a symbolic link to the appropriate AFS file. 

	# cd  /var/sysgen/master.d                                                      
	# ln  -s  /usr/afs/sys/afs  afs                                                 
-----------------------------------------------------------------------------------

Step 3: Create /var/sysgen/boot/afs.a.

--------------------------------------------------------------------------------
Create /var/sysgen/boot/afs.a as a symbolic link to the AFS kernel library,  
by substituting one of the following files for  in the ln -s    
command.                                                                     

Note: In each case below, read "NFS support" to mean that the kernel         
includes support for NFS server functionality.                               

For IRIX 5.1 systems, replace  with:                           

   - libafs.R3000.a for R3000 processor with NFS support                    
   - libafs.R3000.nonfs.a for R3000 processor without NFS support           
   - libafs.R4000.a for R4000 processor with NFS support                    
   - libafs.R4000.nonfs.a for R4000 processor without NFS support           

For IRIX 5.2 and 5.3 systems, replace  with:                   

   - libafs.MP.R3000.a for R3000 multiprocessor with NFS support            
   - libafs.MP.R3000.nonfs.a for R3000 multiprocessor without NFS support   
   - libafs.MP.R4000.a for R4000 multiprocessor with NFS support            
   - libafs.MP.R4000.nonfs.a for R4000 multiprocessor without NFS support   
   - libafs.SP.R3000.a for R3000 single processor with NFS support          
   - libafs.SP.R3000.nonfs.a for R3000 single processor without NFS support 
   - libafs.SP.R4000.a for R4000 single processor with NFS support          
   - libafs.SP.R4000.nonfs.a for R4000 single processor without NFS support 

	# cd  /var/sysgen/boot                                                       

	# ln  -s  /usr/afs/sys/  afs.a                                  
--------------------------------------------------------------------------------

Step 4: Compile the kernel.  The resulting kernel is suitable for (and
must run on) both AFS clients and file server machines of this
system type.  It is created as /unix.install.

Note:  The existing /unix is preserved when /unix.install is
created.  However, the next time the machine is rebooted,
/unix.install will be rewritten to /unix.  If you wish to keep the
original /unix kernel, copy it to a save file.

	----------------
	# autoconfig 
	----------------

If you are installing your cell's first machine, return to
Section 2.7.2 (page 2-32).

If you are installing an additional file server machine, return to
Section 3.1.2.4 (page 3-21).

If you are installing an additional client machine, return to
Section 4.2.4.2 (page 4-17).

 5.7. BUILDING KERNELS ON NCR SYSTEMS

This section explains how to add AFS into the kernel on machines running NCR
Version 3.0.

Step 1: Create a file named afs in /etc/conf/mfsys.d with the following
contents:

	afs afs

Step 2: Create a file named afs in /etc/conf/sfsys.d with the following
contents:

	afs Y

Step 3: Create a directory named afs in /etc/conf/pack.d:

	-------------------------
	# cd /etc/conf/pack.d 
	# mkdir afs           
	-------------------------

Step 4: Copy the appropriate AFS kernel module from /usr/afs/sys to the
indicated kernel binary object directory.  (The AFS kernel modules
are also accessible in /dest/root.client/usr/vice/etc/dkload/libafs.o.)

	-----------------------------------------------
	# cd /usr/afs/sys                           
	# cp libafs.o /etc/conf/pack.d/afs/Driver.o 
	-----------------------------------------------

Step 5: Configure the kernel.  Respond to any prompts by pressing
.  The resulting kernel will reside in /etc/conf/cf.d/unix.

	---------------------------
	# /etc/conf/bin/idbuild 
	---------------------------

Step 6: Reboot the machine with the new kernel as follows:

	-------------------------
	# shutdown -y -i6 -g0 
	-------------------------

To rebuild the kernel with AFS hereafter, simply repeat Steps 4-6.  (To rebuild
the kernel without AFS, change Y to N in the file /etc/conf/sfsys.d/afs.)

 5.8. BUILDING KERNELS ON SUNOS SYSTEMS

This section explains how to add AFS into the kernel on Sun4 and Sun
SPARCstation machines running SunOS.

Step 1: Add the following line(s) to the kernel configuration file housed
in /usr/sys/cpu/conf, where cpu is sun4, sun4c, or sun4m.  Place the
line(s) in the section of the configuration file that defines
options (such as options INET).

-----------------------------------------------------------------------------
Add a line to /usr/sys/cpu/conf/config_name to refer to the AFS 
library file libafs.a:                                                    

	options AFS # AFS client/server                                    

If the kernel does not include support for NFS server functionality, also 
add the following, which refers to libafs.nonfs.a:                        

	options AFS_NONFS  # AFS using libafs.nonfs.a                             
	# (no NFS support)                                     
-----------------------------------------------------------------------------

Step 2: Add the indicated line to /usr/sys/conf.common/files.cmn, which
lists all of the system-independent files constituting the new
kernel.

--------------------------------------------------------------------------
Place the following line at the end of /usr/sys/conf.common/files.cmn: 

	afs/libafs.o     optional AFS 
--------------------------------------------------------------------------

Step 3: Add entries for AFS to /usr/sys/os/vfs_conf.c, which contains a
table listing all supported file systems.

-------------------------------------------------------------------------------------
To /usr/sys/os/vfs_conf.c, add the following lines, which declare AFS among       
the other remote file system entries:                                             

	#ifdef AFS 
	      extern struct vfsops afs_vfsops;                                           
	#endif AFS 

Add the following lines to insert the AFS file system entry into the table. (You  
may place the entry anywhere in the table, because unlike some other operating    
system types, SunOS 4.1.1, 4.1.2, and 4.1.3 look up file system entries by name.) 

	#ifdef  AFS 
	      "afs", &afs_vfsops,     /* AFS */                                         
	#else                                                                             
	      (char *)0, (struct vfsops *)0,                                            
	#endif AFS 
-------------------------------------------------------------------------------------

Step 4: Substitute the following AFS-specific system calls for their
standard UNIX counterparts in /usr/sys/os/init_sysent.c, which
defines all supported system calls:

   - afs_xioctl replaces ioctl (probably in slot 54)

   - afs_xsetgroups replaces setgroups (probably in slot 80)

   - afs_xflock replaces flock (probably in slot 131)

-------------------------------------------------------------------
In /usr/sys/os/init_sysent.c, make the following substitutions: 
Replace                                                         

	3, ioctl,               /* 54 = ioctl */                

with                                                            

#ifdef AFS 
	3, afs_xioctl,          /* 54 = afs_xioctl */           
#else                                                           
	3, ioctl,               /* 54 = ioctl */                
#endif AFS 

Replace                                                         

	2, setgroups,           /* 80 = setgroups */            

with                                                            

#ifdef AFS 
	2, afs_xsetgroups,      /* 80 = afs_xsetgroups */       
#else                                                           
	2, setgroups,           /* 80 = setgroups */            
#endif AFS 

Replace                                                         

	2, flock,               /* 131 = flock */               

with                                                            

#ifdef AFS 
	2, afs_xflock,          /* 131 = afs_xflock */          
#else                                                           
	2, flock,               /* 131 = flock */               
#endif AFS 
-------------------------------------------------------------------


Step 5: Declare additional AFS-specific system calls in
/usr/sys/os/init_sysent.c, using the single-entry system call
method.

-------------------------------------------------------------------------------
Add the following declarations to /usr/sys/os/init_sysent.c:                

	#ifdef  AFS 
	int     afs_syscall(), afs_xioctl(), afs_xflock();                          
	int     afs_xsetgroups();                                                   
	#endif AFS 

Now declare afs_syscall in slot 31.  (In most SunOS 4.1.1, 4.1.2 and 4.1.3  
systems, slot 31 is not used, so it is the default choice for afs_syscall.  
If you have AFS source and wish to declare afs_syscall in a different slot, 
you must also redefine the slot number in /usr/afsws/include/afs/param.h.)  

	#ifdef AFS 
	       7, afs_syscall,       /* 31 = afs entry call */                      
	#else                                                                       
	       0, nosys,             /*  31 = was stty */                           
	#endif AFS 
-------------------------------------------------------------------------------

Step 6: If you followed the loading instructions in Section 5.1 (or
Section 2.3 if you building a kernel on your cell's first file
server machine), the AFS kernel modules reside in /usr/afs/sys; they
are also accessible in /usr/afsws/root.client/bin.  Copy the
appropriate AFS kernel module from /usr/afs/sys to the kernel binary
object directory (/usr/sys/cpu/OBJ, where cpu is one of sun4, sun4c,
or sun4m).  Copy either libafs.a if the kernel you are building
includes support for NFS server functionality, or libafs.nonfs.a if
it does not.

-------------------------------------------------------------------------
For kernels that include support for NFS server functionality:        

	# cp  /usr/afs/sys/libafs.a  /usr/sys//OBJ/libafs.o              

For kernels that do not include support for NFS server functionality: 

	# cp  /usr/afs/sys/libafs.nonfs.a  /usr/sys//OBJ/libafs.o        
-------------------------------------------------------------------------

Step 7: Run ranlib on /usr/sys/cpu/OBJ/libafs.o to restore its table of
contents, which was destroyed by cp in the previous step.

	----------------------------------------
	# ranlib /usr/sys//OBJ/libafs.o 
	----------------------------------------

Step 8: Working in the configuration directory /usr/sys/cpu/conf,
configure the kernel.

	-------------------------------
	# cd /usr/sys//conf    
	# /etc/config  
	-------------------------------

Step 9: Working in the configuration kernel directory,
/usr/sys/cpu/config_name, compile the kernel.  The resulting kernel
is suitable for (and must run on) both AFS clients and file server
machines of this system type.  It is created as
/usr/sys/cpu/config_name/vmunix.

	-------------------------------------
	# cd /usr/sys// 
	# make vmunix                     
	-------------------------------------

If you are installing your cell's first machine, return to Section
2.10.3 (page 2-51).

If you are installing an additional file server machine, return to
Section 3.1.2.6 (page 3-31).

If you are installing an additional client machine, return to
Section 4.2.6.3 (page 4-27).

 5.9. BUILDING KERNELS ON ULTRIX SYSTEMS

This section explains how to add AFS into the kernel on DECstations running
Ultrix.

Note: You must have an Ultrix source license to perform the following steps.

Step 1: Declare AFS as a supported file system in /usr/sys/h/fs_types.h
(which is also accessible as /usr/include/sys/fs_types.h) by making
the indicated changes.  If you do not make these changes, GT_AFS
will be defined in a default slot, possibly with undesirable
results.

----------------------------------------------------------------------------------------
Add the following line to /usr/sys/h/fs_types.h:                                     

#define GT_AFS 0x0c   /* slot 12, or the next free slot */                         

Also add "afs" to the list of fs-type names.  Put it in the twelfth position (or the 
one that matches the GT_AFS declaration), padding with "unknown" if necessary.       
The end result should look like:                                                     

	char *gt_names[GT_NUMTYPES]={                                                        
	"unknown", "ufs", "ods", "brfs", "msdos", "nfs", "dfs",                              
	"sysv", "unknown", "unknown", "unknown", "afs", 0                                    
	}                                                                                    
----------------------------------------------------------------------------------------

Step 2: Add the following lines to the kernel configuration file housed in
/usr/sys/conf/mips.

--------------------------------------------------------------------------------------
Add the following to the list of pseudo-devices in /usr/sys/conf/mips/config_name: 

pseudo-device   AFS 

Place the following in the section of the configuration file that defines          
options (such as options INET), to refer to the AFS library                        
file libafs.a:                                                                     

options AFS		# AFS client/server

If the kernel does not include support for NFS server funtionality,
also add the following which refers to libafs.nonfs.a

options AFS_NONFS	# AFS using libafs.nonfs.a
			# (no NFS support)

--------------------------------------------------------------------------------------

Step 3: Add the indicated line to /usr/sys/conf/mips/files, which lists
all of the system-independent files constituting the new kernel.
Also make the indicated changes to the lines associated with the xdr
module files.  These changes are necessary because these modules are
normally brought in with NFS (they are usually marked
"optional nfs"), but also need to be brought in with AFS.

------------------------------------------------------------------
Add the following line at the end of /usr/sys/conf/mips/files: 

	afs/libafs.c        optional AFS Binary                    

Modify the xdr module lines as shown:                          

	rpc/xdr.c               optional nfs or AFS Binary         
	rpc/xdr_array.c         optional nfs or AFS Binary         
	rpc/xdr_mbuf.c          optional nfs or AFS Binary         
	rpc/xdr_mem.c           optional nfs or AFS Binary         
	rpc/xdr_reference.c     optional nfs or AFS Binary         
------------------------------------------------------------------

Step 4: Add entries for AFS to /usr/sys/data/gfs_data.c, which contains a
table listing all supported file systems.

-------------------------------------------------------------------------------
To /usr/sys/data/gfs_data.c, add the following lines, which declare         
AFS among the other remote file system entries:                             

#ifdef AFS 
	extern struct mount *afs_gmount();                                   
#endif AFS 

Add the following lines to insert the AFS file system entry into the table. 
The entry slot number you assign to GT_AFS should match the one you used in 
/usr/sys/h/fs_types.h, in Step 1:

#ifdef AFS 
	MOUNTFS(GT_AFS) = afs_gmount;                                        
#endif AFS 
-------------------------------------------------------------------------------

Step 5: Substitute the following AFS-specific system calls for their
standard UNIX counterparts in /usr/sys/sys/init_sysent.c, which
defines all supported system calls:

 - afs_xioctl replaces ioctl (probably in slot 54)

 - afs_xsetgroups replaces setgroups (probably in slot 80)

 - afs_xflock replaces flock (probably in slot 131)

--------------------------------------------------------------------
In /usr/sys/sys/init_sysent.c, make the following substitutions: 
Replace                                                          

	3, ioctl,               /* 54 = ioctl */                 

with                                                             

#ifdef AFS 
	3, afs_xioctl,          /* 54 = afs_xioctl */            
#else                                                            
	3, ioctl,               /* 54 = ioctl */                 
#endif AFS 

Replace                                                          

	2, setgroups,           /* 80 = setgroups */             

with                                                             

#ifdef AFS 
	2, afs_xsetgroups,      /* 80 = afs_xsetgroups */        
#else                                                            
	2, setgroups,           /* 80 = setgroups */             
#endif AFS 

Replace                                                          

	2, flock,               /* 131 = flock */                

with                                                             

#ifdef AFS 
	2, afs_xflock,          /* 131 = afs_xflock */           
#else                                                            
	2, flock,               /* 131 = flock */                
#endif AFS 
-------------------------------------------------------------------- 

Step 6: Declare additional AFS-specific system calls in
/usr/sys/sys/init_sysent.c, using the single-entry system call
method.

----------------------------------------------------------------------------------
Add the following declarations to /usr/sys/sys/init_sysent.c:                  

#ifdef AFS 
int    afs_syscall(), afs_xioctl();                                            
int    afs_xflock(), afs_xsetgroups();                                         
#endif AFS 

Now declare afs_syscall in slot 31.  (In most DECstation systems, slot 31 is   
not used, so it is the default choice for afs_syscall.  If you have AFS source 
and wish to declare afs_syscall in a different slot, you must also redefine    
the slot number in /usr/afsws/include/afs/param.h.)                            

#ifdef AFS 
	7, afs_syscall,          /* 31 = afs entry call */                      
#else                                                                          
	0, nosys,                /*  31 = was entry */                          
#endif AFS 
----------------------------------------------------------------------------------

Step 7: If you followed the loading instructions in Section 5.1 (or
Section 2.3 if you building a kernel on your cell's first file
server machine), the AFS kernel modules reside in /usr/afs/sys; they
are also accessible in /usr/afsws/root.client/bin.  Copy the
appropriate AFS kernel module from /usr/afs/sys to
/usr/sys/MIPS/BINARY: either libafs.a if the kernel you are building
includes support for NFS server functionality, or libafs.nonfs.a if
it does not.

Note: For Ultrix systems, the kernel library files found in
/usr/afsws/root.client/usr/vice/etc/dkload are not appropriate for
kernel building.  You must use the modules found in /usr/afs/sys.

-------------------------------------------------------------------------
For kernels that include support for NFS server functionality:        

	# cp  /usr/afs/sys/libafs.a  /usr/sys/MIPS/BINARY/libafs.o            

For kernels that do not include support for NFS server functionality:      

	#cp /usr/afs/sys/libafs.nonfs.a /usr/sys/MIPS/BINARY/libafs.o
-------------------------------------------------------------------------

Step 8: Run ranlib on /usr/sys/MIPS/BINARY/libafs.o.

	------------------------------------------
	# ranlib /usr/sys/MIPS/BINARY/libafs.o 
	------------------------------------------

Step 9: Working in the configuration directory /usr/sys/conf/mips,
configure the kernel.

	-------------------------------
	# cd /usr/sys/conf/mips     
	# /etc/config  
	-------------------------------

Step 10: Working in the configuration kernel directory,
/usr/sys/MIPS/config_name, compile the kernel.  The resulting kernel
is suitable for (and must run on) both AFS clients and file server
machines of this system type.  It is created as
/usr/sys/MIPS/config_name/vmunix.

	------------------------------------
	# cd /usr/sys/MIPS/ 
	# make depend                    
	# make vmunix                    
	------------------------------------

If you are installing your cell's first machine, return to Section
2.11.2 (page 2-57).

If you are installing an additional file server machine, return to
Section 3.1.2.7 (page 3-37).

If you are installing an additional client machine, return to
Section 4.2.7.2 (page 4-30).

 5.10. INVOKING DKLOAD IN A MACHINE'S INITIALIZATION FILE

The section specifies the instructions you should place in a machine's start-up
file (/etc/rc or equivalent) to invoke dkload automatically at each reboot.
The dkload program is available for HP-UX, SunOS, and Ultrix systems, and must
run each time a machine reboots for the machine to be able to access AFS
(unless the machine uses a static kernel that incorporates AFS modifications).

The instructions are distributed in /usr/vice/etc/dkload/rc.dkload and appear
below.  Place them in the file after the instructions that mount the file
systems but before afsd and the BOS Server (on file server machines) are
invoked.

Note: If the machine's kernel does not include support for NFS server
functionality, substitute libafs.nonfs.a for libafs.a.  If you wish to use the
"stripped" version of the AFS library file, substitute libafss.a for libafs.a
or libafss.nonfs.a for libafs.nonfs.a.

if [ -d /usr/vice/etc/dkload ]; then
   echo 'Invoking dynamic kernel loader...' > /dev/console
   cd /usr/vice/etc/dkload
   if [ -f libafs.a ]; then
      echo 'Loading AFS' > /dev/console
      ./dkload -quiet libafs.a 1> /dev/console 2>&1
      if [ $? != 0 ]; then
	echo 'Error loading AFS' > /dev/console
      fi
   else
      echo 'Cannot load AFS--no AFS kernel library' > /dev/console
   fi
   cd /
fi

 5.10.1. INVOKING THE KERNEL EXTENSION FACILITY IN A MACHINE'S INITIALIZATION
File

IBM delivers several function-specific initialization files for AIX systems,
rather than the single file used on some other systems.  This section details
the instructions you should place in one of the machine's initialization files
to invoke the kernel extension facility automatically at each reboot.

The following list summarizes the order in which the indicated commands must
appear in the initialization files for the machine to function properly.  Note
particularly that you should not invoke nfsd at the same place in the
initialization files as the commands that load nfs.ext; nfsd must follow the
call to afsd.

 - command(s) mounting the file systems

 - command(s) loading nfs.ext, if the machine will run NFS, which an
NFS/AFS Translator machine must (but only for AIX version 3.2.2 or
lower; with AIX version 3.2.3 and higher, NFS is already loaded into
the kernel)

 - the commands shown below to invoke the kernel extension facility

 - bosserver (if this is a file server machine)

 - afsd (if this is a client machine)

 - nfsd (if the machine is to be an NFS server)

The kernel extension facility instructions are distributed in
/usr/vice/etc/dkload/rc.dkload and appear below.

If the machine's kernel does include support for NFS server functionality,
substitute export.ext.nonfs for export.ext.

If the machine will act as an NFS/AFS Translator machine, you must make a
substitution on the cfgafs command line.  The section titled "Setting Up an
NFS/AFS Translator Machine" in the NFS/AFS Translator Supplement to the AFS
System Administrator's Guide explains the substitution.

	echo 'Loading AFS ...'>/dev/console
	/usr/vice/etc/dkload/cfgexport -a /usr/vice/etc/dkload/export.ext
	/usr/vice/etc/dkload/cfgafs  -a /usr/vice/etc/dkload/afs.ext

 5.11. INVOKING MODLOAD IN A SUNOS MACHINE'S INITIALIZATION FILE

This section specifies the instructions you should place in a SunOS machine's
start-up file (/etc/rc or equivalent) to invoke modload automatically at each
reboot.  The modload program must run each time a machine reboots for the
machine to be able to access AFS (unless the machine uses a static kernel that
incorporates AFS modifications).

The instructions are distributed in /usr/vice/etc/modload/rc.modload and appear
below.  Place them in the file after the instructions that mount the file
systems but before afsd and the BOS Server (on a file server machine) are
invoked.

Note: If the machine's kernel does not include support for NFS server
functionality, substitute libafs.nonfs.o for libafs.o.

if [ -d /usr/vice/etc/modload ]; then
   echo 'Invoking modload...' > /dev/console
   cd /usr/vice/etc/modload
   if [ -f libafs.o ]; then
      echo 'Loading AFS' > /dev/console
      /usr/etc/modload libafs.o 1 > /dev/console 2 > &1
      if [ $? != 0 ]; then
	echo 'Error loading AFS' > /dev/console
      fi
   else
      echo 'Cannot load AFS--no AFS kernel library' > /dev/console
   fi
   cd /
fi