Linux STREAMS (LiS)


Node:Top, Next:, Previous:(dir), Up:(dir)

Linux STREAMS (LiS)

This file documents the Linux STREAMS (LiS) package. Linux STREAMS is a System V Release 4.2 compatible STREAMS subsystem for Linux. This edition documents version 2.16.18-16.


Node:Introduction to LiS, Next:, Previous:Top, Up:Top

Introduction to LiS

LiS is a software package that comprises an implementation of SVR4 compatible STREAMS for Linux. It takes the form of a loadable module for the Linux kernel. LiS installs in any directory on your system, not in the kernel source tree. (see Installation of LiS) When it is built it is possible to link pre-compiled STREAMS drivers with it so that when LiS loads into the kernel it brings "application" drivers with it. (see Installing Pre-Compiled Drivers) Alternatively, STREAMS drivers can be coded as loadable Linux drivers which depend upon LiS. (see Demand Loading LiS Modules) In this way, individual STREAMS drivers can be loaded and unloaded dynamically.

LiS includes two adapter drivers to assist in interfacing STREAMS drivers to the Linux Kernel's TCP/IP protocols. One driver, ip_strm_mod (see ip_strms), acts as an IP interface driver. It fits below IP using standard ifconfig procedures. It, in turn, communicates downstream with any STREAMS driver using the DLPI protocol in a fashion similar to the manner in which IP on Unix systems interfaces to lower interface drivers. This allows a DLPI STREAMS driver to act as an interface driver to Linux TCP/IP.

A second driver, ldl (see link-drvr), sits on top of any existing Linux IP interface driver and presents a DLPI interface to STREAMS drivers above. This allows any STREAMS driver that communicates downstream using DLPI to utilize the services of existing Linux drivers for Ethernet, token ring, etc.

LiS-2.12 and beyond utilizes aggressive multi-tasking in multiple CPU SMP environments. For further information concerning this implementation, see the section on LiS SMP Implementation.

LiS is licensed using the GNU General Public Library License (except for ldl, which is licensed under the standard GNU Public License). This means that you can link proprietary STREAMS drivers with LiS and load the entirety into the Linux kernel without violating license restrictions. This licensing arrangement is intended to encourage commercial software vendors to port STREAMS based driver packages to Linux.

WARNING This autoconf/RPM release of Linux STREAMS is distributed under the terms of the GNU Public License (GPL) and not the GNU Lesser Public License (LGPL).

LiS Documentation

These documentation pages are included in the LiS distribution. You can also access the original documentation release from Gcom's home page at http://www.gcom.com. Gcom's site offers a search capability that allows you to search the LiS documentation. Just use the search mechanism on the home page and restrict the search to the Linux portion of the site.

Authors

Linux STREAMS, termed LiS, is an SVR4 compatible STREAMS executive which runs in the Linux Kernel as a loadable module. It is the product of a joint effort among the following authors.

Francisco J. Ballesteros nemo@gsyc.escet.urjc.es

John Boyd jaboydjr@netwalk.com

Denis Froschauer Denis.Froschauer@hol.fr

David Grothe dave@gcom.com

Ole Husgaard sparre@login.dknet.dk

Jürgen Magin juergen.magin@octogon.de

Graham Wheeler gram@cdsec.com

G Yeganjaiah yegag@hclt.com

Brian Bidulock bidulock@openss7.org

David Grothe is the principal active supporter of LiS, so please direct questions to him rather than to the others. Ole Husgaard is responsible for the ldl driver and has contributed to the kerneld support and installation procedures. Jürgen Magin contributed patches for Linux SPARC. G Yeganjaiah added interrupt routine support. John Boyd implemented fattach and STREAMS pipes and FIFOs. Brian Bidulock developed a complete set of manual pages for LiS, converted the build process to autoconf, wrapped the source RPMS and updated this manual for texinfo.

See Author Index, for a complete listing and cross-index of authors to sections of this document.

Francisco Ballesteros still maintains an LiS mailing list. Click Here to Subscribe to the LiS mailing list

You can mail to the group by addressing email to linux-streams@gsyc.escet.urjc.es.

You can view the archives at http://gsyc.escet.urjc.es/mailarchive/linux-streams.


Node:Release Notes, Next:, Previous:Introduction to LiS, Up:Top

Release Notes


Node:OpenSS7 Releases, Next:, Up:Release Notes

OpenSS7 Releases

OpenSS7 Release LiS-2.16.18-16

General updates to the build process, optimization options, build options. Corrected library linkage. Synced TLI modules and INET driver to Linux Fast-STREAMS. Removed deadlock from INET driver and loosened locking. Unfortunately suitable libraries must be installed before distcheck will clear.

Smoother and more reliable stripping of kernel symbols, starts with /proc/ksyms if applicable then System.map then modversions.h to attempt to choose symbols most closely synced with an installed or running kernel.

Improvements to autoconf installation of manpages (autocompressed now) and info and pdf manuals are distributed. install-strip target will actually properly strip kernel modules.

Included an option to build and install only kernel or user parts of package to speed rpm rebuild process for multiple kernel. Added `rebuild' target to rebuild the rpms from srpm for multiple kernel and architectures. Added a `sign' and `resign' target to sign srpm and rebuilt rpms respectively.

Greatly enhanced cross-build and cross-compile support, primarily in support of the NexusWare embedded target. Added NexusWare helper script and documentation. DESTDIR is now a blessed environment variable used by configure to set the cross-build root as well as the install root. Try adding -with-k-optimize='size' to configure to optimize for size for embedded targets. Builds clean against NexusWare24 (810p0674.10-rc4).

Added start of an option to build as linkable object for embedded targets rather than loadable kernel module.

OpenSS7 Release LiS-2.16.18-15

Fixed several symbol errors that made -13 and -14 unusable. Corrected error in calculation of kernel debug flags.

OpenSS7 Release LiS-2.16.18-14

A few more enhancements to the build process to work with autoconf 2.59.

OpenSS7 Release LiS-2.16.18-13

Enhanced build process for autoconf-2.59, automake-1.8.3, gettext-0.14.1, and libtool-1.5.6.

OpenSS7 Release LiS-2.16.18-12

Added defaults for SK_WMEM_MAX and SK_RMEM_MAX for lastest 2.4.25 and 2.4.26 kernel builds.

Enhanced build process.

All kernel symbols exported by LiS are versioned on kernels that have versioned symbols. This makes it safer to compile kernel modules against kernel/LiS combinations. This is in preparation for splitting off the strxnet package, and the technique was imported from the Linux Fast-STREAMS build.

OpenSS7 Release LiS-2.16.18-11

Ripped three additional kernel symbols in support of INET driver that were missing in -10 release.

OpenSS7 Release LiS-2.16.18-10

Added support for cooked manpages both for non-rpm systems and for rpm systems. It is still better to leave manpages uncooked for rpm releases because they are much smaller that way. Give the -with-cooked-manpages flag to configure if you want cooked manpages. You still need grefer on the build system.

Updates to all manual pages in man7, and some others (xti) in man3. Removed unused .macros and .refs files.

Moved automake fragments into separate directory. Cleaned up automake fragments.

Rearranged header files in the xti subdirectory to install in LiS package include directory instead. Reworked xti, tihdr and tiuser file groups to include properly from kernel or user space independent of order. tiuser and xti still cannot be included together. Added older TLI interface <tiuser.h> that is still consistent with newer XTI interface. Changed references in man pages to XTI/TLI instead of just XTI.

Added ticlts.h, ticots.h and ticotsord.h header files. Updated dlpi.h and npi.h header files. Removed sys/LiS/tpicommon.h because it is largely replaced by sys/tli.h and sys/tpi.h. Removed the, now redundant, xti header file subdirectory.

A series of bug fixes to xnet.c (libxnet) that resulted from discussions with Gurol Akman on openss7-develop mailing list. Mostly surrounding t_alloc and t_getinfo behaviour and the behavior when NULL pointers are passed to various XTI/TLI library calls. Updated xti documentation as well.

Many changes to the inet.c INET driver. Wildcard IP addresses can now be bound and wildcard addresses will be assigned with no address is passed to most providers. (/dev/rawip still requires an address or TNOADDR is returned.) Option management has been extensively rewritten to be more conformant to XNS documentation. Test programs test-inet_raw, test-inet_udp, test-inet_tcp have been upgraded and converted to multiple child processes. A number of fixes to SMP lock behavior and M_FLUSH have beend added as reported by Dave Grothe. Corrected all level and TBADOPT behavior on negotiation.

Although this driver is now closer to expected behavior, it has not been tested for XNS 5.2 compliance, nor will it be until someone has the time to extend the test programs to handle all test cases in a similar manner as was done for the library. Your mileage many vary. Remember, there is no warranty.

OpenSS7 Release LiS-2.16.18-9

Changes primarily in support of builds on HPPA (PARISC) architectures. LiS doesn't build too well on PARISC so some modifications where used from the Linux Fast-STREAMS package to correct deficiencies. Better building on recent 2.4 kernels (2.4.23, 2.4.24, 2.4.25) is also provided.

OpenSS7 Release LiS-2.16.18-8

Changes to permit better builds on recent RedHat kernels, and especially kernel-2.4.20-30.9.

OpenSS7 Release LiS-2.16.18-7

Fixed a module loading bug in LiS. Previously modules would not demand load.

OpenSS7 Release LiS-2.16.18-6

Fixed a possible null pointer dereference in libxnet. Corrected t_bind to return TNOADDR instead of TBADADDR on wildcard bind attempt. Module loading bug patched.

OpenSS7 Release LiS-2.16.18-5

Fixes a t_open and t_bind problem in libxnet. Fixes alignemnt of data portion of mblks. Adds (untested) ticots_ord, ticots and ticlts devices over UNIX domain sockets.

OpenSS7 Release LiS-2.16.18-4

Adds back in missing strms_up/down/status scripts to distribution and install.

OpenSS7 Release LiS-2.16.18-3

Not publicly released.

OpenSS7 Release LiS-2.16.18-2

Not publicly released.

OpenSS7 Release LiS-2.16.18-1

This OpenSS7 release of LiS-2.16.18 updates the previous LiS-2.16.16 rpm release to the lastest LiS-2.16 release level.

OpenSS7 Release LiS-2.16.16-1

This OpenSS7 release of LiS-2.16.16 includes autoconf for configuration, complete manual pages and documentation, and packaging in source and binary RPMs for ease and repeatability of installation. The package also builds and installs properly versioned LiS shared object libraries.

Before the OpenSS7 release of LiS, it was necessary to have a significant working knowledge of the Linux kernel, kernel source, headers and other intricacies. This made it difficult to distribute software based on LiS to users not proficient in those areas. The OpenSS7 release removes the configuration and installation tasks from the user and permits distribution of applications, modules and driver software based on LiS to users without sufficient kernel expertise to install the package.

This OpenSS7 release fixes few of the outstanding bugs and deficiencies of the LiS software. This release is intended to package and distribute LiS in an efficient manner and, for the most part, does not address LiS deficiencies or errors.

This OpenSS7 release is compatible with Linux 2.4 kernels only and will refuse to configure for older or newer kernels.

Following are the new features of the OpenSS7 release of LiS:

The next release may include some strss7 software.

The remainder of the sections in this chapter are for historical purposes for LiS and are not applicable to this release.


Node:Kernel Compatibility Issues, Next:, Previous:OpenSS7 Releases, Up:Release Notes

Kernel Compatibility Issues Concerning LiS

LiS-2.16 Kernel and Driver Compatibility

LiS-2.16 is a small change from LiS-2.15. The change is that it no longer uses Linux system calls to implement getpmsg and putpmsg. Instead it overloads the read and write file system functions with particular values for the count parameter, values that are otherwise invalid.2

LiS-2.15 Kernel and Driver Compatibility

LiS-2.15 continues to insulate STREAMS drivers from the Linux kernel. It works with 2.2, 2.4, and 2.5 versions of the kernel. Support for 2.0 kernels has been dropped.

Driver writers will need to recompile their drivers against LiS-2.15 include files. You will see the following major changes.

There is one known bug in LiS-2.15 relative to 2.5 kernels. It has to do with a memory leak involving timer structures, and may prove to be a kernel bug rather than an LiS bug. Since the 2.5 kernel is not suitable for general use I am saving the investigation of this bug for later.

LiS-2.14 Kernel and Driver Compatibility

LiS-2.13 was a series of beta releases. LiS-2.14 represents the culmination of this series. There should be enough distribution and kernel compatibility that LiS-2.14 will hold up for some time.

The known fattach and FIFO bugs have still not been fixed. The author of those subsystems has not found the time to put in the fixes, nor have I.

LiS-2.13 Kernel and Driver Compatibility

This version of LiS has been tested with 2.4 kernels up to 2.4.16. LiS does not yet support the fattach/fdetach functions on kernel versions 2.4.7 and beyond. There are also known bugs in the LiS pipe/FIFO code. All of these problems are scheduled to be fixed in early 2002.

LiS-2.13 adds the ability for drivers to make their own "/dev" nodes via the lis_mknod function (see see System Calls from within the Kernel). Also provided is an lis_unlink function that allows drivers to remove their device files.

There is almost no new functionality added by LiS-2.13. The differences between LiS-2.13 and LiS-2.12 are almost entirely kernel compatibility issues and bug fixes.

LiS-2.12 Kernel and Driver Compatibility

This version of LiS is compatible with all 2.2.x versions of the kernel and with early versions of the 2.4.x kernel, at least up to 2.4.2 and perhaps later versions as well.

If you have drivers that have worked with LiS-2.10 or LiS-2.11 (or earlier) please recompile them using the header files from LiS-2.12. This may be the last recompile in quite some time that you will need for your driver code.

LiS-2.12 contains a sufficient Driver/Kernel Interface (DKI), (see see LiS Driver/Kernel Interface), that it is straightforward to write a STREAMS driver that can be compiled against LiS-2.12 and the resulting object modules used either on a 2.2 or 2.4 kernel, with only LiS needing recompilation on the target machine.

When run on 2.4 kernels, LiS makes full use of multiple CPUs (see see LiS SMP Implementation). It forks a queue runner task for each CPU and locks each task onto its CPU. Queue runner tasks are awakened to assist with service procedure processing as the number of scheduled queues increases.

Because of this aggressive use of processors, you may find that your drivers do not function properly when run with LiS-2.12 in a multi-CPU SMP environment. You should expect that drivers that worked in single-CPU environments will continue to work as before.

Making your drivers MP safe involves the use of spin locks. The DKI documentation contains advice on the use of these locks. See LiS Spin Locks.

This version of LiS also contains a rewrite of the flushing code and tests added to strtst for flushing. In particular the details of the rules for flushing queue bands are now adhered to. See Flushing Queue Bands. Be advised, however, that Solaris STREAMS does not adhere strictly to these rules so there may be some subtle differences in behavior between LiS and Solaris when flushing queue bands.

Speaking of queue bands, the queue band handling code has been debugged a bit more and a test added to strtst to illustrate its correct behavior.

Differences between LiS-2.12.2 and LiS-2.12.1

Differences between LiS-2.12.1 and LiS-2.12

Differences between LiS-2.12 and LiS-2.11

The following is a list of differences between LiS-2.11 and LiS-2.12. The list may not be complete.

LiS-2.10 Kernel and Driver Compatibility

This version of LiS is compatible with all 2.2.x versions of the Linux kernel. It may work with 2.4.x kernels, but you should probably wait for LiS-2.11 for that.

If you have drivers that worked with LiS-2.8 or earlier, you must recompile your drivers in the context of the LiS-2.10 header files. The queue_t structure has changed in size since LiS-2.8 which means that the old RD and WR macros will not compute the correct addresses.

LiS-2.10 contains features that are intended to greately reduce the necessity of recompiling STREAMS driver code in future versions of LiS or future versions of the kernel. The goal is to be able to compile STREAMS drivers against LiS-2.10 header files and use the resulting object code on both 2.2.x kernels and 2.4.x kernels.

For more details about the interface between STREAMS drivers and the kernel, see the Driver/Kernel Interface documentation, (see LiS Driver/Kernel Interface).

New Features in LiS-2.11

LiS-2.11 only differs from LiS-2.10 in that LiS-2.11 runs on kernel version 2.4.0 in addition to the 2.2 series of kernels.

NOTE: When running with a 2.4 kernel, make sure that you are using modutils at least as recent as 2.3.21. The alignment of the text segment in loadable modules changed in the 2.4 kernel and the old modutils do not understand the new alignment. The strtst program will not run correctly unless LiS is loaded using the newer modutils. You can find the source for the new modutils at http://www.kernel.org/pub/linux/utils/kernel/modutils/v2.3.

New Features in LiS-2.10

LiS-2.10 contains a number of new features since LiS-2.8. LiS-2.9 was largely a beta release that tested these features.

Kernel Version 2.3.x

For LiS version 2.7 and later and for kernel version 2.3.x there are some significant compatibility issues. See Kernel Version 2.3.x, for more on this topic.

Kernel Version 2.2.x

For LiS version 2.5 and later and for kernel version 2.2.x there are no compatibility issues; there are no kernel patches whatsoever required to install LiS. You will need LiS-2.4 at minimum to run in a 2.2.x kernel.

Kernel Version 2.0.36

The latest version of LiS has not been tested on 2.0 kernels. Therefore, do not be surprised if it does not install or execute correctly in these kernels. If you are using an old kernel, you must also use an older version of LiS, perhaps LiS-2.5.

For LiS version 2.5 and later and for kernel version 2.0.36 there are no kernel patches required to run LiS as a "bottom half" process. A one-line patch is required to run LiS as a kernel daemon process. The installation default is to run as a bottom half process in 2.0.36. LiS-1.25 or later should install properly with 2.0.36. The more recent the version of LiS, the less kernel patching is required.

Extracting Old LiS Kernel Patches (obsolete)

Previousversions of LiS installed inside the kernel source tree and included patches to the kernel in order to install LiS into the kernel. There was no provision made for removing these patches from the kernel.

Beginning with LiS-1.25 any patches made to kernels whose version number is 2.0.35 or later can be removed from the kernel just by doing a "make realclean" in the LiS installation directory. If you have installed the older version of LiS in your kernel then you need to take steps to remove it prior to installing this version of LiS.

There are two methods of doing this. Both are manual procedures.

  1. Change the name of your kernel source directory, as in
              % mv /usr/src/linux /usr/src/linux.old
              
    and then untar a fresh kernel source as /usr/src/linux. This method works fine if LiS was the only patch to your kernel. Once the new kernel works, remove the linux.old directory.
  2. In your kernel tree, do the following:
              % cd /usr/src/linux/drivers
              % rm -r streams
              
    That deletes almost all of the files that came with the old version of LiS. Next, you must restore the patched kernel files to their original state. From the directory /usr/src/linux, look for the following files:
    LiS:
    • arch/i386/kernel/entry.S.orig
    • fs/read_write.c.orig
    • fs/select.c.orig
    • kernel/ksyms.c.orig
    • init/main.c.orig
    • include/asm-i386/unistd.h.orig
    • drivers/Makefile.orig

    Semaphores:
    • arch/i386/lib/semaphore.S.orig
    • kernel/sched.c.orig
    • include/asm/semaphore.h.orig

    If you do not have any other patches applied to these files, then change their names back to the original file names (these names minus the .orig suffix). Not all of these files will be present on every version of the kernel. Kernels later than 2.0.30 would not have had the semaphore patch, for example.

    If you have other patches in these files then you will need to consult one of the following files from the newly installed /usr/src/LiS directory:

    There is really no recourse at this point other than to examine the patches and manually extract the LiS patches from the affected files.


Node:Open Flags, Next:, Previous:Kernel Compatibility Issues, Up:Release Notes

Open Flags (obsolete)

The open flags MODOPEN and CLONEOPEN have been changed since the previous version. You must recompile your STREAMS drivers using the new header files in order to incorporate this change. The change brings the bit assignments into conformance with SVR4. STREAMS drivers compiled against the old header files should not be linked into LiS without recompiling. The old open routines will misinterpret their flags argument.


Node:System Calls, Next:, Previous:Open Flags, Up:Release Notes

System Calls (obsolete)

This change affects all application level programs that use the STREAMS constructs getpmsg, putpmsg or poll.

For kernel versions prior to 2.0.36, LiS did not have official system call numbers assigned for getpmsg, putpmsg and poll. Beginning with kernel version 2.0.36, and all 2.2 kernels, LiS has official system call numbers assigned for getpmsg and putpmsg. The 2.2 kernels have a built-in poll system call. Therefore, there is no LiS poll system call in 2.2 kernels.

The system call slots that LiS used for getpmsg and putpmsg in earlier kernels were, of course, taken up by other functions by the time the official system call slots got assigned for the 2.2 (and 2.1) kernel. That means that older STREAMS applications compiled for use with earlier versions of LiS, when run on newer kernels, will be issuing incorrect system calls for getpmsg and putpmsg. These applications need to be recompiled and relinked using the new LiS.

The new version of LiS, even when run on kernels prior to 2.0.36, will always plug the system call table slots for the new "official" STREAMS system calls in addition to the older ad hoc slots. This means that you can use applications that utilize putpmsg and getpmsg with the new system calls on older kernels by using the new version of LiS.

However, the poll system call is not so easy. If your application uses poll then you must maintain a version of it that is compatible with kernel versions prior to 2.0.36 and another version that is compatible with kernel versions 2.0.36 and beyond, including 2.2 kernels. The reason for this is that prior to 2.0.36, LiS contained the only implementation of the poll system call. However, starting with 2.0.36, the kernel contains its own implementation of poll and the LiS implementation must yield to the kernel's implementation. The system call slot used by LiS for poll and the one used by the Linux kernel are different. So there is really no way around maintaining two versions of such applications.

The following table summarizes the system call number assignments for different kernel versions. Numbers in plain text are the ad hoc numbers used by earlier versions of LiS. Numbers in italics are official kernel assigned numbers. The problem with the poll system call is that the number 169, used by earlier version of LiS, is used for a different system call in kernel version 2.0.36 and beyond. Thus, it is not possible for LiS to plug that system call slot with a pointer to its poll routine for backward compatibility.

            Version                          Getpmsg Putpmsg Poll
            LiS for kernel versions < 2.0.36   168     167   169
            LiS for kernel version 2.0.36      188     189   168
            LiS for kernel versions >= 2.2.0   188     189   168
     

In kernel versions 2.0.36 and earlier, LiS provides the implementation of the poll system call. In 2.2 kernels, the kernel provides the implementation of poll and LiS hooks into it on behalf of its STREAMS drivers.


Node:Libraries, Next:, Previous:System Calls, Up:Release Notes

Libraries

The older version of LiS had direct inline code for STREAMS system calls defined in stropts.h. The new version contains function prototypes in stropts.h with the actual system call code contained in a library that you link with your application program. The library resides in the directory /lib and is named libLiS.a. Thus, you need to include the directive "-lLiS" with the link of your STREAMS applications. For more about LiS libraries, See LiS Library Routines.


Node:Other Interactions, Next:, Previous:Libraries, Up:Release Notes

Interactions with Other Packages

In kernel versions around 2.2.14 there were some compile time clashes with the irda driver. These have been resolved and/or worked around in LiS-2.10.

On kernel version prior to 2.0.36 there can be problems with LiS interacting with other packages such as JDK and, perhaps, iBSC. In particular, JDK looks to see if system call number 168 has been assigned. If it has, it assumes that the operating system implements the poll system call in that slot. As you can see from the chart above, older versions of LiS did plug system call 168, but with the getpmsg routine, not with poll. Although we do not know for sure there is a possibility that iBSC would have the same problem.

The solution is to upgrade to a kernel at least as new as 2.0.36 or a 2.2 series kernel.


Node:Kernel Version 2.3.x, Next:, Previous:Other Interactions, Up:Release Notes

Compatibility with Kernel Version 2.3.x

Version 2.3 of the Linux kernel brings with it some compatibility issues that need to be addressed by the LiS user. The two most important ones concern the file <sys/stropts.h> and the major device numbers used by LiS.


Node:stropts.h Compatibility, Next:, Previous:Kernel Version 2.3.x, Up:Release Notes

stropts.h Compatibility

There are no more compatibility problems with <sys/stropts.h> with glibc-2.1 and LiS-2.10. The following is more for historical purposes than practical necessity.

Beginning at least with egcs-2.91.66 (egcs-1.1.2 release), which comes with Red Hat 6.0, there is a file in the standard include directory named <sys/stropts.h>. This file has constant definitions that are incompatible with those used in LiS/include/sys/stropts.h. If you compile an application against the glibc version of stropts.h, and compile LiS using its own version then certain ioctls may not work correctly. You should be aware of this problem and be sure to include "-I/usr/src/LiS/include" in the compiler options that you use in compiling your STREAMS based applications.

In this version of LiS, some of the constants in stropts.h have been changed to conform to the values used by UnixWare and Solaris. These are different values than previously used in LiS. When you install LiS the installation procedure will ask you whether you want LiS compiled with the backward-compatible LiS constants, or the UnixWare/Solaris compatible constants. Logically speaking, it does not matter which set you use as long as LiS and your application code are both compiled with the same values.

I highly recommend that you use the UnixWare/Solaris compatible version, however. A future release of egcs, utilizing glibc 2.2, will contain an updated version of its stropts.h which has constants that are compatible with UnixWare, Solaris and LiS. So by selecting the UnixWare/Solaris compatible version at this time you can ensure that your applications will be fully compatible with these values in the future.

With any luck, these constants will never have to change again.


Node:Major Device Number Compatibility, Previous:stropts.h Compatibility, Up:Release Notes

Major Device Number Compatibility

The second major compatibility issue concerns the major device numbers that LiS assigns to STREAMS devices. In the past LiS based these device numbers at 50, since the Linux kernel did not pre-define many major device numbers. As of kernel version 2.3.x there are major device numbers defined up to 220 and beyone! So starting with LiS-2.12, we have used the major number of 240 as the base for STREAMS device files. This range is supposed to be reserved for "experimental drivers" which should make it safe to use.

What this means is that you must be sure to run the strmakenodes program before running any STREAMS applications after installing LiS-2.12. This need not concern you overly, since doing a "make install" in the /usr/src/LiS directory causes strmakenodes to be run anyway. This is more a concern if you are compiling LiS on one machine and then loading it onto another for execution. In such cases you may need to load the new strmakenodes program and run it.

I am hoping that the kernel developers will expand the major and minor device number spaces for 2.6. If they do that then LiS should be able to get a block of majors allocated to it.


Node:Downloading LiS, Next:, Previous:Release Notes, Up:Top

Downloading LiS

The OpenSS7 release of LiS can be downloaded from the downloads page at http://www.openss7.org/download.html. It is available in tar ball, SRPM and (for popular architectures) RPM format.

If you are using a browsable viewer, you can obtain this OpenSS7 release of LiS from the following links:


Node:Downloading the Binary RPMs, Next:, Up:Downloading LiS

Downloading the Binary RPMs

To install from Binary RPM, you will need all of the following kernel indepdendent packages for your architecture, and one of the kernel-depdendent packages from the next section.

Kernel-Independent Binary RPMs

All of the following kernel-independent packages are required for your architecture. If your architecture is not on the list, you can build binary RPMs from the source RPM (see Downloading the Source RPM).

