Example Module

The following is a compilable example of a module called pass.

Note: Before it can be compiled, the code must exist in a file called pass.c.

#include <errno.h>
#include <sys/stream.h>

static int passclose(), passopen
(), passrput(), passwput();
static struct module_info minfo =  { 0, "pass", 0, INFPSZ, 2048, 128 };
static struct qinit rinit = { passrput, 0, passopen, passclose, 0, &minfo };
static struct qinit winit = { passwput, 0, 0, 0, 0, &minfo };
struct streamtab passinfo = { &rinit, &winit };

static int
passclose (queue_t *q)
{
        return 0;
}

static int
passopen (queue_t *q, dev_t *devp, int flag, int sflag, cred_t *credp)
{
        return 0;
}

static int
passrput (queue_t *q, mblk_t *mp)
{
        putnext(q, mp);
        return 0;
}

static int
passwput (queue_t *q, mblk_t *mp)
{
        putnext(q, mp);
        return 0;
}
#include <sys/device.h>
#include <sys/strconf.h>

int
passconfig(int cmd, struct uio *uiop)
{
      static strconf_t conf = { 
              "pass", &passinfo, STR_NEW_OPEN,
      };

      switch (cmd) {
      case CFG_INIT:   return str_install(STR_LOAD_MOD, &conf);
      case CFG_TERM:   return str_install(STR_UNLOAD_MOD, &conf);
      default:         return EINVAL;
      }
}
The object named pass can be created using the following commands:

cc -c pass.c
ld -o pass pass.o -epass_config -bimport:/lib/pse.exp -lcsys
Use the following command to install the module:

strload -m pass
Use the following command to remove the module:

strload -u -m pass