Amiga Unix — 68040 · 68060

Manual pages › System calls (2)

sysm68k(2)

machine-specific functions

From the original Amiga UNIX 2.1 manual. Some things it mentions may not be in this release.

NAME

sysm68k - machine-specific functions

SYNOPSIS

#include <sys/sysm68k.h>

int sysm68k(int cmd, ...);

DESCRIPTION

sysm68k implements machine-specific functions. The cmd argument determines the function performed. The type and number of arguments expected depends on the function.

Command _m68k_SETNAME

When cmd is _m68k_SETNAME, a single argument of type const char * is expected. The contents of the string are used to establish the system's nodename. This is the text that is placed in the nodename member of the structure utsname that is returned by uname(2).

        sysm68k(_m68k_SETNAME, "amiga1");

Command _m698k_LIMUSER

When cmd is _m68k_LIMUSER, one additional integer argument is expected. This function provides the interface to the system license mechanism. The arguments that may be supplied are:

EUA_GET_LIM return the maximum number of users permitted on this system.

EUA_GET_CUR return the number of interactive users on this system.

EUA_REM_USER attempt to register a process as an interactive user

EUA_ADD_USER relinquish a license

EUA_UUCP register a process as a UUCP process.

<sys/proc.h>.)

     EUA_GET_LIC     return the license bits for this  process.   (See

License enforcement. Licenses are required for any process that has a controling terminal. If an unlicensed process attempts to fork, the kernel will dispatch a SIGKILL signal. Licenses are inherited by child processes.

The following code fragment is taken, from the login program. If you are writing your own login program, or any program that will establish an interactive session with the system, you must include this fragment. (An assumption has been made that pwd is of type struct passwd * and contains the password entry for the user requesting access. This code fragment may also be found in /usr/amiga/lib/license/register.c.

You will note that if the requesting user is the superuser, the result of the EUA_ADD_USER operation is basically ignored. The superuser is not bound by the user limit and may proceed as long as superuser privileges are maintained.

if (strstr(pwd->pw_shell, "uucico")) {
    sysm68k(_m68k_LIMUSER, EUA_UUCP);
}
else {
    if (sysm68k(_m68k_LIMUSER, EUA_ADD_USER) == -1) {
     if (errno == EACCES) {
         if (pwd->pw_uid != 0) {
          printf("This system is licensed for only %d users,\n",
              sysm68k(_m68k_LIMUSER, EUA_GET_LIM));
          puts("and this session would exceed that limit.0);
          puts("You may try again later.0);
          sleep(2);
          exit(1);
         }
     }
     else
         if (errno != EINVAL) {
          perror("Couldn't get session license");
          sleep(2);
          exit(1);
         }
    }
}

Processes that are registered as UUCP processes are allowed to fork, but must call setsid() to relinquish the controling terminal before making any exec() call. The following code fragment is used by uucico before executing a command:

pid = fork();
if (pid == 0) {
     /* child */
     setsid(); /* relinquish the terminal */
     execl(...);
}

For system defined routines such as popen() and system(),
workalikes are provided in /usr/amiga/lib/license/uucp.c
and /usr/amiga/lib/license/uucp.o.

DIAGNOSTICS

On success, sysm68k returns a value that depends on cmd as follows:

_m68k_SETNAME

A value of zero.

_m68k_LIMUSER

For EUA_GET_LIM, EUA_GET_CUR, and EUA_GET_LIC, the appropriate data is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error.

sysm68k fails if one or more of the following are true:

EINVAL cmd is not a valid command.

EPERM The requesting user was not the superuser.

EACCES The command was _m68k_LIMUSER and the subcommand was EUA_ADD_USER and the number of users was greater than or equal to the system wide license. When cmd is invalid, errno is set to EINVAL on return.