LiS-lib-2.16.18-16.i686.rpm
The LiS-libs package contains the run-time shared libraries necessary to run applications programs developed for Linux STREAMS. In addition, it contains a user-space implementation of the STREAMS subsystem.
LiS-doc-2.16.18-16.i686.rpm
The LiS-docs package contains html documentation for the development of STREAMS applications, modules and drivers.
LiS-devel-2.16.18-16.i686.rpm
The LiS-devel package contains library archives for static compilation, headers files to develop STREAMS modules and drivers. This also includes the header files and static libraries required to compile STREAMS applications programs. In addition it contains all of the manual pages necessary for developing STREAMS application programs.
LiS-dev-2.16.18-16.i686.rpm
The LiS-devs package contains the device definitions necessary to run applications programs developed for Linux STREAMS.
LiS-source-2.16.18-16.i686.rpm
The LiS-source package contains the source code necessary for building the LiS release. It includes the autoconf configuration utilities ncessary to create and distribute this rpm.
LiS-util-2.16.18-16.i686.rpm
The LiS-utils package provides adminstrative and configuration test utilities and commands associated with the Linux STREAMS package.

Kernel-Dependent Binary RPMs

One of the following kernel-dependent packages is required. We have provided binary RPMS for RedHat 7.x UP boot kernels only.

LiS-core-2.4.20-30.9BOOT-2.16.18-16.i686.rpm
The LiS-core-2.4.20-30.9BOOT package contains the kernel modules that provide the Linux kernel SVR 4.2 STREAMS facility. This also includes assorted basic STREAMS drivers and modules such as pipes, fifos, timod, tirdwr, echo, etc. This package is heavily tied to the kernel for which it was compiled. This package applies to kernel version 2.4.20-30.9BOOT.

Installation

To install the binary RPMs, See Installing the Binary RPMs.


Node:Downloading the Source RPM, Next:, Up:Downloading LiS

Downloading the Source RPM

If you cannot obtain a binary RPM for your architecture, or would like to roll your own binary RPM, download the following source RPM.

LiS-2.16.18-16.src.rpm
This is the source RPM for the package. From this souce RPM it is possible to build binary RPMs for any supported architecture and for any 2.4 kernel. For details on this process, See Installation of LiS.

Installation

To install the source RPM, See Installing the Source RPM.


Node:Downloading the Tar Ball, Next:, Up:Downloading LiS

Downloading the Tar Ball

For non-RPM architectures such as the NexusWare embedded target, download the tarball as follows:

LiS-2.16.18-16.tar.gz
LiS-2.16.18-16.tar.bz2
These are the tar balls


Node:Old LiS Download Instructions, Next:, Up:Downloading LiS

Old LiS Download Instructions

WARNING: the following instructions are for downloading the original releases of LiS from Gcom's website:

Downloading LiS (obsolete)

LiS can be downloaded using a browser, or the FTP utility. Save the file somewhere outside the kernel source code tree. We recommend using the directory /usr/src or /usr/local/src.

Downloading via Browser

If you are viewing this document with a web browser, you can download LiS by clicking here. This will take you to a directory containing a number of LiS tar archives. The symbolic link Latest-LiS points to the latest version. The .message file also contains information about the latest version.

Downloading via FTP

Connect to ftp.gcom.com and change to the directory /pub/linux/src/LiS. This directory contains all the LiS tar archives. The symbolic link Latest-LiS points to the latest version. The .message file also contains information about the latest version.

After Downloading

Untar the file using a command similar to the following:

     % tar xzf LiS-2.16.tgz
     

This will create a subdirectory named LiS-2.16 containing all of the files and subdirectories for LiS.

Installation

See Old LiS Installation Instructions.


Node:Installation of LiS, Next:, Previous:Downloading LiS, Up:Top

Installation of LiS


Node:Installing the Binary RPMs, Next:, Previous:Downloading the Binary RPMs, Up:Installation of LiS

Installing the Binary RPMs

If you have downloaded the necessary binary RPMs (see Downloading the Binary RPMs) or have built binary RPMS (see Installing the Source RPM) then the following instructions will install the RPMs on your system. (See rpm(8) for additional information on rpm.)

     % cd RPMS/i686
     % rpm -ihv LiS-*-16.i686.rpm
     

You must have the correct binary RPMs downloaded or built for this to be successful.


Node:Installing the Source RPM, Next:, Previous:Downloading the Source RPM, Up:Installation of LiS

Installing the Source RPM

If you have downloaded the necessary source RPM (see Downloading the Source RPM), then the following instructions will rebuild the binary RPMs on your system. Once the binary RPMs are rebuilt, you may install then a described above (see Installing the Binary RPMs).

The source RPM is rebuilt to binary RPMs as follows:

     % rpm --rebuild LiS-2.16.18-16.src.rpm
     

The rebuild process can also recognize a number of options that can be used to tweak the resulting binaries. They are as follows:

--define "_kversion $PACKAGE_KVERION"
Specifies a kernel version other than the running kernel for which to build. If _kversion is not defined when the RPM is rebuilt, the environment variable PACKAGE_KVERSION is used. If the environment variable is not defined, then the verion of the running kernel is used as the target version for Linux STREAMS kernel modules.
--with modules, --without modules
Specifies whether kernel modules packages are to be rebuilt. The default is to build kernel modules. This option can be useful when rebuilding for multiple architectures and target kernels. The rebuild automake taret uses this feature to rebuild for all available architectures and kernels.
--with tools, --without tools
Specifies whether user space packages are to be rebuilt. The default is to build user space packages. This option can be useful when rebuilding for multiple architectures and target kernels. The rebuild automake taret uses this feature when rebuilding for all available architectures and kernels, to rebuild user packages once per architecture instead of once per kernel.
--with cooked-manpages, --without cooked-manpages
Some systems do not like grefer references in manpages. This option will cook soelim, refer, tbl, and pic commands from the manpages and also strip roff comments. The default is to leave manpages uncooked (they are actually smaller tha way).
--with public, --without public
Release public packages or private packages. This option has no effect. The default is to release public packages.
--with k-debug, --without k-debug
Specifies whether kernel debugging is to be perforemed. Mutually exclusive with test and safe below. This has the effect of removing static and inline attributes from functions and invoking all debugging macros in the code. The default is to not perform kernel debugging.
--with k-test, --without k-test
Specifies whether kernel testing is to be perforemed. Mutually exclusive with debug above and safe below. This has the effect of removing static and inline attributes from functions and invoking most debugging macros in the code. The default is to not perform kernel testing.
--with k-safe, --without k-safe
Specifies whether kernel safety is to be performed. Mutually exclusive with debug and test above. This has the effect of invoking some more pedantic assertion macros in the code. The default is to not apply kernel safety.
--with solaris-cmn_err, --without solaris-cmn_err
Specifies whether Solaris-style cmn_err is used. The Solaris style prints a newline at the end of each statement. The SVR 4.2 style prints a newline at the beginning of each statement unless CE_CONT is specified. Linux kernel logs use the former, so this defaults to Solaris-style.
--with solaris-consts, --without solaris-consts
Attempt to be compatible with Solaris constants. The default is to attempt to be compatible with SVR 4.2/Unixware constants.
--with k-cache, --without k-cache
Invoke Linux kernel caching on primary structures. This incresase speed and efficiency. The default is to perform kernel caching on primary structures.
--with k-timers, --without k-timers
Invoke Linux kernel cahcing on timer structures. This increases speed and efficiency but is unsafe on SMP architectures and for buggy drivers. The default is to perform kernel caching on timer structures.
--with broken-cpu-flags, --without broken-cpu-flags
Specify int instead of long interrupt flags. Linux uses long interrupt flags exclusively. The default is to use long interrupt flags.
--with tli, --without tli
Build and package the TLI modules (streams-timod.o and streams-tirdwr.o). These are needed by the XTI/XNS Unix98 libraries. The default is to build and package TLI modules.
--with inet, --without inet
Build and package the INET driver (streams-inet.o). This driver is needed for XTI/XNS Unix98 compatibility. The default is to build and package the INET driver.
--with xnet, --without xnet
Build and package the XTI/XNS library (libxnet). This library is needed for XTI/XNS Unix98 compatiblity. The default is to build and package the XNET library.

In general, the default values of these options are sufficient for most purposes and no options need be provided when rebuilding the Source RPMs.


Node:Installing the Tar Ball, Next:, Previous:Downloading the Tar Ball, Up:Installation of LiS

Installing the Tar Ball

Native Build Tar Ball Installation

Following is an example for a native build against the running kernel:

     % wget http://www.openss7.org/LiS-2.16.18-16.tar.bz2
     % tar -xjvf LiS-2.16.18-16.tar.bz2
     % cd LiS-2.16.18-16
     % ./configure
     % make
     % make install-strip
     

Cross-Build Tar Ball Installation

Following is an example for a cross-build. The kernel release version must always be specified fro a cross build. If you are cross-building specify the root for the build with DESTDIR. The cross-compile host must be specified if different from the build host and either the compiler and other tools must be in the usual places where GNU autoconf can find them or they must be specified with declarations such as CC=/u5/NexusWare24/ppc-linux/gcc on the configure command line. Look in the file configure.nexusware for an example.

     % wget http://www.openss7.org/LiS-2.16.18-16.tar.bz2
     % tar -xjvf LiS-2.16.18-16.tar.bz2
     % cd LiS-2.16.18-16
     % ./configure DESTDIR="/some/other/root" \
             --with-k-release=2.4.18 --host sparc-linux
     % make
     % make install-strip
     

NexusWare Tar Ball Installation

Additional support is provided for cross-building for the Performance Technologies Inc. NexusWare embedded target for the CPC-384, CPC-388 and CPC-396 cards. A configuration script wrapper (configure.nexusware) is provided to simply the cross-build operation for these targets.

Follow the normal NexusWare instructions for rebuiding a generic kernel and flash image as follows: (I keep my NexusWare build in /u5/NexusWare24.)

     % cd /u5/NexusWare24
     % source SETUP.sh
     % make
     

Next download, unpack, configure using the provide configure.nexusware wrapper for configure. This wrapper simply tells the configure script where to find the NexusWare sources and which NexusWare cross-building tools to use for a cross compile.3

Any of the normal configure script options described below can be used on the same line as ./configure.nexusware. One of particularl interest to embedded targets is --with-k-optimize=size to attempt to reduce the side of the kernel modules.

Install as normal, however, for embedded targets the install-strip target should be used instead of the install target. The install-strip target will strip unnecessary symbols from kernel modules and further reduce their size in the root filesystem flash image.

Following it what I use for configuration and installation: (My NexusWare tree is rooted at /u5/NexusWare24.)

     % wget http://www.openss7.org/LiS-2.16.18-16.tar.bz2
     % tar -xjvf LiS-2.16.18-16.tar.bz2
     % cd LiS-2.16.18-16
     % # (cd /u5/Nexusware; source SETUP.sh)
     % # or export NEXUSWARE_PREFIX=/u5/NexusWare24
     % # if not done in step above
     % ./configure.nexusware --with-k-optimize=size
     % make
     % make install-strip
     

Once built an installed in the NexusWare directory, you will have to (currently) hand edit a .spec file to include the components you want in the NexusWare root file system. If you are cross-building for NexusWare your should already know what that means. Objects that you might be interested in copying to the root file system are kernel modules that were installed in $NEXUSWARE_PREFIX/lib/modules/2.4.18/misc, libraries installed in /usr/lib and utility functions installed in /usr/bin, /usr/sbin and test programs in /usr/libexec. If you would prefer that these programs be installed in /lib, /bin, /sbin and /libexec (say, because you want to remote mount the /usr directory after boot), then specify --exec-prefix / to ./configure.nexusware.

In addition, because NexusWare does not include an /etc/modules.conf file by default, it will be necessary to add one or edit your rc.4 file to insmod the necessary LiS modules at boot time.

Once you have completed the necessare .spec and rc.4 file entries, you need to rebuild the generic kernel flash image once more for these objects to be included in the flash file system. It is important that this second build of the kernel image be the same as the first.

When modifying and rebuilding a NexusWare kernel, it will be necessary to rebuild and install LiS. Simply perform the last make install-strip stage or start again with ./configure.nexusware. You can place the unpacked tarball in $NEXUSWARE_PREFIX/usr/src/LiS, and add the following to the top-level NexusWare makefile to make the build process a single step process instead of dual pass:

     all:
     ...
             (cd kernels/generic; $(MAKE) depend)
             (cd usr/src/pcmcia-cs-3.2.1; $(MAKE) config)
             (cd kernels/generic; $(MAKE))
             (cd usr/src/pcmcia-cs-3.2.1; $(MAKE) pti)
             (cd usr/src/pti; $(MAKE))
             (cd drivers; $(MAKE))
             (cd utility; $(MAKE))
     #       uncomment for LiS build
     #       (cd usr/src/LiS; ./configure.nexusware; make install-strip)
             (cd build/generic; $(MAKE))
     ...
     

Configuration Options

All of the normal GNU autoconf configuration options and environment variables apply. Additional options and environment variables are provided to tailor or customize the build and are described below.

Configure Options

Following are the additional configure options, their meaning and use:


--disable-compress-manpages
Compress manpges with gzip -9 or leave them uncompressed. The default is to compress manpages with gzip -9 if a single compressed manpage exists in the target installation directory. This disables automatic compression.
--disable-public
Disable public release. Has no effect on LiS releases. No private components exist in LiS releases.
--enable-tools
Specifies whether user space programs and libraries are to be built and installed. The default is to build and install user space programs and libraries. This option can be useful when rebuilding for multiple architectures and target kernels. The rebuild automake taret uses this feature when rebuilding RPMs for all available architectures and kernels, to rebuild user packages once per architecture instead of once per kernel.
--enable-modules
Specifies whether kernel modules are to be built and installed. The default is to build and install kernel modules. This option can be useful when rebuilding for multiple architectures and target kernels. The rebuild automake target uses this feature to rebuild for all available architectures and kernels.
--enable-user-mode
Enable user mode build. The default is no. Don't use this option, it hasn't been tested.
--disable-modules
Disable kernel modules, prepare object for linking into the kernel. The default is to build as kernel modules. This option is not fully implemented yet.
--enable-k-inline
Enable kernel inline functions. Most Linux kernels build without -finline-functions. This option adds the -finline-functions and -Winline flags to the compilation of kernel modules. Use with care.
--enable-k-safe
Enable kernel module run-time safety checks. Specifies whether kernel safety is to be performed. Mutually exclusive with test and debug below. This has the effect of invoking some more pedantic assertion macros in the code. The default is to not apply kernel safety.
--enable-k-test
Enable kernel module run-time testing. Specifies whether kernel testing is to be perforemed. Mutually exclusive with debug below and safe above. This has the effect of removing static and inline attributes from functions and invoking most debugging macros in the code. The default is to not perform kernel testing.
--enable-k-debug
Enable kernel module run-time debugging. Specifies whether kernel debugging is to be perforemed. Mutually exclusive with safe and test above. This has the effect of removing static and inline attributes from functions and invoking all debugging macros in the code. The default is to not perform kernel debugging.
--enable-broken-cpu-flags
Specify int instead of long interrupt flags. Linux uses long interrupt flags exclusively. The default is to use long interrupt flags.
--enable-k-cache
Invoke Linux kernel caching on primary structures. This incresase speed and efficiency. The default is to perform kernel caching on primary structures.
--enable-k-timers
Invoke Linux kernel cahcing on timer structures. This increases speed and efficiency but is unsafe on SMP architectures and for buggy drivers. The default is to perform kernel caching on timer structures.
--with-cooked-manpages
Convert manual pages to remove macro dependencies and grefer references. Some systems do not like grefer references in manpages. This option will cook soelim, refer, tbl, and pic commands from the manpages and also strip roff comments. The default is to leave manpages uncooked (they are actually smaller tha way).
--with-rpm-epoch=EPOCH
Specify the EPOCH for the RPM spec file. [default=1]
--with-rpm-release=RELEASE
Specify the RELEASE for the RPM spec file. [default=Custom]
--with-gpg-user=USERNAME
Specify the USERNAME for signing RPMs and tarballs. [default=${GNUPGUSER}]
--with-gpg-home=HOMEDIR
Specify the HOMEDIR directory for signing RPMs and tarballs. [default=${GNUPGHOME:-~/.gnupg}]
--with-k-release=UTSRELEASE
Specify the UTS release of the linux kernel for which the build is targetted. When not cross compiling, if this option is not set, the build will be targetted at the kernel running in the build environment. [default=`uname -r`] When cross-comipling this option must be specified or the configure script will generate an error.
--with-k-prefix=DIR
Specify the kernel directory prefix for install. [default=/]
--with-k-rootdir=DIR
Specify the root directory for configure. [default=${DESTDIR:-/}]
--with-k-modules=DIR
Specify the directory to which kernel modules will be installed. [default=/lib/modules/K-RELEASE/misc]
--with-k-build=DIR
Specify the base kernel build directory in which configured kernel source resides. [default=K-MODULES-DIR/build]
--with-k-sysmap=MAP
Specify the kernel system map file. [default=K-BUILD-DIR/System.map]
--with-k-includes=DIR
Specify the include directory of the kernel for which the build is targetted. [default=K-BUILD-DIR/include]
--with-k-archdir=DIR
Specify the kernel source architecture specific directory. [default=K-BUILD-DIR/arch]
--with-k-machdir=DIR
Specify the kernel source machine specific directory. [default=K-ARCHDIR/ARCH]
--with-k-optimize=HOW
Specify optimization, normal, size, speed or quick. [default=normal] size compiles kernel modules -Os, speed compiles kernel modules -O3, and quick compiles kernel modules -O0.
--with-sctp
Include xopen sctp driver in build. [default=yes] Unused.
--with-sctp2
Include xopen sctp version 2 driver in build. [default=no] Unused.
--with-xns
Include xopen xns headers in install. [default=yes]
--with-tli
Include xopen tli modules in build. [default=yes] Build and package the TLI modules (streams-timod.o and streams-tirdwr.o). These are needed by the XTI/XNS Unix98 libraries. The default is to build and package TLI modules.
--with-inet
Include xopen inet driver in build. [default=yes] Build and package the INET driver (streams-inet.o). This driver is needed for XTI/XNS Unix98 compatibility. The default is to build and package the INET driver.
--with-xnet
Include xopen xnet library in build. [default=yes] Build and package the XTI/XNS library (libxnet). This library is needed for XTI/XNS Unix98 compatiblity. The default is to build and package the XNET library.
--with-sock
Include xopen sock library in build. [default=yes]
--with-solaris-consts
Use Unixware/Solaris compatible constants if yes, or use LiS backward compatible constants if no. [default=yes]
--with-solaris-cmn_err
Use a Solaris-style cmn_err that puts a newline at the end of the line rather than the beginning [default=yes]
--with-strconf-master=FILENAME
Specify the file name to which the configuration master file is written [default=Config.master]
--with-base-major=MAJOR specify the base major device number from which to
Start numbering major devices [default=230]
Environment Variables

Following are the additional environment variables to configure, their meaning and use:


SOELIM
Roff source elminiation command. This is only necessary when the option --with-cooked-manpages has been specified. By default, the configuration script will search for this tool.
REFER
Roff references command. This is only necessary when the option --with-cooked-manpages has been specified. By default, the configuration script will search for this tool.
TBL
Roff table command. This is only necessary when the option --with-cooked-manpages has been specified. By default, the configuration script will search for this tool.
PIC
Roff picture command. This is only necessary when the option --with-cooked-manpages has been specified. By default, the configuration script will search for this tool.
GZIP
Manpages compression command. This is only necessary when the option --without-compressed-manpages has not been specified. By default, the configuration script will search for this tool.
RPM
Rpm command. This is only necessary for RPM builds. By default, the configuration script will search for this tool.
RPMBUILD
Build rpms command. This is only necessary for RPM builds. By default, the configuration script will search for this tool. rpm will be used instead of rpmbuild if rpmbuild cannot be found.
GPG
GPG signature command. This is used for signing distributions by the maintainer. By default, the configuration script will search for this tool.
GNUPGUSER
GPG user name. This is used for signing distributions by the maintainer.
GNUPGHOME
GPG home directory. This is used for signing distributions by the maintainer.
LDCONFIG
Configure loader command. Command used to configure the loader when libraries are installed. By default, the configuration script will search for this tool.
DESTDIR
Cross build root directory. Specifies the root directory for build and installation. e.g. for NexusWare cross-builds, this is set to $NEXUWARE_PREFIX on configuration to point to the root of the cross-build tree for both configuration and installation.
DEPMOD
Build kernel module dependencies command. This is used during installation of kernel modules to a running kernel to rebuild the modules dependency database. By default, the configuration script will search for this tool.
MODPROBE
Probe kernel module dependencies command. This is used during installation of kernel modules to a running kernel to remove old modules. By default, the configuration script will search for this tool.
LSMOD
List kernel modules command. This is used during installation of kernel modules to a running kernel to detect old modules for removal. By default, the configuration script will search for this tool.
LSOF
List open files command. This is used during installation of kernel modules to a running kernel to detect old modules for removal. Processes owning the old kernel modules will be killed and the module removed. If the process restarts, the new module will be demand loaded. By default, the configuration script will search for this tool.
GENKSYMS
Generate kernel symbols command. This is used when bulding generating module symbol versions during build. By default, the configuration script will search for this tool.


Node:Old LiS Installation Instructions, Next:, Previous:Old LiS Download Instructions, Up:Installation of LiS

Old LiS Installation Instructions

WARNING: the folowing procedures are for installing the Gcom release. These installation procedures are not applicable to the OpenSS7 release.

Installation of LiS is performed using a configuration script and then running "make". If you run "make" with no configuration file present, the makefile will run the configuration script automatically.

For the installation to proceed to its conclusion you must be logged in as "root". However, you can install LiS using a non-privileged user id. In this case the compilation of LiS will proceed but the installation of the resulting module will likely fail due to permission problems.

The easiest way to install LiS is to proceed as follows.

     % cd /usr/src/LiS-2.16 (Or wherever you installed the files)
     % make
     % make install
     

The version number in the above example is used for illustrative purposes only. Use the version number of the package that you downloaded.

The makefile will automatically run the LiS Configure script. You will be asked a series of questions by the configuration script and then the build will proceed. If your intent is to install and run LiS on your currently running Linux kernel then you are safe in answering all questions by hitting the Enter key, that is, using default answers.

The configuration script will make a symbolic link from /usr/src/LiS to whatever directory the Configure script was run from. This makes it easy to refer to the directory containing the latest installed version of LiS. This symbolic link will only be made if the Configure script (or initial "make") is run under "root".

Once the "make" is complete, enter make install to install the LiS utility programs in their proper places on your system.

If you want to uninstall LiS, enter make very-clean. When it completes you can then do rm -rf /usr/src/LiS-2.16 (or whatever version of LiS you are removing). For more information about uninstalling LiS, See Removal of LiS.

Configuration

The configuration is extremely simple for the most common case of using LiS. This case occurs when you intend to run LiS as a loadable module installed in the directory /lib/modules/kernel-version/misc and your kernel source resides in the directory /usr/src/linux. For this case you can simply hit Enter/Return to select the default answer for each question and proceed quickly to the compilation phase.

If at any time you think that the configuration process has taken a wrong turn, you can terminate it by typing Ctrl-C (or your equivalent "intr" character). You can then start over from the beginning.

Re-Configuration

You can re-configure LiS by running the Configure script again at any time. The defaults for a re-configuration are the settings arrived at by the most recent previous run of Configure.

If you get your configuration hopelessly out of whack, just remove the file config.in and run Configure (or make). This will start over just as for a fresh installation.

When you change the configuration parameters it is a good idea to do a "make clean" before doing a "make".

Making LiS

You can make LiS by typing "make; make install" in the LiS installation directory.

The following make targets are defined.

Default target
Compile LiS plus binary drivers into streams.o. Copy to modules directory if configured to do so. Compile utility programs.
install
Makes the LiS library routines and utilities. Installs utilities in their proper directories. Runs strmakenodes to make /dev entries for STREAMS drivers.
uninstall
Removes the STREAMS utility programs and the files created in the /dev directory.
clean
Remove all object code and utility programs. Leave configuration file in place.
realclean
Like "clean" except remove configuration files as well. very-clean This is equivalent to "make uninstall clean realclean".
dep
Make dependencies. Done automatically by default target. all Like default target except skip steps requiring root login.

Utility Programs Made

In addition to the file streams.o, which contains LiS and any STREAMS drivers linked with it, the build procedure also makes the following utility programs. These programs are copied to the indicated directory if the "make" uses the default make target and if you are logged in as "root". These programs are documented separately, (see see LiS User Commands).

/usr/sbin/streams
Prints out statistics from running LiS. Sets debug mask for LiS.
/usr/sbin/strconf
Interprets STREAMS driver Config file and generates corresponding config.h and makenodes.c files.
/usr/sbin/strmakenodes
Program to make /dev entries for STREAMS drivers. The result of compiling makenodes.c.
/usr/local/bin/strtst
A comprehensive test program for STREAMS.
/usr/local/bin/timetst
Times round-trip delay from user application to STREAMS loopback driver.

Of these programs, only strmakenodes and strconf are essential to the operation of LiS. Strmakenodes must be run prior to attempting to use any STREAMS application programs to make the proper entries in the /dev directory for STREAMS files.

The strconf program is needed for the build of LiS itself. However, the LiS build executes the program from the local LiS installation directory. Thus it is not necessary to copy this program to /usr/sbin in order to make streams.o.

Configuration Procedure

The following sections describe the steps of the Configure script.

User or Kernel

The first question posed by the Configure script is the type of environment that LiS is to run in. The default is to build LiS to run in the Linux kernel. You can also build a user-space version of LiS that can be used for "laboratory" testing. The QNX alternative is not useful.

Kernel Source Location

Configure asks you for the location of your kernel source tree. The default is /usr/src/linux and likely suffices for the vast majority of cases. Once Configure has this information it can determine the version of the kernel for which you are compiling LiS.

Kernel version 2.0.x is no longer supported and the LiS installation will fail if Configure detects this kernel version.

If your kernel source has not had "menuconfig" run on it yet, Configure will propose doing so at this time automatically.

Likewise, if you have not done a "make dep" on your kernel source yet, Configure will propose doing so at this time automatically.

Kernel Version Verification

The LiS Configure script discovers the version of your kernel by looking in several places in your kernel source directory. If it cannot determine your kernel version the LiS configuration will terminate. The Configure script cannot proceed without this information.

The Configure script then asks for your verification of the kernel version for which LiS is to be compiled. Note, that the kernel for which you are compiling LiS does not have to be the kernel version on which your system is running. If you gave Configure a pathname to your intended kernel source version in the previous step this could be a different kernel version than the one that is running on your machine.

You can also enter a kernel version other than the one found in version.h at this time. However, entering such a version may cause the subsequent "make" to make unverified assumptions about your kernel version. So be careful about answering this question with anything other than an Enter/Return.

If the kernel version displayed does not match your idea of the version of the kernel that resides at the indicated location on disk, it is probably best to terminate the Configure program at this point and investigate rather than end up compilation or module loading errors.

Kernel Option Verification

The Configure script will ask you if you intend to run LiS on the same kernel that is running on the installation machine. This is the most common case of installing LiS, so the default answer is "yes."

If you answer "yes" to this question then the Configure script will verify that the kernel version in you kernel source directory matches the stated version of your running kernel. It will also verify that the kernel options of SMP and module versions are the same between the two kernel locations. If any discrepencies are found the installation of LiS will terminate.

