• Aucun résultat trouvé

UNIX Asun®

N/A
N/A
Protected

Academic year: 2022

Partager "UNIX Asun®"

Copied!
656
0
0

Texte intégral

(1)

Asun®

microsystems

UNIX Interface Reference Manual

Sun Microsystems, Inc. • 2550 Garcia Avenue • Mountain View, CA 94043 • 415-960-1300

(2)

Credits and Trademarks

Sun Workstation® is a registered trademark of Sun Microsystems, Inc.

SunStation®, Sun Microsystems®, SunCore®, SunWindows®, DVMA®, and the combination of Sun with a numeric suffix are trademarks of Sun Microsystems, Inc.

UNIX, UNIXI32V, UNIX System III, and UNIX System V are trademarks of AT&T Bell Laboratories.

Intel ® and Multibus® are registered trademarks of Intel Corporation.

DEC®, PDP®, VT®, and VAX® are registered trademarks of Digital Equipment Corporation.

Copyright © 1986 by Sun Microsystems.

This publication is protected by Federal Copyright Law, with all rights reserved. No part of this publica- tion may be reproduced, stored in a retrieval system, translated, transcribed, or transmitted, in any form, or by any means manual, electric, electronic, electro-magnetic, mechanical, chemical, optical, or otherwise, without prior explicit written permission from Sun Microsystems.

(3)

INTRO(2) SYSTEM CALLS INTRO(2)

NAME

intro - introduction to system calls and error numbers SYNOPSIS

#include <errno.b>

DESCRIPTION

This section describes all of the system calls. A "(2V)" heading indicates that the system call performs dif- ferently when called from programs that use the System V libraries (programs compiled using lusr/5binlcc). On these pages, both the regular behavior and the System V behavior is described.

Most of these calls have one or more error returns. An error condition is indicated by an otherwise impos- sible return value. This is almost always -1; the individual descriptions specify the details. Note that a number of system calls overload the meanings of these error numbers, and that the meanings must be inter- preted according to the type and circumstances of the call.

As with normal arguments, all return codes and values from functions are of type integer unless otherwise noted. An error number is also made available in the external variable errno, which is not cleared on suc- cessful calls. Thus errno should be tested only after an error has occurred.

Each system call description attempts to list all possible error numbers. The following is a complete list of the errors and their names as given in <errno.h>.

o

Error 0

Unused.

EPERM Not owner

Typically this error indicates an attempt to modify a file in some way forbidden except to its owner or super-user. It is also returned for attempts by ordinary users to do things allowed only to the super-user.

2 ENOENT No such file or directory

This error occurs when a filename is specified and the file should exist but doesn't, or when one of the directories in a pathname does not exist.

3 ESRCH No such process

The process or process group whose number was given does not exist, or any such process is already dead.

4 EINTR Interrupted system call

An asynchronous signal (such as interrupt or quit), which the user has elected to catch, occurred during a system call. If execution is resumed after processing the signal, and the system call is not restarted, it will appear as if the interrupted system call returned this error condition.

S EIO I/O error

Some physical I/O error occurred. This error may in some cases occur on a call following the one to which it actually applies.

6 ENXIO No such device or address

I/O on a special file refers to a subdevice which does not exist, or beyond the limits of the device.

It may also occur when, for example, a tape drive is not on-line or a disk pack is not loaded on a drive.

7 E2BIG Arg list too long

An argument list longer than 10240 bytes is presented to execve.

8 ENOEXEC Exec format error

A request is made to execute a file which, although it has the appropriate permissions, does not start with a valid magic number (see a.out(5)).

9 EBADF Bad file number

Sun Release 3.2

Either a file descriptor refers to no open file, or a read (respectively, write) request is made to a file which is open only for writing (respectively, reading).

Last change: 16 July 1986 1

(4)

INTRO(2) SYSTEM CALLS INTRO(2)

2

10 ECHILD No children

A wait was executed by a process that had no existing or unwaited-for child processes.

11 EAGAIN No more processes

A fork failed because the system's process table is full or the user is not allowed to create any more processes.

12 ENOMEM Not enough memory

During an exeeve, brk, or sbrk, a program asks for more address space or swap space than the system is able to supply, or a process size limit would be exceeded. A lack of swap space is nor- mally a temporary condition; however, a lack of address space is not a temporary condition. The maximum size of the text, data, and stack segments is a system parameter. Soft limits may be increased to their corresponding hard limits.

13 EACCES Permission denied

An attempt was made to access a file in a way forbidden by the protection system.

14 EF AUL T Bad address

The system encountered a hardware fault in attempting to access the arguments of a system call.

15 ENOTBLK Block device required

A file which is not a block device was mentioned where a block device was required, for example, in mount.

16 EBUSY Device busy

An attempt to mount a file system that was already mounted or an attempt was made to dismount a file system on which there is an active file (open file, current directory, mounted-on file, or active text segment).

17 EEXIST File exists

An existing file was mentioned in an inappropriate context, for example, link.

18 EXDEV Cross-device link

A hard link to a file on another file system was attempted 19 ENODEV No such device

An attempt was made to apply an inappropriate system call to a device (for example, an attempt to read a write-only device) or an attempt was made to use a device not configured by the system.

20 ENOTDIR Not a directory

A non-directory was specified where a directory is required, for example, in a patbname or as an argument to eMir.

21 EISDIR Is a directory

An attempt was made to write on a directory.

22 EINV AL Invalid argument

A system call was made with an invalid argument; for example, dismounting a non-mounted file system, mentioning an unknown signal in sigvee or kill, reading or writing a file for which lseek has generated a negative pointer, or some other argument inappropriate for the call. Also set by math functions, see intro(3).

23 ENFILE File table overflow

The system's table of open files is full, and temporarily no more opens can be accepted.

24 EMFILE Too many open files

A process tried to have more open files than the system allows a process to have. The customary configuration limit is 30 per process.

25 ENOTTY Inappropriate ioctl for device

The code used in an ioetl call is not supported by the object that the file descriptor in the call refers to.

Last change: 16 July 1986 Sun Release 3.2

(5)

INTRO(2) SYSTEM CALLS INTRO(2)

26 ETXTBSY Text file busy

An attempt to execute a pure-procedure program which is currently open for writing. Also an attempt to open for writing a pure-procedure program that is being executed.

27 EFBIG File too large

The size of a file exceeded the maximum file size (1,082,201,088 bytes).

28 ENOSPC No space left on device

A write to an ordinary file, the creation of a directory or symbolic link, or the creation of a direc- tory entry failed because no more disk blocks are available on the file system, or the allocation of an inode for a newly created file failed because no more inodes are available on the file system.

29 ESPIPE Illegal seek

An lseek was issued to a socket or pipe. This error may also be issued for other non-seekable dev- ices.

30 EROFS Read-only file system

An attempt to modify a file or directory was made on a file system mounted read-only.

31 EMLINK Too many links

An attempt to make more than 32767 hard links to a file.

32 EPIPE Broken pipe

