[parisc-linux] utssys?

Kevin Vajk kvajk@ricochet.net
Tue, 10 Aug 1999 14:58:55 -0700 (PDT)

On Sat, 7 Aug 1999, Matthew Wilcox wrote:

> Can anyone tell me what the utssys() system call does?  There's no manual
> page for it.

It takes 3 arguments; a pointer, and two ints.

The second int is the request type.  If an unknown request type is
passed in, it returns EFAULT.
If the request does something like sets the hostname, the first int
passed in is the number of bytes in the hostname.
If the request does something like gets the hostname, the first int
passed in is the size of the character buffer for it to put the answer in.
Otherwise it's ignored.

type=0 gets the utsname (see sys/utsname.h).  first int is ignored.
type=1 is obsolete; it returns EFAULT
I don't know what type=2 does.
type=3 sets utsname.nodename, if you're root
type=4 sets the hostname, if you're root
type=5 gets the hostname
type=6 sets utsname.sysname, if you're root
type=7 is undocumented; it's only used during OS updates.  Just return EFAULT.

Here's an example of using utssys() to get the system's hostname:

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <syscall.h>
int main(argc,argv)
int argc; char *argv[];
    char buf[2048];
    memset(buf, 0, sizeof(buf));
    /*  utssys(buf, sizeof(buf), 5);  */
    if( syscall( SYS_UTSSYS, buf, sizeof(buf)-1, 5 ) == -1 ) {
    printf("Hostname = \"%s\"\n", buf);

- Kevin Vajk