It is important for the correct operation of LiS, and the STREAMS drivers that utilize LiS, that these options be in agreement between the running kernel and the kernel source. If they are not, the consequences can be anything from unresolved externals when attempting to load LiS all the way to system hangs on multi-CPU systems because of having the SMP option set incorrectly.

Therefore, it is important that you correct these problems and bring the kernel source and running kernel into agreement before installing LiS.

One common source of error is to recompile your kernel in /usr/src/linux and run lilo, but fail to copy the kernel executable to one of the kernel locations specified in /etc/lilo.conf. In this case you may think that you have successfully compiled and booted a new kernel when, in fact, you are running on your old kernel.

LiS Module Location

You will be asked whether or not you wish the "make" to copy the resulting streams.o file to the modules directory associated with your selected kernel version. The alternative is to have "make" build streams.o in the LiS directory and simply leave it there for manual copying later.

If you are intending to run LiS on the machine that you are using for the compilation you will probably want to answer this question with a "y". If you are intending to compile on this machine and copy the result to another machine for testing, then "n" is the appropriate answer here.

Debugging

If you intend to link LiS directly into the kernel and use GDB for kernel level debugging then you will likely want LiS to be compiled using the -g option. Configure asks you about this so that you can control whether to compile using -g or not.


Node:Removal of LiS, Next:, Previous:Installation of LiS, Up:Top

Removal of LiS


Node:Removing the Binary RPMs, Previous:Installing the Binary RPMs, Up:Removal of LiS

Removing the Binary RPMs

To remove an installed version of the binary RPMs (whether obtained from the OpenSS7 binary RPM releases, or whether created by the source RPM), execute the following command:

     % rpm -ev `rpm -qa | grep '^\<LiS'`
     

See rpm(8) for additional information.


Node:Removing the Source RPM, Previous:Installing the Source RPM, Up:Removal of LiS

Removing the Source RPM

To remove an installed version built from the source RPM, remove the installed binaries with (see rpm(8) for more information):

     % rpm -ev `rpm -qa | grep '^\<LiS'`
     

Then remove the rpms with a command such as

     % find / -name "LiS-*.rpm" -type f -print0 | xargs --null rm -f
     


Node:Removing the Tar Ball, Previous:Installing the Tar Ball, Up:Removal of LiS

Removing the Tar Ball

To remove an installed version, change to the build directory and use the uninstall make target as follows:

     % cd /usr/src/LiS-2.16.18-16
     % make uninstall
     % cd ..
     % rm -rf LiS-2.16.18-16
     % rm -f LiS-2.16.18-16.tar.gz
     % rm -f LiS-2.16.18-16.tar.bz2
     

If you have removed the build directory and, therefore, no longer have a configured directory from which to execute make uninstall, perform all of the steps for configuration and installation (see Installing the Tar Ball) except the final installation and then perform the steps above.


Node:Old LiS Removal Instructions, Previous:Old LiS Installation Instructions, Up:Removal of LiS

Old LiS Removal Instructions

WARNING: These instructions are not applicable to the OpenSS7 RPM release of LiS. For instructions, See Removal of LiS.4

You can remove LiS from your system by following this procedure.

In your LiS installation directory do a "make very-clean". This will remove any character special files in /dev that were created by an earlier "make install" plus any patches that were placed into the kernel source tree. It will also remove STREAMS utilities that were installed in /usr/sbin and /usr/local/bin. Note: for kernel version 2.0.36 and later there will be no patches in the kernel source tree unless you requested direct linking of LiS with the kernel at LiS installation time.

Then, in the directory above, enter "rm -r LiS-2.12". Substitute whatever the version of LiS is that you are removing. Then do rm /usr/src/LiS to remove the symbolic link to the LiS installation directory.

If you were linking LiS directly into the kernel, you need to rebuild your kernel.

Problems Removing LiS (obsolete)

If the automatic removal if LiS does not seem to go well you can delete the STREAMS oriented patches from your kernel source by hand just by editing a few files.

In your kernel source directory, edit the file init/main.c. Scan for lines containing the word "STREAMS". Delete all such line and save the file.

Now edit the file drivers/char/Makefile. Scan for lines containing the word "STREAMS". Before deleting all such lines, examine the first such line in context to see if it looks like the following:

     L_OBJS := tty_io.o n_tty.o tty_ioctl.o mem.o random.o \
             /usr/src/LiS-1.25/streams.o   # STREAMS
     

If so then delete the backslash from the first line as well as the line containing the word "STREAMS". Then delete all other lines in this file containing the word "STREAMS".

Alternate Method (obsolete)

If LiS is the only patch that you have applied to the files init/main.c and drivers/char/Makefile then you can do the following.

Change to the directory ./init in your kernel source tree and do the following.

     % mv main.c main.c.streams
     % mv main.c.orig main.c
     

Then change to the directory drivers/char (cd ../drivers/char) and do the following.

     % mv Makefile Makefile.streams
     % mv Makefile.orig Makefile
     


Node:Loading LiS, Next:, Previous:Removal of LiS, Up:Top

Loading LiS

WARNING: this section does not apply to the OpenSS7 rpm release of LiS. The OpenSS7 rpm release will always demand load.5

Once you have built LiS you need to load it into memory in order to execute STREAMS drivers. What you do at this point depends upon whether you built LiS as a loadable module or linked it into the kernel.

LiS as Loadable Module

The build process should have copied the file streams.o to the directory /lib/modules/kernel-version/misc. Where kernel-version is something like 2.4.2.

This means that to load LiS you simply type in modprobe streams. However, the recommended method for starting LiS is to use the streams utility program. streams start loads LiS and streams stop unloads it.

When LiS loads it will print a series of messages showing the names and major device numbers of all STREAMS drivers and pushable modules loaded with it. It will also print some version information about itself, including the version of the kernel for which it has been compiled.

LiS and kerneld

If your kernel has been built using the kerneld construct then LiS will automatically load as soon as any STREAMS file is opened. After installing LiS, simply type in the command streams -s just to test this mechanism. LiS should automatically load, with messages on the console displaying version information and drivers registered. Then the streams command should run and print out a summary of STREAMS activity. You can unload LiS via streams stop.

LiS Compiled into Kernel (obsolete)

If you have compiled LiS into the kernel then you need to make your new kernel executable and reboot your system.

You should always be careful when booting a new kernel. If you have not done so already, you should set up your /etc/lilo.conf file so that you have a trusted backup kernel that you can always boot in case a newly-built kernel crashes at boot time.

From your kernel source tree, copy the file arch/i386/boot/bzImage (or zImage) to the global file that you want to boot from. This is usually either /vmlinuz or /boot/vmlinuz depending upon your distribution of Linux.

Having done that, enter "lilo" to run the lilo utility on your newly copied kernel. You should see some messages from lilo telling you that your new kernel is configured for booting.

Now just reboot your computer.

As the kernel comes up, LiS's initialization routine will be run and it will print out the same driver registration and version information as for the loadable module case, above.

Making /dev Entries

A "normal" LiS build will have made a program named "makenodes" and copied it to /usr/sbin/strmakenodes. Before you can use any of your STREAMS drivers you must run that program. Simply enter "/usr/sbin/strmakenodes" and the program will make all of the STREAMS related entries in the /dev directory.

You do not need to do this every time you rebuild LiS. This only needs to be done if you add "node" entries to the STREAMS Config file or if you do something that would cause the major device numbers of STREAMS files to change.

The "make install" target of LiS runs strmakenodes automatically and is the recommended method of making the /dev entries.


Node:Coding LiS Drivers, Next:, Previous:Loading LiS, Up:Top

Coding LiS Drivers

This document is concerned with the include files and compilation techniques for STREAMS drivers. It is not intended to be a tutorial on the subject of writing STREAMS drivers. Additional resources are available, (see see Other Resources), for reference material. Please consult the Driver/Kernel Interface section (see LiS Driver/Kernel Interface) for information about how drivers interact with LiS and the Linux kernel for system services.

Header Files

In your C language source file for a STREAMS driver, you should place the following line of code.

     #include <sys/stream.h>
     

This line will include all of the additional header files and function prototypes needed to code a STREAMS driver.

If your STREAMS driver needs to decode the flush bits in M_FLUSH messages then also include the following.

     #include <sys/stropts.h>
     

If your driver uses some of the portable Driver Kernel Interface (DKI) (see LiS Driver/Kernel Interface) features of LiS you may need to include some additional header files.

Compilation Options

When you compile your STREAMS driver, put the following compiler option on the gcc (cc) command line for each C language file that contains one or the other of the above include lines.

     -I/usr/src/LiS/include -D__KERNEL__ -DLINUX
     

This directive assumes that you used standard installation procedures for LiS so that the name /usr/src/LiS is a symbolic link to the LiS installation directory.6 The -D's are necessary to give your driver the kernel's view of the header files and to get the Linux version in those cases where alternatives exist.

Driver Prefix

Choose a short prefix to put on the front of all your identifier names and routine names. For example, "xylo_". Thus, the main streamtab entry for your driver would be:

     struct streamtab xylo_info = {
             &xylo_rinit,                    /* read queue */
             &xylo_winit,                    /* write queue */
             NULL,                           /* mux read queue */
             NULL                            /* mux write queue */
     };
     

The open routine would be called "xylo_open(....)" and so on.

The role of this prefix is to allow the LiS configuration process (see The strconf Utility) to build some tables that reference certain symbols within your driver. Just to take one example, the "prefixinfo" structure's name must be known to LiS so that it can build the queue structures that are passed to your driver at open time.

Driver Open Routine

It is important that you get the declaration of your driver open routine correct. There was a different prototype for the open routine in SVR 3 versus SVR 4. The Linux STREAMS package uses the SVR 4 style only. The prototype for your open routine should be as follows:

     int xylo_open(queue_t *q, dev_t *dev, int oflag, int sflag, cred_t *cred_p);
     

These prototypes can be found in the DDI/DKI or consult the LiS include file include/sys/LiS/queue.h. Look for the definition of the structure qinit_t.

Driver Registration

Your driver will be automatically registered with the Linux kernel as a character mode special device driver if it is linked in with LiS. The LiS configuration process builds tables that allow LiS to perform this registration function on behalf of your driver. Thus, your STREAMS drivers should not contain any code to register itself as a Linux driver.

If your driver is to be loaded separately (see Loadable Specification) there are some special considerations that apply.


Node:Configuration, Next:, Previous:Coding LiS Drivers, Up:Top

Configuration

When LiS is built, its makefiles gather configuration information about the STREAMS drivers that are to be linked in with LiS. This information comes from several ASCII files within the LiS directory tree.

Once all of the configuration information is consolidated into a single file, the file is processed by a utility program strconf to produce several output files, which, in turn, are input to the final stages of the LiS build process.

This chapter describes this process and the strconf program itself.


Node:Config Files, Next:, Up:Configuration

Config Files

There are several locations in the LiS directory tree in which a file by the special name Config appears. Each Config file describes configuration information for one or more STREAMS drivers. These Config files are all concatenated together for processing by the strconf utility program.

Drivers that are built into LiS are located in the directory /usr/src/LiS/drivers/str. This directory contains a Config file which describes these drivers for the strconf program. In this case a single Config file describes multiple drivers.

Drivers that are added to LiS in binary form at build time reside in subdirectories of the directory /usr/src/LiS/pkg. Each subdirectory contains a Config file for its own driver. All such Config files are concatenated into the directory /usr/src/LiS/pkg into a file named config.pkg.

During the LiS build procedure, in the directory /usr/src/LiS, the Config file from the drivers/str directory is concatenated with the config.pkg file into a file named Config.master. This file is processed by the strconf utility to produce the files config.h, modconf.c and makenodes.c.

The config.h file is available to be included in the compilation of individual Space.c files which appear in the /usr/src/LiS/pkg subdirectories. The contents of the config.h file summarize the information contained in the Config files in C language #defines which can be used for building driver configuration tables. It is placed in the directory /usr/src/LiS/include/sys/LiS.

The modconf.c file is compiled as a component of LiS. It contains initialized tables for all of the STREAMS drivers and pushable modules that LiS is configured to manage.

The makenodes.c file is compiled into a utility program, makenodes, which will create all of the entries for STREAMS drivers in the /dev directory.


Node:SVR4 Compatibility, Next:, Previous:Config Files, Up:Configuration

SVR4 Compatibility

Configuration of drivers in LiS is similar in flavor to the method used in SVR4, but is different in almost all details. Included with LiS is a PERL script (nodeconfig.pl) that can be used to process an SVR4 Node(4dsp) file into an LiS Config file. This is an unsupported contribution from an LiS user.


Node:Loadable STREAMS Modules, Next:, Previous:SVR4 Compatibility, Up:Configuration

Loadable STREAMS Drivers and Modules

In order to support loadable STREAMS drivers and modules, the LiS configuration file language contains keywords to support the notion of object files.

An object file contains one or more drivers or modules. It is typically a file with suffix ".o" containing linkable object code built by compiling C language source with the "-c" option.

By default, object files are linked with LiS at compile time, but you can use the "loadable" keyword (see Loadable Specification) in a Config file to specify that an object file should be considered a kernel loadable module. This allows individual STREAMS drivers or modules to have the status of Linux loadable modules.

For an example of this observe how the "ldl" driver is built and installed as a part of the LiS package itself. The driver source resides in drivers/str/linux. The Config file that contains enties for "ldl" is in drivers/str. You can observe the LiS build process to see how the driver is named and copied to the appropriate subdirectory of /lib/modules.

You can place a Config file in a subdirectory of the pkg directory without placing any driver object code there. This is sufficient for LiS to process your Config file entries and make proper preparations for your loadable driver, such as assigning it a major device number. For more information on this process, See Installing Pre-Compiled Drivers.

If the kernel is configured with support for kerneld(8), a loadable module will be demand loaded (see Demand Loading LiS Modules). All kernel module names defined within LiS begin with the prefix "streams" to avoid name clashes with other Linux kernel modules.

For a non-clone device, the kernel will demand load the module under the name "char-major-nn". This will cause kerneld(8) to autoload a Linux kernel module using the aliases in /etc/conf.modules (or /etc/modules.conf). If /etc/conf.modules contains an alias for a STREAMS driver then the driver can be autoloaded via this mechanism. To the kernel a loadable STREAMS driver is just a character driver known by its major device number.

When the clone device is opened for a major configured in a loadable object file "myobj" (for example), LiS will ask kerneld(8) to load "streams-myobj". If this fails, LiS tries to demand load a module named "char-major-nn". If this also fails, an error is logged and the open fails.

When the name of a STREAMS module "mymod" configured in a loadable object file "myobj" is used for I_PUSH, LiS demand loads a kernel module named "streams-myobj". If this fails, LiS will try to demand load a kernel module named "streams-mymod". If this also fails, an error is logged and the I_PUSH fails.

When an unknown module name "mymod" is used for I_PUSH, LiS tries to demand load a kernel module named "streams-mymod".

The strconf utility will emit a file with the aliases needed for kerneld(8) support. This file can be incorporated into the file /etc/conf.modules. Refer to the "-L" option for the strconf utility, below.


Node:The strconf Utility, Next:, Previous:Loadable STREAMS Modules, Up:Configuration

The strconf Utility

In order to construct a Config file, it is useful to know the syntax of the contents of the file. The strconf utility is used to process a Config file and generate the output files mentioned above.

Command Line Syntax
     strconf [options] input-file
     strconf -?, --help
     strconf -V, --version
     

The options for strconf consist of zero or more of the following.

-b, --basemajor=[number]
Set the base major number for automatic assignment of major device numbers. The LiS Configure script, run from the top level "make", uses the value of the environment variable LIS_MAJOR_BASE to set this parameter, or a default value if this variable is not defined. By defining this symbol in your environment you can override the default base for major device numbers.
-h, --hconfig=[file]
Set the output header file name to something other than the default, config.h.
-l, --driverconf=[file]
Set the output driver configuration makefile include file name to something other than the default "drvrconf.mk".
-L, --confmodules=[file]
Set the output Linux loadable module configuration file name to something other than the default "conf.modules".
-m, --makenodes=[file]
Set the output file name for the program that will make the nodes to something other than makenodes.c. This program is compiled and then run to create all the /dev entries for the STREAMS drivers.
-M, -r, --functionname=[name]
The name of the mknod() routine to call in the makenodes.c program. The default is "mknod".
-o, --modconf=[file]
Set the output file name to something other than the default name modconf.c. This is the file that must be linked in with STREAMS.
-p, --permission=[perm]
Set default permissions to something other than 0666 for /dev entries created by the makenodes.c program.
-r, --functionname=[name]
The name of the routine to build in makenodes.c. The default is "main".
-s, --strmknods=[makedevices]

-V, --version
Display the program version and exit.
-?, --help
Display a ussage and option summary and exit.

The input-file parameter is the name of the file containing the configuration information in ASCII.

Example:
     strconf -b51 config.master
     

This command bases the major device numbers for STREAMS drivers at 51 and outputs files to the standard places.


Node:Configuration File Syntax, Next:, Previous:The strconf Utility, Up:Configuration

Configuration File Syntax

The input to the strconf program is informally referred to as a Config file. This file consists of lines of ASCII text which is interpreted by the strconf program.

Blank lines are ignored. The "#" serves as a comment symbol, terminating any line on which it appears.

Input to strconf consists of a series of tokens, which are strings of ASCII characters with no embedded white space. Some tokens are keywords known to strconf; some are numbers in C language syntax; some are identifiers supplied by the user to give names to drivers, etc. Tokens are separated from one another by white space.

Each line in the file is self-contained. That is, a construct consisting of a keyword followed by its arguments must all appear on the same line of the file.

Strconf processes lines for the following constructs.


Node:Driver Specification, Next:, Previous:Configuration File Syntax, Up:Configuration

Driver Specification

     driver driver-name prefix major minors
     
driver-name
is the name of the STREAMS driver (not pushable module), for example loop-around. It is any string of characters not including "white space" characters.
prefix
is alphanumeric, plus underscore, and will be prefixed to any table entries referencing variables within this driver. For example, the prefix loop_ will be used to derive the reference to the streamtab entry loop_info. The driver must have a variable declared within it by the name prefixinfo of type struct streamtab.
major
specifies the major device number that will be assigned to the device. The character "*" means that the config program will choose the major number (see The strconf Utility). A numeric value is used as it is given.
minors
is the number of minors the device has. If this field is omitted, the number 1 will be used. The value of this field is not used for anything except to generate a #define in the config.h output file.

Example:

     driver loop-around loop_ *
     

This declares a driver which has the name loop-around for reference purposes within the strconf program. Its prefix is loop_, and the strconf program is to assign its major device number.


Node:Module Specification, Next:, Previous:Driver Specification, Up:Configuration

Module Specification

     module name prefix
     
name
is the name of the module, for example relay-mod. It is any string of characters not including "white space" characters.
prefix
is alphanumeric, plus underscore, and will be prefixed to any table entries referencing variables within this module. For example, the prefix relay_ will be used to derive the reference to the streamtab entry relay_info. The module must have a variable declared within it by the name prefixinfo of type struct streamtab.

Example:

     module relay-mod relay_
     

This example declares a pushable module to be referred to internally as relay-mod. Its prefix is relay_.


Node:Node Specification, Next:, Previous:Module Specification, Up:Configuration

Node Specification

     node dev-name type perm major minor
     

The keyword node introduces this entry.

dev-name
is the full path name of the device file to be created, for example, /dev/loop.
type
is the type of file to create. This consists of a single letter as follows:
b
block special device (S_IFBLK)
c
character special device (S_IFCHR)
p
pipe device (S_IFIFO)

perm
is the device permissions to use, 0666 gives everyone permission to use the device. perm can be "*" in which case default permissions are supplied (see -p command line option).
major
is the major device number to assign to this entry. It can be a number, but is usually the name of the associated driver entry. The [50]major specified for the named driver is then used.
minor
is the minor device number to assign to this entry. It can be a number or the name of another driver. If the name form is used then the major number of the other driver is used as the minor number of the device being created.

Example:

     node /dev/loop c * loop-around 1
     
     node /dev/loop_clone c * clone-drvr loop-around
     

The first example defines a device /dev/loop as a character special device with default permissions as minor device 1 of the loop-around driver.

The second example defines a device /dev/loop_clone as a character device with default permissions with major device number equal to that assigned to the driver named clone-drvr and minor device number equal to that assigned to the driver named loop-around.


Node:Device Specifications, Next:, Previous:Node Specification, Up:Configuration

Device Specifications

These entries are used to describe the configuration of each physical device or port of a multi-port device on the system. Those familiar with the Unix sdevice file format will see some similarity to this format. The syntax for this type of entry is as follows:

     device driver-name unit port nports irq-share irq mem mem-size dma1 dma2
     

All 11 fields must be on the same line. Only the device keyword and driver-name fields are mandatory.

driver-name
is the name of the driver that handles the device. It must match the name of a declared driver in this file.
unit
is the unit number of the device being declared. A unit number means anything that the driver writer wants it to. It is assumed to be a small integer that will index a configuration table that is built from #defines generated by running this program. If this field is missing it is set to -1.
port
is the I/O port that the device uses. Set to -1 if the device does not use any I/O ports. If this field is missing it is set to -1.
nports
is the number of consecutive I/O ports used by the driver. If ports is -1 then nports can be any value, zero is suggested. If this field is missing it is set to zero.
irq-share
is a letter-coded field as follows:
n
No sharing of IRQ
s
Sharing of IRQ
S
Sharing of IRQ but only with the same driver
x
Don't care, the device does not use an IRQ

If the irq-share field is missing it is defaulted to the value corresponding to "x".

irq
is the interrupt number for the device. The value -1 is used when the device does not have an interrupt. If this value is specified then it is assumed that there exists a routine with the name prefixintr, where prefix is the driver prefix specified in the driver section. If this field is missing it is set to -1.
mem
is the shared-memory address used by this device, if any. Set to 0 if the device does not use shared memory. If this field is missing it is set to zero.
mem-size is the amount of shared memory used, in bytes. If this field is missing it is set to zero.
dma1
dma2
specify up to two DMA channels used by this device. Set to -1 if no DMA channels are being used. If either of these fields is missing it is set to -1.

The device entry causes a set of #defines to be generated into the file config.h. This file may be #included into a driver configuration file to load tables, etc. The form of the #defines in the config.h file is compatible with the form used by Unix SVR4. Thus, if you are porting a STREAMS driver from SVR4 you can use a variant of your System file entries as the device entries and use the resulting config.h file in your existing Space.c file.

The present implementation of LiS does not dispatch interrupts for STREAMS drivers. It is possible that some future version will do so, in which case the IRQ specifications will be more meaningful. At present these specifications only cause entries to be generated in the config.h file. You can utilize this information in a Space.c file to build a table that your driver uses to attach its IRQ from its initialization routine.

Example:

     device cdip 0 0x310 8 S 10 0xD0000 0x4000
     

This example declares a device entry for the driver named cdip. Its unit number field is zero. It has eight I/O ports starting at port address 0x310. The device can share IRQ10 with other devices of the same driver. It has shared memory based at 0xD0000 which is 16K bytes (0x4000) in size. It does not use any DMA channels.


Node:Initialization Specification, Next:, Previous:Device Specifications, Up:Configuration

Driver Initialization Specification

     initialize driver-name
     
driver-name
is the name of the driver whose init routine is to be called. The driver must supply a routine such as the following:
     void prefixinit(void)
     {
     }
     

Example:

     initialize loop-around
     

This leads to a call to the routine loop_init() since loop_ is the associated prefix for the loop-around driver. This routine is called by LiS when LiS is initialized. If LiS is linked with the kernel then this call occurs at system boot time. If it is loaded as a module then the call occurs at module initialization time for LiS.


Node:Termination Specification, Next:, Previous:Initialization Specification, Up:Configuration

Driver Termination Specification

     terminate driver-name
     
driver-name
The driver-name is the name of the driver whose term routine is to be called.

The driver must supply a routine such as the following:

     void prefixterm(void)
     {
     }
     

Example:

     terminate loop-around
     

This leads to a call to the routine loop_term() since loop_ is the associated prefix for the loop-around driver. This routine is called by LiS when LiS is terminating. If LiS is linked with the kernel then this call never occurs because LiS is never terminated. If LiS is loaded as a module then the call occurs at module termination time for LiS. This occurs just prior to unloading LiS from memory.


Node:Interrupt Specification, Next:, Previous:Termination Specification, Up:Configuration

Driver Interrupt Specification

     interrupt driver-name
     
driver-name
The driver-name is the name of the driver whose intr routine is to be attached.

The driver must supply a routine such as the following:

     void prefixintr(void)
     {
     }
     

Example:

     interrupt loop-around
     

This causes LiS to register the driver's interrupt routine for each of the IRQs used in the driver's device specifications. This occurs at module init time within LiS. The routine is unregistered when LiS is unloaded.


Node:Object Name Specification, Next:, Previous:Interrupt Specification, Up:Configuration

Object Name Specification

     objname type name object-name
     

The keyword objname specifies the base name of the object code file for a driver or module. Several drivers and modules may reside in the same object file. If an object-name is never specified for a driver or module, the object-name defaults to the name of the driver or module.

type
is either driver for a streams driver or module for a streams module.
name
is the name of the driver or module.
object-name
is the base name of the object code file used for this driver or module.

The purpose of this keyword is twofold:

  1. It specifies to the drivers/str make process the names of the object files that need to be compiled. These names need not be the same as the configuration names.
  2. If name is also specified as loadable and the Linux kernel is compiled with kerneld(8) support, LiS will demand load name by asking kerneld(8) for "streams-object-name".

Example:

     objname driver loop-around loop
     


Node:Loadable Specification, Next:, Previous:Object Name Specification, Up:Configuration

Loadable Specification

     loadable object-name
     

The keyword loadable specifies that an object code file (as specified by the objname keyword) is a Linux kernel loadable module. If the kernel is compiled with kerneld(8) support, LiS will ask kerneld(8) to [57]load the module on demand.

Please note that you will have to explicitly declare object-name with the objname keyword first. Default object-names will not do for this keyword, as they may be changed later in the configuration file.

object-name
is the base name of the object code file.

Example:

     loadable loop
     


Node:Autopush Specification, Next:, Previous:Loadable Specification, Up:Configuration

Autopush Specification

     autopush driver-name minor last-minor module-list
     

The keyword autopush specifies a list of modules that should be pushed onto a stream when it is opened.

driver-name
is the name of a driver. The autopush specification only applies to this driver.
minor
specifies the first minor device number that this autopush specification applies to. If minor is -1, last-minor is ignored and the autopush applies to all minors of this driver.
last-minor
specifies the last minor in a range that this autopush specification applies to. If last-minor is 0, this autopush specification applies only to the single minor device number minor, otherwise last-minor must be greater than minor and the autopush applies to all minor devices of the named driver from minor to last-minor inclusively.
module-list
is a list of one or more STREAMS modules that should be pushed onto the stream when it is opened. The leftmost module is pushed first.

WARNING: Autopush status is currently "complete, untested".

Example:

     autopush loop-around 8 15 relay
     


Node:Tunable Parameter Specification, Next:, Previous:Autopush Specification, Up:Configuration

Tunable Parameter Specification

This type of entry allows you to insert define text into the output file (config.h default). These values can be used as parameters for drivers or the streams package itself.

The syntax is:

     define name value
     