An attempt was made to write on a pipe or socket for which there is no process to read the data.

This condition normally generates a signal; the error is returned if the signal is caught or ignored.

33 EDOM Math argument

The argument of a function in the math library (as described in section 3M) is out of the domain of the function.

34 ERANGE Result too large

The value of a function in the math library (as described in section 3M) is unrepresentable within machine precision.

35 EWOULDBLOCK Operation would block

An operation which would cause a process to block was attempted on an object in non-blocking mode (see ioctl(2».

36 EINPROGRESS Operation now in progress

An operation which takes a long time to complete (such as a conneet(2» was attempted on a non- blocking object (see ioetl (2».

37 EALREADY Operation already in progress

An operation was attempted on a non-blocking object which already had an operation in progress.

38 ENOTSOCK Socket operation on non-socket Self-explanatory .

39 EDEST ADDRREQ Destination address required

A required address was omitted from an operation on a socket.

40 EMSGSIZE Message too long

A message sent on a socket was larger than the internal message buffer.

41 EPROTOTYPE Protocol wrong type for socket

A protocol was specified which does not support the semantics of the socket type requested. For example, you cannot use the ARPA Internet UDP protocol with type SOCK_STREAM.

42 ENOPROTOOPT Option not supported by protocol

A bad option was specified in a getsockopt(2) or setsockopt(2) call.

43 EPROTONOSUPPORT Protocol not supported

The protocol has not been configured into the system or no implementation for it exists.

Sun Release 3.2 Last change: 16 July 1986 3

(6)

INTRO(2) SYSTEM CALLS INTRO(2)

4

44 ESOCKTNOSUPPORT Socket type not supported

The support for the socket type has not been configured into the system or no implementation for it exists.

45 EOPNOTSUPP Operation not supported on socket

For example, trying to accept a connection on a datagram socket.

46 EPFNOSUPPORT Protocol family not supported

The protocol family has not been configured into the system or no implementation for it exists.

47 EAFNOSUPPORT Address family not supported by protocol family

An address incompatible with the requested protocol was used. For example, you shouldn't necessarily expect to be able to use PUP Internet addresses with ARPA Internet protocols.

48 EADDRINUSE Address already in use

Only one usage of each address is normally permitted.

49 EADDRNOTA V AIL Can't assign requested address

Normally results from an attempt to create a socket with an address not on this machine.

50 ENETDOWN Network is down

A socket operation encountered a dead network.

51 ENETUNREACH Network is unreachable

A socket operation was attempted to an unreachable network.

52 ENETRESET Network dropped connection on reset The host you were connected to crashed and rebooted 53 ECONNABORTED Software caused connection abort

A connection abort was caused internal to your host machine.

54 ECONNRESET Connection reset by peer

A connection was forcibly closed by a peer. This nonnally results from the peer executing a shut- down(2) call.

55 ENOBUFS No buffer space available

An operation on a socket or pipe was not performed because the system lacked sufficient buffer space.

56 EISCONN Socket is already connected

A connect request was made on an already connected socket; or, a sendto or sendmsg request on a connected socket specified a destination other than the connected party.

57 ENOTCONN Socket is not connected

An request to send or receive data was disallowed because the socket is not connected.

58 ESHUTDOWN Can't send after socket shutdown

A request to send data was disallowed because the socket had already been shut down with a pre- vious shutdown (2) call.

59 unused

60 ETIMEDOUT Connection timed out

A connect request failed because the connected party did not properly respond after a period of time. (The timeout period is dependent on the communication protocol.)

61 ECONNREFUSED Connection refused

No connection could be made because the target machine actively refused it This usually results from trying to connect to a service which is inactive on the foreign host

62 ELOOP Too many levels of symbolic links

A pathname lookup involved more than 8 symbolic links.

Last change: 16 July 1986 S un Release 3.2

(7)

INTRO(2) SYSTEM CALLS INTRO(2)

63 ENAMETOOLONG File name too long

A component of a pathname exceeded 255 characters, or an entire pathname exceeded 1023 char- acters.

64 EHOSTDOWN Host is down

A socket operation failed because the destination host was down.

65 EHOSTUNREACH Host is unreachable

A socket operation was attempted to an unreachable host.

66 ENOTEMPTY Directory not empty

An attempt was made to remove a directory with entries other than • and •• by performing a rmdir system call or a rename system call with that directory specified as the target directory.

67 unused 68 unused

69 EDQUOT Disc quota exceeded

A write to an ordinary file, the creation of a directory or symbolic link, or the creation of a direc- tory entry failed because the user's quota of disk blocks was exhausted, or the allocation of an inode for a newly created file failed because the user's quota of inodes was exhausted.

70 ESTALE Stale NFS file handle

A client referenced a an open file, when the file has been deleted.

71 EREMOTE Too many levels of remote in path

An attempt was made to remotely mount a file system into a path which already has a remotely mounted component

72 unused 73 unused 74 unused

75 ENOMSG No message of desired type

An attempt was made to receive a message of a type that does not exist on the specified message queue; see msgop(2).

76 unused

77 EIDRM Identifier removed

This error is returned to processes that resume execution due to the removal of an identifier from the IPC system's name space (see msgctl(2), semctl(2), and shmctl(2».

DEFINITIONS Descriptor

An integer assigned by the system when a file is referenced by open(2V), dup(2), or pipe (2) or a socket is referenced by socket(2) or socketpair(2) which uniquely identifies an access path to that file or socket from a given process or any of its children.

Directory

A directory is a special type of file which contains entries which are references to other files. Directory entries are called links. By convention, a directory contains at least two links, • and •. , referred to as dot and dot-dot respectively. Dot refers to the directory itself and dot-dot refers to its parent directory.

Effective User ID, Effective Group ID, and Access Groups

Access to system resources is governed by three values: the effective user ID, the effective group ID, and the group access list.

The effective user ID and effective group ID are initially the process's real user ID and real group ID respectively. Either may be modified through execution of a set-user-ID or set-group-ID file (possibly by one of its ancestors) (see execve(2».

Sun Release 3.2 Last change: 16 July 1986 5

(8)

INTRO(2) SYSTEM CALLS INTRO(2)

6

The group access list is an additional set of group ID's used only in determining resource accessibility.

Access checks are performed as described below in "File Access Permissions" . File Access Permissions

Every file in the file system has a set of access permissions. These permissions are used in determining whether a process may perform a requested operation on the file (such as opening a file for writing).

Access permissions are established at the time a file is created. They may be changed at some later time through the chmod (2) call.

File access is broken down according to whether a file may be: read, written, or executed. Directory files use the execute permission to control if the directory may be searched.

File access permissions are interpreted by the system as they apply to three different classes of users: the owner of the file, those users in the file's group, anyone else. Every file has an independent set of access permissions for each of these classes. When an access check is made, the system decides if permission should be granted by checking the access information applicable to the caller.

Read, write, and execute/search permissions on a file are granted to a process if:

The process's effective user ID is that of the super-user.

The process's effective user ID matches the user ID of the owner of the file and the owner permis- sions allow the access.

The process's effective user ID does not match the user ID of the owner of the file, and either the process's effective group ID matches the group ID of the file, or the group ID of the file is in the process's group access list, and the group permissions allow the access.

Neither the effective user ID nor effective group ID and group access list of the process match the corresponding user ID and group ID of the file, but the permissions for "other users" allow access.

Otherwise, permission is denied.

File Name

N ames consisting of up to 255 characters may be used to name an ordinary file, special file, or directory.

These characters may be selected from the set of all ASCII character excluding \0 (null) and the ASCII code for I (slash). (The parity bit, bit 8, must be 0.)

Note that it is generally unwise to use *, ?, [, or ] as part of filenames because of the special meaning attached to these characters by the shell. See sh(l). Although permitted, it is advisable to avoid the use of unprintable characters in filenames.

Message Queue Identifier

A message queue identifier (msqid) is a unique positive integer created by a msgget(2) system call. Each msqid has a message queue and a data structure associated with it. The data structure is referred to as msqid _ds and contains the following members:

struct ushort ushort ushort ushort time t time t time t

ipc yerm msg---.J>erm;

msg_qnum;

msg_qbytes;

msg_Ispid;

msg_lrpid;

msg_stime;

msg_rtime;

msg_ctime;

/* operation permission struct */

/* number of msgs on q */

/* max number of bytes on q */

/* pid of last msgsnd operation */

/* pid of last msgrcv operation */

/* last msgsnd time */

/* last msgrcv time */

/ *

last change time

* /

/* Times measured in secs since */

/* 00:00:00 GMT, Jan. 1, 1970 */

msgyerm is an ipc yerm structure that specifies the message operation permission (see below). This structure includes the following members:

Last change: 16 July 1986 S un Release 3.2

(9)

INTRa (2) SYSTEM CALLS INTRO(2)

ushort cuid; 1* creator user id *1 ushort cgid; 1* creator group id *1 ushort uid; 1* user id *1

ushort gid; 1* group id */

ushort mode; 1* rlw permission *1

msg_ qnum is the number of messages currently on the queue. msg_ q bytes is the maximum number of bytes allowed on the queue. msg_lspid is the process id of the last process that performed a msgsnd opera- tion. msg_lrpid is the process id of the last process that performed a msgrcv operation. msg_ stime is the time of the last msgsnd operation, msg_ rtime is the time of the last msgrcv operation, and msg_ ctime is the time of the last msgctl (2) operation that changed a member of the above structure.

Message Operation Permissions

In the msgop(2) and msgctl (2) system call descriptions, the permission required for an operation is given as

"{token}", where "token" is the type of permission needed interpreted as follows:

00400 00200 00060 00006

Read by user Write by user Read, Write by group Read, Write by others

Read and Write permissions on a msqid are granted to a process if one or more of the following are true:

The effective user ID of the process is super-user.

The effective user ID of the process matches msgyerm.[ c ]uid in the data structure associated with msqid and the appropriate bit of the "user" portion (0600) of msgyerm.mode is set.

The effective user ID of the process does not match msgyerm.[c]uid and the effective group ID of the process matches msgyerm.[c]gid and the appropriate bit of the "group" portion (060) of msgyerm.mode is set.

The effective user ID of the process does not match msgyerm.[c]uid and the effective group ID of the process does not match msgyerm.[c]gid and the appropriate bit of the "other" portion (06) of msgyerm.mode is set

Otherwise, the corresponding permissions are denied.

Parent Process ID

A new process is created by a currently active process (see fork (2». The parent process ID of a process is the process ID of its creator.

Path Name and Path Prefix

A pathname is a null-terminated character string starting with an optional slash (/), followed by zero or more directory names separated by slashes, optionally followed by a filename. The total length of a path- name must be less than {MAXPATHLEN} (1024) characters.

More precisely, a pathname is a null-terminated character string constructed as follows:

<path-name>: :=<file-name> I <path-prefix><file-name>

II

<path-prefix>:: = <rtprefix> I/<rtprefix>

<rtprefix>::=<dirname>/1 <rtprefix><dirname>1

where <file-name> is a string of 1 to 255 characters other than the ASCII slash and null, and <dirname> is a string of 1 to 255 characters (other than the ASCn slash and null) that names a directory.

If a pathname begins with a slash, the search begins at the root directory. Otherwise, the search begins at the current working directory.

A slash, by itself, names the root directory. A dot ( . ) names the current working directory.

A null pathname also refers to the current directory. However, this is not true of all UNIX systems. (On such systems, accidental use of a null pathname in routines that don't check for it may corrupt the current working directory.) For portable code, specify the current directory explicitly using".", rather than ''''.

Sun Release 3.2 Last change: 16 July 1986 7

(10)

INTRO(2) SYSTEM CALLS INTRO(2)

8

Process Group ID

Each active process is a member of a process group that is identified by a positive integer called the process group ID. This is the process 10 of the group leader. This grouping permits the signaling of related processes (see killpg(2» and the job control mechanisms of csh(I).

ProcessID

Each active process in the system is uniquely identified by a positive integer called a process ID. The range of this ID is from 0 to 30000.

Real User ID and Real Group ID

Each user on the system is identified by a positive integer termed the real user ID.

Each user is also a member of one or more groups. One of these groups is distinguished from others and used in implementing accounting facilities. The positive integer corresponding to this distinguished group is termed the real group ID.

All processes have a real user ID and real group ID. These are initialized from the equivalent attributes of the process which created it.

Root Directory and Current Working Directory

Each process has associated with it a concept of a root directory and a current working directory for the purpose of resolving path name searches. A process's root directory need not be the root directory of the root file system.

Semaphore Identifier

A semaphore identifier (semid) is a unique positive integer created by a semget(2) system call. Each semid has a set of semaphores and a data structure associated with it. The data structure is referred to as semid _ ds and contains the following members:

struct ushort time t time t

ipc yerm sem j>eTJIl;

sem_nsems;

sem_otime;

sem_ctime;

/* operation permission struct */

/* number of sems in set */

/* last operation time */

/* last change time */

/* Times measured in secs since *1 /* 00:00:00 GMT, Jan. 1, 1970 */

sem yerm is an ipc yerm structure that specifies the semaphore operation permission (see below). This structure includes the following members:

ushort cuid; /* creator user id *1 ushort cgid; /* creator group id *1 ushort uid; /* user id *1

ushort gid; /* group id *1 ushort mode; /* rIa permission *1

The value of sem_osems is equal to the number of semaphores in the set. Each semaphore in the set is referenced by a positive integer referred to as a sem _ num. sem _num values run sequentially from 0 to the value of sem _ osems minus 1. sem _ otime is the time of the last semop(2) operation, and sem _ ctime is the time of the last semctl (2) operation that changed a member of the above structure.

A semaphore is a data structure that contains the following members:

ushort short ushort ushort

semval;

sempid;

semncnt;

semzcnt;

1* semaphore value *1 /* pid of last operation *1 1* It awaiting semval > cval *1 1* It awaiting semval = 0 */

semval is a non-negative integer. sempid is equal to the process ID of the last process that performed a semaphore operation on this semaphore. semnent is a count of the number of processes that are currently suspended awaiting this semaphore's semval to become greater than its current value. semzeot is a count of the number of processes that are currently suspended awaiting this semaphore's semval to become zero.

Last change: 16 July 1986 Sun Release 3.2

(11)

INTRO(2) SYSTEM CALLS INTRO(2)

Semaphore Operation Permissions

In the semop(2) and semctl(2) system call descriptions, the permission required for an operation is given as

"{token}", where "token" is the type of permission needed interpreted as follows:

00400 Read by user

00200 Alter by user

00060 Read, Alter by group

00006 Read, Alter by others

Read and Alter permissions on a semid are granted to a process if one or more of the following are true:

The effective user ID of the process is super-user.

The effective user ID of the process matches semyerm.[c]uid in the data structure associated with semid and the appropriate bit of the "user" portion (0600) of sem yerm.mode is set The effective user ID of the process does not match semyerm.[c]uid and the effective group ID of the process matches sem yerm.[c]gid and the appropriate bit of the "group" portion (060) of semyerm.mode is set.

The effective user ID of the process does not match semyerm.[c]uid and the effective group ID of the process does not match semyerm.[c]gid and the appropriate bit of the "other" portion (06) of sem yerm.mode is set.

Otherwise, the corresponding permissions are denied.

Shared Memory Identifier

A shared memory identifier (shmid) is a unique positive integer created by a shmget(2) system call. Each shmid has a segment of memory (referred to as a shared memory segment) and a data structure associated with it. The data structure is referred to as shmid _ds and contains the following members:

struct ipc yerrn shm yenn; /* operation permission struct */

int shm _segsz; /* size of segment */

ushort shm _ cpid; /* creator pid */

ushort shm Jpid; /* pid of last operation */

short shm _ nattch; /* number of current attaches */

time t shm _ atime; /* last attach time */

time t shm _ dtime; /* last detach time */

time t shm _ ctime; /* last change time */

/* Times measured in secs since */

/* 00:00:00 GMT, Jan. 1, 1970 */

shm yerm is an ipc yerm structure that specifies the shared memory operation permission (see below).

This structure includes the following members:

ushort cuid; /* creator user id */

ushort cgid; /* creator group id */

ushort uid; /* user id */

ushort gid; /* group id */

ushort mode; /* r/w permission */

shm _segsz specifies the size of the shared memory segment. shm _ cpid is the process id of the process that created the shared memory identifier. shm Jpid is the process id of the last process that perfonned a shmop (2) operation. shm _nattch is the number of processes that currently have this segment attached.

shm _ atime is the time of the last shmat operation, shm _ dtirne is the time of the last shmdt operation, and shm_ctime is the time of the last shmctl(2) operation that changed one of the members of the above struc- ture.

Shared Memory Operation Permissions

In the shmop(2) and shmctl (2) system call descriptions, the permission required for an operation is given as

"{token}", where "token" is the type of permission needed interpreted as follows:

Sun Release 3.2 Last change: 16 July 1986 9

(12)

INTRO(2) SYSTEM CALLS INTRO(2)

00400 00200 00060 00006

Read by user Write by user Read, Write by group Read, Write by others

Read and Write permissions on a shmid are granted to a process if one or more of the following are true:

The effective user ID of the process is super-user.

The effective user ID of the process matches shmyerm.[c]uid in the data structure associated with shmid and the appropriate bit of the "user" portion (0600) of shm yerm.mode is set.

The effective user ID of the process does not match shmj)erm.[c]uid and the effective group ID of the process matches shmyerm.[c]gid and the appropriate bit of the "group" portion (060) of shm yerm.mode is set.

The effective user ID of the process does not match shm j)erm.[c]uid and the effective group ID of the process does not match shmyerm.[c]gid and the appropriate bit of the "other" portion (06) of shm yerm.mode is set

Otherwise, the corresponding permissions are denied.

Sockets and Address Families

A socket is an endpoint for communication between processes. Each socket has queues for sending and receiving data.

Sockets are typed according to their communications properties. These properties include whether mes- sages sent and received at a socket require the name of the partner, whether communication is reliable, the format used in naming message recipients, etc.

Each instance of the system supports some collection of socket types; consult socket(2) for more informa- tion about the types available and their properties.

Each instance of the system supports some number of sets of communications protocols. Each protocol set supports addresses of a certain format. An Address Family is the set of addresses for a specific group of protocols. Each socket has an address chosen from the address family in which the socket was created.

Special Processes

The processes with a process ID's of 0, 1, and 2 are special. Process 0 is the scheduler. Process 1 is the initialization process init, and is the ancestor of every other process in the system. It is used to control the process structure. Process 2 is the paging daemon.

Super-user

A process is recognized as a super-user process and is granted special privileges if its effective user ID is

o.

Tty Group ID

Each active process can be a member of a terminal group that is identified by a positive integer called the tty group ID. This grouping is used to arbitrate between multiple jobs contending for the same terminal (see csh(l), and tty (4».

SEE ALSO

intro(3), perror(3) LIST OF SYSTEM CALLS

10

Name

exit accept access acct adjtime async _daemon

Appears on Page

exit(2) accept(2) access(2) acct(2) adjtime(2) nfssvc(2)

Description

terminate a process

accept a connection on a socket determine accessibility of file tum accounting on or off

correct the time to allow synchronization of the system ( NFS daemons

Last change: 16 July 1986 Sun Release 3.2

(13)

INTRO(2)

bind brk chdir chmod chown chroot close connect creat dup dup2 execve fchmod fchown fcntl flock fork fstat fsync ftruncate getdirentries getdomainname getdtablesize getegid geteuid getgid getgroups gethostid gethostname getitimer getpagesize getpeemame getpgrp getpid getppid getpriority getrlimit getrusage getsockname getsockopt gettimeofday getuid ioctl kill killpg link listen lseek lstat mkdir mknod mmap mount

Sun Release 3.2

SYSTEM CALLS INTRO(2)

bind(2) brk(2) chdir(2) chmod(2) chown(2) chroot(2) close(2) connetc(2) creat(2) dup(2) dup(2) execve(2) chmod(2) chown(2) fcntl(2) flock(2) fork(2) stat(2) fsync(2) truncate(2) getdirentries(2) getdomainname(2) getdtablesize(2) getgid(2) getuid(2) getgid(2) getgroups(2) gethostid(2) gethostname(2) getitimer(2) getpagesizename(2) getpeemame(2) setpgrp(2V) getpid(2) getpid(2) getpriority(2) getrlimit(2) getrusage(2) getsockname(2) getsockopt(2) gettimeofday(2) getuid(2) ioct1(2) kil1(2) killpg(2) link(2) listen(2) Iseek(2) stat(2) mkdir(2) mknod(2) mmap(2) mount(2)

bind a name to a socket change data segment size change current working directory change mode of file

change owner and group of a file change root directory

delete a descriptor

initiate a connection on a socket create a new file

duplicate a descriptor duplicate a descriptor execute a file

change mode of file

change owner and group of a file file control

apply or remove an advisory lock on an open file create a new process

get file status

synchronize a file's in-core state with that on disk truncate a file to a specified length

gets directory entries in a filesystem independent format get name of current domain

get descriptor table size get group identity get effective user identity get group identity get group access list

get unique identifier of current host get name of current host

get value of interval timer get system page size get name of connected peer

set and/or return the process group of a process get parent process identification

get process identification get program scheduling priority

control maximum system resource consumption get information about resource utilization get socket name

get options on sockets get date and time get user identity control device

send signal to a process send signal to a process group make a hard link to a file

listen for connections on a socket move read/write pointer

get file status make a directory file make a special file

map or unmap pages of memory mount file system

Last change: 16 July 1986 11

(14)

INTRO(2) SYSTEM CALLS INTRO(2)

rnsgctl msgctl(2) message control operations

rnsgget msgget(2) get message queue

rnsgop msgop(2) message operations

rnsgrcv msgop(2) message operations

rnsgsnd msgop(2) message operations

munmap munmap(2) map or unmap pages of memory

nfssvc nfssvc(2) NFSdaemons

open open(2V) open or create a file for reading or writing

pipe pipe(2) create an interprocess communication channel

profil profil(2) execution time profile

ptrace ptrace(2) process trace

quotactl quotactl(2) manipulate disk quotas

read read(2V) read input

readlink readlink(2) read value of a symbolic link

ready read(2V) read input

reboot reboot(2) reboot system or halt processor

recv recv(2) receive a message from a socket

recvfrom recv(2) receive a message from a socket

recvrnsg recv(2) receive a message from a socket

rename rename(2) change the name of a file

rmdir rmdir(2) remove a directory file

sbrk brk(2) change data segment size

select select(2) synchronous I/O multiplexing

semctl semctl(2) semaphore control operations

semget semget(2) get set of semaphores

semop semop(2) semaphore operations

send send(2) send a message from a socket

sendmsg send(2) send a message from a socket

sendto send(2) send a message from a socket

setdomainname getdomainname(2) set name of current domain

setgroups getgroups(2) set group access list

sethostname gethostname(2) set name of current host

setitimer getitimer(2) set value of interval timer

setpgrp setpgrp(2V) set andl or return the process group of a process setpriority getpriority(2) set program scheduling priority

setregid setregid(2) set real and effective group IDs

setreuid setreuid(2) set real and effective user IDs

setrlimit getrlimit(2) control maximum system resource consumption

setsockopt getsockopt(2) set options on sockets

settimeofday gettimeofday(2) set date and time

shmat shmop(2) shared memory operations

shmctl shmctl(2) shared memory control operations

shmdt shmop(2) shared memory operations

shmget shmget(2) get shared memory segment

shmop shmop(2) shared memory operations

shutdown shutdown(2) shut down part of a full-duplex connection

sigblock sigblock(2) block signals

sigpause sigpause(2) atomically release blocked signals and wait for interrup' sigsetmask sigsetmask(2 ) set current signal mask

sigstack sigstack(2) set andlor get signal stack context

sigvec sigvec(2) software signal facilities

socket socket(2) create an endpoint for communication

socketpair socketpair(2) create a pair of connected sockets

12 Last change: 16 July 1986 Sun Release 3.2

(15)

INTRO(2) SYSTEM CALLS INTRO(2)

stat stat(2) get file status

statfs statfs(2) get file system statistics

swapon swapon(2) add a swap device for interleaved paging/swapping

symlink syrnlink(2) make symbolic link to a file

sync sync(2) update super-block

syscall syscall(2) indirect system call

tell lseek(2) locate read/write pointer

truncate truncate(2) truncate a file to a specified length

umask umask(2) set file creation mode mask

uname uname(2V) get name of current UNIX system

unlink unlink(2) remove directory entry

unmount umount(2) remove a file system

utimes utimes(2) set file times

vadvise vadvise(2) give advice to paging system

vfork vfork(2) spawn new process in a virtual memory efficient way

vhangup vhangup(2) virtually "hangup" the current control terminal

wait wait(2) wait for process to terminate or stop

wait3 wait(2) wait for process to terminate or stop

write write(2V) write output

writev write(2V) write output

Sun Release 3.2 Last change: 16 July 1986 13

(16)

ACCEPT(2) SYSTEM CALLS ACCEPT(2)

NAME

accept - accept a connection on a socket SYNOPSIS

#include <sysltypes.h>

#include <syslsocket.h>

os

=

accept(s, addr, addrleo) iot os, s;

struct sockaddr *addr;

iot *addrleo;

DESCRIPTION

The argument s is a socket that has been created with socket(2), bound to an address with bind(2), and is listening for connections after a listen(2). Accept extracts the first connection on the queue of pending con- nections, creates a new socket with the same properties of s and allocates a new file descriptor, ns, for the socket. If no pending connections are present on the queue, and the socket is not marked as non-blocking, accept blocks the caller until a connection is present If the socket is marked non-blocking and no pending connections are present on the queue, accept returns an error as described below. The accepted socket, ns, is used to read and write data to and from the socket which connected to this one; it is not used to accept more connections. The original sockets remains open for accepting further connections.

The argument addr is a result parameter that is filled in with the address of the connecting entity, as known to the communications layer. The exact format of the addr parameter is determined by the domain in which the communication is occurring. The addrlen is a value-result parameter; it should initially contain the amount of space pointed to by addr; on return it will contain the actual length (in bytes) of the address returned. This call is used with connection-based socket types, currently with SOCK_STREAM.

It is possible to select (2) a socket for the purposes of doing an accept by selecting it for read.

RETURN VALUE

The call returns -Ion error. If it succeeds, it returns a non-negative integer that is a descriptor for the accepted socket

ERRORS

The accept will fail if:

EBADF

ENOTSOCK EOPNOTSUPP

EFAULT

EWOULDBLOCK SEE ALSO

The descriptor is invalid.

The descriptor references a file, not a socket

The referenced socket is not of type SOCK_STREAM.

The addr parameter is not in a writable part of the user address space.

The socket is marked non-blocking and no connections are present to be accepted.

bind(2), connect(2), listen(2), select(2), socket(2)

14 Last change: 16 July 1986 Sun Release 3.2

(17)

ACCESS (2) SYSTEM CALLS ACCESS (2)

NAME

access - determine accessibility of file SYNOPSIS

#include <syS/file.h>

#define R OK 4

#define W OK 2

#define X OK 1

#define F OK 0

1* test for read permission *1 1* test for write permission *1

1* test for execute (search) permission *1 1* test for presence of file *1

accessible

=

access(path, mode) int accessible;

char *path;

int mode;

DESCRIPTION

path points to a path name naming a file. access checks the named file for accessibility according to mode, which is an inclusive or of the bits R _OK, W _OK and X_OK. Specifying mode as F _OK (that is, 0) tests whether the directories leading to the file can be searched and the file exists.

The real user ID and the group access list (including the real group ID) are used in verifying permission, so this call is useful to set-UID programs.

The owner of a file has permission checked with respect to the owner read, write, and execute mode bits, members of the file's group other than the owner have permission checked with respect to the group mode bjts, and all others have permissions checked with respect to the other mode bits.

Notice that only access bits are checked. A directory may be indicated as writable by access, but an attempt to open it for writing will fail (although files may be created there); a file may look executable, but execve will fail unless it is in proper format.

RETURN VALUE

If path cannot be found or if any of the desired access modes would not be granted, then a -1 value is returned; otherwise a 0 value is returned.

ERRORS

Access to the file is denied if one or more of the following are true:

ENOTDIR A component of the path prefix of path is not a directory.

EINV AL path contains a byte with the high-order bit set.

ENAMETOOLONG

ENOENT EACCES ELOOP EROFS ETXTBSY EACCES EFAULT EIO

Sun Release 3.2

The length of a component of path exceeds 255 characters, or the length of path exceeds 1023 characters.

The file named by path does not exist.

Search permission is denied for a component of the path prefix of path.

Too many symbolic links were encountered in translating path.

The file named by path is on a read-only file system and write access was requested.

The file named by path is a pure procedure (shared text) file that is being executed and write access was requested.

Permission bits of the file mode do not permit the requested access to the file named by path.

path points outside the process's allocated address space.

An I/O error occurred while reading from or writing to the file system.

Last change: 5 June 1986 15

(18)

ACCESS (2) SYSTEM CALLS ACCESS (2)

SEE ALSO

chmod(2), stat(2)

16 Last change: 5 June 1986 Sun Release 3.2

(19)

ACCT(2) SYSTEM CALLS ACCT(2)

NAME

acct - turn accounting on or off SYNOPSIS

acct(fiIe) char *fiIe;

DESCRIPTION

NOTES

acct is used to enable or disable the process accounting. If process accounting is enabled, an accounting record will be written on an accounting file for each process that terminates. Termination can be caused by one of two things: an exit call or a signal; see exit(2) and sigvec(2). The effective user ID of the calling process must be super-user to use this call.

name points to a path name naming the accounting file. The accounting file format is given in acct(5).

The accounting routine is enabled if name is non-zero and no errors occur during the system call. It is dis- abled if name is zero and no errors occur during the system call.

If accounting is already turned on, and a successful acct call is made with a non-zero name, all subsequent accounting records will be written to the new accounting file.

Accounting is automatically disabled when the file system the accounting file resides on runs out of space;

it is enabled when space once again becomes available.

RETURN VALUE

The value -1 is returned if an error occurs, and external variable errno is set to indicate the cause of the error. Otherwise the value 0 is returned.

ERRORS

acct will fail if one of the following is true:

EPERM ENOTDIR

The caller is not the super-user.

A component of the path prefix of file is not a directory.

EINV AL file contains a character with the high-order bit set.

EINV AL Support for accounting was not configured into the system.

ENAMETOOLONG

ENOENT EACCES EACCES ELooP EROFS EFAULT EIO

The length of a component of file exceeds 255 characters, or the length of file exceeds 1023 characters.

The named file does not exist.

Search permission is denied for a component of the path prefix of file.

The file referred to by file is not a regular file.

Too many symbolic links were encountered in translating the path name.

The named file resides on a read-only file system.

file points outside the process's allocated address space.

An I/O error occurred while reading from or writing to the file system.

SEE ALSO

BUGS

acct(5), sa(8)

No accounting is produced for programs running when a crash occurs. In particular non-terminating pro- grams are never accounted for.

Sun Release 3.2 Last change: 5 June 1986 17

(20)

AD1TIME(2) SYSTEM CALLS AD1TIME(2)

NAME

adjtirne - correct the time to allow synchronization of the system clock SYNOPSIS

#include <sys/time.h>

adjtime(delta, olddeJta) struct timeval *delta;

struct timeval *olddelta;

DESCRIPTION

adjtime adjusts the system's notion of the current time, as returned by gettimeofday(2), advancing or retarding it by the amount of time specified in the struct timeval *delta.

The adjustment is effected by speeding up (if *delta is positive) or slowing down (if *delta is negative) the system's clock by a fixed percentage, currently 10%. Thus, the time is always a monotonically increasing function. A time correction from an earlier call to adjtime may not be finished when adjtime is called again. If olddelta is non-zero, then the structure pointed to will contain, upon return, the number of microseconds still to be corrected from the earlier call.

The structures pointed to by delta and olddelta are defined in <sysltime.h> as:

struct timeval {

u_Iong tv_sec;

long tv_usec;

};

1* seconds since Jan. 1, 1970 *1 1* and microseconds *1

If olddelta is a NULL pointer, the corresponding information will not be returned.

This call may be used in time servers that synchronize the clocks of computers in a local area network.

Such time servers would slow down the clocks of some machines and speed up the clocks of others to bring them to the average network time.

Only the super-user may adjust the time of day.

The adjustment value will be silently rounded to the resolution of the system clock.

RETURN

A 0 return value indicates that the call succeeded. A -1 return value indicates an error occurred, and in this case an error code is stored into the global variable errno.

ERRORS

The following error codes may be set in errno:

EFAULT

EPERM

delta or olddelta points outside the process's allocated address space, or olddelta points to a region of the process' allocated address space which is not writable.

The process's effective user ID is not that of the super-user.

SEE ALSO

settimeofday(2), date( 1)

18 Last change: 16 July 1986 S un Release 3.2

(21)

BIND(2) SYSTEM CALLS BIND (2)

NAME

bind - bind a name to a socket SYNOPSIS

#include <sys/types.h>

#include <sys/socket.h>

bind(s, name, namelen) int s;

struct sockaddr *name;

int nameleo;

DESCRIPTION

bind assigns a name to an unnamed socket. When a socket is created with socket(2) it exists in a name space (address family) but has no name assigned. bind requests that the name pointed to by name be assigned to the socket.

NOTES

Binding a name in the UNIX domain creates a socket in the file system that must be deleted by the caller when it is no longer needed (using unlink(2».

The rules used in name binding vary between communication domains. Consult the manual entries in sec- tion 4 for detailed information.

RETURN VALUE

If the bind is successful, a 0 value is returned. A return value of -1 indicates an error, which is further specified in the global errno.

ERRORS

The bind call will fail if:

EBADF ENOTSOCK EADDRNOTA V AIL EADDRINUSE

S is not a valid descriptor.

S is not a socket

The specified address is not available from the local machine.

The specified address is already in use.

The socket is already bound to an address.

EINVAL

EACCES The requested address is protected, and the current user has inadequate permission to access it

EF AUL T The name parameter is not in a valid part of the user address space.

The following errors are specific to binding names in the UNIX domain.

ENOTDIR A component of the path prefix of the path name in name is not a directory.

EINV AL The path name in name contains a character with the high-order bit set.

ENAMETOOLONG

ENOENT EACCES ELOOP EIO EROFS EISDIR

Sun Release 3.2

The length of a component of the path name in name exceeds 255 characters, or the length of the path name in name exceeds 1023 characters.

A component of the path prefix of the path name in name does not exist.

Search permission is denied for a component of the path prefix of the path name in name.

Too many symbolic links were encountered in translating the path name in name . An I/O error occurred while making the directory entry or allocating the inode.

The inode would reside on a read-only file system.

A null path name was specified.

Last change: 16 July 1986 19

(22)

BIND(2) SYSTEM CALLS BIND (2)

SEE ALSO

connect(2), listen(2), socket(2), getsockname(2)

20 Last change: 16 July 1986 Sun Release 3.2

(23)

BRK(2) SYSTEM CALLS BRK(2)

NAME

brk, sbrk - change data segment size SYNOPSIS

#include <sys/types.h>

eaddr_t brk(addr) eaddr _ t addr;

eaddr_t sbrk(iner) int iner;

DESCRIPTION Brk

brk sets the system's idea of the lowest data segment location not used by the program (called the break) to addr (rounded up to the next multiple of the system's page size). Locations greater than addr and below the stack pointer are not in the address space and will thus cause a memory violation if accessed.

Sbrk

In the alternate function sbrk, incr more bytes are added to the program's data space and a pointer to the start of the new area is returned.

When a program begins execution via execve the break is set at the highest location defined by the program and data storage areas. Ordinarily, therefore, only programs with growing data areas need to use sbrk.

The getrlimit(2) system call may be used to determine the maximum permissible size of the data segment;

it will not be possible to set the break beyond the rlim _ max value returned from a call to getrlimit, e.g.

"etext + rlp~rlim_max." (See end(3) for the definition of etext.) RETURN VALUE

Zero is returned if the brk could be set; -1 if the program requests more memory than the system limit Sbrk normally returns the current value of the break, but -1 if it could not be set.

ERRORS

Sbrk will fail and no additional memory will be allocated if one of the following are true:

ENOMEM The limit, as set by setrlimit(2), was exceeded.

ENOMEM ENOMEM

The maximum possible size of a data segment (compiled into the system) was exceeded.

Insufficient space existed in the swap area to support the expansion.

SEE ALSO BUGS

execve(2), getrlimit(2), malloc(3), end(3)

Setting the break may fail due to a temporary lack of swap space. It is not possible to distinguish this from a failure caused by exceeding the maximum size of the data segment without consulting getrlimit.

Sun Release 3.2 Last change: 26 February 1985 21

(24)

CHDIR(2) SYSTEM CALLS CHDIR(2)

NAME

chdir - change current working directory SYNOPSIS

chdir(path) char *path;

DESCRIPTION

path points to the path name of a directory. e hdir causes this directory to become the current working directory, the starting point for path names not beginning with I.

In order for a directory to become the current directory, a process must have execute (search) access to the directory.

RETURN VALUE

Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error.

ERRORS

eMir will fail and the current working directory will be unchanged if one or more of the following are true:

ENOTDIR ENOTDIR

A component of the path prefix of path is not a directory.

The file named by path is not a directory.

EINV AL path contains a byte with the high-order bit set

ENAMETOOLONG

ENOENT ELooP EACCES EACCES EFAULT EIO

The length of a component of path exceeds 255 characters, or the length of path exceeds 1023 characters.

The directory referred to by path does not exist.

Too many symbolic links were encountered in translating path.

Search permission is denied for a component of the path prefix of path.

Search permission is denied for the directory referred to by path.

path points outside the process's allocated address space.

An 110 error occurred while reading from or writing to the file system.

SEE ALSO chroot(2)

22 Last change: 16 July 1986 Sun Release 3.2

(25)

CHMOD(2) SYSTEM CALLS CHMOD(2)

NAME

chmod, fchmod - change mode of file SYNOPSIS

#include lusr/includelsyslstat.h chmod(path, mode)

char .path;

int mode;

fchmod(fd, mode) int fd, mode;

DESCRIPTION

The file whose name is given by path or referenced by the descriptor fd has its mode changed to mode.

Modes are constructed by or'ing together some combination of the following:

S ISUID S ISGID S ISVTX S IREAD S IWRITE S IEXEC

04000 set user ID on execution 02000 set group ID on execution

01000 save text image after execution (sticky bit) 00400 read by owner

00200 write by owner

00100 execute (search on directory) by owner 00070 read, write, execute (search) by group 00007 read, write, execute (search) by others These bit patterns are defined in lusr/include/syslstat.h.

The effective user ID of the process must match the owner of the file or be super-user to change the mode of a file.

If the effective user ID of the process is not super-user and the process attempts to set the set group ill bit on a file owned by a group which is not in its group access list, mode bit 02000 (set group ID on execution) is cleared

If an executable file is set up for sharing (this is the default) then mode 01000 (save text image after execu- tion) prevents the system from abandoning the swap-space image of the program-text portion of the file when its last user terminates. If the effective user ID of the process is not super-user, this bit is cleared.

If a user other than the super-user writes to a file, the set user ID and set group ID bits are turned off. This makes the system somewhat more secure by protecting set-user-ID (set-group-ID) files from remaining set-user-ID (set-group-ID) if they are modified, at the expense of a degree of compatibility.

RETURN VALUE

Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error.

ERRORS

chmod will fail and the file mode will be unchanged if:

ENOIDIR A component of the path prefix of path is not a directory.

EINV AL path contains a byte with the high-order bit set.

ENAMETOOLONG

The length of a component of path exceeds 255 characters, or the length of path exceeds 1023 characters.

ENOENT EACCES ELOOP EPERM

Sun Release 3.2

The file referred to by path does not exist.

Search permission is denied for a component of the path prefix of path.

Too many symbolic links were encountered in translating path.

The effective user ID does not match the owner of the file and the effective user ID is

Last change: 16 July 1986 23

(26)

CHMOD(2) SYSTEM CALLS

not the super-user.

EINVAL EROFS

fd refers to a socket, not to a file.

The file referred to by path resides on a read-only file system.

EFAULT path points outside the process's allocated address space.

EIO An I/O error occurred while reading from or writing to the file system.

fchmod will fail if:

EBADF The descriptor is not valid.

The file referred to by fd resides on a read-only file system.

CHMOD(2)

EROFS

EPERM The effective user ID does not match the owner of the file and the effective user ID is not the super-user.

EIO An I/O error occurred while reading from or writing to the file system.

FILES

lusr/include/sys/stath SEE ALSO

open(2V), chown(2), stat(2), sticky(8)

24 Last change: 16 July 1986 Sun Release 3.2

(27)

CHOWN(2) SYSTEM CALLS CHOWN(2)

NAME

chown, fchown - change owner and group of a file SYNOPSIS

chown(path, owner, group) char *path;

int owner, group;

fchown(fd, owner, group) int fd, owner, group;

DESCRIPTION

The file that is named by path or referenced by fd has its owner and group changed as specified. Only the super-user may change the owner of the file, because if users were able to give files away, they could defeat the file-space accounting procedures. The owner of the file may change the group to a group of which he is a member; the super-user may change the group arbitrarily.

fchown is particularly useful when used in conjunction with the file locking primitives (seeflock(2».

If owner or group is specified as -1, the corresponding ill of the file is not changed.

If a process whose effective user ill is not super-user successfully changes the group ill of a file, the set- user-ID and set-group-ill bits of the file mode, 04000 and 02000 respectively, will be cleared

If the final component of path is a symbolic link, the ownership and group of the symbolic link is changed, not the ownership and group of the file or directory to which it points.

RETURN VALUE

Zero is returned if the operation was successful; -1 is returned, and a more specific error code is placed in the global variable errno, if an error occurs.

ERRORS

chown will fail and the file will be unchanged if:

ENOTDIR A component of the path prefix of path is not a directory.

EINV AL path contains a byte with the high-order bit set ENAMETOOLONG

ENOENT EACCES ELOOP EPERM

EROFS EFAULT EIO

fchown will fail if:

The length of a component of path exceeds 255 characters, or the length of path exceeds 1023 characters.

The file referred to by path does not exist.

Search permission is denied for a component of the path prefix of path.

Too many symbolic links were encountered in translating path.

The user ID specified by owner is not the current owner ID of the file, or the group ID specified by group is not the current group ill fo the file and is not in the process' group access list, and the effective user ID is not the super-user.

The file referred to by path resides on a read-only file system.

path points outside the process's allocated address space.

An 110 error occurred while reading from or writing to the file system.

EBADF fd does not refer to a valid descriptor.

EINVAL EPERM

Sun Release 3.2

fd refers to a socket, not a file.

The user ID specified by owner is not the current owner ID of the file, or the group ID specified by group is not the current group group access list, and the effective user ID is not the super-user.

Last change: 16 July 1986 25

(28)

CHOWN(2)

EROFS EIO SEE ALSO

SYSTEM CALLS

The file referred to by fd resides on a read-only file system.

An I/O error occurred while reading from or writing to the file system.

chmod(2), fiock(2)

26 Last change: 16 July 1986

CHOWN(2)

Sun Release 3.2

(29)

CHROOT(2) SYSTEM CALLS CHROOT(2)

NAME

chroot - change root directory SYNOPSIS

chroot( dirname) char *dirname;

DESCRIPTION

dirname points to a path name naming a directory. chroot causes this directory to become the root direc- tory, the starting point for path names beginning with I. The current working directory is unaffected by this call. This root directory setting is inherited across execve (2) and by all children of this process created with fork (2) calls.

The effective user ill of the process must be super-user to change the root directory.

The .• entry in the root directory is interpreted to mean the root directory itself. Thus, •. cannot be used to access files outside the subtree rooted at the root directory.

In order for a directory to become the root directory a process must have execute (search) access to the directory.

RETURN VALUE

Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate an error.

ERRORS

chroot will fail and the root directory will be unchanged if one or more of the following are true:

ENOIDIR ENOIDIR EINVAL

A component of the path prefix of dirname is not a directory.

The file referred to by dirname is not a directory.

dirname contains a byte with the high-order bit set.

ENAMETOOLONG

ENOENT EACCES EACCES ELooP EPERM EFAULT EIO SEE ALSO

chdir(2)

Sun Release 3.2

The length of a component of dirname exceeds 255 characters, or the length of dirname exceeds 1023 characters.

The directory referred to by dirname does not exist.

Search permission is denied for a component of the path prefix of dirname . Search permission is denied for the directory referred to by dirname . Too many symbolic links were encountered in translating dirname . The effective user ID is not super-user.

dirname points outside the process's allocated address space.

An I/O error occurred while reading from or writing to the file system.

Last change: 16 July 1986 27

(30)

CLOSE (2) SYSTEM CALLS CLOSE (2)

NAME

close - delete a descriptor SYNOPSIS

close (d) int d;

DESCRIPTION

The close call deletes a descriptor from the per-process object reference table. If this is the last reference to the underlying object, then it will be deactivated. For example, on the last close of a file the current seek pointer associated with the file is lost; on the last close of a socket(2) associated naming information and queued data are discarded; on the last close of a file holding an advisory lock the lock is released (see flock(2) for further information).

A close of all of a process's descriptors is automatic on exit, but since there is a limit on the number of active descriptors per process, close is necessary for programs that deal with many descriptors.

When a process forks (see fork (2», all descriptors for the new child process reference the same objects as they did in the parent before the fork. If a new process is then to be run using execve (2), the process would normally inherit these descriptors. Most of the descriptors can be rearranged with dup2 (2) or deleted with close before the execve is attempted, but if some of these descriptors will still be needed if the execve fails, it is necessary to arrange for them to be closed if the execve succeeds. For this reason, the call "fcnt1( d, F _SETFD, 1)" is provided, which arranges that a descriptor will be closed after a successful execve; the call "fcnt1(d, F _SETFD, 0)" restores the default, which is to not close the descriptor.

Close unmaps pages mapped through this file descriptor.

RETURN VALUE

Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and the global integer variable errno is set to indicate the error.

ERRORS

Close will fail if:

EBADF

EINTR SEE ALSO

D is not an active descriptor.

A read from a slow device was interrupted before any data arrived by the delivery of a signal.

accept(2), llock(2), open(2V), pipe(2), socket(2), socketpair(2), execve(2), fcnt1(2), rnrnap(2), munmap(2)

28 Last change: 16 July 1986 Sun Release 3.2

Références

Documents relatifs

• The process's effective user ID does not match the user ID of the owner of the file, and either the process's effective group ID matches the group ID of the file,

Complications of hepatic lesions affecting the suprahepatic veins and/or the inferior vena cava can also be suspected (4 cases) when the lesion is adjacent to,

We define sender-initiated file transfer for IP as a TCP service as follows: a receiver program (the server or &#34;daemon&#34;) listens on port 608 for inbound

The process's effective user ID does not match the user ID of the owner of the file, and either the process's effective group ID matches the group ill of the file, or

We tested for two additional contrasts an- alyzed by Smolka et al.: the difference in priming strength between Transparent and Opaque Deriva- tion (not significant in either

Similarly, we can define the weaker Property (FA) ∞ , replacing complete real trees by ordinary trees (and allowing fixed points to be middle of edges), and the three

Hongjin Qiu : Post-doctoral position from December 2003 to November 2004 (polypeptides with pendant porphyrins : towards the elaboration of novel type of glues).. Fabio

Being compactly presented is a notion reserved for Hausdorff topological groups and we consider Bir( P 2 ) endowed with the Euclidean topology as constructed in [BlaFur13, Section