name
The name is the identifier that is being defined. It must be constructed of characters that comprise a legal C language identifier.
value
The value is any text up to the end of the line.

The output for this entry is of the form:

     #define name value
     

Example:

     define MAX_PORTS 16
     

Generates the following in the output file:

     #define MAX_PORTS 16
     


Node:The Space.c File, Next:, Previous:Tunable Parameter Specification, Up:Configuration

The Space.c File

The Space.c file plays a role in LiS configuration similar to the file of the same name in Unix SVR4. It is a file associated with each driver package which contains configuration information for the driver. It is compiled during the LiS build phase.

The Space.c file can utilize information obtained by processing the Config files using strconf. This processing is automatic and is a part of the LiS build procedure. The strconf utility is run prior to compiling the Space.c file for each driver package.

The Space.c file can include the file config.h which contains #defines for the information gleaned from the Config files. This allows the Space.c file for a particular driver to capture this information in a table that the driver can consult during initialization. The LiS build procedure supplies the proper "-I" command line option to make the config.h file visible when compiling the Space.c files.

The #defines generated by strconf are of the following form.

For each driver:

     #define prefix 1
     #define prefix_CTLS Nr-device-entries
     #define prefix_UNITS minors
     #define prefix_CMAJORS majors
     #define prefix_CMAJOR_0 assigned-major-device-number
     #define prefix_TYPE -1
     

For each declared device:

     #define prefix_unit 1
     #define prefix_unit_SIOA port
     #define prefix_unit_EIOA port+nports-1
     #define prefix_unit_VECT irq
     #define prefix_unit_SCMA mem
     #define prefix_unit_ECMA mem+mem-size-1
     #define prefix_unit_CHAN dma1
     #define prefix_unit_CHAN dma2
     


Node:A Simple Example, Next:, Previous:The Space.c File, Up:Configuration

A Simple Example

Let us suppose that you have a STREAMS driver for which you have chosen the prefix "xylo_". You need to make a Config file to go with your driver. In the Config file you need to declare the existence of your driver as follows.

     driver mydrvr xylo_ *
     

By doing this you are declaring that you have a driver named "mydrvr" which uses the symbol-name prefix "xylo_" and you don't care what its major device number is. The "mydrvr" is a name that you make up that is not used anywhere but in the Config file to refer to this driver. The "xylo_" is the prefix that you used in coding your driver. It is used to synthesize the name "xylo_info", the main streamtab structure for your driver. The "*" says that you don't care what [62]major number your driver is assigned. The "n-minors" field is a place to say how many minor devices your driver handles, but it is not used anywhere, and thus is left empty.

Use the "driver" declaration for hardware drivers and STREAMS multiplexor drivers.

If your driver had been a pushable module rather than an actual driver then you would have used, something like the following.

     module mydrvr xylo_
     

You will probably want some /dev entries made so that you can access your driver via the stream head and the file system. Do that by including a "node" section of the Config file. For example:

     # name  type perm major  minor
     node /dev/xylo  c * mydrvr  0
     node /dev/xylo_clone c * clone-drvr mydrvr
     

In this case we have added an entry that opens minor device zero (/dev/xylo) and a clone entry that will open your driver via the STREAMS clone driver (/dev/xylo_clone). The name "clone-drvr" is always present when LiS processes your Config file.

The clone driver is a special feature of STREAMS. You can read all about it in the [63]reference documents, or the [64]drivers page of the LiS documentation, but the gist of the idea is to make it easy for an application program to open a file to the STREAM and always get an available minor device. In the case of a non-clone device, the application has to "guess" as to which minor device numbers are unused. For a clone device, the driver itself assigns the minor device number and always picks one that is unused for the newly opened file.

The mechanism for the clone device involves the use of a special driver, the clone driver. It is declared in a Config file just like any other STREAMS driver under the name "clone-drvr". The clone driver has a specified major device number. It also has minor devices that are opened via directed (non-clone) opens. The minor device numbers of the clone driver are the major device numbers of another STREAMS driver. The clone driver's open routine calls the open routine of the second STREAMS driver by using the minor device number of the open to /dev/clone_drvr as the major device number of the driver whose open routine is to be called.

This is why the entry in the "node" section of the Config file for a clone device has the name of the clone driver in the major number field and the name of the driver which eventually gets the open call in its minor number field.

Note that the cflag parameter to the driver open routine will indicate a clone open if the open has passed through the clone driver. This allows your driver to distinguish between directed (non-clone) opens and clone opens.


Node:Installing Your Driver, Previous:A Simple Example, Up:Configuration

Installing Your Driver

To install your driver so that it is linked with LiS when LiS is built you need to do the following.

Go to the directory /usr/src/LiS/pkg. Make a subdirectory for your driver. For example, mkdir xylo.

Then copy the object code (.o) file for your driver into that directory. Also copy your driver's Config file to that directory. For a loadable driver, do not copy your driver's object code file to the pkg/xylo subdirectory, instead, copy it to /lib/modules/kernel-version/misc/streams-xylo.o. There are special considerations for [66]demand loadable drivers.

If your driver needs to build any tables for configuration based on the config.h file that is generated from running the LiS strconf utility then you need to create a file named Space.c and copy it to the pkg/xylo directory.

You also need to create a Makefile for your pkg/xylo directory. If you do not have a Space.c file then your Makefile can consist of just the following.

     nothing:
     

If you have a Space.c file then your Makefile can consist of this.

     include ../proto/Makefile
     

The ../proto/Makefile contains a rule to compile your Space.c file into Space.o.

That is all you have to do. The LiS build will concatenate your Config file with the LiS built-in Config file and produce a config.h file. It will enter your directory and perform a "make". It will then link in all files ending in ".o" from your directory into the streams.o file. The streams.o file is the file that is loaded when the command insmod streams is executed.


Node:Demand Loading LiS Modules, Next:, Previous:Configuration, Up:Top

Demand Loading LiS Modules and Drivers

The LiS demand load system supports both the old kerneld and the new kmod mechanisms for demand loading kernel modules.

The convention for LiS kernel loadable object files is:

Unconfigured drivers and modules

An unconfigured driver or module is a driver or module that LiS does not have any special information about. Even in this case, you can take advantage of demand loading.

Modules

Module demand loading is simple. When a user does an I_PUSH requesting that module mymod be pushed onto a stream, LiS will check if mymod is already registered. If not, LiS asks the kernel to load streams-mymod.

A security related implication of this is that any user capable of doing an I_PUSH can provoke loading of any module that has the streams- prefix.

Demand loading also works when autopushing modules, but you should be aware that when a module is unloaded, it is silently removed from all autopush lists.

You can have more than one module in a single kernel loadable module, but for demand loading to work with modules whose object names are not derived from the module name, you have to set up alias lines in /etc/conf.modules.

For example, if you have modules mymod and mymod2 in the kernel loadable object file streams-mymod.o, you have to add the line

     alias streams-mymod2 streams-mymod
     
in your /etc/conf.modules for demand loading to work properly when pushing mymod2.

Drivers

Demand loading drivers is slightly more complicated. When a device special node with major device number major is opened, the kernel checks if device major is registered in the kernel. If not, the kernel will try to load "char-major-major".

If a clone open is done LiS will check if the driver is registered. If not, LiS will ask the kernel to load char-major-minor, where minor is the minor device number of the clone device opened. In this case the value of minor is the major device number of the driver that needs to be loaded and opened.

Kernel loadable modules generally do not have names of the form char-major-number, so a mapping to the correct name is needed. This is done with alias lines in /etc/conf.modules, or, on newer systems, /etc/modules.conf. If your driver has major device number 123 and is in the kernel loadable object file streams-mydriver.o, you should have the line

     alias char-major-123 streams-mydriver
     
in your /etc/conf.modules.

If you also have the line

     alias char-major-240 streams
     
in your /etc/conf.modules and the clone driver major is 240, both LiS and your driver will be demand loaded when you do a clone open of your driver.

You can configure autopush on an unconfigured driver, but you should be aware that when the driver is unloaded, all its autopush lists are silently removed.

You can have more than one driver in a single kernel loadable module, but you should set up a separate alias line for each driver.

Configured drivers and modules

When drivers and modules are added to the [17]LiS configuration files, you can specify the object name that will be used for requesting a demand load of the driver or module. If demand loading of the configured object name fails, LiS will revert to the procedure for demand loading an unconfigured driver or module.

The advantage of configured drivers and modules is that the LiS installation procedure takes care of adding the needed alias lines to /etc/conf.modules. Also, the autopush configuration is not changed when a configured driver or module is unloaded.

Writing kernel loadable modules for LiS

It takes little extra effort to make LiS modules and drivers loadable. In most cases, all you have to do is to add the special Linux module functions init_module() and cleanup_module() and some lines to maintain the usage count of the loadable module.

The init_module() function id used for initializing the loadable module, and can be as simple as:

     int init_module(void)
     {
             return lis_register_strmod(&mymod_info, "mymod");
     }
     
for a module, or
     int init_module(void)
     {
             return lis_register_strdev(123, &mydrv_info, 10, "mydrv");
     }
     
for a driver.

In this example, the driver's major device number is assumed to be 123. You must know this major device number ahead of time so that you can make the entry in the /dev directory that will cause your driver to autoload. The major number in your /dev entry and in your call to lis_register_strdev must match.

The cleanup_module() function is called by the kernel just before a loadable module is unloaded. This function has to unregister the drivers and/or modules registered in the init_module() function.

The cleanup_module() function can be as simple as:

     void cleanup_module(void)
     {
             lis_unregister_strmod(&mymod_info);
     }
     
for a module, or
     void cleanup_module(void)
     {
             lis_unregister_strdev(123);
     }
     
for a driver.

To avoid that the loadable module is unloaded while somebody is still using it, a usage count has to be maintained. This is done using the macros MOD_INC_USE_COUNT and MOD_DEC_USE_COUNT. MOD_INC_USE_COUNT is used in the open routines, but be careful not to call it if your open fails. MOD_DEC_USE_COUNT is used in the close routines.

For a complete example, see the [18]ldl driver in drivers/str/linux/ldl.c.


Node:Installing Pre-Compiled Drivers, Next:, Previous:Demand Loading LiS Modules, Up:Top

Installing Pre-Compiled Drivers

LiS makes provision for you to add your own STREAMS drivers to the build of LiS. You drivers are built outside the LiS source code tree. The object code and configuration information pertaining to your driver must be copied into the LiS source code tree in order to be incorporated into LiS.

The LiS pkg Directory

The directory /usr/src/LiS/pkg is the directory where pre-compiled drivers are to be copied. This directory contains subdirectories, one for each driver to be linked in with LiS when LiS is built.

If you have a driver named foo then you need to do a mkdir /usr/src/LiS/pkg/foo to create the directory that will contain the components of your driver.

Driver Components

You need to copy the following files into your package directory (/usr/src/LiS/pkg/foo).

Component Description

Makefile
A make file to do anything that needs to be done just prior to linking your driver's object code file into LiS. If there is nothing to be done then just provide a dummy default target. The Makefile has to be present for the LiS build procedure to function properly.
Driver.o
Any number of object files with suffix ".o" will do. These files can be copied into this directory from elsewhere, they do not have to be built by the Makefile. Alternatively, the Makefile can copy in updated driver object files as needed. Which style you use is entirely up to you.
Space.c
This is optional. If you want to incorporate configuration information from your Config file into your driver at link time, then place a file by this name into your driver's package directory. Your Makefile should contain an include ../proto/Makefile to incorporate a rule to make this file into an object file. Your Space.c file should include the file config.h in it. See the section on [17]Configuration for more details about Space.c and config.h.
Config
This is the STREAMS configuration file for your driver. It is combined with other Config files for other drivers to produce a master Config file. This master Config file is then processed by the LiS strconf utility to produce, among other things, the file config.h. See the section on [18]Configuration for more information about the Config file.

Dynamically Loadable STREAMS Drivers

You can also compile your STREAMS driver as a loadable module and load it dynamically either [19]on demand or using the insmod command.

In order to do this you need to inform the Linux kernel that your driver depends upon the LiS STREAMS driver. You do this by placing an entry into the file /etc/conf.modules (on newer distributions of Linux this file has been renamed to /etc/modules.conf) . In order to code this entry correctly, you need to know the major device number that is to be assigned to your driver. One way to find this out is to make a directory for your driver in the LiS pkg directory and include a [20]Config file but no object code. You can then use the resulting config.h file (located in the directory /usr/src/LiS/include/sys/LiS and left behind by the LiS build process) to determine your driver's major device number.

When your driver loads and you register it, you need to ask for this major device number.

The entry in the /etc/conf.modules file looks like the following:

     alias char-major-maj streams
     

This entry tells the kernel that a driver with major device number maj is dependent upon the module named "streams," the module name for LiS. The LiS strconf utility program contains constructs which support this process. See the [21]Configuration section for more information.

Tip: Be sure not to include your driver's ".o" file in the LiS pkg directory. Instead you will need to copy it to the appropriate subdirectory of /lib/modules.


Node:Coding STREAMS Applications, Next:, Previous:Installing Pre-Compiled Drivers, Up:Top

Coding STREAMS Applications

This document is concerned with the include files and compilation techniques for STREAMS application programs. It is not intended to be a tutorial on the subject of writing STREAMS applications. Additional resources are available [17]here for reference material.

Header Files

In your STREAMS application program C language source, use the following line to include LiS header files.

     #include <sys/stropts.h>
     

This will include all of the STREAMS related information that you need for a user level program.

If your application program uses the poll system call then you need to include one or the other of the following lines depending upon the kernel version that the application is intended to run on. For kernel versions in the 2.0 group, use the following in order to include the poll.h from LiS.

     #include <sys/poll.h>
     

For kernel versions in the 2.2 group, use the following in order to include poll.h from the kernel's source tree.

     #include <linux/poll.h>
     

Compilation Options

When you compile your STREAMS application, put the following compiler option on the gcc (cc) command line for each C language file that contains any of the above include lines.

     -I/usr/src/LiS/include
     

This directive assumes that you used standard installation procedures for LiS so that the name /usr/src/LiS is a symbolic link to the LiS installation directory.

Linking Options

When you perform the final link of your application using cc or gcc, add the following to the end of your list of files and libraries to be linked. This links in the system call interface routines for LiS.

     -lLiS
     

This library includes the STREAMS based version of the pipe system call. If you want to use the standard STREAMS library routines, such as getmsg and putmsg, but you want to use the standard Linux pipe system call, use the following instead.

     -lpLiS
     

Other STREAMS Resources

Click [18]here for a list of other locations that you can consult for general information concerning writing STREAMS applications.


Node:LiS SMP Implementation, Next:, Previous:Coding STREAMS Applications, Up:Top

LiS SMP Implementation

Beginning with LiS-2.12, LiS makes aggressive use of multiple CPUs in SMP kernels. It is useful for the STREAMS programmer to have some insight into this design in order to know whether, or which, locking techniques must be used in driver code.


Node:CPU Scheduling, Next:, Up:LiS SMP Implementation

CPU Scheduling

LiS starts up a kernel thread for each CPU on the system. In the output of a ps display each thread will show as a process with a name such as "LiS-2.12:0". This notation means that an LiS kernel thread is running and is bound to CPU 0 (":0").

LiS maintains a single global list of queues whose service procedures need to be run. A queue is place into this list by calling the function qenable, whether directly or indirectly. A given queue can only be in this list once. The read queue and write queue of a queue-pair are considered two different queues for scheduling purposes and both can be scheduled simultaneously.

At "certain points in time" LiS performs an operation that makes a decision concerning the manner in which service procedures are to be invoked via the list of scheduled queues. There are several factors which influence this decision.

In the case that the queue processing routine does not get called directly, LiS needs to decide whether to wake up a kernel thread process or whether to defer queue processing until an LiS system call is about to exit.

LiS tries to enlist one CPU for every four queues that are scheduled. This number is based on considerations of CPU loading and average queue lengths from queueing theory. If the number of CPUs currently processing queues is not enough to meet this target then the scheduling process seeks to enlist more CPUs until the number of CPUs is sufficient to meet this target value. Of course, sometimes there are simply too may queues schedule for processing for the number of available CPUs. In that case, all available CPUs run their queue processing threads.

When making the decision as to whether or not to wake up a kernel thread, LiS gives precedence to the CPU that it is running on. If the scheduling algorithm is called from a point just prior to executing back to the user, and if the kernel thread for the active CPU is sleeping, then LiS will simply call the queue processing routine without waking up the kernel thread. This saves the wakeup and context switch overhead.

The routine that actually runs the queues removes one element at a time from the list of scheduled queues and calls the service procedure pointed to by the queue. The routine continues until the list of scheduled queues is empty. Thus, when a kernel thread is actively processing queues, and if the number of scheduled queues does not exceed the estimated capacity of the running threads, it is quite efficient to simply add a queue to the list and let the already running threads process them in due course.


Node:Queue Locking, Next:, Previous:CPU Scheduling, Up:LiS SMP Implementation

Queue Locking

The queue_t structure in LiS contains a spin lock that is used by LiS to ensure that service procedures are not reentered for the same queue. This lock is not to be used by driver code.

When the LiS queue running routine removes a queue from the list of scheduled queues it acquires this lock prior to calling the service procedure.

LiS also acquires this lock when calling the put procedure associated with a queue. Thus, execution of the put and service procedure are excluded for the same queue.

In a multi-CPU environment, it can happen that one CPU is calling the put procedure while a second CPU is calling the service procedure for the same queue. In this case, one or the other spins until the first CPU finishes the operation and releases the spin lock.

When LiS is about to call the put procedure of a queue from the put or service procedure of a neighboring queue (because the driver called the putnext function), it continues to hold the lock for the calling queue while acquiring the lock for the destination queue. The locks are acquired sequentially as the chain of putnext calls traverse the stream. The locks are released in reverse order as the put procedures return. This has the effect of incrementally locking the entire stream as messages are passed from one module to another.

This behavior is only of interest when modules are I_PUSHed on top of a driver. Otherwise, it is just the stream head write queue and the driver write queue that need to be locked (or other pairwise combinations such as the driver read queue and stream head read queue, or queues involving multiplexors).

The lock that LiS uses has the effect of excluding multiple entries from different threads into the put or service procedure for a given queue. The other queue in the queue pair is unaffected by this locking. Therefore, if there are data structures shared between the read and write put and service procedures of a driver or module, it is up to the driver writer to protect these structures with spin locks.


Node:Service Procedure Context, Next:, Previous:Queue Locking, Up:LiS SMP Implementation

Service Procedure Context

Due to the manner in which service procedures are called, sometimes from the LiS queue runner threads and sometimes from a "borrowed" system call, service procedures may or may not have some user context present when they run. Service procedures should always assume that there is no user context. Even in the cases where there is some user context, the identity of the user process is unpredictable.

LiS does, however, maintain a copy of the credentials of the process that opened the stream when it calls service procedures on the stream. LiS saves the user and group identifiers plus the capability masks (credentials) of the running process in the stream head structure at the time that the STREAMS file is opened. These identifiers are restored to the task structure before calling a service procedure on that stream.

When calling put procedures, however, no such identity restoration occurs. So the credentials in place when a driver or module put procedure is invoked are those of the invoking entity. Because the queue runner theads always begin driver entry with a call to the service procedure, entries into the put procedures of subsequent drivers will have the credentials of the stream whose service procedure was called in the first instance. When a driver's put procedure is entered from a system call the credentials will be that of the user process which issued the system call.


Node:Scheduling Statistics, Previous:Service Procedure Context, Up:LiS SMP Implementation

Scheduling Statistics

LiS gathers statistics on its queue scheduling algorithm. They can be printed out with the command streams -S. The output looks like the following.

     N-CPUs N-Qrunners N-Running N-Requested
          2          2         0          0
     
     CPU   Qsched-Cnts Qsched-ISR Svc-Q-Cnts Qrun-Cnts Active Thread-PID
       0     540752204  175753842  459587537 239611835      0        857
       1     540683832  175833424  459150290 239672683      0        858
     

The fields have the following meanings.

N-CPUs
Number of CPUs on the system.
N-Qrunners
Number of queue runner kernel threads. These are the processes that appear as LiS-2.12:0 in a ps display.
N-Running
Number of qeuue runner threads that are currently active.
N-Requested
The number of queues that are in the list of scheduled queues.
CPU
The remainder of the statistics are kept on a per-CPU basis.
Qsched-Cnts
This is the number times the routine (lis_setqsched) that decides whether or not to wake up a queue runner process or to directly process scheduled queues has been called. This routine is called whenever a queue is added to the scheduling list. The counter reflects which CPU made the call to the routine.
Qsched-ISR
The number of times lis_setqsched was called from an interrupt routine and from which CPU.
Svc-Q-Cnts
The number of callouts to service procedures on a per-CPU basis.
Qrun-Cnts
The number of times the routine (queurun) that removes queues from the schedule list was called. This routine does not return until the queue scheduling list is empty. It can be running on multiple CPUs simultaneously. It is typically called from the queue runner threads but can also be called from an LiS system call either just prior to returning to the user or just prior to sleeping on some event such as the arrival of messages at the stream head.
Active
Displays as 0 or 1 depending upon whether there is a queue runner thread running on the particular CPU at the time that the statistics were sampled.
Thread-PID
The process id of the queue runner thread assaigned to eachCPU.


Node:Other Resources, Next:, Previous:LiS SMP Implementation, Up:Top

Other Resources

Information about writing STREAMS drivers and applications is available from other sites on the Internet. The following links may prove useful. Keep in mind that these links are to Unix documentation. Therefore, these documents cover many more kernel routines and services than appear in LiS.


Node:LiS User Commands, Next:, Previous:Other Resources, Up:Top

LiS User Commands

The Linux STREAMS (LiS) package contains some user level commands that are used to manage the package and assist the user with STREAMS functions.

These commands are installed in /usr/bin or /usr/sbin. They are referred to a "global commands."

A second group is built in the LiS installation directory and left there. This second group is oriented more towards testing of LiS than towards its operation. These commands remain undocumented since they are primarily intended for the use of the authors of the modules that they test.

These are the commands that are installed in /usr/bin or /usr/sbin, and are thus globally accessible to any user with those directories in his/her path.


Node:fattach, Next:, Up:LiS User Commands

fattach

     /usr/sbin/fattach [-v] [-m|-u|-M mode] [-p|STREAMS-path] path ...
     /usr/sbin/fattach -?
     

Description

The fattach program provides a command-line interface to the underlying fattach(3) function. If the -p and/or the -c option is specified, a STREAMS-based pipe is created and its two ends are alternately attached to the path names given. In this mode of usage, at least two path names are required, but there need not be an even number of path names (i.e., the pipe ends need not be attached to the same number of paths).

If the -p and -c options are not specified, the first path name given must identify a STREAMS-based file. That file will be opened, and it will be attached to each of the path names subsequently specified (of which there must be at least one).

Options

-p
Create a STREAMS-based pipe, to which to attach the subsequently specified path names. The first path will be attached to the first pipe end, the second to the second pipe end, the third to the first pipe end, etc., until the list of path names is exhausted.

By default, the umask (see umask(2)) is also applied to each end of the pipe after attaching. (See fattach(3)).

-c
Like -p (both may be given), but additionally pushes the connld module onto the first end of the pipe. This conveniently creates a free-standing pipe-serving pipe (see connld(9), and below).
-m
Apply the mode of the last-specified path(s) to the attached STREAMS-based file(s) after attaching. (See fattach(3).
-u
Apply the umask (see umask(2)) of the STREAMS-based file after attaching. (See fattach(3)). This is done by default when a pipe is created via -p.
-M mode
Apply the given mode to the STREAMS-based file(s) after attaching. (See fattach(3)).
-v
Operate in a "verbose" manner. This causes fattach to report its progress via message output to stdout or stderr.
-?
Provide a usage summary.

Return Value

Upon successful completion, i.e., if all given path names are attached to, fattach returns 0. Upon failure, fattach returns 1. However, the failure of one more attachments does not otherwise affect those that succeed, and the user is responsible for detaching any that may have succeeded if that is the desired behavior in the event of any failures.

Application Usage

The -p and -c options provide a convenient means for creating free-standing mounted pipes. The openers of the paths attached via -p will share a single pipe, while the openers of the paths attached via -c will have access to a pipe-serving pipe. I.e., each open of the first end (e.g., the client end) will generate a new pipe, one end of which will be given to the opener, and the other end of which will be passed as if by the I_SENDFD ioctl to the path attached to the other end (e.g., the server end). Each opener of the server path could poll(2) for input, receive a new pipe end using the I_RECVFD ioctl, and then close the server path, therefter using the new pipe end to communicate with the corresponding opener of the client path (note that the sense of client and server will in fact depend on the application - users of the two paths need only be aware of whether or not an I_RECVFD ioctl must be performed).

See Also

connld(9), fattach(3), fdetach(3), fdetach(8), STREAMS(4), umask(2)

History

An fattach function has been provided for various STREAMS implementations based on SVR4 STREAMS. Not all of these have provided a corresponding utility program of this sort.

Author

John Boyd, protologos LLC jaboydjr@netwalk.com


Node:fdetach, Next:, Previous:fattach, Up:LiS User Commands

fdetach

     /usr/sbin/fdetach [-v] path ...
     /usr/sbin/fdetach -a
     /usr/sbin/fdetach -?
     

Description

The fdetach program provides a command-line interface to the underlying fdetach(3) function.

It is thus intended to provide a convenient means to dismantle so-called mounted STREAMS.

If the -a option is specified, all currently attached STREAMS-based files are detached. If the -a option is not specified, the path names given are taken to identify paths to which STREAMS-based files are currently attached. Those files will be detached from these paths.

Options

-a
Undo all attachments currently in effect.
-v
Operate in a "verbose" manner. This causes fdetach to report its progress via message output to stdout or stderr.
-?
Provide a usage summary.

Return Value

Upon successful completion, i.e., if all given path names identify mounted STREAMS and these are all successfully detached, fdetach returns 0. Upon failure, fdetach returns 1.

Note, however, that a failure indication does not mean that no action is taken; i.e., those detachments that succeed are not affected by those that fail.

Warnings

It should be noted that although the fdetach program implements the -a option, by passing "*" to the fdetach function, this is not at all equivalent to specifying "*" on the command line when executing the program. Normally, "*" specified on the command line will be converted by a shell into a list of all files in the current working directory. By contrast, the -a option causes the fdetach operation to operate not with respect to path names at all, but with respect to STREAMS devices currently active within the STREAMS subsystem. I.e., each active stream head is examined for attachments, and any attachments found are dismantled.

The intended use for the -a option is thus to undo all attachments, e.g., in preparation for unloading the STREAMS subsystem.

See Also

fdetach(3), fattach(8), STREAMS(4)

History

An fdetach function has been provided for various STREAMS implementations based on SVR4 STREAMS. Not all of these have provided a corresponding utility program of this sort.

Author

John Boyd, protologos LLC jaboydjr@netwalk.com


Node:ldlconfig, Next:, Previous:fdetach, Up:LiS User Commands

ldlconfig

     /usr/sbin/ldlconfig Options
     /usr/sbin/ldlconfig -h
     

Description

ldlconfig() is used to configure the ldl STREAMS driver as a client of a standard Linux network driver. Once configured other STREAMS drivers can be pushed or I_LINKed on top of the ldl driver, thus giving STREAMS drivers access to Linux network drivers.

Options

-a name
The name of the network driver interface to attach. For example, "-aeth0" attaches to the eth0 network driver.
-b sap
The SAP to bind. The interpretation of the SAP depends upon the mode (-p) and framing (-F) being used.
-d filed
Instead of opening /dev/ldl, use the given file descriptor number. This allows an external program to open /dev/ldl, use ldlconfig() to configure the STREAM, and then continue to use the open file descriptor for further operations.
-f flag
Flag to set with ioctl. Mnemonic values for flag are PEDANTIC_STANDARD and RAW.
-F framing
The type of framing to use in interactions with the network driver. Mnemonic values for framing are EII, 802.2, SNAP, 802.3 and RAWLLC.
-h
Print a command usage synopsis.
-p mode
Set promiscuous mode. Mnemonic values for mode are PHYS, SAP or MULTI.
-v mask
Set verbose mask.

Operation

ldlconfig() opens the clone device /dev/ldl, or accepts a file descriptor to a file already opened to that device. It performs a DLPI Attach Request based upon the -a parameter. This attaches the file to a Linux network device.

It then sets operational options based upon the -f and -p options, if any were specified.

If the -b option is specified it also performs a DLPI Bind Request on the stream.

The resulting stream connects to the ldl driver which acts as a DLPI Provider and translates between the DLPI STREAMS protocol from above to the Linux network driver interface below. The effect is to present a DLPI interface to a Linux network driver.

The type of network driver (Ethernet, Token Ring, FDDI, HDLC) is compared with the requested framing type (is option) and RAW flag (is option). If the given driver does not support the requested framing type then the ldlconfig() command will fail. All drivers support the RAW frame interface.

Depending upon the driver type and framing type, the ldl driver will set up to decode incoming "frames" according to the framing type. This has an effect on where the driver looks in the incoming "frame" to find the SAP to match against the requested SAP in the DLPI Bind Request to ldl (-b option). The framing type of RAWLLC generally means that the entire frame is passed upstream. This allows the upstream client driver to interpret the LLC information within the frame.

Frame types other than RAWLLC generally mean that the LLC header will be stripped from received frames passing just the payload portion to the upstream client. The received frame is passed upstream in a DL_UNITDATA_IND M_PROTO message and the address carried by this frame will be set to the source MAC address from the frame header.

In the transmit direction, a frame type of RAWLLC means that the formatting of the frame to be sent to the medium is under the control of the upstream client.

For other types of framing, the ldl driver will build the LLC header according to the framing type. The address in the DL_UNITDATA_REQ is used to develop the destination MAC address.

For any given frame type and driver type, it is often necessary to consult the driver source code in order to understand the fine details of the frame processing involved.

Return Value

ldlconfig() returns 0 upon success and 1 if any indicated operation failed.

Author

Ole Husgaard sparre@login.dknet.dk


Node:ldltest, Next:, Previous:ldlconfig, Up:LiS User Commands

ldltest

     /usr/sbin/ldltest Options Driver Local-IP
     

Description

ldltest is used to test the ldl STREAMS driver by using one of the existing standard Linux network drivers to send a "ping" to another host on the network. The command line parameters specify the local-IP and remote-IP addresses and the name of the Driver to use when sending the ping.

ldltest is also used to obtain statistics from the ldl STREAMS driver and to set debugging masks.

Options

-a
Respond to received ARP queries.
-s
Respond to received pings. Also enables LLC TEST/XID echo mode.
-S dsap:ssap
Set the DSAP and SSAP to use when sending an LLC TEST or XID.
-r remote-IP
The remote IP address to which the ping is to be directed.
-R remote-MAC
The remote MAC address for sending LLC TEST/XID frames.
-c packet-cnt
The number of ping packets to send. Default is 1.
-v number
Set verbosity level.
-f framing
Set framing style to EII (default), RAW or SNAP.
-d mask
Set debug mask for the ldl driver to mask.
-H
Print out the values for the debug mask bits.
-g
Print out global statistics obtained from the ldl driver.
-T
Send LLC TEST command.
-X
Send LLC XID command

Operation

In test mode, ldltest constructs a ping packet from the parameters given and sends it to the remote host. It awaits the response and prints out the round trip time when it receives the response. If the -c option is used it sends the ping repeatedly and prints out the round-trip time every 1,000 packets.

With the -s (lower case) option, ldltest listens for received frames from the indicated interface driver. If the framing is specified as RAW then it will receive LLC frames from the driver. Other types of framing result in non-LLC Ethernet types of frames such as IP packets and ARP messages. Thus, the setting of the -f option conditions the type of messages that can be received from the interface. When an ICMP ping is received, it is responded to. When an LLC TEST or XID command is received it is responded to with the corresponding response frame.

With the -g option, ldltest obtains statistics maintained by the ldl driver and prints them out. This is useful for troubleshooting protocol stack configuration since you can see whether packets entering ldl from either above or below was forwarded to the neighboring module.

By setting debug bits via the -d option, you can cause the ldl driver to print the contents of packets flowing into it and out of it.

Examples

ldltest -r 192.168.1.1 eth0 192.168.1.117

Sends a ping to 192.168.1.1. The local host address is 192.168.1.117 (obtainable from the ifconfig command).

ldltest -S 0x00:0x0C -T -R 00:00:C0:D7:54:F8 eth0

Sends an LLC TEST command to the remote system with Ethernet address 00:00:C0:D7:54:F8, DSAP 0x00 and SSAP 0x0C. Await the response.

ldltest -s -f RAW eth0 192.168.1.47

Listens for RAW LLC frames addressed to the local machine whose IP address is 192.168.1.47. Send responses to TEST and XID commands.

ldltest -d 0x0f

Sets the debug mask in the ldl driver.

ldltest -H

Prints the values assigned to the debug mask bits as follows:

0x00000001 dump raw frame from net driver

0x00000002 dump UNITDATA_IND upstream

0x00000004 dump UNITDATA_REQ downstream

0x00000008 dump Tx to net driver

0x00000010 dump full buffer, not just header

0x00000020 debug info for DL_ATTACH

0x00000040 debug info for DL_BIND

Author

Ole Husgaard sparre@login.dknet.dk


Node:polltst, Next:, Previous:ldltest, Up:LiS User Commands

polltst

     /usr/bin/polltst
     

Description

polltst is a simple test program for the poll system call. Using poll, it reads keystrokes from stdin, writes them to one end of the LiS loopback driver, reads them from the other end and then writes them back to stdout.

While performing this operation it configures stdin for "no echo" mode, so the appearance of "echoed" characters is evidence of the operation of poll involving both a STREAMS and a non-STREAMS file.

Author

David Grothe dave@gcom.com


Node:streams, Next:, Previous:polltst, Up:LiS User Commands

streams

     /usr/sbin/streams Options
     

Description

The streams program is used to perform several different management functions for the LiS package, including starting and stopping the LiS subsystem.

Options

start
Start the LiS subsystem. This amounts to performing the command "modprobe streams".
stop
Stop the LiS subsystem. This amounts to performing the command "modprobe -r streams".
status
Reports on the status of the LiS subsystem.
-c Kbytes
Print or set the maximum message memory usage for LiS. The value 0 (default) means unlimited.
-C Kbytes
Print or set the maximum total memory usage for LiS. The value 0 (default) means unlimited.
-d mask
Set the debug mask for LiS. See below for details.
-D mask
Set an additional debug mask for LiS. See below for details.
-s
Print STREAMS memory usage statistics.
-m
Print STREAMS memory allocation to the system messages file (from kernel). This option should be used only for debugging and only when LiS is in a quiescent state. Unpredictable results can occur if this option is used while LiS memory allocations are changing dynamically.
-p
Print the LiS lock trace buffer to the system messages file (from kernel). Used in conjunction with the DEBUG_SPL_TRACE debug option.
-q
Print all STREAMS queues to the system messages file (from kernel). This option should be used only for debugging and only when LiS is in a quiescent state. Unpredictable results can occur if this option is used while LiS queue allocations are changing dynamically.
-t
Print STREAMS timing statistics. Used inconjunction with the DEBUG_MEAS_TIME debug option.
-h
Print a command synopsis.
-H
Print a command synopsis including the debug mask mnemonics.
Debug Options

The value that is used with the -d option consists of the logical "or" of the following single bit options.

-d Options
          DEBUG_OPEN        0x00000001
          DEBUG_CLOSE       0x00000002
          DEBUG_READ        0x00000004
          DEBUG_WRITE       0x00000008
          DEBUG_IOCTL       0x00000010
          DEBUG_PUTNEXT     0x00000020
          DEBUG_STRRPUT     0x00000040
          DEBUG_SIG         0x00000080
          DEBUG_PUTMSG      0x00000100
          DEBUG_GETMSG      0x00000200
          DEBUG_POLL        0x00000400
          DEBUG_LINK        0x00000800
          DEBUG_MEAS_TIME   0x00001000
          DEBUG_MEM_LEAK    0x00002000
          DEBUG_FLUSH       0x00004000
          DEBUG_FATTACH     0x00008000
          DEBUG_SAFE        0x00010000
          DEBUG_TRCE_MSG    0x00020000
          DEBUG_CLEAN_MSG   0x00040000
          DEBUG_SPL_TRACE   0x00080000
          DEBUG_MP_ALLOC    0x00100000
          DEBUG_MP_FREEMSG  0x00200000
          DEBUG_MALLOC      0x00400000
          DEBUG_MONITOR_MEM 0x00800000
          DEBUG_DMP_QUEUE   0x01000000
          DEBUG_DMP_MBLK    0x02000000
          DEBUG_DMP_DBLK    0x04000000
          DEBUG_DMP_STRHD   0x08000000
          DEBUG_ADDRS       0x80000000
          

-D Options
          DEBUG_SNDFD       0x00000001
          

Most of these options are intuitive as to their operation from the mnemonics.

The DEBUG_MEAS_TIME option causes LiS to use a high precision timer to calculate the execution time of several operations within itself. These timings include the time spent in STREAMS drivers. Thus, under controlled circumstances this option can be used to time STREAMS driver code. It is used in conjunction with the -t option to print out the timing statistics.

The DEBUG_SAFE option causes LiS to carefully check for NULL pointers when performing message passing and queueing operations such as putq and putnext.

The DEBUG_CLEAN_MSG option causes LiS to clear message data buffers to zero when they are allocated. It is useful for tracking down driver problems relating to using uninitialized areas of messages.

The DEBUG_SPL_TRACE option causes LiS to maintain a trace table of all LiS locking operations. It is used in conjunction with the -p option to print out the lock trace table. The locking operations that are traced include calls on the LiS locking primitives from STREAMS drivers.

The options DEBUG_DMP_QUEUE, DEBUG_DMP_MBLK and DEBUG_DMP_DBLK control the verbosity of the printing out of LiS memory areas via the -m option. With these debug mask bits set, LiS will print out the contents of these structures as well as the headers indicating that such a structure was allocated.

The DEBUG_ADDRS option causes the -m option to print out the addresses of structures as well as their memory tags and/or contents.

The DEBUG_MONITOR_MEM option causes LiS to monitor the guard words surrounding allocated memory areas in an attempt to catch overwriting of these words in a timely fashion. This option comes at a fairly substantial CPU time penalty.

Author

David Grothe dave@gcom.com


Node:strmakenodes, Next:, Previous:streams, Up:LiS User Commands

strmakenodes

     /usr/sbin/strmakenodes
     

Description

strmakenodes makes all of the /dev entries that are associated with LiS as a result of the LiS build process. All of the Config files that contributed to the LiS build are scanned for their "node" declarations. strmakenodes performs a mknod system call for each specified "node".

This command must be run before LiS can operate correctly after it is installed. This command is run automatically as a result of the "make install" operation of LiS.

This command accepts the option "-r" to mean remove nodes instead of making them. The command is run with this option as a result of the "make uninstall" operation.

The source code for this command is generated automatically as a side-effect of running the strconf utility.


Node:strtst, Next:, Previous:strmakenodes, Up:LiS User Commands

strtst

     /usr/bin/strtst
     

Description

strtst is a test program which tests the core functionality of LiS. It is a user level program which uses the built-in drivers that are installed by default with LiS. It performs numerous STREAMS operations and checks the results for correctness. It prints out a voluminous log file whose output is routed to the "messages" file (kernel informational messages).

The output of strtst can be compared to earlier "reference" outputs to see if the behavior of LiS has changed as a result of modifications to the code.

Author

David Grothe dave@gcom.com


Node:timetst, Previous:strtst, Up:LiS User Commands

timetst

     /usr/bin/timetst [Iterations]
     

Description

timetst peforms a timing test using the LiS loopback driver. It writes short messages downstream under several different LiS options and measures the round trip time for the messages. The Iterations parameter specified the number of iterations that timetst uses in its timing loop, the default being 100,000.

Author

David Grothe dave@gcom.com


Node:LiS Driver/Kernel Interface, Next:, Previous:LiS User Commands, Up:Top

LiS Driver/Kernel Interface

Linux STREAMS (LiS) provides for an interface between STREAMS drivers and the surrounding kernel environment. This interface has grown over time and is likely to expand in the future.

In the Linux kernel, much of the interface between drivers and other kernel modules and the core kernel services, such as memory allocation and synchronization primitives, is implemented in macros and inline functions declared in kernel header files. This technique was used (probably) out of considerations of efficiency (defined as execution speed) and a consideration that there were no version problems with such constructs because one could always recompile one's drivers in the context of the new kernel. The only "kernel primitives" compatibility that has been attempted from one kernel release to the next is source code compatibility.

The real world of paying customers is quite different. And, as it happens, the world of paying customers seems to impinge upon LiS considerably.

In this world, the customers do not want to rebuild the kernel. They don't want to build the kernel at all. They want to install a distribution with a binary kernel that was configured only at install time. They then want to install add-on binary packages, and they expect these packages to operate correctly with their kernel.

When these add-on packages consist of STREAMS based protocol drivers, LiS is usually the only piece of code that is recompiled from source upon installation into the customer's environment. The STREAMS drivers themselves are typically distributed in binary and linked in with LiS. The resulting module is then typically loaded using "modprobe" or some equivalent command.

In these circumstances it is highly desirable for LiS to "buffer" the interface between the STREAMS drivers and the kernel environment. This allows the STREAMS driver writers to deliver smaller binary packages to their customers and minimizes the number of different versions of those packages that must be maintained by the STREAMS driver writers. Ideally, LiS would be able to present a uniform DKI that would support one version of a user's STREAMS driver across all versions of the Linux kernel.

This ultimate goal is probably not achievable, but it is possible to insulate STREAMS drivers from the Linux kernel to a considerable extent. This is possible in part due to the implied DKI of a STREAMS driver. A STREAMS driver most likely will confine itself to the SVR4 types of DKI calls which have syntax and semantics that do not change over time. The main challenges come from the use of constructs, such as PCI configuration and interrupt service routines, that go outside the SVR4 DKI and must use services of the Linux kernel more-or-less directly.

In general, LiS attempts to replace inline functions and macros with actual subroutine calls to perform kernel operations. This allows the STREAMS driver to be compiled once with references to these routines, with the routines themselves being compiled in the context of the specific kernel version at package installation time. Thus, the STREAMS drivers do not have to be sensitive to differences in kernel versions.


Node:Operating System Interface, Next:, Up:LiS Driver/Kernel Interface

Operating System Interface Routines

In the file <sys/osif.h>, LiS provides insulation routines for a number of commonly used kernel functions. These functions are used with their Linux kernel names, but those names are redefined in <sys/osif.h> to be subroutine calls on functions that are actually defined in the file osif.c within LiS. The osif.c file is compiled at LiS installation time and is sensitive to kernel version information.

In order to use this interface, you include the header files that you would normally include to use the kernel functions, and then include <sys/osif.h> after all of the kernel include files. This allows for the redefinition of the names.

The kernel functions provided via <sys/osif.h> are as follows, grouped by type of function.


Node:PCI BIOS Interface, Next:, Previous:Operating System Interface, Up:LiS Driver/Kernel Interface

PCI BIOS Interface

These are routines that utilize or simulate the original PCI BIOS interface of the 2.0 series of kernels. The names of these routines are changed via defines. Use them as if the prototypes were as follows. You can use these routines on 2.2 kernels even though they represent the 2.0 style of inteface.

     #if LINUX_VERSION_CODE < 0x020100       /* 2.0 kernel */
     unsigned long pcibios_init(unsigned long memory_start,
                                unsigned long memory_end);
     #else   /* 2.1 or 2.2 kernel * /
     void pcibios_init(void) ;
     #endif
     int pcibios_find_class(unsigned int class_code, unsigned short index,
                            unsigned char *bus, unsigned char *dev_fn);
     int pcibios_find_device(unsigned short vendor, unsigned short dev_id,
                             unsigned short index, unsigned char *bus,
                             unsigned char *dev_fn);
     int pcibios_read_config_byte(unsigned char bus, unsigned char dev_fn,
                                  unsigned char where, unsigned char *val);
     int pcibios_read_config_word(unsigned char bus, unsigned char dev_fn,
                                  unsigned char where, unsigned short *val);
     int pcibios_read_config_dword(unsigned char bus, unsigned char dev_fn,
                                   unsigned char where, unsigned int *val);
     int pcibios_write_config_byte(unsigned char bus, unsigned char dev_fn,
                                   unsigned char where, unsigned char val);
     int pcibios_write_config_word(unsigned char bus, unsigned char dev_fn,
                                   unsigned char where, unsigned short val);
     int pcibios_write_config_dword(unsigned char bus, unsigned char dev_fn,
                                    unsigned char where, unsigned int val);
     const char *pcibios_strerror(int error) ;
     


Node:PCI Interface, Next:, Previous:PCI BIOS Interface, Up:LiS Driver/Kernel Interface

PCI Interface

These routines constitute the PCI interface as implemented in the 2.2 series of kernels. Please note that these are filtered calls to the operating system and still depend directly upon the kernel structure "struct pci_dev". LiS provides a more abstract interface to PCI that does not depend upon the direct definition kernel structures. The [61]LiS PCI interface is to be preferred since it provides more insulation against changes in the kernel.

     struct pci_dev *pci_find_device(unsigned int vendor, unsigned int device,
                                     struct pci_dev *from);
     struct pci_dev *pci_find_class(unsigned int class, struct pci_dev *from);
     struct pci_dev *pci_find_slot(unsigned int bus, unsigned int devfn);
     int pci_read_config_byte(struct pci_dev *dev, u8 where, u8 * val);
     int pci_read_config_word(struct pci_dev *dev, u8 where, u16 * val);
     int pci_read_config_dword(struct pci_dev *dev, u8 where, u32 * val);
     int pci_write_config_byte(struct pci_dev *dev, u8 where, u8 val);
     int pci_write_config_word(struct pci_dev *dev, u8 where, u16 val);
     int pci_write_config_dword(struct pci_dev *dev, u8 where, u32 val);
     void pci_set_master(struct pci_dev *dev);
     


Node:IRQ Interface, Next:, Previous:PCI Interface, Up:LiS Driver/Kernel Interface

IRQ Interface

These are the routines that are used to attach and detach interrupt service routines to hardware interrupts.

     int request_irq(unsigned int irq,
     void (*handler) ((int, void *, void *), unsigned long flags, const char *device,
                      void *dev_id);
     void free_irq(unsigned int irq, void *dev_id);
     void disable_irq(unsigned int irq);
     void enable_irq(unsigned int irq);
     


Node:I/O Memory Mapping, Next:, Previous:IRQ Interface, Up:LiS Driver/Kernel Interface

I/O Memory Mapping

These are the routines that are typically used to map PCI bus or physical addresses to CPU virtual addresses. LiS includes some backward compatibility here to older kernel versions.

     void *ioremap_nocache(unsigned long offset, unsigned long size);
     void iounmap(void *addr);
     void *vremap(unsigned long offset, unsigned long size);
     unsigned long virt_to_phys(volatile void *addr);
     void *phys_to_virt(unsigned long addr);
     


Node:I/O Port Access, Next:, Previous:I/O Memory Mapping, Up:LiS Driver/Kernel Interface

I/O Port Access

These are the routines that allow a driver to register I/O ports.

     int check_region(unsigned int from, unsigned int extent);
     void request_region(unsigned int from, unsigned int extent, const char *name);
     void release_region(unsigned int from, unsigned int extent);
     


Node:Memory Allocation, Next:, Previous:I/O Port Access, Up:LiS Driver/Kernel Interface

Memory Allocation

These are the kernel routines that can be used to allocate memory. LiS also has a more insulated abstraction for kernel memory allocation. It is recommended that you use the [66]LiS memory allocator versions rather than the direct kernel versions.

     void *kmalloc(size_t nbytes, int type);
     void kfree(const void *ptr);
     void *vmalloc(unsigned long size);
     void vfree(void *ptr);
     


Node:DMA Routines, Next:, Previous:Memory Allocation, Up:LiS Driver/Kernel Interface

DMA Routines

These are the routines that are used to allocate a main-board old-style DMA channel for use by your driver. These are not much used anymore.

     int request_dma(unsigned int dma_nr, const char *device_id);
     void free_dma(unsigned int dma_nr);
     


Node:Delay Routines, Next:, Previous:DMA Routines, Up:LiS Driver/Kernel Interface

Delay Routines

This is the routine that simply spins the CPU for a given number of microseconds. LiS also redefines the symbol "jiffies" to a subroutine call to help insulate STREAMS drivers from changes in the way the kernel keeps track of time. Remember, the redefinition is accomplished using C language defines, so the following declarations describe the effective usage of these symbols, not their literal definition.

     void udelay(long micro_secs);
     unsigned long jiffies;
     


Node:Printing Routines, Next:, Previous:Delay Routines, Up:LiS Driver/Kernel Interface

Printing Routines

These are the most commonly used printf-like routines in the kernel. STREAMS drivers would be more portable if they used the cmn_err routine instead of printk.

     int printk(const char *fmt, ...);
     int sprintf(char *bfr, const char *fmt, ...);
     int vsprintf(char *bfr, const char *fmt, va_list args);
     


Node:Timer Routines, Next:, Previous:Printing Routines, Up:LiS Driver/Kernel Interface

Timer Routines

These are the the routines that start and stop kernel timers. STREAMS drivers would be more portable if they used the standard "[71]timeout" routine.

     void add_timer(struct timer_list *timer);
     int del_timer(struct timer_list *timer);
     

The following routine converts time in micro seconds to system "ticks". The "ticks" value is suitable for use with the timeout routine. Note that if the micro_sec parameter is less than the number of micro seconds in a system tick then the routine returns zero.

     unsigned lis_usectohz(unsigned micro_sec);
     

The following routine is an LiS abstraction of the C library routine gettimeofday. Note the absence of the time zone parameter.

     void lis_gettimeofday(struct timeval *tv);
     

The following two kernel routines are called via the LiS osif.c code.

     void do_gettimeofday(struct timeval *tp);
     void do_settimeofday(struct timeval *tp);
     


Node:Sleep and Wakeup Routines, Next:, Previous:Timer Routines, Up:LiS Driver/Kernel Interface

Sleep and Wakeup Routines

These are the kernel routines for sleeping using wait queues. STREAMS drivers should not be using these since only "open" and "close" routines are allowed to sleep, and for those cases, [73]LiS semaphores would provide better insulation from the kernel. STREAMS "put" and "service" routines should use [74]LiS spin locks for mutual exclusion.

     void sleep_on(OSIF_WAIT_Q_ARG);
     void interruptible_sleep_on(OSIF_WAIT_Q_ARG);
     void wake_up(OSIF_WAIT_Q_ARG);
     void wake_up_interruptible(OSIF_WAIT_Q_ARG);
     


Node:Thread Creation, Next:, Previous:Sleep and Wakeup Routines, Up:LiS Driver/Kernel Interface

Thread Creation

A STREAMS driver in LiS can create kernel threads if it so chooses. The following routine simplifies this task. It consolidates all of the kernel manipulations involved with the creation of a kernel thread into one place, thus removing references to these kernel functions from STREAMS driver code.

Prototype

     pid_t lis_thread_start(int (*fcn) (void *), void *arg, const char *name);
     int lis_thread_stop(pid_t pid);
     

Arguments

fcn

The function that is to be used as the entry point for the thread.

arg

The argument passed to the function.

name

An ASCII name associated with the thread. This name should be less than 16 characters in length. It will be the name of the thread that displays in a ps listing.

Operation

lis_thread_start creates a new thread, performs some operations prior to entering the fcn, and then calls fcn which acts as the "main" routine for the thread. The arg parameter is passed to fcn.

Before fcn is entered, the newly created thread will have shed all user space files and mapped memory. Thus, it is a kernel-only thread.

All signals are still enabled. Note that when the kernel goes down for reboot all processes are first sent a SIGTERM. Once those have been processed, all processes are then sent a SIGKILL. It is the implementor's choice which of these it pays attention to in order to exit prior to a reboot.

The fcn is entered with the "big kernel lock" NOT held, just as it would be for calling the "kernel_thread" function directly. On 2.2 kernels, the fcn should get this lock so that it can utilize kernel services safely.

The user's fcn returns a value when it exits and that value is returned to the kernel. It is not clear that anything actually pays any attention to this returned value. It particular, it is not visible to the thread that started the new thread.

lis_thread_start itself returns the process id of the new thread, or a negative error number. This value can be used to kill the thread.

lis_thread_stop kills a thread started by lis_thread_start. It returns 0 for success or a negative error number for failure.


Node:Major/Minor Device Numbering, Next:, Previous:Thread Creation, Up:LiS Driver/Kernel Interface

Major/Minor Device Numbering

In STREAMS the dev_t structure is used to combine a major device number and a minor device number into a single integer length quantity. The Linux kernel restricts these numbers to the range 0 to 255 (8-bit values).

LiS provides a typedef for dev_t that results in an unsigned integer quantity.

The Linux kernel, on the other hand, defines a structure of type kdev_t that it uses internally for this same purpose. The kdev_t type is an actual structure, and not an integer. Furthermore, the kernel defines a routine named makedevice that generates one of these structures, given the major and minor numbers as integers. It appears that eventually the kernel will use this structure exclusively and will expand the numbering space for both major and minor device numbers.

This has caused LiS to use non-standard nomenclature for handling its dev_t structures, since the routine makedevice is not compatible with the LiS dev_t structure.

LiS now provides the following operations on dev_t structures. Most of these functions are provided by macros, so the following are "virtual" prototypes.

int MAJOR(dev_t dev);
Extracts the major device number
int MINOR(dev_t dev);
Extracts the minor device number
dev_t MKDEV(int maj, int min);
Combines a major and minor device number into a dev_t
int DEV_SAME(dev_t d1, dev_t d2);
True if the two devices are the same
int DEV_TO_INT(dev_t dev);
Converts dev_t to an int

The sample drivers that come with LiS now use these constructs to manipulate device structures and can serve as examples for their usage.


Node:LiS Memory Allocation, Next:, Previous:Major/Minor Device Numbering, Up:LiS Driver/Kernel Interface

LiS Memory Allocation

LiS provides for several different styles of memory allocation, all of them insulated from the Linux kernel. These routines allow your driver to allocate memory in several different ways while still maintaining compatibility with different versions of the Linux kernel, with no driver recompilation required.

To use the LiS memory allocation routines include the file <sys/lismem.h> in your STREAMS driver source code.


Node:LiS malloc and free Equivalents, Next:, Previous:LiS Memory Allocation, Up:LiS Driver/Kernel Interface

LiS malloc and free Equivalents

The first group of memory allocation routines are the routines that play the role of "malloc" and "free." These routines keep a master linked list of all allocated memory areas. This list can be printed out via an ioctl to LiS. Each allocated area is tagged with the file name and line number of the code that caused it to be allocated. Each area contains a guard word at the front and back to enable the allocator to detect "off by one" accesses outside the allocated area.

LiS uses this allocator internally for allocating queues, messages and other internal data structures. This would be the allocator of choice for STREAMS drivers to use to allocate instance structures.

Memory allocated in this manner is ultimately allocated by the kernel routine "kmalloc". As such, it is not guaranteed to be DMA-able (in the old style), or to occupy physically contiguous memory locations. [78]See below for routines that can be used to allocate these types of memory areas.

The routines are as follows:

     void *ALLOC(int nbytes);
     void *ALLOCF(int nbytes, char *tag);
     void FREE(void *ptr);
     

The ALLOC and FREE routines are analogous to "malloc" and "free". The ALLOCF routine includes a character string which is prepended to the file name stored as the location from which the allocation occurred. It can serve as a tag for the type of memory being allocated.

Usage examples:

     ptr = ALLOC(456);
     FREE(ptr);
     ptr = ALLOCF(578, "Instance: ");
     FREE(ptr);
     


Node:LiS Kernel Memory Allocators, Next:, Previous:LiS malloc and free Equivalents, Up:LiS Driver/Kernel Interface

LiS Kernel Memory Allocators

These routines use the LiS malloc/free internal routines to allow for more flexibility in the options used when calling the kernel allocator. These routines all lead to a call on "kmalloc" with appropriate options. It is worth noting that the numerical value of the constants used in calling the kernel's "kmalloc" routine changed between the 2.2 and 2.4 versions of the kernel. Thus, drivers which called the kernel's "kmalloc" directly have to be recompiled to run in a 2.4 kernel. STREAMS drivers using the memory allocation interface defined here could run without modification and without a recompilation on both kernels, assuming that the drivers otherwise did not use any direct kernel functions.

     void *lis_alloc_atomic(int nbytes);
     void *lis_alloc_kernel(int nbytes);
     void *lis_alloc_dma(int nbytes);
     void *lis_free_mem(void *mem_area);
     

These routines pass the allocation options GFP_ATOMIC, GFP_KERNEL, and GFP_DMA, respectively, to "kmalloc" when allocating the memory. LiS takes care of passing the proper values to the kernel routine so that driver code can remain portable.

The routine lis_free_mem returns a NULL pointer for the convenience of the caller.

The kernel's kmalloc is restricted as to the number of bytes that it will allocate. The LiS routines do not have this restriction. If the number of requested bytes is larger than 16K the LiS allocation routines will call the page allocator to allocate the memory. The lis_free_mem routine knows whether to free pages or to use the kernel's kfree routine.

Usage Examples:

     ptr = lis_alloc_kernel(sizeof(structure));
     ptr = lis_free_mem(ptr);        /* returns NULL pointer */
     


Node:LiS Page Allocator, Next:, Previous:LiS Kernel Memory Allocators, Up:LiS Driver/Kernel Interface

LiS Page Allocator

These routines allow a STREAMS driver to allocate memory directly from the kernel's page allocator. Memory allocated in this manner occupies physically contiguous locations and is suitable for use with bus master DMA PCI devices.

Unlike the kernel's page allocator, the size that is specified when calling the LiS page allocator is in bytes, not "order", or other encoding of page size. LiS calculates the number of pages based upon the requested size.

Also, LiS does not require you to pass the size of the area when freeing the page.

The routines are as follows:

     void *lis_get_free_pages(int nbytes);
     void *lis_free_pages(void *ptr);
     

The lis_free_pages routine returns a NULL pointer for the convenience of the caller.

Usage Examples:

     ptr = lis_get_free_pages(1024 * kbytes);
     ptr = lis_free_pages(ptr);
     


Node:LiS PCI Interface, Next:, Previous:LiS Page Allocator, Up:LiS Driver/Kernel Interface

LiS PCI Interface

In order to assist in the portability of STREAMS drivers across different versions of the Linux kernel, LiS provides an abstraction of the PCI configuration interface. It defines a data structure that is used to describe a PCI device and a set of routines that perform operations on PCI configuration space.

Using these abstractions, a STREAMS driver can be portable from the 2.2 kernel to the 2.4 kernel with no recompilation required. The LiS structures completely hide the kernel data structures and PCI configuration space operations from the STREAMS driver.

To use this interface include the file <sys/lispci.h> in your STREAMS driver source code.


Node:The LiS PCI Device Structure, Next:, Previous:LiS PCI Interface, Up:LiS Driver/Kernel Interface

The LiS PCI Device Structure

This structure is distinct from a similar structure which is defined by the Linux kernel, but which differs significantly between the 2.2 and 2.4 kernels. The LiS version of this structure is oriented towards providing just enough information to allow a driver to operate the PCI device, without being concerned about the details of PCI bus topology.

This structure is used to return information to the STREAMS driver concerning devices that meet certain criteria, such as device class or manufacturer devide identification.

     #define LIS_PCI_MEM_CNT 12      /* # mem addrs */
     typedef struct lis_pci_dev {
             unsigned bus;                   /* bus number */
             unsigned dev_fcn;               /* device/function code */
             unsigned vendor;                /* vendor id */
             unsigned device;                /* device id */
             unsigned class;                 /* class type */
             unsigned hdr_type;              /* PCI header type */
             unsigned irq;                   /* IRQ number */
             unsigned long mem_addrs[LIS_PCI_MEM_CNT];
             void *user_ptr;                 /* private for user */
     } lis_pci_dev_t;
     

The bus field contains the bus number on which the device is located. LiS obtains this information from the kernel.

The dev_fcn field contains an encoding of the device number on the bus and the function number within the device that this particular structure pertains to. The pair bus and dev_fcn uniquely identifies a device in the PCI subsystem. Devices can be searched for on the PCI bus by bus number and dev_fcn value (see below).

Given a dev_fcn value, a pair of macros will extract the "device" portion and the "function number" portion from it.

#define LIS_PCI_DEV(devfcn)
Extracts the "device" portion
#define LIS_PCI_FCN(devfcn)
Extracts the "function number" portion
#define LIS_MK_DEV_FCN(dev,fcn)
Put dev and fcn together

Given a device number and a function number, this macro will synthesize a dev_fcn value suitable for use in searching the bus.

The vendor and device fields contain the vendor id (manuracturer code) and the vendor's device identifier for the device. Devices can be searched for on the PCI bus by vendor and device identifier (see below).

The class field contains the class code associated with the device. Devices can be searched for on the PCI bus by class code (see below).

The hdr_type field gives the type information for the PCI configuration space header.

The irq field gives the IRQ number that is assigned to this device. This is the number that is used to attach an interrupt service routine to the device.

The mem_addrs field contains a list of addresses associated with the device. These are raw PCI bus addresses and are not mapped into the address space of the processor. Empty slots contain the value zero.


Node:LiS PCI Search Routines, Next:, Previous:The LiS PCI Device Structure, Up:LiS Driver/Kernel Interface

LiS PCI Search Routines

These routines allow the STREAMS driver to find devices on the PCI bus and obtain a pointer to the lis_pci_dev_t structure for the device.

lis_pci_dev_t *lis_pci_find_device(unsigned vendor, unsigned device, lis_pci_dev_t *previous_struct);

Find the device by vendor identification and vendor device identification. By passing in the pointer to the previous structure returned it is possible to find all devices of a given type.

The routine returns NULL if there are no (more) devices for the given vender and device identifiers.

Usage example:

     lis_pci_dev_t *pcip = NULL;
     while ((pcip = lis_pci_find_device(0x109e, 0x8474, pcip)) != NULL) {
             pcip points to a unique device from this vendor
     }
     

lis_pci_dev_t *lis_pci_find_class(unsigned class, lis_pci_dev_t *previous_struct);

Find the device by class. The usage is similar to lis_pci_find_device in that you can use a pointer to loop through all devices of a given class.

The function returns NULL if there are no (more) devices of the given class.

lis_pci_dev_t *lis_pci_find_slot(unsigned bus, unsigned dev_fcn);

Find the device by slot number. If you know the bus number (zero for most simple Intel PC systems) and the dev_fcn, you can obtain the PCI configuration information for that particular "slot". Use the LIS_MK_DEV_FCN macro to synthesize the dev_fcn value from the "device" (slot) number and the function number.

The function returns NULL if there is no device in that slot.

Note that this routine only returns one structure since it is not meaningful to process a list of devices for the same slot.


Node:LiS PCI Configuration Space Routines, Next:, Previous:LiS PCI Search Routines, Up:LiS Driver/Kernel Interface

LiS PCI Configuration Space Routines

The following routines are used to read and write PCI configuration space for a particular device. Configuration space can be accessed by byte, word (16 bit) or dword (32 bit).

Each routine takes a pointer to an lis_pci_dev_t structure as an argument. It also takes an index value which is the byte offset from the base of the configuration space for the device at which the given byte/word/dword is to be read or written.

Care should be exercised when writing to configuration space since many of these values are determined by the PCI BIOS at system boot time.

The lis_pci_set_master routine sets the "bus master DMA" bit for the given device. This is used for devices that perform bus master DMA.

The routines are as follows:

     int lis_pci_read_config_byte(lis_pci_dev_t *dev, unsigned index,
                                  unsigned char *rtn_val);
     int lis_pci_read_config_word(lis_pci_dev_t *dev, unsigned index,
                                  unsigned short *rtn_val);
     int lis_pci_read_config_dword(lis_pci_dev_t *dev, unsigned index,
                                   unsigned long *rtn_val);
     int lis_pci_write_config_byte(lis_pci_dev_t *dev, unsigned index,
                                   unsigned char val);
     int lis_pci_write_config_word(lis_pci_dev_t *dev, unsigned index,
                                   unsigned short val);
     int lis_pci_write_config_dword(lis_pci_dev_t *dev, unsigned index,
                                    unsigned long val);
     void lis_pci_set_master(lis_pci_dev_t *dev);
     


Node:LiS PCI DMA Routines, Next:, Previous:LiS PCI Configuration Space Routines, Up:LiS Driver/Kernel Interface

LiS PCI DMA Routines

These routines are used to allocate memory suitable for use with PCI bus master DMA devices or to map page-allocated memory for those purposes.

In order to understand what these routines do, please refer to the file /usr/src/linux/Documentation/DMA-mapping.txt in a fairly recent 2.4 kernel source tree. The kernel provides more functionality than is provided in LiS, so there are more routines documented there than are found in this interface.

You can use these routines in 2.2 kernels but the functions perfomed are simply approximations of the 2.4 semantics and may not work in all cases.

Note that the LiS routines have simplified the kernel interface involving "DMA handles" in such a way as to make these constructs easier to use and less error prone.

The following routines are used to allocate memory which the hardware keeps consistent between CPU access and DMA access.

     void *lis_pci_alloc_consistent(lis_pci_dev_t *dev, size_t size,
                                    lis_dma_addr_t * dma_handle);
     void *lis_pci_free_consistent(lis_dma_addr_t * dma_handle);
     

The following routines are used to obtain a DMA address from a returned DMA handle. You need to know whether or not your hardware environment is using 32-bit or 64-bit DMA addresses.

     u32 lis_pci_dma_handle_to_32(lis_dma_addr_t * dma_handle);
     u64 lis_pci_dma_handle_to_64(lis_dma_addr_t * dma_handle);
     

The following routines are usd to map page-allocated memory for DMA purposes. The direction indicator of LIS_SYNC_FOR_CPU means that you intend to use the memory for DMA transfers into memory. The direction indicator of LIS_SYNC_FOR_DMA means that you intend to use the memory for DMA transfers out of memory. If the DMA operation goes both ways then use LIS_SYNC_FOR_BOTH.

     void lis_pci_map_single(lis_pci_dev_t *dev, void *ptr, size_t size,
                             lis_dma_addr_t * dma_handle, int direction);
     void *lis_pci_unmap_single(lis_dma_addr_t * dma_handle);
     

The direction indicators are as follows:

     LIS_SYNC_FOR_CPU
     LIS_SYNC_FOR_DMA
     LIS_SYNC_FOR_BOTH
     

With mapped memory, i.e., non-consistent memory, you need to synchronize the memory whenever the CPU writes into it and the DMA needs to read it, or when the DMA has written into it and the CPU needs to read it. The following routine is used for that purpose.

     void lis_pci_dma_sync_single(lis_dma_addr_t * dma_handle, size_t size,
                                  int direction);
     

The following routines can be used at driver initialization time to discover and control the addressing boundary restrictions of a device.

     int lis_pci_dma_supported(lis_pci_dev_t *dev, u64 mask);
     int lis_pci_set_dma_mask(lis_pci_dev_t *dev, u64 mask);
     


Node:LiS Atomic Functions, Next:, Previous:LiS PCI DMA Routines, Up:LiS Driver/Kernel Interface

LiS Atomic Functions

LiS provides for atomic integers implemented in a portable fashion. To declare an LiS portable atomic integer use the following declaration syntax:

     lis_atomic_t myatom;
     

LiS then provides the following operations on variables of this type.

     void lis_atomic_set(lis_atomic_t *atomic_addr, int valu);
     int lis_atomic_read(lis_atomic_t *atomic_addr);
     void lis_atomic_add(lis_atomic_t *atomic_addr, int amt);
     void lis_atomic_sub(lis_atomic_t *atomic_addr, int amt);
     void lis_atomic_inc(lis_atomic_t *atomic_addr);
     void lis_atomic_dec(lis_atomic_t *atomic_addr);
     int lis_atomic_dec_and_test(lis_atomic_t *atomic_addr);
     

Of these, only lis_atomic_dec_and_test needs any explanation. This routine performs an atomic_dec on the variable and returns true if the counter reached zero via that decrement operation. Note that by the time the routine returns some other CPU with access to the same variable may have changed its value. So the return reports only on the instantaneous value of the variable.


Node:LiS Locks, Next:, Previous:LiS Atomic Functions, Up:LiS Driver/Kernel Interface

LiS Locks

LiS provides an abstraction and an insulated interface to the Linux kernel for spin locks, interrupt disabling and semaphores. If you use this interface in your STREAMS driver you can utilize these kernel services on different versions of the Linux kernel without the necessity of recompiling your driver for each version of the kernel.

The LiS locks are especially useful in consideration of Linux kernels compiled with and without the SMP option set. The spin locks and semaphores of the Linux kernel are implemented using external inline functions. These functions are coded in assembly language and generate different sequences of instructions depending upon the compile time setting of the SMP option. Spin locks and semaphores compiled with SMP reset will not function properly on a multi-CPU system running an SMP kernel.

The LiS locks mechanism solves this problem by abstracting the locking primitives into actual subroutines, not inlines, defined within LiS. Since LiS is compiled from source code when it is installed the subroutines in LiS have the correct setting of SMP for the locking primitives. This allows the STREAMS driver code to be compiled once and the object code reused for multiple installations with varying options.

The following sections document the spin locks, interrupt disabling and semaphore mechanisms offered by LiS. To use these mechanisms include the file <sys/lislocks.h> in your STREAMS driver source code.

In choosing the appropriate type of lock to use, one must bear in mind that STREAMS drivers are not allowed to "sleep" in "put" and "service" procedures, only in "open" and "close" routines. That means that spin locks are the mutual exclusion mechanism of choice for "put" and "service" procedures. It is reasonable to use sleeping semaphores in "open" and "close" routines.

The simple interrupt exclusion mechanism can be used to exclude only interrupt routine execution for a section of code. However, this mechanism does not exclude other "put" or "service" procedures that may be executed on other CPUs. This may not be much of a consideration since LiS acquires a lock in the queue structure before executing the "put" or "service" procedure pointed to by that queue.

However, it could happen that the "read put/service" and "write put/service" procedures get executed simultaneously since there are two different locks in the STREAMS queues, one in the read queue and one in the write queue. In this case, the STREAMS driver code would need to use spin locks to protect data structures shared between the read and write "put" or "service" procedures.


Node:LiS Spin Locks, Next:, Previous:LiS Locks, Up:LiS Driver/Kernel Interface

LiS Spin Locks

LiS provides an implementation of spin locks that utilizes the Linux kernel's spin lock mechanism to perform the actual locking functions. The LiS implementation adds features to the kernel spin locks such as the following:

For these reasons I highly recommend that STREAMS drivers use the LiS spin lock implementation in place of the direct kernel spin locks. The portability aspect of LiS spin locks cannot be overemphasized. Different Linux kernel compile-time options can lead to a proliferation of STREAMS driver code versions, or the necessity of always compiling the driver from source when it is installed. LiS spin locks allow a STREAMS driver to be compiled independently of kernel options with only the binary needed at driver installation time.

To declare a spin lock, use the typedef lis_spin_lock_t, as in the following:

     lis_spin_lock_t mylock;
     

LiS spin locks must be initialized before they are used. There is one initialization routine no matter which style of locking you intend to use.

void lis_spin_lock_init(lis_spin_lock_t *lock, const char *name) ;

This routine initializes the spin lock and associates an ASCII string name with it. The pointer name is saved in the lock structure for later use in printing out the lock trace table. It is the caller's responsibility to ensure that the name resides in memory that will persist for the duration of the existence of the lock.

You can also use dynamically allocated spin locks. This technique allows your STREAMS driver to be completely immune from changes in kernel version regarding the size of a spin lock since your driver only has to store a pointer to the allocated lock. The allocation and deallocation routines are as follows.

     lis_spin_lock_t *lis_spin_lock_alloc(const char *name);
     lis_spin_lock_t *lis_spin_lock_free(lis_spin_lock_t *lock, const char *name);
     

The allocation function returns a pointer to the spin lock, or NULL if the memory could not be allocated. The free function returns a NULL pointer for the convenience of the caller.

For further information on spin locks, see the section on [89]debugging spin locks.

To lock and unlock a spinlock, use any of the following pairs of routines. If you use the first routine to lock the spin lock then be sure to use its companion unlock routine. For nesting considerations, [91]see below.

     void lis_spin_lock(lis_spin_lock_t *lock);
     void lis_spin_unlock(lis_spin_lock_t *lock);
     int lis_spin_trylock(lis_spin_lock_t *lock);
     

These routines are to be called only from background processing to lock and unlock a spin lock. The trylock routine locks the spin lock if it is available, returning "true", or leaves it unlocked if it is unavailable, returning "false".

Background processing means any STREAMS driver processing that does not occur at interrupt time. These routines lock the lock but do not exclude interrupt routines from execution. Thus, your interrupt service routine can still be called whether or not your driver is holding a spin lock that was locked with one of these routines.

You can nest pairs of calls to these routines from the same thread of execution. [92]See below for more information on lock nesting.

Usage example:

     lis_spin_lock(&mylock);
     ...
     lis_spin_unlock(&mylock);
     
     void lis_spin_lock_irq(lis_spin_lock_t *lock);
     void lis_spin_unlock_irq(lis_spin_lock_t *lock);
     

This pair of routines locks the spin lock with interrupts disabled for the duration of the holding of the lock. The routine lis_spin_lock_irq re-enables interrupts after unlocking the lock.

You can use this technique to exclude interrupt routine execution. However, it is not advisable for interrupt routines themselves, or any routines called from an interrupt routine, to use this mechanism since the unlock primitive unconditionally enables interrupts, which may not be desirable from inside an interrupt routine.

These routines may be used in nested fashion. Only the outermost unlock routine will actually enable interrupts. [94]See below for more information about lock nesting.

Usage example:

     lis_spin_lock_irq(&mylock);
     ...
     lis_spin_unlock_irq(&mylock);
     
     void lis_spin_lock_irqsave(lis_spin_lock_t *lock, int *flags);
     void lis_spin_unlock_irqrestore(lis_spin_lock_t *lock, int *flags);
     

This pair of routines is similar to the "spin_lock_irq" routines in that the locking routine disables interrupts. However, it saves the interrupt state in the integer argument whose pointer is passed to the locking routine. The unlock routine then restores the interrupt state after unlocking the lock.

These routines are suitable for use by routines that are called both from interrupt level and from background. They also have the effect, when used in an interrupt routine, of excluding multiple execution of an interrupt routine on multiple CPUs in an SMP system.

These routines may be used in nested fashion. Only the outermost unlock routine will actually restore the interrupt state. [96]See below for more information about lock nesting.

Usage example:

     lis_spin_lock_t mylock;
     int flags;
     lis_spin_lock_irqsave(&mylock, &flags);
     ...
     lis_spin_unlock_irqrestore(&mylock, &flags);
     

Note that the unlock routine is passed the address of the flags just as in calling the lock routine.


Node:Lock Nesting, Next:, Previous:LiS Spin Locks, Up:LiS Driver/Kernel Interface

Lock Nesting

LiS spin locks can be locked and unlocked in nested fashion. When doing so, it is always best to use the same pair of lock and unlock routines at all levels of nesting for the same lock. Mixing different types of locking can lead to unexpected results and non-portable behavior.

LiS allows a single thread to lock spin locks in nested fashion. That is, the second and subsequent calls to the lock routine from a single thread will not spin on the lock because of finding it in a locked state from the first call. Also, every unlock call except the last one, the one that balances the first locking call, does not unlock the lock. Only the outermost unlock call causes the lock to be unlocked.

If the nesting is via lis_spin_lock_irq, then only the outermost unlock call enables interrupts. If the nesting is via lis_spin_lock_irqsave, then only the outermost unlock call restores the interrupt state.

When two or more threads attempt to lock a spin lock "simultaneously" only one thread is allowed to proceed at a time. The other threads "spin", that is, the CPUs executing the other threads are executing a loop that tests the lock repeatedly until it becomes available. Consequently, it is advisable to use locks to protect the execution of fairly short pieces of code if there is any likelihood of contention for the lock. While one thread is holding the lock, other CPUs may be idling waiting for it.

In the context of locking, "simultaneously" means any time from the moment of the first thread locking the spin lock until that thread unlocks the lock. If another thread attempts to lock the spin lock at any point in that interval then it will "spin."

When multiple threads use multiple spin locks to protect multiple resources, it is always a good idea if all threads execute "lock" operations on the multiple spin locks in the same order. It is also highly recommended that they execute "unlock" operations in the exact reverse order as the "lock" operations. This avoids so-called "deadly embrace" situations in which process A acquires spin lock A, process B acquires spin lock B, and then process A waits on B while process B waits on A.


Node:LiS Read/Write Locks, Next:, Previous:Lock Nesting, Up:LiS Driver/Kernel Interface

LiS Read/Write Locks

LiS offers an abstraction of the kernel's read/write locks. The LiS abstractions allow STREAMS drivers to use these locks without concern for changes that occur from one version of the kernel to the next.

A read/write lock is declared as a special data object of type lis_rw_lock_t. There are two types of routines to manipulate these locks. One set operates on the lock as a "read" lock. The other set operates on the lock as a "write" lock.

There can be multiple threads owning the lock in read mode. There can only be one thread that owns the lock in write mode. Furthermore, in order to acquire the lock in write mode, all the owners of the read mode lock must give it up.

The locks are used in the obvious way. If you only need to read the protected structure you use the read lock routine. If you need to change the structure you use the write lock routine.

Note that once you have a read lock you must give it up in order to get the same lock as a write lock.

The lock manipulation routines also allow for "regular", "irq" and "irqsave" manipulations of the read/write locks, just as with spin locks.

You must initialize your lock before using it, just as with spin locks. And in parallel to spin locks LiS provides two initialization routines. One operates directly on the read/write lock, and the other allocates memory dynamically for the lock. You can deallocate the dynamically allocated lock by calling the "free" routine.

The following is a listing of the read/write lock routines in LiS. The prototypes are in the file <sys/lislocks.h>.

     void lis_rw_read_lock(lis_rw_lock_t *lock);
     void lis_rw_write_lock(lis_rw_lock_t *lock);
     void lis_rw_read_unlock(lis_rw_lock_t *lock);
     void lis_rw_write_unlock(lis_rw_lock_t *lock);
     
     void lis_rw_read_lock_irq(lis_rw_lock_t *lock);
     void lis_rw_write_lock_irq(lis_rw_lock_t *lock);
     void lis_rw_read_unlock_irq(lis_rw_lock_t *lock);
     void lis_rw_write_unlock_irq(lis_rw_lock_t *lock);
     
     void lis_rw_read_lock_irqsave(lis_rw_lock_t *lock, int *flags);
     void lis_rw_write_lock_irqsave(lis_rw_lock_t *lock, int *flags);
     void lis_rw_read_unlock_irqrestore(lis_rw_lock_t *lock, int *flags);
     void lis_rw_write_unlock_irqrestore(lis_rw_lock_t *lock, int *flags);
     
     void lis_rw_lock_init(lis_rw_lock_t *lock, const char *name);
     lis_rw_lock_t *lis_rw_lock_alloc(const char *name);
     lis_rw_lock_t *lis_rw_lock_free(lis_rw_lock_t *lock, const char *name);
     


Node:LiS Interrupt Enable/Disable, Next:, Previous:LiS Read/Write Locks, Up:LiS Driver/Kernel Interface

LiS Interrupt Enable/Disable

LiS provides primitives for enabling and disabling interrupts modelled after the SVR4 SPL mechanism. There is one routine that is used to disable interrupts and another one for enabling interrupts. The routines are as follows:

     int lis_splstr(void);
     void lis_splx(int x);
     

The lis_splstr routine is used to disable interrupts. It returns a value that must be passed to lis_splx when it it desired to restore the interrupt level to its previous state. These two routines are implemented using the primitives lis_spin_lock_irqsave and lis_spin_unlock_irqrestore.

These routines can be used from background code ("put" and "service" procedures, or "open" and "close" routines), or from interrupt level. LiS itself uses these routines to protect STREAMS structures from ill-timed modification by interrupt routines. Many LiS utility routines, such as putq, getq and qenable, call these routines within themselves.

It is safe, and occurs frequently, to use these routines in a nested fashion. When using these routines in a nested fashion be sure that the value returned by the call to lis_splstr at level n is the value passed back to lis_splx at level n. The nesting rules for these routines are otherwise the same as for the pair lis_spin_lock_irqsave and lis_spin_unlock_irqrestore.

Usage examples:

     int x, y;
     x = lis_splstr();
     ...
     y = lis_splstr();
     ...
     lis_splx(y);
     ...
     lis_splx(x);
     

For further information on these routines see the section on [100]debugging spin locks.


Node:LiS Semaphores, Next:, Previous:LiS Interrupt Enable/Disable, Up:LiS Driver/Kernel Interface

LiS Semaphores

LiS provides an implementation of semaphores that is built upon the Linux kernel's semaphores. The LiS implementation adds features to the kernel semaphores such as the following:

For these reasons I highly recommend that STREAMS drivers use the LiS semaphore implementation in place of the direct kernel semaphores. The portability aspect of LiS semaphores cannot be overemphasized. Different Linux kernel compile-time options can lead to a proliferation of STREAMS driver code versions, or the necessity of always compiling the driver from source when it is installed. LiS semaphores allow a STREAMS driver to be compiled independently of kernel options with only the binary needed at driver installation time.

To declare an LiS semaphore, use a declaration similar to the following:

     lis_semaphore_t mysem;
     

LiS semaphores must be initialized before they are used. Use the following routine to initialize a declared semaphore.

     void lis_sem_init(lis_semaphore_t *, int);
     

If you initialize the semaphore to 0, then the first "down" operation on the semaphore will wait. If you initialize it to 1, then the first "down" operation will not wait. If you initialize it to n, then the first n "down" operations will not wait.

You can also allocate semaphores dynamically using the following routine.

     lis_semaphore_t *lis_sem_alloc(int);
     

This routine uses the kernel's memory allocator to allocate space for the semaphore. The lis_sem_destroy routine will deallocate it for you. The advantage of using this routine is that your STREAMS driver only has to have a pointer to the semaphore, not a semaphore structure itself. This adds an extra level of protection of your driver from kernel version considerations.

You can use the semaphore value to manage a pool of resources by initializing a semaphore to the number of items in the resource and having a driver open routine perform a "down" operation on the semaphore. This causes the open operations to be queued until the resource is available.

LiS semaphores should be explicitly destroyed when they are no longer needed, typically from your STREAMS driver close routine. This operation is accomplished via the following routine.

     lis_semaphore_t *lis_sem_destroy(lis_semaphore_t *,int);
     

This routine returns a NULL pointer for the convenience of the caller.

For further information on semaphores, see the section on [102]debugging semaphores.

The following two routines are used to acquire and release a semaphore.

     int lis_down(lis_semaphore_t *sem);
     void lis_up(lis_semaphore_t *sem);
     

The routine lis_down returns 0 for success and a negative error code for failure. The caller has not acquired the semaphore unless the routine returns zero.

One reason for a negative return could be that the calling task was signalled while waiting for the semaphore to become available. If this has occurred the return code will be set to -EINTR.

Semaphores cannot be used in nested fashion. Care must be exercised that a single thread only performs one "down" operation on a given semaphore.

When multiple threads use multiple semaphores to protect multiple resources, it is always a good idea if all threads execute "down" operations on the multiple semaphores in the same order. It is also highly recommended that they execute "up" operations in the exact reverse order as the "down" operations. This avoids so-called "deadly embrace" situations in which process A acquires semaphore A, process B acquires semaphore B, and then process A waits on B while process B waits on A.

Semaphores should be used only in STREAMS driver "open" and "close" routines. STREAMS driver "put" and "service" procedures are not allowed to sleep. They should use spin locks instead of semaphores.

Usage example:

     if (lis_down(&mysem) == 0) {
             ...
             lis_up(&mysem);
     }
     


Node:Debugging Spin Locks, Next:, Previous:LiS Semaphores, Up:LiS Driver/Kernel Interface

Debugging Spin Locks

LiS spin lock structures contain fields that assist in the debugging of spin-lock related problems. The LiS spin lock structure contains the following fields.

Field Description

spin_lock_mem An opaque memory area that contains the kernel's spin lock structure.

name

Pointer to an ASCII name for the lock. This allows one to readily identify the function of the lock (assuming that it is aptly named).

taskp

A (void *) which is really a (struct task_struct *) pointer. It points to the task that originally acquired the lock, or is NULL if no task has acquired the lock.

spinner_file, spinner_line

File and line number of the most recent call to one of the lis_spin_lock functions. This tells which line of code most recently tried to get the lock.

owner_file, owner_line

File and line number of the call to one of the lis_spin_lock functions that first acquired the lock. These fields are set at the same time as the taskp field.

unlocker_file, unlocker_line

File and line number of the call to one of the lis_spin_unlock functions that performed the final unlock on the lock, thus making it available for another thread. These fields are set at the same time as the taskp field is set to NULL.

If a thread owns the lock then its value of the current task pointer will be in taskp. If there is no other thread spinning on the lock, and if the lock has not been acquired in a nested fashion, then the spinner and owner fields will indicate the same file and line number.

If the spinner and owner fields are different and if the taskp is non-NULL then if the thread that most recently called one of the lis_spin_lock routines is different from the task that owns the lock, then that other task is spinning on the lock. By examination of the lock you can see which task owns the lock and where in the code it was acquired. This is often enough information to figure out why a deadlock is occurring.

A "deadly embrace" occurs when two threads each need to acquire two spin locks but they acquire them in the opposite order from each other. Under circumstances of contention each process owns the lock that the other is spinning on and will not release the lock until it acquires the other lock. Thus, both threads spin forever.

Note that the LiS splstr and splx functions are written in terms of LiS spin locks. LiS does not use these routines internally. They are provided to the user for backwards compatibility. However, it is important to know that these routines are spin locks in disguise. This means that the order of use of these functions mixed in with explicit spin lock manipulations may also lead to deadly embraces.

An effective technique for troubleshooting these kinds of problems is to use the two-machine kernel debugger, [105]kgdb. With this setup you can break into the target machine and look at memory using high level debugging techniques, including printing out of structures. Using kgdb you can find out where each CPU is executing, look at the corresponding source code lines, observe the locks that are involved, and then print out the lis_spin_lock_t structures for the specific locks. Oftentimes the information contained in the two locks will immediately reveal the nature of the deadly embrace.

It is also possible to have LiS trace all lock and semaphore operations. One of the LiS debug bits enables this function. To set this debug bit use the following command.

     streams -d0x0x80000
     

This causes LiS to make entries in a global trace buffer named lis_spl_track. The global pointer lis_spl_track_ptr indicates the next location in the table into which an entry is to be placed, which means that it points to the oldest entry in the buffer. Entries in the buffer are of type spl_track_t.

The fields of this structure are as follows. Field Description type The type of entry as follows.

Value

Meaning

1

splstr

2

splx

3

spin lock

4

spin unlock

5

semaphore down

6

semaphore up

cpu

The cpu number of the processor which made this entry. addr The address of the spin lock or semaphore involved in the operation.

tskp The task pointer for the task that made this entry. state Nesting value for spin locks, count field of the semaphore.

file, line

File and line number of the call to the LiS locking or semaphore routine that caused this entry to be made.

The trace buffer contains 4096 of these entries, maintained in a circular fashion. By printing out these entries you can see the history of lock manipulation within LiS. The command streams -p causes LiS to print out this table from within the kernel. The resulting output can be found in /var/log/messages (typically). However, in practice the system is usually hung when you need this information so you end up printing it from within the debugger.


Node:Debugging Semaphores, Next:, Previous:Debugging Spin Locks, Up:LiS Driver/Kernel Interface

Debugging Semaphores

LiS semaphore structures contain fields that assist in the debugging of semaphore related problems. The LiS semaphore structure contains the following fields.

Field Description

sem_mem An opaque memory area that contains the kernel's semaphore structure.

taskp

A (void *) which is really a (struct task_struct *) pointer. It points to the task that most recently acquired the semaphore, or is NULL if no task has acquired the semaphore. The taskp is set to NULL just prior to calling the kernel's up routine on the semaphore. Thus it stays NULL if no other task is pending on the semaphore.

downer_file, downer_line File and line number of the most recent call to the lis_down function. This tells which line of code most recently tried to get the semaphore.

owner_file, owner_line File and line number of the call to the lis_down function that acquired the semaphore. These fields are set at the same time as the taskp field.

upper_file, upper_line File and line number of the call to the lis_up function. These fields are set at the same time as the taskp field is set to NULL.

If the taskp field is non-NULL then the semaphore is owned by the task so indicated. If it is NULL then the semaphore is unowned. The upper fields show where the semaphore was last released.

If the downer and owner fields both indicate the same file and line number then that is an indication that the semaphore was acquired at that location in the program. If they are different, and if the taskp is non-NULL, that is an indication that there is a task waiting on the semaphore at the downer location. The owner fields show where the semaphore was acquired.

Bear in mind that semaphore acquisitions do not nest as is the case with spin locks. Therefore, if the same thread calls lis_down without calling lis_up on the same semaphore then the thread will be deadlocked. The downer and owner fields will usually offer a clue to this type of deadlock.

You can also use the LiS [107]lock trace buffer mechanism to assist in debugging semaphore usage.


Node:STREAMS Utility Routines, Next:, Previous:Debugging Semaphores, Up:LiS Driver/Kernel Interface

STREAMS Utility Routines

The following routines are available to LiS STREAMS drivers. These are standard AT&T SVR4 utility routines. They (hopefully) have the same semantics in LiS as they do in SVR4 STREAMS.

These routines are presented here in alphabetical order with no description. Please refer to the [109]AT&T SVR4 STREAMS documentation for the descriptions of these routines.


Node:Flushing Queue Bands, Next:, Previous:STREAMS Utility Routines, Up:LiS Driver/Kernel Interface

Flushing Queue Bands

A special note on flushing queue bands is in order. The rules for flushing queues are a bit complex, so we wish to review them here in some detail.

First some definitions and some things that affect all queue flushing. The term "data message" in the context of queue flushing means messages of type M_DATA, M_PROTO, M_PCPROTO or M_DELAY. All other message types are considered "non-data messages". You may find it less than intuitive that M_PCPROTO is considered a "data message".

The term "ordinary message" in the context of queue flushing means messages of type M_DATA, M_PROTO, M_BREAK, M_CTL, M_DELAY, M_IOCTL, M_PASSFP, M_RSE, M_SETOPTS or M_SIG. Please note that M_PCPROTO is not on this list.

The flag argument of FLUSHDATA means that only "data messages" are to be flushed. The flag argument of FLUSHALL means that "all" messages are to be flushed. As we shall see, in flushing queue bands whether a message gets flushed or not depends upon what the meaning of the word "all" is.

First, let's take the case of the routine flushq(q,flag). If flag is set to FLUSHDATA then all "data messages" in the entire queue, including all queue bands, are flushed. If the flag is set to FLUSHALL then the entire queue is flushed.

The case of the routine flushband(q,band,flag) is more complicated.

If the band argument is zero then special rules apply. In this case, only "ordinary" messages are flushed from the queue. The value of the flag parameter does not influence the operation. In Solaris STREAMS this behavior does not occur. They flush either "data messages" or "all" messages on band zero. Comments in the Solaris 8 source code indicate that the author of the flush code was somewhat confused on this point.

If the band argument is non-zero then the specific band of the queue is flushed in a manner similar to that of flushq. That is, the flag argument of FLUSHDATA means just flush "data messages" and the value of FLUSHALL means flush "all" messages from the specific band.

One further item needs some attention. Whenever an M_PCPROTO (or other "high priority") message is inserted into a STREAMS queue it is queued ahead of all messages in any queue band. This means that an M_PCPROTO cannot be directed to a queue band. It also means that flushband can never flush an M_PCPROTO, or any other "high priority" message from the queue. In order to flush M_PCPROTOs you must call flushq and flush the entire queue of either "data messages" or "all" messages.


Node:Utility Prototypes, Next:, Previous:Flushing Queue Bands, Up:LiS Driver/Kernel Interface

Utility Prototypes

     int adjmsg(mblk_t *mp, int length);
     struct msgb *allocb(int size, unsigned int priority);
     __________________________________________
     
     queue_t *backq(queue_t *q);
     int bcanput(queue_t *q, unsigned char band);
     int bcanputnext(queue_t *q, unsigned char band);
     void bcopy(void *src, void *dst, int nbytes);
     int bufcall(unsigned size, int priority, void (*function) (long), long arg);
     void bzero(void *addr, int nbytes);
     __________________________________________
     
     int canput(queue_t *q);
     int canputnext(queue_t *q);
     void cmn_err(int err_lvl, char *fmt, ...);
     mblk_t *copyb(mblk_t *mp);
     mblk_t *copymsg(mblk_t *mp);
     __________________________________________
     
     #define datamsg(type) -- true if msg->b_datap->db_type is data
     mblk_t *dupb(mblk_t *mp);
     mblk_t *dupmsg(mblk_t *mp);
     __________________________________________
     
     void enableok(queue_t *q);
     mblk_t *esballoc(unsigned char *base, int size, int priority, frtn_t *freeinfo);
     int esbbcall(int priority, void (*function) (long), long arg);
     __________________________________________
     
     void[117] flushband(queue_t *q, unsigned char band, int flag);
     void[118] flushq(queue_t *q, int flag);
     void freeb(mblk_t *bp);
     void freemsg(mblk_t *mp);
     __________________________________________
     
     int getmajor(dev_t dev);
     int getminor(dev_t dev);
     mblk_t *getq(queue_t *q);
     __________________________________________
     
     int insq(queue_t *q, mblk_t *emp, mblk_t *mp);
     __________________________________________
     
     void *kmem_alloc(int siz, int wait_code);
     void *kmem_zalloc(int siz, int wait_code);
     void kmem_free(void *ptr, int siz);
     __________________________________________
     
     void linkb(mblk_t *mp1, mblk_t *mp2);
     __________________________________________
     
     int msgdsize(mblk_t *mp);
     mblk_t *msgpullup(mblk_t *mp, int length);
     int msgsize(mblk_t *mp);
     __________________________________________
     
     void noenable(queue_t *q);
     __________________________________________
     
     queue_t *OTHERQ(queue_t *q);
     __________________________________________
     
     int pullupmsg(mblk_t *mp, int length);
     int putbq(queue_t *q, mblk_t *mp);
     int putctl(queue_t *q, int type);
     int putctl1(queue_t *q, int type, int param);
     void putnext(queue_t *q, mblk_t *mp);
     int putnextctl(queue_t *q, int type);
     int putnextctl1(queue_t *q, int type, int param);
     int putq(queue_t *q, mblk_t *mp);
     __________________________________________
     
     void qenable(queue_t *q);
     void qreply(queue_t *q, mblk_t *mp);
     int qsize(queue_t *q);
     void qprocsoff(queue_t *rdq);
     void qprocson(queue_t *rdq);
     __________________________________________
     
     queue_t *RD(queue_t *q);
     queue_t *WR(queue_t *q);
     queue_t *OTHERQ(queue_t *q);
     mblk_t *rmvb(mblk_t *mp, mblk_t *bp);
     void rmvq(queue_t *q, mblk_t *mp);
     __________________________________________
     
     int SAMESTR(queue_t *q);
     int strqget(queue_t *q, qfields_t what, unsigned char band, long *val);
     int strqset(queue_t *q, qfields_t what, unsigned char band, long val);
     __________________________________________
     
     int testb(int size, unsigned int priority);
     __________________________________________
     
     #define HZ -- ticks per second
     typedef void timo_fcn_t (caddr_t arg);
     toid_t timeout(timo_fcn_t *timo_fcn, caddr_t arg, long ticks);
     toid_t lis_untimeout(toid_t id);
     __________________________________________
     
     void unbufcall(int bcid);
     mblk_t *unlinkb(mblk_t *mp);
     int untimeout(int id);
     __________________________________________
     
     queue_t *WR(queue_t *q);
     __________________________________________
     
     int xmsgsize(mblk_t *mp);
     


Node:System Calls from within the Kernel, Previous:Utility Prototypes, Up:LiS Driver/Kernel Interface

System Calls from within the Kernel

LiS provides STREAMS drivers with a few system calls that can be made from within the kernel. These calls are intended to allow STREAMS drivers to manage their device special files through which the drivers are accessed. For example, by using the lis_mknod function a dynamically loaded driver can register itself with LiS, obtain a major device number and make its "/dev" entries at module load time. Using the lis_unlink function it can remove these "/dev" entries when the module unloads.

The semantics of the following routines are exactly the same as the user level routines of the same names without the "lis_" prefix. This is so because these routines are really just wrappers on a kernel system call. We list the function prototypes here but leave the detailed documentation to "man pages" and other documentation.

The following function prototypes exist in the file <sys/dki.h>.

     int lis_mknod(char *name, int mode, dev_t dev);
     int lis_unlink(char *name);
     int lis_mount(char *dev_name, char *dir_name, char *fstype,
                   unsigned long rwfla g, void *data);
     int lis_umount(char *file, int flags);
     


Node:LiS Library Routines, Next:, Previous:LiS Driver/Kernel Interface, Up:Top

LiS Library Routines

During the installation process of Linux STREAMS (LiS) a subroutine library is built and installed on your system. Three versions of the library are built and installed. They are as follows.

libLiS.a
Interface routines to LiS in static library form.
libLiS.so
Interface routines to LiS in dynamic library form.
libpLiS.so
Like libLiS.so but omits the "pipe" system call.

These three libraries are copied to the directory /usr/lib when LiS is installed.

In addition, the utility program ldconfig is run during the LiS make install. This causes this library to be linked, or searched, ahead of the standard C library. This is necessary because the standard C library contains dummy routines for the STREAMS interface functions, or most of them in the best case. If these dummy routines preempt the LiS versions then STREAMS applications will always perceive error returns from such routines as getmsg and putmsg.


Node:Library Routines, Next:, Up:LiS Library Routines

Library Routines

The following routines are present in the libraries libLiS.a and libLiS.so. The library libpLiS.so omits the "pipe" routine.

The routines in these libraries are standard STREAMS interface routines. As such we do not offer detailed descriptions of the functions of these routines. Instead we refer the reader to the [21]AT&T SVR4 STREAMS documentation.

     int fattach(int fd, const char *path);
     int fdetach(const char *path);
     int getmsg(int fd, void *ctlptr, void *dataptr, int *flagsp);
     int getpmsg(int fd, void *ctlptr, void *dataptr, int *bandp, int *flagsp);
     int isastream(int fd);
     int pipe(int *fd);
     int poll(void *pollfds, long nfds, int timeout);
     int putmsg(int fd, void *ctlptr, void *dataptr, int flags);
     int putpmsg(int fd, void *ctlptr, void *dataptr, int *bandp, int *flagsp);
     

These routines are all very small pieces of code. Most of them simply pass their parameters to LiS via a system call. The fattach and fdetach routines use ioctls to LiS if there is no system call available to call directly.

The poll routine simply executes the poll system call. It is present for backward compatibility to 2.0 kernels, in which LiS provided the poll system call.

The pipe routine has the same semantics as the standard C library routine. It uses STREAMS FIFOs to implement the pipe instead of the standard Linux pipes.

The libpLiS.so library, the one that preempts the standard C library, omits the STREAMS pipe routine so that standard Linux pipes are used unless the user explicitly links in libLiS.


Node:Using the Library, Previous:Library Routines, Up:LiS Library Routines

Using the Library

In order to use one of the LiS libraries you should include the file <sys/stropts.h> in you program source code. On you compiler command line you can add the option "-I/usr/src/LiS/include" to include the version of stropts.h that is distributed with LiS, or omit the option to include the system standard header file. The two header files are believed to be compatible enough that it does not matter which one you include in your program.

When linking your program, or performing a final "cc" to build your executable, include one of the following options on your command line.

/usr/lib/libLiS.a
Use libLiS.a (static, includes "pipe")
-lLiS
Use libLiS.so (dynamic, includes "pipe")
-lpLiS
Use libpLiS.so (dynamic, omits "pipe")

Omit any options

As of libc-2.2.1 the LiS STREAMS interface routines will be used automatically via libpLiS.so.


Node:LiS Drivers, Next:, Previous:LiS Library Routines, Up:Top

LiS Drivers

The LiS package comes with a number of STREAMS drivers and pushable modules in source code form. A number of these drivers and modules are small entities that are used in the testing of LiS. They are included so as to make it easy for any user to run the LiS tests for themselves.

Other drivers are used to interface between STREAMS and the Linux networking subsystem (link-drvr, ip_strms). Still others are used to implement STREAMS based pipes and FIFOs.


Node:STREAMS Drivers, Next:, Up:LiS Drivers

STREAMS Drivers

A driver in STREAMS has a major and minor device number associated with it and an entry in the /dev directory. The driver is opened and closed just like any file.


Node:Pushable Modules, Previous:STREAMS Drivers, Up:LiS Drivers

Pushable Modules

A pushable module in STREAMS is an entity that is added to an existing STREAMS file via the I_PUSH ioctl. These modules are known to LiS by mnemonic name, given as an argument to the I_PUSH ioctl. There are no major and minor device numbers or /dev entries associated with pushable modules.

This document is broken down into two sections. The STREAMS drivers and pushable modules are documented separately. The driver names used in this document are the declared names that appear in the LiS Config file for the particular driver.


Node:clone-drvr, Next:, Up:STREAMS Drivers

clone-drvr

Device Name

     /dev/clone_drvr
     

Description

This driver is used to assist LiS in implementing the "clone" open function. It appears under its own name as /dev/clone_drvr. By convention, it is allocated the first major number of all the STREAMS drivers.

In order to implement clone opens, one creates a node in the /dev directory for a device whose major number is set to that of the clone driver, and whose minor number is the major number of the driver to which the clone open is to be directed.

The clone driver's open routine forwards the open call to the target driver, passing a unique flag that informs the driver that a clone open is being requested. The target driver then allocated a minor device number to uniquely associate with this instance of the open operation. The clone driver synthesizes a new major/minor "device id" to pass back to LiS. LiS recognizes the change of major/minor from the original open and takes steps to allocate control structures unique to this open.

The "clone open" operation is intended to make is easy to open one device from a pool of devices, such as pseudo ttys or logical connections. It saves application programs from having to scan a list of device mnemonics issuing trial opens until one is found that succeeds.

Note that the driver is named /dev/clone_drvr instead of the more traditional SVR4 /dev/clone. This is to avoid a conflict with another driver named /dev/clone on Linux systems.

Author

David Grothe dave@gcom.com


Node:fifo, Next:, Previous:clone-drvr, Up:STREAMS Drivers

fifo

Device Name

     /dev/fifo (clone device)
     /dev/fifo.0
     

Description

The fifo pseudo-driver (which is internal to LiS) provides STREAMS-based fifos as single character special files, and STREAMS-based pipes as pairs of character special files which are interconnected (see pipe(3)).

STREAMS-based fifos differ from typical STREAMS-based character special files in that there are not separate stream head and driver queue pair within the STREAMS-based file. Instead, a fifo is created with only a single queue pair for the stream head. Moreover, in a typical driver queue pair, the write queue is not connected to a next queue. In a fifo, the write queue is directed to the read queue of the pair. A pipe comprises a pair of fifos, with the write queue of each pair directed to the read queue of the other. The two fifos comprising a pipe are referred to as peers, and each somewhat represents a driver to the other. As a degenerate case, a fifo is its own peer.

STREAMS modules may be pushed onto fifos and pipes, but should not expect a driver below them; instead, the SAMESTR() function should be used from the write queue of a pair to determine if the module is the lowest in the STREAMS-based file (this is called the midpoint). The structure of a fifo or pipe is preserved when modules are pushed (and popped); i.e., the write queue at the midpoint will always be directed at the read queue of the peer.

Input and output are handled at a fifo stream head as they would normally be handled at a stream head. In LiS, an fifo open() entry point exists to assign minor device numbers to new opens under the fifo major device number, and a close() entry point is used correspondingly to release them. These functions are kept in a streamtab data struc ture (as they would normally be for any STREAMS driver or module) which is private to the LiS implementation.

Application Usage

In the current Linux kernels, character special major numbers are limited to 16 bits, and major and minor device numbers to 8 bits each. This limits a system to 256 total major device numbers and 256 total minor devices per major device number. This is a rather severe limitation where mechanisms like fifos and pipes are concerned.

However, a driver may handle more than one major device number. The fifo pseudo-driver uses this to overcome this limitation, by supporting the automatic allocation and use of multiple major device numbers for fifos and pipes. Specifying more than 256 minor devices is done in the usual manner, i.e., by specifying the number of "units" in the appropriate Config file. Enough major device numbers will be allocated to cover the requested number of minor devices (if available, else an error will occur in strconf(8)). The number allocated will include one minor device per major number to be used as a fifo-specific clone minor device (specifically, minor number 0), which exhibits special behavior.

Normally, when cloning is done via the clone pseudo-driver, the clone major device number is used, along with the desired actual major number as the minor device num ber. When an open() is performed on such a device, the clone open() routine in turn calls the appropriate driver's open(), with the sflag parameter set to CLONEOPEN. The driver's open() is expected in this case to allocate an unused minor device number, and return it via an entirely new device number in the devp parameter. In this way, a driver can change the device number to be used for a STREAMS-based file. When minor device 0 for a specified for a fifo major device, the driver will also clone a new minor device number. However, LiS opens fifo devices differently; specifically, when an already-opened fifo-specific clone minor device is reopened, the new and subsequent opens will use the already-opened clone. Thus, using minor device 0 for a fifo when creating a file sys tem node will ensure that all concurrent opens of the associated path name will use the same STREAMS-based file; at the same time, opens of different file system nodes via different paths will open their respectively different STREAMS-based files. This is essentially how kernel-based fifos behave -applications and users of STREAMS-based fifos don't have to keep track of minor numbers to achieve this same behavior when it is desired.

It is in fact recommended that only two forms of file sys tem nodes be used for STREAMS-based fifos: the clone major number as major number with a fifo major number as minor number, to be used when every open of the associated path must clone a new fifo, and a fifo major number as major number with 0 as the minor number, to be used when new opens are to clone a new fifo but subsequent concurrent opens are to use the already opened fifo. These are represented by two device special file paths created when LiS is installed: /dev/fifo for the former, and /dev/fifo.0 for the latter. It is recommended that these be used, possibly along with the equivalent of stat(2) to determine appropriate major device numbers for the clone and fifo pseudo-drivers, which are also determined when LiS is installed. It can be noted that pipes are actually created as instances of the former, after which the write queues are peer-connected.

The fifo pseudo-driver allocates minor devices in round-robin fashion; i.e., a list of available minor devices is kept, and once a minor number is finally closed, it is put at the end of this list. Thus, a fifo minor device which is opened and closed will not be immediately reused.

Warnings

Because STREAMS-based fifos and pipes are implemented as character special devices, they do not appear as pipe devices when examined with stat(2) or the equivalent (e.g., ls(1)); i.e. the S_IFIFO indication is not set in the mode - S_IFCHR is set instead, and the actual device number is indicated in the st_rdev field of the stat data structure.

Because of the potential use of multiple major numbers, applications should not depend on a fifo or pipe having a specific major device number, nor should an application depend on all fifos and pipes having the same major device number.

See Also

clone(9), connld(9), fifo(4), ls(1), pipe(3), pipemod(9), STREAMS(4), stat(2), strconf(8)

Author

John Boyd, protologos LLC. jaboydjr@netwalk.com


Node:link-drvr, Next:, Previous:fifo, Up:STREAMS Drivers

link-drvr

Device Name

     /dev/ldl (clone device)
     

Description

The LDL driver provides an interface between STREAMS drivers and Linux network drivers. It registers itself as a client of a Linux network driver and then presents a DLPI Provider interface to STREAMS drivers, which may be pushed or linked above LDL.

The LDL is controlled by DLPI primitives from its upstream client. The DLPI primitives understood by this driver are as follows. DLPI mnemonics come from the file <sys/dlpi.h>. LDL mnemonics come from the file <sys/ldl.h>.

DL_INFO_REQ

Causes LDL to return a DL_INFO_ACK. If the stream has not been attached to a device then the returned values will consist of default values. If the stream has been attached then information will be returned that pertains the the underlying Linux network device.

DL_PHYS_ADDR_REQ

Causes LDL to return a DL_PHYS_ADDR_ACK (or DL_ERROR_ACK). The response will contain the current physical address of the Linux network device. The option to retrieve the factory address is not implemented and will always produce a DL_ERROR_ACK response.

DL_ATTACH_REQ

The stream must be in the DL_UNATTACHED state for this primitive to succeed.

The dl_ppa field specifies the device number of the Linux network device to attach in its low order bits. In the LDL_FRAME_MASK bits, the dl_ppa specifies the framing type to use with the device. The valid framing types are: LDL_FRAME_EII, LDL_FRAME_802_2, LDL_FRAME_802_3, LDL_FRAME_SNAP and LDL_FRAME_RAW_LLC.

The device number is usually obtained by issuing an LDL_FINDPPA ioctl. This ioctl takes a network device mnemonic, such as "etho", as an argument and produces a number suitable for use as the dl_ppa value in a DL_ATTACH_REQ.

If the attach succeeds, LDL returns a DL_OK_ACK and sets the state of the stream to DL_UNBOUND. It returns a DL_ERROR_ACK if it fails.

DL_DETACH_REQ

Causes LDL to detach from the Linux network device. The stream must be in the DL_UNBOUND state for this primitive to be valid.

If the detach succeeds, LDL returns a DL_OK_ACK and sets the state of the stream to DL_UNATTACHED. It returns a DL_ERROR_ACK if it fails.

DL_BIND_REQ

Causes LDL to bind an address to the stream. The stream must be in the DL_UNBOUND state for this primitive to succeed.

The bound address is used in demultiplexing frames received from the Linux network driver. The SAP conveyed in the DL_BIND_REQ is used to select those received frames that are sent upstream on a particular stream.

If the bind succeeds LDL returns a DL_OK_ACK and sets the state of the stream to DL_IDLE. If it fails then a DL_ERROR_ACK is sent upstream.

DL_UNBIND_REQ

Causes LDL to unbind all SAPs from the stream. The stream must be in the DL_IDLE state for this primitive to succeed.

If the unbind succeeds, LDL returns a DL_OK_ACK and sets the state of the stream to DL_UNBOUND. If it fails then a DL_ERROR_ACK is sent upstream.

DL_SUBS_BIND_REQ

Causes LDL to add an additional SAP to the list of SAPs associated with the stream. The stream must be in the DL_IDLE state for this primitive to succeed.

If the subs-bind succeeds, LDL returns a DL_SUBS_BIND_ACK. If it fails then a DL_ERROR_ACK is sent upstream.

DL_SUBS_UNBIND_REQ

Causes LDL to remove the given SAP from the list of SAPs associated with the stream. The stream must be in the DL_IDLE state for this primitive to succeed.

If the subs-unbind succeeds, LDL returns a DL_OK_ACK. If it fails then a DL_ERROR_ACK is sent upstream. The state of the stream is left in the DL_IDLE state in either case.

DL_PROMISCON_REQ

The intent of this primitive is to set the Linux network device into the so-called "promiscuous" mode of operation. However, it is unimplemented.

DL_PROMISCOFF_REQ

This primitive would undo the effect of a DL_PROMISCON_REQ. However, it is unimplemented.

DL_UNITDATA_REQ

This primitive is used to send data to the Linux network driver. The destination address is used to set the physical address of the receiver of the data. The stream must be in the DL_IDLE state for this primitive to succeed.

If the stream is operating in raw mode then the address field is ignored and it is assumed that the client has completely formatted the frame for transmission by the Linux network driver.

If this primitive fails, a DL_UDERROR_IND is sent upstream. There is no response in the case of success.

M_DATA

An M_DATA is an acceptable alternative to a DL_UNITDATA_REQ for sending data on a raw-mode stream.

If the data transmission operation fails, a DL_UDERROR_IND is sent upstream. There is no response in the case of success.

For data received from the Linux network driver, LDL forwards a copy of the received data in a DL_UNITDATA_IND DLPI message to each client whose stream is attached to the particular network driver and who has a SAP bound to the stream that matches the SAP information in the received frame. Note that for non-raw frame operations that the MAC header is stripped from the received frame prior to forwarding it to the client. The address of the sender is retained in the address field of the DL_UNITDATA_IND primitive.

Driver ioctls

The LDL driver implements the following ioctls. The user codes these ioctls as type I_STR and passes a structure of type struct strioctl to the driver. The ic_cmd field of this structure is decoded according to the following table. the ic_dp and ic_len fields delimit an argument structure which is also passed to the driver. The argument structure differs for each type of ic_cmd.

ic_cmd value Argument Structure Description
LDL_SETFLAGS IN/OUT: struct ldl_flags_ioctl Used to set internal option flags for the open stream. See ldl.c source for details.
LDL_FINDPPA IN: char[] OUT: long The agrument is an ASCII string representing a network device mnemonic such as "eth0." If such a device can be found then the argument is overwritten with a long word whose numerical value can be used as the dl_ppa field of a DL_ATTACH_REQ.
LDL_GETNAME IN: None OUT: char[] This ioctl returns the ASCII string form of the network device mnemonic for the stream.

Author

Ole Husgaard sparre@login.dknet.dk


Node:loop-around, Next:, Previous:link-drvr, Up:STREAMS Drivers

loop-around

Device Name

     /dev/loop_clone (clone device)
     /dev/loop.1
     /dev/loop.2
     

Description

This driver is used by LiS and the strtst utility to assist in the regression testing of LiS. It connects two streams together in a manner similar to that of a pipe. Messages written into one stream can be read back from the other.

The driver can be operated as a clone device with the two streams being connected via ioctls. A number of ioctls exist that tailor the operation of the driver. The user codes these ioctls as type I_STR and passes a structure of type struct strioctl to the driver. The ic_cmd field of this structure is decoded according to the following table. the ic_dp and ic_len fields delimit an argument structure which is also passed to the driver. The argument structure differs for each type of ic_cmd.

ic_cmd value Argument Structure Description
LOOP_SET IN: int Argument is the minor device number of the loop device to use for the other end of the connection. If the loop-around device had been opened by a directed open, such as to /dev/loop.1, then the minor device number is known from the device node. If it was opened via the /dev/loop_clone device then the minor device can be discovered via the LOOP_GET_DEV ioctl.
LOOP_PUTNXT None Set the driver into a mode in which it will perform a direct putnext call on the other stream rather than the default behavior of using the service queue to forward the message.
LOOP_MSGLVL IN: int Set to the number of messages to queue in the service queue before forwarding to the other stream. Zero means forward immediately.
LOOP_TIMR IN: int Set the number of "ticks" to hold messages before forwarding them to the other stream.
LOOP_MARK IN: int Set the MSGMARK flag for each of the next n messages before forwarding them to the other stream.
LOOP_GET_DEV OUT: int Return the minor device number of this stream. Useful for finding out the minor number of a clone device.
LOOP_BUFCALL None Use the bufcall mechanism to allocate a buffer for copying the next message.
LOOP_CONCAT IN: int Concatenate this many messages into a single message and then forward on the other stream. One concatenation resets this value to zero and the ioctl needs to be issued again to repeat the behavior.
LOOP_COPY None From this point on, copy messages rather than passing them through to the other stream.

Author

David Grothe dave@gcom.com plus others originally.


Node:mini-mux, Next:, Previous:loop-around, Up:STREAMS Drivers

mini-mux

Device Name

     /dev/mux_clone (clone device)
     /dev/minimux.1
     /dev/minimux.2
     

Description

This driver is used by LiS in its testing procedures. It is a small multiplexing driver that allows cascaded multiplexors to be built and torn down. The driver uses a pair of ioctls to establish connectivity between upper streams and lower streams. This allows control over how data flows through the multiplexor.

Both of these ioctls are coded as type I_STR and pass a structure of type struct strioctl to the driver. The ic_cmd field of this structure is decoded according to the following table. the ic_dp and ic_len fields delimit an argument structure which is also passed to the driver. The argument structure may differ for each type of ic_cmd.

ic_cmd value Argument Structure Description
MINIMUX_UP IN: int The argument is a muxid that was returned from an I_LINK ioctl. This ioctl causes the lower stream indicated by the muxid to be connected to this stream. This is unidirectional linkage and only affects the upstream flow of messages.
MINIMUX_DOWN IN: int The argument is a muxid that was returned from an I_LINK ioctl. This ioctl causes this stream to be connected to the lower stream indicated by the muxid. This is unidirectional linkage and only affects the downstream flow of messages.

Author

David Grothe dave@gcom.com


Node:printk, Next:, Previous:mini-mux, Up:STREAMS Drivers

printk

Device Name

     /dev/printk
     

Description

This driver accepts messages written to it and prints them from the kernel using the kernel's printk function. It is used by the LiS test software to keep messages from LiS and messages from the test program in sequence.

Author

David Grothe dave@gcom.com


Node:sad, Previous:printk, Up:STREAMS Drivers

sad

Device Name

     /dev/sad
     

Description

The STREAMS Administrative Driver manages the autopush function of LiS. Using ioctls the system administrator can provide a list of modules that are to be automatically pushed onto a given device when that device is opened. The controls are specified via the strapush structure which is defined in <sys/sad.h>.

The ioctl used by the user is of the form:

ioctl(fd, command, arg)

Where fd is the file descriptor of the file that is open to the sad driver, command and arg are described in the following table.

Command Argument Description

SAD_SAP struct strapush * Set the list of autopushed modules according to the sap_cmd and other arguments contained within the strapush structure.

SAD_GAP struct strapush * Get the list of configured autopushed modules associated with the indicated major and minor device number. The sad driver fills in this structure with the names of the modules and the applicable range of minor device numbers.

SAD_VML struct str_list * Validates a list of pushable module names to verify that they are installed in LiS. The str_list structure is defined in the file <sys/stropts.h>.

The strapush structure used by the SAD_SAP and SAD_GAP ioctls contains the following fields.

unsigned sap_cmd
This is the autopush command to be executed. The values are as follows.
SAP_ONE
Configure one minor device of the driver indicated by sap_major.
SAP_RANGE
Configure a range of minor devices of the driver indicated by sap_major. The range runs from sap_minor to sap_lastminor, inclusively.
SAP_ALL
Configure all minor devices of the driver indicated by sap_major.
SAP_CLEAR
Undo all autopush configuration for the driver indicated by sap_major.

major_t sap_major
The major device number of the driver which is being configured for autopush.
minor_t sap_minor
The minor device being configured, or the first of a range.
minor_t sap_lastminor
The last minor device of a range to be configured.
unsigned sap_npush
Number of modules to be pushed when the indicated device is opened.
char sap_list[MAXAPUSH][FMNAMESZ+1]
List of module names to be pushed, or list of modules names returned to user.

The ioctl function call returns zero upon success or -1 on failure. Upon failure errno is set to the error number describing the failure, usually either EFAULT or EINVAL.

Note that the sad driver is a standard AT&T STREAMS function. More comprehensive documentation for this driver can be found in the [40]SVR4 Programmer's Guide: STREAMS.

Author

Ole Husgaard sparre@login.dknet.dk


Node:connld, Next:, Up:Pushable Modules

connld

Module Name

connld

Description

The connld module provides a means to generate multiple unique STREAMS-based pipes from a single existing pipe end. connld may only be pushed (via the STREAMS I_PUSH ioctl) onto a STREAMS-based pipe. When first pushed, connld does nothing; on each subsequent open(2), connld will generate a unique STREAMS-based pipe. One end of each new pipe replaces the original pipe end from the perspective of the open call. The other end of each new pipe is sent, effectively as if by the I_SENDFD ioctl, to the other end of the original pipe, ostensibly to be received by a subsequent I_RECVFD ioctl operation.

Application Usage

The intent of connld is to provide a means to generate unique pipes which separately and independently connect client processes to a server process. The point of access for such clients is expected to be a path name known to all such clients and to which a pipe end may be connected (via fattach(3)) by the server process. The server establishes the original pipe, pushes connld onto the client end, and then listens via I_RECVFD for new connections on the server end. A client wishing to connect to the server will open(2) the path name representing the client end, and can determine via isastream(3) whether or not the server process is active and attached. If it is, the open() call returns one end of a unique new pipe that thus connects the client to the server.

Such a server is responsible both for accepting new connections via I_RECVFD on the original pipe, and for communicating with clients so connected via the received pipe ends. It would also be reasonable for such a server process to invalidate the point of access by calling fdetach(3) before terminating.

It should be noted that the poll(2) primitive may be used to indicate when an M_PASSFP representing a newly passed file is available on the original server pipe end. This is reflected by the POLLIN status setting in the events and revents fields of a pollfd structure. Moreover, any attempt to read an M_PASSFP message via the data-receiving primitives (i.e., read(2), getmsg(3), and getpmsg(3)) will fail with errno(3) returning an EBADMSG indication without discarding the message.

Even so, it should be reasonable to expect only M_PASSFP messages will be received on the original server pipe end, since it is not possible to carry on normal data traffic which has connld on one end, since connld does not support such traffic.

The use of connld can be made entirely free-standing by attaching well-known paths to both ends of the original pipe. The relevant capabilities are implemented in LiS so that the original creator of the pipe can close both ends after attaching paths to them, and the process of passing file descriptors can still be carried out via new open()'s as long as both ends remain attached.

See Also

fattach(3), fattach(8), fdetach(3), fifo(4), fifo(9),

pipe(3), STREAMS(4)

History

Unix System V Release 4 (SVR4)

Author

John Boyd, protologos LLC. jaboydjr@netwalk.com


Node:ip_strms, Next:, Previous:connld, Up:Pushable Modules

ip_strms

Module Name

ip_strms

Description

This module is pushed onto an open stream to a driver which implements the DLPI STREAMS protocol. It provides an interface between the DLPI driver below and the Linux IP module above. The effect is to be able to use a STREAMS DLPI driver as a network interface below Linux TCP/IP.

The ip_strms module monitors DLPI primitives sent from above on the stream file and shuttles them between the process which pushed the module onto the stream and the DLPI driver below. The ip_strms module will also allow data to be exchanged between the stream user and the DLPI driver until such time as the stream is logically attached to IP as a network driver.

In order to attach the stream to IP, the user process issues an ioctl of type SIOCSIFNAME. This ioctl causes ip_strms to register itself as a network driver of the given name. From that point onward data, in the form of M_DATA messages or of DL_UNITDATA_IND messages, are forwarded upstream to IP rather than to the stream user. Likewise, data messages received from IP are forwarded downstream to the DLPI driver as DL_UNITDATA_REQ messages. Downstream messages are completely formatted for the transmission medium and should be processed accordingly by the DLPI driver below.

After attaching to IP, the stream user must continue to remain in execution, holding the stream open. If the stream closes then ip_strms will detach from IP. Also, if the stream user sends a SIOCSIFNAME ioctl with an empty name then ip_strms will detach from IP.

The interfaces attached to IP will appear in the output of the netstat and ifconfig commands. An "ifconfig" down operation on the interface will also cause a detach from IP.

Application Processing

The application level program which manages the connection between a DLPI driver and TCP/IP should be coded to implement the following steps.

Author

David Grothe dave@gcom.com


Node:pipemod, Next:, Previous:ip_strms, Up:Pushable Modules

pipemod

Module Name

pipemod

Description

The pipemod module has the relatively simple task of reversing the sense of the FLUSH flag bits in M_FLUSH messages sent in STREAMS-based fifos and pipes. This must happen at the midpoint of a fifo or pipe, so that FLUSHR becomes FLUSHW, and FLUSHW becomes FLUSHR. pipemod does this, and has no other function.

To be used appropriately, then, pipemod must be the first module pushed onto a pipe end or a fifo, but it is only necessary on one end of a pipe.

pipemod is not needed if flush handling need not be supported, or if its function is supported by other means.

See Also

fifo(9), pipe(3), fifo(4), STREAMS(4)

History

Unix System V Release 4 (SVR4)

Author

John Boyd, protologos LLC. jaboydjr@netwalk.com


Node:relay, Next:, Previous:pipemod, Up:Pushable Modules


Node:relay2, Next:, Previous:relay, Up:Pushable Modules

relay, relay2

Module Name

relay relay2

Description

These are two names for the same module. All the module does is forward STREAMS messages along on the stream using putnext. These modules are used in the testing of LiS but are not otherwise useful. One could use the source code as a starting point for coding a pushable STREAMS module.

Author

David Grothe dave@gcom.com


Node:timod, Next:, Previous:relay2, Up:Pushable Modules

timod

Module Name

timod

Description

This is a primitive version of the standard AT&T SVR4 timod module. Its function is to convert user level ioctls to TLI primitives downstream.

Since there is no TLI Provider code within LiS, the timod module could be considered to be well ahead of its time.

Author

Ole Husgaard sparre@login.dknet.dk


Node:tirdwr, Previous:timod, Up:Pushable Modules

tirdwr

Module Name

tirdwr

Description

This is a primitive version of the standard AT&T SVR4 tirdwr module. Its function is to convert user level reads and writes to appropriate TLI protocol downstream.

Since there is no TLI Provider code within LiS, the tirdwr module could be considered to be well ahead of its time.

Author

Ole Husgaard sparre@login.dknet.dk


Node:GNU General Public License, Next:, Previous:LiS Drivers, Up:Top

GNU General Public License

GNU GENERAL PUBLIC LICENSE

Version 2, June 1991
     Copyright © 1989, 1991 Free Software Foundation, Inc.
     675 Mass Ave, Cambridge, MA 02139, USA
     
     Everyone is permitted to copy and distribute verbatim copies
     of this license document, but changing it is not allowed.
     

Preamble

The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.

When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.

We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.

Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and modification follow.

  1. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".

    Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.

  2. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.

    You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.

  3. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
    1. You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
    2. You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
    3. If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)

    These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.

    Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.

    In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.

  4. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
    1. Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
    2. Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
    3. Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)

    The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.

    If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.

  5. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
  6. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
  7. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
  8. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.

    If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.

    It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.

    This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.

  9. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
  10. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.

    Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.

  11. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
  12. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
  13. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.

     one line to give the program's name and an idea of what it does.
     Copyright (C) 19yy  name of author
     
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License
     as published by the Free Software Foundation; either version 2
     of the License, or (at your option) any later version.
     
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
     
     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this when it starts in an interactive mode:

     Gnomovision version 69, Copyright (C) 19yy name of author
     Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
     type `show w'.  This is free software, and you are welcome
     to redistribute it under certain conditions; type `show c'
     for details.
     

The hypothetical commands show w and show c should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than show w and show c; they could even be mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:

     Yoyodyne, Inc., hereby disclaims all copyright
     interest in the program `Gnomovision'
     (which makes passes at compilers) written
     by James Hacker.
     
     signature of Ty Coon, 1 April 1989
     Ty Coon, President of Vice
     

This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.


Node:GNU Lesser General Public License, Next:, Previous:GNU General Public License, Up:Top

GNU Lesser General Public License

GNU Lesser General Public License

Version 2.1, February 1999
     Copyright © 1991, 1999 Free Software Foundation, Inc.
     59 Temple Place -- Suite 330, Boston, MA 02111-1307, USA
     
     Everyone is permitted to copy and distribute verbatim copies
     of this license document, but changing it is not allowed.
     
     [This is the first released version of the Lesser GPL.  It also counts
     as the successor of the GNU Library Public License, version 2, hence the
     version number 2.1.]
     

Preamble

The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users.

This license, the Lesser General Public License, applies to some specially designated software--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below.

When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things.

To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it.

For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights.

We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library.

To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others.

Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license.

Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs.

When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library.

We call this license the Lesser General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances.

For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License.

In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system.

Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library.

The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run.

  1. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you".

    A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables.

    The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".)

    "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library.

    Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does.

  2. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library.

    You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.

  3. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
    1. The modified work must itself be a software library.
    2. You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change.
    3. You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License.
    4. If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful.

      (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.)

    These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.

    Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library.

    In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.

  4. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices.

    Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy.

    This option is useful when you wish to copy part of the code of the Library into a program that is not a library.

  5. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange.

    If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code.

  6. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.

    However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables.

    When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law.

    If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.)

    Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself.

  7. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications.

    You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things:

    1. Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.)
    2. Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with.
    3. Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution.
    4. If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place.
    5. Verify that the user has already received a copy of these materials or that you have already sent this user a copy.

    For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.

    It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute.

  8. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things:
    1. Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above.
    2. Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
  9. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
  10. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it.
  11. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License.
  12. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library.

    If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances.

    It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.

    This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.

  13. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
  14. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.

    Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation.

  15. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
  16. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
  17. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

How to Apply These Terms to Your New Libraries

If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License).

To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.

     one line to give the library's name and an idea of what it does.
     Copyright (C) year  name of author
     
     This library is free software; you can redistribute it and/or modify it
     under the terms of the GNU Lesser General Public License as published by
     the Free Software Foundation; either version 2.1 of the License, or (at
     your option) any later version.
     
     This library is distributed in the hope that it will be useful, but
     WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     Lesser General Public License for more details.
     
     You should have received a copy of the GNU Lesser General Public
     License along with this library; if not, write to the Free Software
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
     USA.
     

Also add information on how to contact you by electronic and paper mail.

You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names:

     Yoyodyne, Inc., hereby disclaims all copyright interest in the library
     `Frob' (a library for tweaking knobs) written by James Random Hacker.
     
     signature of Ty Coon, 1 April 1990
     Ty Coon, President of Vice
     

That's all there is to it!


Node:GNU Free Documentation License, Next:, Previous:GNU Lesser General Public License, Up:Top

GNU Free Documentation License

GNU Free Documentation License

Version 1.1, March 2000
     Copyright © 2000 Free Software Foundation, Inc.
     59 Temple Place, Suite 330, Boston, MA  02111-1307, USA
     
     Everyone is permitted to copy and distribute verbatim copies
     of this license document, but changing it is not allowed.
     
  1. PREAMBLE

    The purpose of this License is to make a manual, textbook, or other written document free in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.

    This License is a kind of "copyleft", which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.

    We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.

  2. APPLICABILITY AND DEFINITIONS

    This License applies to any manual or other work that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. The "Document", below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as "you".

    A "Modified Version" of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.

    A "Secondary Section" is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (For example, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.

    The "Invariant Sections" are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License.

    The "Cover Texts" are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License.

    A "Transparent" copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, whose contents can be viewed and edited directly and straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup has been designed to thwart or discourage subsequent modification by readers is not Transparent. A copy that is not "Transparent" is called "Opaque".

    Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML designed for human modification. Opaque formats include PostScript, PDF, proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML produced by some word processors for output purposes only.

    The "Title Page" means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, "Title Page" means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text.

  3. VERBATIM COPYING

    You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.

    You may also lend copies, under the same conditions stated above, and you may publicly display copies.

  4. COPYING IN QUANTITY

    If you publish printed copies of the Document numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.

    If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.

    If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a publicly-accessible computer-network location containing a complete Transparent copy of the Document, free of added material, which the general network-using public has access to download anonymously at no charge using public-standard network protocols. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.

    It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.

  5. MODIFICATIONS

    You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:

    1. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission.
    2. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has less than five).
    3. State on the Title page the name of the publisher of the Modified Version, as the publisher.
    4. Preserve all the copyright notices of the Document.
    5. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.
    6. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below.
    7. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document's license notice.
    8. Include an unaltered copy of this License.
    9. Preserve the section entitled "History", and its title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section entitled "History" in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence.
    10. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the "History" section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission.
    11. In any section entitled "Acknowledgments" or "Dedications", preserve the section's title, and preserve in the section all the substance and tone of each of the contributor acknowledgments and/or dedications given therein.
    12. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles.
    13. Delete any section entitled "Endorsements". Such a section may not be included in the Modified Version.
    14. Do not retitle any existing section as "Endorsements" or to conflict in title with any Invariant Section.

    If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles.

    You may add a section entitled "Endorsements", provided it contains nothing but endorsements of your Modified Version by various parties--for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.

    You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.

    The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.

  6. COMBINING DOCUMENTS

    You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice.

    The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.

    In the combination, you must combine any sections entitled "History" in the various original documents, forming one section entitled "History"; likewise combine any sections entitled "Acknowledgments", and any sections entitled "Dedications". You must delete all sections entitled "Endorsements."

  7. COLLECTIONS OF DOCUMENTS

    You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.

    You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.

  8. AGGREGATION WITH INDEPENDENT WORKS

    A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, does not as a whole count as a Modified Version of the Document, provided no compilation copyright is claimed for the compilation. Such a compilation is called an "aggregate", and this License does not apply to the other self-contained works thus compiled with the Document, on account of their being thus compiled, if they are not themselves derivative works of the Document.

    If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one quarter of the entire aggregate, the Document's Cover Texts may be placed on covers that surround only the Document within the aggregate. Otherwise they must appear on covers around the whole aggregate.

  9. TRANSLATION

    Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License provided that you also include the original English version of this License. In case of a disagreement between the translation and the original English version of this License, the original English version will prevail.

  10. TERMINATION

    You may not copy, modify, sublicense, or distribute the Document except as expressly provided for under this License. Any other attempt to copy, modify, sublicense or distribute the Document is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.

  11. FUTURE REVISIONS OF THIS LICENSE

    The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See http://www.gnu.org/copyleft/.

    Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License "or any later version" applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation.

ADDENDUM: How to use this License for your documents

To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page:

       Copyright (C)  year  your name.
       Permission is granted to copy, distribute and/or modify this document
       under the terms of the GNU Free Documentation License, Version 1.1
       or any later version published by the Free Software Foundation;
       with the Invariant Sections being list their titles, with the
       Front-Cover Texts being list, and with the Back-Cover Texts being list.
       A copy of the license is included in the section entitled ``GNU
       Free Documentation License''.
     

If you have no Invariant Sections, write "with no Invariant Sections" instead of saying which ones are invariant. If you have no Front-Cover Texts, write "no Front-Cover Texts" instead of "Front-Cover Texts being list"; likewise for Back-Cover Texts.

If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.


Node:Author Index, Next:, Previous:GNU Free Documentation License, Up:Top

Author Index


Node:Concept Index, Next:, Previous:Author Index, Up:Top

Concept Index


Node:Function and Macro Index, Next:, Previous:Concept Index, Up:Top

Function and Macro Index


Node:Variable and Constant Macro Index, Next:, Previous:Function and Macro Index, Up:Top

Variable and Constant Macro Index


Node:Data Type Index, Next:, Previous:Variable and Constant Macro Index, Up:Top

Data Type Index


Node:Program and File Index, Next:, Previous:Data Type Index, Up:Top

Program and File Index


Node:Configuration Keyword Index, Previous:Program and File Index, Up:Top

Configuration Keyword Index

Short Contents

Table of Contents


Footnotes

  1. The tirdwr module included with the Gcom LiS-2.16.18 (and even more current) releases is almost completely disfunctional and has been replaced in entirety.

  2. This change is far from small because it outdates libLiS.a and libLiS.so. A libLiS.a or libLiS.so from a previous version will not work correctly. All applications statically linking libLiS.a must be recompiled to use a libLiS.a from the more recent version. Unfortunately, LiS did not include versioning on its libraries. This has been corrected with the OpenSS7 release of LiS.

  3. Although I hvae not tried it, because we use GNU autoconf for configuration, these instructions should work equally well for the Solaris NexusWare cross-building environment as it does for the Linux NexusWare cross-building environment.

  4. WARNING: These instructions are not applicable to the OpenSS7 RPM release of LiS. For instructions, See Removal of LiS.

  5. WARNING: this section does not apply to the OpenSS7 rpm release of LiS. The OpenSS7 rpm release will always demand load.

  6. OpenSS7 autoconf/rpm release also place a copy of the LiS header files in the normal include directory, so the include directive can be -I/usr/include/LiS instead of -I/usr/src/LiS/include