Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <unistd.h>
Link against: libc.lib

access(const char *,int)

Interface status: externallyDefinedApi

IMPORT_C int access(const char *, int);

Description

The access system calls check the accessibility of the file named in the fn argument for the access permissions indicated by the flags argument. The value of flags is either the bitwise-inclusive OR of the access permissions to be checked (R_OK for read permission, W_OK for write permission, and X_OK for execute/search permission), or the existence test ( F_OK. )

For additional information on file access permissions see File Access Permissions.

Examples:

/* Detailed description: This sample code checks read-ok accessibility of file Example.c

 Precondtions: Example.txt file should be present in working directory.
 */
# 25 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
int main()
{
  if(access("Example.c" , 0x04 )  < 0)  
  {
    printf("Read operation on the file is not permitted") ;
    return -1 ;
  }
  printf("Read operation permitted on Example.c file") ;
  return 0 ;
}

Output

Read operation permitted on Example.c file

Limitations:

The fn parameter should not exceed 256 characters in length.

KErrNotReady of Symbian error code is mapped to ENOENT, which typically means drive not found or filesystem not mounted on the drive.

Parameters

const char *

int

Return value

int

Upon successful completion, the value 0 is returned; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

See also:

[Top]


chdir(const char *)

Interface status: externallyDefinedApi

IMPORT_C int chdir(const char *);

Description

The path argument points to the pathname of a directory. The chdir system call causes the named directory to become the current working directory, that is, the starting point for path searches of pathnames not beginning with a slash, ‘/.’

The fchdir system call causes the directory referenced by the file descriptor fd to become the current working directory, the starting point for path searches of pathnames not beginning with a slash, ‘/.’

Examples:

/*
  Detailed description   : This test code demonstrates usage of chdir system call

  Preconditions : "Example" directory should be present in current working
   directory.
 */
# 91 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
int main()
{
  if(chdir("Example") < 0 )  
  {
     printf("Failed to change working directory");
     return -1 ;
  }
  printf("Working directory changed");
  return 0 ;
}

Output

Working directory changed
# 110 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 111 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
int test_fchdir()
{
   int retVal;
   int rmdr;
   int mkdr = mkdir("test_dir", S_IWUSR);
   if( !mkdr )
   {
     int opn = open("test_dir", O_RDONLY);
     if( opn != -1 )
     {
       retVal = fchdir( opn );
       if( !retVal )
       {
         printf("Fchdir passed");
       }
       else
       {
         printf("Failed");
       }
       int cls = close(opn);
     }
     else
     {
       printf("Failed");
     }
     rmdr = rmdir("test_dir");  
   }
   else
   {
     printf("Failed");
   }
}

Output

Fchdir passed

Limitations:

The path parameter should not exceed 256 characters in length. KErrNotReady of Symbian error code is mapped to 2 , which typically means drive not found or filesystem not mounted on the drive.

Parameters

const char *

Note: This description also covers the following functions - fchdir(int)fchdir(int)

Return value

int

Upon successful completion, the value 0 is returned; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

[Top]


chown(const char *,uid_t,gid_t)

Interface status: externallyDefinedApi

IMPORT_C int chown(const char *, uid_t, gid_t);

Description

The chown and lchown functions are build supported but not available functionally.

Symbian OS does not support the concepts of multiple users and groups.

Limitations:

KErrNotReady of symbian error code is mapped to ENOENT, which typically means drive not found or filesystem not mounted on the drive.

Parameters

const char *

uid_tuid_t

gid_tgid_t

Note: This description also covers the following functions - lchown(const char *,uid_t,gid_t)lchown(const char *,uid_t,gid_t)

Return value

int

These functions always return 0.

[Top]


close(int)

Interface status: externallyDefinedApi

IMPORT_C int close(int);

Description

The close system call deletes a descriptor from the per-process object reference table. If this is the last reference to the underlying object the object 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 any file descriptor for that file is closed by that process.

When a process exits all associated file descriptors are freed. As there is a limit on active descriptors per processes the close system call is useful when a large quantity of file descriptors are being handled.

Examples:

/* Detailed description   : This test code demonstrates usage of close  system call

 Preconditions :  None.
 */
# 214 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 215 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 216 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 217 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
int main()
{
  int fd = 0;
  fd = open("Example.txt" ,  0x0200  |  0x0002  , 0666);
  if(fd < 0 ) 
  {
    printf("Failed to open file Example.txt");
    return -1;
  }
 if(close(fd) < 0 )
 {
   printf("Failed to close  file Example.txt");
   return -1;
 }
 printf("File Example.txt closed" );
 return 0;
}

Output

File Example.txt closed

Parameters

int

Return value

int

The close function returns the value 0 if successful; otherwise it returns the value -1 and sets the global variable errno to indicate the error.

See also:

[Top]


dup(int)

Interface status: externallyDefinedApi

IMPORT_C int dup(int);

Description

The dup system call duplicates an existing object descriptor and returns its value to the calling process ( newd = dup (aFid, ).); The argument aFid is a small non-negative integer index in the per-process descriptor table.

The new descriptor returned by the call is the lowest numbered descriptor currently not in use by the process.

The object referenced by the descriptor does not distinguish between aFid and newd in any way. Thus if newd and aFid are duplicate references to an open file, read , write and lseek calls all move a single pointer into the file, and append mode, non-blocking I/O and asynchronous I/O options are shared between the references. If a separate pointer into the file is desired, a different object reference to the file must be obtained by issuing an additional open system call.

In dup2, the value of the new descriptor newd is specified. If this descriptor is already in use and oldd != newd, the descriptor is first deallocated as if the close system call had been used. If aFid is not a valid descriptor, then newd is not closed. If aFid == newd and aFid is a valid descriptor, then dup2 is successful, and does nothing.

Limitation:

dup2(int oldfd, int newfd); 

The return value of dup2 can be different from the one user expected to be (newfd). Users of dup2 must therefor use the return value of dup2 as the new allocated fd rather than the one passed in (newfd). As described above, if dup2 is successful the newfd and return values are the same, .

Examples:

/*
 *Detailed description : Sample usage of dup system call
 */
# 305 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 306 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 307 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
int main()
{
  int fd;
  FILE *Fil;
  int Newfd;
  fd = open("Example.txt" ,  0x0200  |  0x0002  , 0666);
  if(fd < 0 )  {
     printf("Failed to open file Example.txt");
     return -1;
  }
  Newfd  = dup(fd );
  if(Newfd < 0 ) 
  {
    printf("Failed to duplicate file descriptor");
    return -1 ;
  }
  close(fd);
  close(Newfd);
  printf("New Duped fd is %d" , Newfd);
  return 0;
}

Output

New Duped fd is 4
/*
 *Detailed description : Sample usage of dup system call
 */
# 340 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 341 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 342 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 343 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
int main()
{
  int fd;
  FILE *Fil;
  int Newfd;
  fd = open("Example.txt" ,  0x0200  |  0x0002  , 0666);
  if(fd < 0 )  {
     printf("Failed to open file Example.txt");
     return -1;
  }
  Newfd  = dup2(fd  , 4);
  if(Newfd < 0 )  {
    printf("Failed to duplicate file descriptor");
    return -1;
  }
  close(fd);
  close(Newfd);
  printf("New Duped fd is %d" , Newfd);
  return 0;
}

Output

New Duped fd is 4

Parameters

int

Note: This description also covers the following functions - dup2

Return value

int

The value -1 is returned if an error occurs in either call. The external variable errno indicates the cause of the error.

See also:

[Top]


dup2(int,int)

Interface status: externallyDefinedApi

IMPORT_C int dup2(int, int);

Description

Parameters

int

int

Refer to dup for the documentation

Return value

int

See also:

[Top]


fpathconf(int,int)

Interface status: externallyDefinedApi

IMPORT_C long fpathconf(int, int);

Description

Parameters

int

int

Refer to pathconf(const char *,int)pathconf(const char *,int) for the documentation

Return value

long

[Top]


getcwd(char *,size_t)

Interface status: externallyDefinedApi

IMPORT_C char* getcwd(char *, size_t);

Description

The getcwd function copies the absolute pathname of the current working directory into the memory referenced by buf and returns a pointer to buf. The size argument is the _size, in bytes, of the array referenced by buf.

If _buf is NULL, space is allocated as indicated by size to store the pathname and the current working directory is returned as long as the _size bytes are sufficient to hold the working directory name. This space may later be free’d.

This routine has traditionally been used by programs to save the name of a working directory for the purpose of returning to it. A much faster and less error-prone method of accomplishing this is to open the current directory ((‘.’) and use the fchdir function to return.

Examples:

#include<unistd.h>
#include<stdio.h>
#include <stdlib.h>
#define BUF_SIZE 100
  
int main()
{
 //change directory to c:
 int c;
 long size = BUF_SIZE;
 char *buf = NULL;
 char *ptr = NULL;
  
 c = chdir("c:\");
  
 buf = (char *)malloc((size_t)size);
  
 if (buf != NULL && c == 0)
 {
  //call getcwd to fetch teh current directory
  ptr = getcwd(buf, (size_t)size);
  printf("getcwd returned: %s", ptr);
 }
   
 return 0;
}

Output

getcwd returned: c:

Notes:

The getcwd function returns the default working directory as c:\private\XXXXXXXX (where XXXXXXXX is the UID of the process) as the default session path is initialised to c:\private\current_process'_UID, in case of Symbian OS.

Parameters

char *

size_tsize_t

Return value

char *

Upon successful completion a pointer to the pathname is returned. Otherwise a NULL pointer is returned and the global variable errno is set to indicate the error. In addition, getwd copies the error message associated with errno into the memory referenced by buf.

See also:

[Top]


getegid(void)

Interface status: externallyDefinedApi

IMPORT_C gid_t getegid(void);

Description

Refer to getgid(void)getgid(void) for the documentation

Return value

gid_tgid_t

[Top]


geteuid(void)

Interface status: externallyDefinedApi

IMPORT_C uid_t geteuid(void);

Description

Refer to getuid(void)getuid(void) for the documentation

Return value

uid_tuid_t

[Top]


getgid(void)

Interface status: externallyDefinedApi

IMPORT_C gid_t getgid(void);

Description

Note: This description also covers the following functions - getegid(void)getegid(void)

getgid and getegid are build supported but not available functionally. Symbian OS does not support multiple users and groups.

Return value

gid_tgid_t

These functions always return 0.

[Top]


getgroups(int,gid_t)

Interface status: externallyDefinedApi

IMPORT_C int getgroups(int, gid_t[]);

Description

The getgroups function build supported but not available functionally. Symbian OS does not support multiple users and groups.

Parameters

int

gid_tgid_t

Return value

int

These functions always return 0.

[Top]


getpgrp(void)

Interface status: externallyDefinedApi

IMPORT_C pid_t getpgrp(void);

Description

Note: This description also covers the following functions - getpgid(pid_t)getpgid(pid_t)

getpgrp and getpgid are build supported but not available functionally. Symbian OS does not support multiple users and groups.

Return value

pid_tpid_t

These functions always return 0.

[Top]


getpid(void)

Interface status: externallyDefinedApi

IMPORT_C pid_t getpid(void);

Description

Note: This description also covers the following functions - getppid(void)getppid(void)

The getpid system call returns the process ID of the calling process. Though the ID is guaranteed to be unique it should NOT be used for constructing temporary file names for security reasons; see mkstemp instead.

The getppid system call returns the process ID of the parent of the calling process.

Examples:

/*
 Detailed description : Sample usage of getpid system call
 */
# 584 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
int main() 
{
  pid_t pid ;
  if((pid = getpid()) < 0 ) 
  {
     printf("getpid system call failed") ;
     return -1 ;
  }
  printf("pid of this process is %d " , pid) ;
  return 0 ;
}

Return value

pid_tpid_t

[Top]


getppid(void)

Interface status: externallyDefinedApi

IMPORT_C pid_t getppid(void);

Description

Refer to getpid(void)getpid(void) for the documentation

Return value

pid_tpid_t

[Top]


getuid(void)

Interface status: externallyDefinedApi

IMPORT_C uid_t getuid(void);

Description

Note: This description also covers the following functions - geteuid(void)geteuid(void)

getuid and geteuid are build supported but not available functionally. Symbian OS does not support multiple users and groups.

Return value

uid_tuid_t

These functions always return 0.

[Top]


isatty(int)

Interface status: externallyDefinedApi

IMPORT_C int isatty(int);

Description

This function operate on the system file descriptors for character special devices.

The isatty function determines if the file descriptor fd refers to a valid terminal type device.

Examples:

#include<unistd.h>
#include<stdio.h>
#include<fcntl.h> //O_APPEND
 
int main()
{
 int x = isatty(0); //stdin (fd = 0)
 int y = isatty(1); //stdout (fd = 1)
 int z = isatty(2); //stderr (fd = 2)
 
 printf("{Expected: 1 1 1} %d %d %d", x, y, z);
 
 int i = isatty(5); //some invalid fd
  
 int fd_file = open("c:\some.txt", O_APPEND);
  
 int j = isatty(fd_file); //valid fd of a text file
  
 int fd_pipe[3];
 int p = pipe(fd_pipe);
  
 int k = isatty(fd_pipe[1]); //valid fd of a pipe
       
 close(fd_file);         
 close(fd_pipe[0]);      
 close(fd_pipe[1]);
      
 printf("{Expected: 0 0 0} %d %d %d", i, j, k);
 
 unlink("c:\some.txt");
 
 return 0;
}

Output

{Expected: 1 1 1} 1 1 1
{Expected: 0 0 0} 0 0 0

Parameters

int

Return value

int

The isatty returns 1 if fd is an open descriptor connected to a terminal; returns 0 otherwise.

[Top]


link(const char *,const char *)

Interface status: externallyDefinedApi

IMPORT_C int link(const char *, const char *);

Description

The link system call atomically creates the specified directory entry (hard link) newpath with the attributes of the underlying object pointed at by oldpath. Note that if the link is successful the link count of the underlying object is not incremented: On Symbian OS link functionality is simulated and the underlying object is not aware of a existing link. oldpath and newpath share equal access and rights to the underlying object. Link is supported only on regular files and fifos. It is not on directories. Creation of link on a existing link file is not supported.

If oldpath is removed, the file newpath is also deleted as the platform recognizes the underlying object only by oldpath.

The object pointed at by the oldpath argument must exist for the hard link to succeed and both oldpath and newpath must be in the same file system. The oldpath argument may not be a directory. Creation time stamp of the file is not supported and access time stamp is equal to modification time stamp. A newly created file will not alter the time stamp of parent directory.

Examples:

/*
 Detailed description  : Example to create link to a file
 Precondition : "Parent.txt" should exist in c: drive

 */
# 720 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 721 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
int main(void)
 {
    if(link("C:\Parent.txt","C:\Link") < 0)
    {
         printf("Link creation to parent file failed");
         return -1;
    }
    printf("Link to parent file created");
    return 0;
 }

Output

Link to parent file created.

Limitations:

Parameters

const char *

const char *

Return value

int

Returns 0 on successful completion. Otherwise returns -1 and sets errno to indicate the error.

See also:

[Top]


pathconf(const char *,int)

Interface status: externallyDefinedApi

IMPORT_C long pathconf(const char *, int);

Description

The pathconf and fpathconf system calls provide a method for applications to determine the current value of a configurable system limit or option variable associated with a pathname or file descriptor.

For pathconf, the path argument is the name of a file or directory. For fpathconf, the fd argument is an open file descriptor. The name argument specifies the system variable to be queried. Symbolic constants for each name value are found in the include file <unistd.h>.

The available values are as follows:

 _PC_LINK_MAX
   The maximum file link count.
_PC_MAX_CANON
   The maximum number of bytes in terminal canonical input line.
_PC_MAX_INPUT
   The minimum maximum number of bytes for which space is available in a terminal input queue.
_PC_NAME_MAX
   The maximum number of bytes in a file name.
_PC_PATH_MAX
   The maximum number of bytes in a pathname.
_PC_PIPE_BUF
   The maximum number of bytes which will be written atomically to a pipe.
_PC_CHOWN_RESTRICTED
   Return 1 if appropriate privilege is required for the chown system call, otherwise 0. -p1003.1-2001 requires appropriate privilege in all cases, but this behavior was optional in prior editions of the standard.
_PC_NO_TRUNC
   Return greater than zero if attempts to use pathname components longer than
.Brq Dv NAME_MAX will result in an [ENAMETOOLONG] error; otherwise, such components will be truncated to
.Brq Dv NAME_MAX. -p1003.1-2001 requires the error in all cases, but this behavior was optional in prior editions of the standard, and some non- POSIX -compliant file systems do not support this behavior.
_PC_VDISABLE
   Returns the terminal character disabling value.
_PC_ASYNC_IO
   Return 1 if asynchronous I/O is supported, otherwise 0.
_PC_PRIO_IO
   Returns 1 if prioritised I/O is supported for this file, otherwise 0.
_PC_SYNC_IO
   Returns 1 if synchronised I/O is supported for this file, otherwise 0.
_PC_ALLOC_SIZE_MIN
   Minimum number of bytes of storage allocated for any portion of a file.
_PC_FILESIZEBITS
   Number of bits needed to represent the maximum file size.
_PC_REC_INCR_XFER_SIZE
   Recommended increment for file transfer sizes between _PC_REC_MIN_XFER_SIZE and _PC_REC_MAX_XFER_SIZE.
_PC_REC_MAX_XFER_SIZE
   Maximum recommended file transfer size.
_PC_REC_MIN_XFER_SIZE
   Minimum recommended file transfer size.
_PC_REC_XFER_ALIGN
   Recommended file transfer buffer alignment.
_PC_SYMLINK_MAX
   Maximum number of bytes in a symbolic link.
_PC_ACL_EXTENDED
   Returns 1 if an Access Control List (ACL) can be set on the specified file, otherwise 0.
_PC_ACL_PATH_MAX
   Maximum number of ACL entries per file.
_PC_CAP_PRESENT
   Returns 1 if a capability state can be set on the specified file, otherwise 0.
_PC_INF_PRESENT
   Returns 1 if an information label can be set on the specified file, otherwise 0.
_PC_MAC_PRESENT
   Returns 1 if a Mandatory Access Control (MAC) label can be set on the specified file, otherwise 0.

Errors:

If any of the following conditions occur, the pathconf and fpathconf system calls shall return -1 and set errno to the corresponding value. [EINVAL] The value of the name argument is invalid. [EINVAL] The implementation does not support an association of the variable name with the associated file. The pathconf system call will fail if: [ENOTDIR] A component of the path prefix is not a directory. [ENAMETOOLONG] A component of a pathname exceeded .Brq Dv NAME_MAX characters (but see _PC_NO_TRUNC above), or an entire path name exceeded .Brq Dv PATH_MAX characters. [ENOENT] The named file does not exist. [EACCES] Search permission is denied for a component of the path prefix. [ELOOP] Too many symbolic links were encountered in translating the pathname. [EIO] An I/O error occurred while reading from or writing to the file system. The fpathconf system call will fail if: [EBADF] The fd argument is not a valid open file descriptor. [EIO] An I/O error occurred while reading from or writing to the file system.

Examples:

#include<unistd.h>
#include<stdio.h>
int test_pathconf()
{
   int fp = open("test_pathconf1.txt", O_RDWR|O_CREAT);
   if(fp != -1)
   {
     int n = pathconf("test_pathconf1.txt", _PC_LINK_MAX);
     if( n < _POSIX_LINK_MAX )
     {
       return -1;
     }
     else
     {
       printf("_PC_LINK_MAX value: %d", n);
       printf("Pathconf passed");
       return 0;
     }
   }
   else
   {
     printf("failed");
     return -1;
   }    
}               

Output

_PC_LINK_MAX value: 1
Pathconf passed

Note:

 The current implementation of the functions pathconf and fpathconf considers only the following configurable variables. _PC_LINK_MAX _PC_MAX_CANON _PC_MAX_INPUT _PC_NAME_MAX _PC_PATH_MAX _PC_PIPE_BUF _PC_CHOWN_RESTRICTED _PC_NO_TRUNC _PC_VDISABLE   Also, these functions return the limits as required by the POSIX
standard instead of the actual system limits determined on the run. 

Parameters

const char *

int

Note: This description also covers the following functions - fpathconf

Return value

long

If the call to pathconf or fpathconf is not successful, -1 is returned and errno is set appropriately. Otherwise, if the variable is associated with functionality that does not have a limit in the system, -1 is returned and errno is not modified. Otherwise, the current variable value is returned.

[Top]


pipe(int *)

Interface status: externallyDefinedApi

IMPORT_C int pipe(int *);

Description

The pipe system call creates a pipe, which is an object allowing bidirectional data flow, and allocates a pair of file descriptors.

By convention, the first descriptor is normally used as the read end of the pipe, and the second is normally the write end, so that data written to fildes[1] appears on (i.e. can be read from) fildes[0]. This allows the output of one thread to be sent to another thread: the source's standard output is set up to be the write end of the pipe and the sink's standard input is set up to be the read end of the pipe. The pipe itself persists until all its associated descriptors are closed.

A pipe that has had an end closed is considered widowed. Writing on such a pipe causes the writing process to fail and errno is set to EPIPE . Widowing a pipe is the only way to deliver end-of-file to a reader: After the reader consumes any buffered data, reading a widowed pipe returns a zero count.

Examples:

#include <unistd.h>
#include <stdio.h>

int main(void)
{
    int fds[2];
    if (pipe(fds) == -1) {
       printf("Pipe creation failed");
    }
    /* fds[0] - opened for read */
    /* fds[1] - opened for write */
    close(fds[0]);
    close(fds[1]);
    return 0;
}

Parameters

int *

Return value

int

The pipe function returns the value 0 if successful; otherwise the value -1 is returned and errno is set to indicate the error.

[Top]


read(int,void *,size_t)

Interface status: externallyDefinedApi

IMPORT_C ssize_t read(int, void *, size_t);

Description

The read system call attempts to read cnt bytes of data from the object referenced by the descriptor fd into the buffer pointed to by buf. The readv system call performs the same action, but scatters the input data into the iovcnt buffers specified by the members of the iov array: iov[0], iov[1], ..., iov[iovcnt-1].

For readv the iovec structure is defined as:

struct iovec { void *iov_base; // Base address. size_t iov_len; // Length. };

Each iovec entry specifies the base address and length of an area in memory where data should be placed. The readv system call will always fill an area completely before proceeding to the next.

On objects capable of seeking, the read starts at a position given by the pointer associated with fd (see lseek ) Upon return from read, the pointer is incremented by the number of bytes actually read.

Objects that are not capable of seeking always read from the current position. The value of the pointer associated with such an object is undefined.

Upon successful completion, read, and readv return the number of bytes actually read and placed in the buffer. The system guarantees to read the number of bytes requested if the descriptor references a normal file that has that many bytes left before the end-of-file, but in no other case.

Errors:

The read, and readv system calls will succeed unless: [EBADF] The d argument is not a valid file or socket descriptor open for reading. [ECONNRESET]The d argument refers to a socket, and the remote socket end is forcibly closed. [EFAULT] The buf argument points outside the allocated address space(Not supported). [EIO] An I/O error occurred while reading from the file system(Not supported). [EINTR] A read from a slow device was interrupted before any data arrived by the delivery of a signal(Not supported). [EINVAL] The pointer associated with d was negative. [EAGAIN] The file was marked for non-blocking I/O, and no data were ready to be read. [EISDIR] The file descriptor is associated with a directory residing on a file system that does not allow regular read operations on directories (e.g. NFS)(Not supported). [EOPNOTSUPP] The file descriptor is associated with a file system and file type that do not allow regular read operations on it(Not supported). [EOVERFLOW] The file descriptor is associated with a regular file, nbytes is greater than 0, offset is before the end-of-file, and offset is greater than or equal to the offset maximum established for this file system(Not supported). [EINVAL] The value nbytes is greater than INT_MAX. In addition, readv and preadv may return one of the following errors: [EINVAL] The iovcnt argument was less than or equal to 0, or greater than IOV_MAX. [EINVAL] One of the iov_len values in the iov array was negative. [EINVAL] The sum of the iov_len values in the iov array overflowed a 32-bit integer. [EFAULT] Part of the iov array points outside the process’s allocated address space.

Examples:

/* Detailed description :This example demonstrates usage of read-system call, this
 Example reads 10 bytes from a file specified

 Preconditions: Example.txt file should be present in C: and should contain
 string Hello World.

 */  
# 1081 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 1082 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 1083 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 1084 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
int main()
{
  int fd = 0;
  char Buff[12] = {0};
 
  fd = open("C:\Example.txt" ,  0x0000  );
 
  if(fd < 0 )  {
     printf("Failed to open C:\Example.txt file");
     return -1;
  }
 
  if(read(fd , Buff , 11) < 11)   {
     printf("Failed to read specified number of bytes from file");
     return -1;
  }
 
  printf("file contains %s 
" , Buff);
  return 0;
}

Output

file contains Hello World
/*
 Detailed description: Sample usage of readv system call
 Preconditions: Example.txt file should be present in working directory containing  Hello world   in it

 */
# 1119 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 1120 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 1121 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 1122 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
int main()
{
  int fd = 0;
  struct iovec io_vec[1];
  char Buf[12] = { 0 };
  io_vec[0].iov_base  = Buf;
  io_vec[0].iov_len = 11;
  fd = open("Example.txt" ,  0x0000  );
  if(fd < 0 )  {
    printf("File open failed");
    return -1;
  }
  if(readv(fd , io_vec , 1) <  11 )   {
    printf("Failed to read fron Example.txt file");
    return -1;
  }
  printf("Read succes %s"  , io_vec[0].iov_base);
  return 0;
}

Output

Read succes Hello World

Parameters

int

void *

size_tsize_t

Note: This description also covers the following functions - readv

Return value

ssize_tssize_t

If successful, the number of bytes actually read is returned. Upon reading end-of-file, zero is returned. Otherwise, -1 is returned and the global variable errno is set to indicate the error.

See also:

[Top]


rmdir(const char *)

Interface status: externallyDefinedApi

IMPORT_C int rmdir(const char *);

Description

The rmdir system call removes a directory file whose name is given by path. The directory must not have any entries other than '.' and '..'. Examples:

/*
  Detailed description: This test code demonstrates usage of rmdir systemcall, it removes directory
  Example from the current working directory.

  Preconditions: Expects empty directory "Example" in current working directory.
 */
# 1183 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
int main()
{
  if(rmdir("Example") < 0 )  
  {
     printf("Rmdir failed");
     return -1;
  }
  printf("Directory Example removed");
  return 0;
}

Output Directory Example removed

Limitations:

The _path parameter of the rmdir(const char *)rmdir(const char *) function should not exceed 256 characters in length.

KErrNotReady of Symbian error code is mapped to 2 , which typically means drive not found or filesystem not mounted on the drive.

Parameters

const char *

Return value

int

The rmdir(const char *)rmdir(const char *) function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

[Top]


setgid(gid_t)

Interface status: externallyDefinedApi

IMPORT_C int setgid(gid_t);

Description

Parameters

gid_tgid_t

Refer to setuid(uid_t)setuid(uid_t) for the documentation

Return value

int

[Top]


setpgid(pid_t,pid_t)

Interface status: externallyDefinedApi

IMPORT_C int setpgid(pid_t, pid_t);

Description

These functions are build supported but not available functionally. Symbian OS does not support multiple users and groups.

Parameters

pid_tpid_t

pid_tpid_t

Note: This description also covers the following functions - setpgrp(pid_t,pid_t)setpgrp(pid_t,pid_t)

Return value

int

These functions always return 0.

[Top]


setsid(void)

Interface status: externallyDefinedApi

IMPORT_C pid_t setsid(void);

Description

These functions are build supported but not available functionally. Symbian OS does not support multiple users and groups.

Return value

pid_tpid_t

These functions always return 0.

[Top]


setuid(uid_t)

Interface status: externallyDefinedApi

IMPORT_C int setuid(uid_t);

Description

These functions are build supported but not available functionally. Symbian OS does not support multiple users and groups.

Parameters

uid_tuid_t

Note: This description also covers the following functions - seteuid(uid_t)seteuid(uid_t) setgid(gid_t)setgid(gid_t) setegid(gid_t)setegid(gid_t)

Return value

int

These functions always return 0.

[Top]


sleep(unsigned)

Interface status: externallyDefinedApi

IMPORT_C unsigned int sleep(unsigned int);

Description

The sleep function suspends execution of the calling process until seconds seconds have elapse

TimeTime interval is internally represented using 32 bit value(range +-2147483647). Any time interval greater 2147483647 returns 0 without sleeping. Hence Maximum sleep time supported here is 35 minutes, 47 seconds.

Examples:

/*
 Detailed description: This test code shows usage of sleep system call , here sample code
 sleeps for 2 seconds.
 */
# 1301 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
int main()
{
  if(sleep(2) < 0 )  
  {
    printf("Sleep failed");
    return -1;
  }
  printf("Sleep successful");
  return 0;
}

Output

Sleep successful

Parameters

unsigned int

Return value

unsigned int

If the sleep function returns because the requested time has elapsed, the value returned will be zero.

[Top]


sysconf(int)

Interface status: externallyDefinedApi

IMPORT_C long sysconf(int);

Description

This interface is defined by -p1003.1-88 .A far more complete interface is available using sysctl.

The sysconf function provides a method for applications to determine the current value of a configurable system limit or option variable. The name argument specifies the system variable to be queried. Symbolic constants for each name value are found in the include file #include <unistd.h> . Shell programmers who need access to these parameters should use the getconf utility.

The available values are as follows:

 _SC_ARG_MAX
  The maximum number of argument to execve.
 _SC_CHILD_MAX
  The maximum number of simultaneous processes per user id.(Not supported)
 _SC_CLK_TCK
  The frequency of the statistics clock in ticks per second.
 _SC_IOV_MAX
  The maximum number of elements in the I/O vector used by readv , writev , recvmsg ,
 and sendmsg .
 _SC_NGROUPS_MAX
  The maximum number of supplemental groups.(Not supported)
 _SC_NPROCESSORS_CONF
  The number of processors configured.(Not supported)
 _SC_NPROCESSORS_ONLN
  The number of processors currently online.(Not supported)
 _SC_OPEN_MAX
  The maximum number of open files per user id.(Not supported)
 _SC_STREAM_MAX
  The minimum maximum number of streams that a process may have open( Not supported)
 at any one time.
 _SC_TZNAME_MAX
  The minimum maximum number of types supported for the name of a
 timezone.(Not supported)
 _SC_JOB_CONTROL
  Return 1 if job control is available on this system, otherwise -1.
 _SC_SAVED_IDS
  Returns 1 if saved set-group and saved set-user ID is available,
 otherwise -1.(Not supported)
 _SC_VERSION
  The version of -p1003.1 with which the system
 attempts to comply.(Not supported)
 _SC_BC_BASE_MAX
  The maximum ibase/obase values in the bc utility.(Not supported)
 _SC_BC_DIM_MAX
  The maximum array size in the bc utility.(Not supported)
 _SC_BC_SCALE_MAX
  The maximum scale value in the bc utility.(Not supported)
 _SC_BC_STRING_MAX
  The maximum string length in the bc utility.(Not supported)
 _SC_COLL_WEIGHTS_MAX
  The maximum number of weights that can be assigned to any entry of
 the LC_COLLATE order keyword in the locale definition file.(Not supported)
 _SC_EXPR_NEST_MAX
  The maximum number of expressions that can be nested within
 parenthesis by the expr utility.(Not supported)
 _SC_LINE_MAX
  The maximum length in bytes of a text-processing utility's input
 line.(Not supported)
 _SC_RE_DUP_MAX
  The maximum number of repeated occurrences of a regular expression
 permitted when using interval notation.(Not supported)
 _SC_2_VERSION
  The version of -p1003.2 with which the system attempts to comply.( Not supported)
 _SC_2_C_BIND
  Return 1 if the system's C-language development facilities support the
 C-Language Bindings Option, otherwise -1.
 _SC_2_C_DEV
  Return 1 if the system supports the C-Language Development Utilities Option,
 otherwise -1.
 _SC_2_CHAR_TERM
  Return 1 if the system supports at least one terminal type capable of
 all operations described in -p1003.2 ,
 otherwise -1.
 _SC_2_FORT_DEV
  Return 1 if the system supports the FORTRAN Development Utilities Option,
 otherwise -1.
 _SC_2_FORT_RUN
  Return 1 if the system supports the FORTRAN Runtime Utilities Option,
 otherwise -1.
 _SC_2_LOCALEDEF
  Return 1 if the system supports the creation of locales, otherwise -1.
 _SC_2_SW_DEV
  Return 1 if the system supports the Software Development Utilities Option,
 otherwise -1.
 _SC_2_UPE
  Return 1 if the system supports the User Portability Utilities Option,
 otherwise -1.
 _SC_PAGESIZE
  Returns size of a page in bytes.  (Some systems use PAGE_SIZE instead.)

Note: Some of the return values may not be posix compliant.

Examples:

/*
  Detailed description  : This test code demonstrates usage of sysconf system call , here it get max command
    line arguments that can be passed to process.
*/
# 1434 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
int main()
{
  int ret = 0 ;
  ret = sysconf( 1 ) ;
  if(ret < 0 )  {
    printf("Sysconf call failed") ;
    return -1 ;
 }
 printf("Max command line arguments = %d" , ret) ;
 return 0 ;
}

Output

max-number of commandline args supproted by system.

Bugs:

The value for 26 is a minimum maximum, and is required to be the same as ANSI C's 20 , so the returned value is a ridiculously small and misleading number.

Parameters

int

Return value

long

If the call to sysconf is not successful, -1 is returned and errno is set appropriately. Otherwise, if the variable is associated with functionality that is not supported, -1 is returned and errno is not modified. Otherwise, the current variable value is returned.

See also:

[Top]


unlink(const char *)

Interface status: externallyDefinedApi

IMPORT_C int unlink(const char *);

Description

The unlink system call removes the link named by pathname from its file system.

Symbian OS simulates links so there is no reference count and files are unaware of links. Calling unlink on a file will always close the file, regardless of whether there is another link.

The pathname argument may not be a directory.

Examples:

/*
 Detailed description  : Example to unlink a link file
 Precondition : A link file by name "Link" should exist in
                c: drive.
 */
# 1489 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 1490 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
int main(void)
{
    char rdbuff[25];
    if(unlink("C:\Link"))
    {
         printf("unlink on link file failed");
    }
    printf("Unlink on link file succeeded");
}

Output

Unlink on link file succeeded.

Limitations:

Parameters

const char *

Return value

int

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

See also:

[Top]


write(int,const void *,size_t)

Interface status: externallyDefinedApi

IMPORT_C ssize_t write(int, const void *, size_t);

Description

The write system call attempts to write cnt bytes of data to the object referenced by the descriptor fd from the buffer pointed to by buf . The writev system call performs the same action, but gathers the output data from the iovcnt buffers specified by the members of the iov array: iov[0], iov[1], ..., iov[iovcnt-1]. The pwrite and pwritev system calls perform the same functions, but write to the specified position in the file without modifying the file pointer.

For writev and pwritev, the iovec structure is defined as:

 struct iovec {
void   *iov_base;  //Base address.
size_t iov_len;    // Length.
};

Each iovec entry specifies the base address and length of an area in memory from which data should be written. The writev system call will always write a complete area before proceeding to the next.

On objects capable of seeking, the write starts at a position given by the pointer associated with fd , see lseek . Upon return from write , the pointer is incremented by the number of bytes which were written.

Objects that are not capable of seeking always write from the current position. The value of the pointer associated with such an object is undefined.

When using non-blocking I/O on objects such as sockets that are subject to flow control, write and writev may write fewer bytes than requested; the return value must be noted, and the remainder of the operation should be retried when possible.

Examples:

/* Detailed description: This sample code creates an Example.txt file in the current working
 directory(if file existes then it is truncated) and writes "Hello World" string
 to the file.

 Preconditions: Example.txt if present, it should not be read-only.
 */
int main()
{
 int fd = 0 ;
 char Buf[] = "Hello World" ;
 fd = open("Example.txt" ,  0x0200  |  0x0400  |  0x0002   ,0666) ;
 if(fd < 0 )
 {
    printf("Failed to open file Example.txt") ;
    return -1 ;
 }
 if(write(fd , Buf , sizeof(Buf)) < sizeof(Buf))
  {
    printf("Failed to write string %s to file" , Buf) ;
    return -1 ;
  }
  printf("String %s written to file 
" , Buf) ;
  return 0 ;
 }

Output

String Hello World written to file
/*
 Detailed description  : Sample usage of readv system call
 */
# 1615 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 1616 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 1617 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 1618 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
int main()
{
  int fd = 0 ;
  struct iovec io_vec[1] ;
  char Buf[12] = "Hello world" ;
  io_vec[0].iov_base  = Buf ;
  io_vec[0].iov_len = 11 ;
  fd = open("Example.txt" ,  0x0200  |  0x0002  , 0666 ) ;
  if(fd < 0 )  {
    printf("File open failed") ;
    return -1 ;
  }
  if(writev(fd , io_vec , 1) <  11 )   {
    printf("Failed to read fron Example.txt file") ;
    return -1 ;
  }
  printf("writev succes %s written"  , io_vec[0].iov_base) ;
  return 0 ; }

Output

writev succes Hello world written

Parameters

int

const void *

size_tsize_t

Note: This description also covers the following functions - pwrite() writev pwritev()

Return value

ssize_tssize_t

Upon successful completion the number of bytes which were written is returned. Otherwise a -1 is returned and the global variable errno is set to indicate the error.

See also:

[Top]


confstr(int,char *,size_t)

Interface status: externallyDefinedApi

IMPORT_C size_t confstr(int, char *, size_t);

Description

The confstr function provides a method for applications to get configuration defined string values.

The name argument specifies the system variable to be queried. Symbolic constants for each name value are found in the include file #include <unistd.h.> The len argument specifies the size of the buffer referenced by the argument buf. If len is non-zero, buf is a non-null pointer, and name has a value, up to len - 1 bytes of the value are copied into the buffer buf. The copied value is always null terminated. The available values are as follows:

 _CS_PATH
  Return a value for the PATH environment variable that finds all the standard utilities.

Examples:

#include<unistd.h>
#include<stdio.h>
#include <stdlib.h>
 
int main()
{
 int n = 0;
 char *buf = NULL;
 int len = 0;
   
 n = confstr(_CS_PATH, NULL, 0);
    
 printf("{Expected: 31} %d", n);
       
 if( n == 0 )
    return -1;
                    
 buf = (char *)malloc(n);
  
 if ( buf == NULL )
 {
    printf("malloc failed!!");
    return -1;
 }
             
 len = confstr(_CS_PATH, buf, n);
                
 printf("PATH in buffer: \n%s", buf);
 printf("length: %d", len);
 free(buf);
 
 return 0;
}

Output

PATH in buffer:
/usr/bin:/bin:/usr/sbin:/sbin:
length: 31

Parameters

int

char *

size_tsize_t

Return value

size_tsize_t

If the call to confstr is not successful, 0 is returned and errno is set appropriately. Otherwise, if the variable does not have a configuration defined value, 0 is returned and errno is not modified. Otherwise, the buffer size needed to hold the entire configuration-defined value is returned. If this size is greater than the argument len, the string in buf was truncated.

See also:

[Top]


fsync(int)

Interface status: externallyDefinedApi

IMPORT_C int fsync(int);

Description

The fsync system call causes all modified data and attributes of fd to be moved to a permanent storage device. This normally results in all in-core modified copies of buffers for the associated file to be written to a disk.

The fsync system call should be used by programs that require a file to be in a known state, for example, when building a simple transaction facility.

Examples:

/*
 Detailed description : Simple usage of fsync system call.
 Preconditions : Example.txt if present should not a ready-only file
 */
# 1866 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 1867 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
int main()
{
  int fd = 0;
  fd = open("Example.txt" ,  0x0200  |  0x0002  , 0666);
  if(fd < 0 )  
  {
     printf("Failed to open file Example.txt");
     return -1;
  }
  if(fsync(fd) < 0 )  
  {
     printf("fsync system call failed");
     return -1;
  }
  close(fd);
  printf("fsync system call succeeded");
  return 0;
}

Output

fsync system call succeeded

Parameters

int

Return value

int

Upon successful completion, fsync returns 0. Otherwise, it returns -1 and sets errno to indicate the error. If the fsync function fails, outstanding I/O operations are not guaranteed to have been completed.

[Top]


fdatasync(int)

Interface status: externallyDefinedApi

IMPORT_C int fdatasync(int);

Description

The fdatasync system call causes all modified data and attributes of fd to be moved to a permanent storage device. This normally results in all in-core modified copies of buffers for the associated file to be written to a disk. The fdatasync(int)fdatasync(int) function forces all the queued I/O operations associated that file, as indicated by the file descriptor fd, to the synchronized I/O completion state.

The functionality shall be equivalent to fsync with the symbol _POSIX_SYNCHRONIZED_IO defined. This has an exception that all I/O operations shall be completed before the call.

The fdatasync should be used by programs that require a file to be in a known state, for example when building a simple transaction facility.

Examples:

#include<unistd.h>
#include<stdio.h>
#define KMAXCHARS 100
int test_fdatasync()
{
   char* array = "abcdefghijklmnopqrstuvwxyz";
   struct stat buf;
   if((fd = open(file , O_CREAT | O_RDWR , 0666))  < 0)
   {
      printf("Failed  to create file");
   }
   size_t size = write(fd,array, KMAXCHARS);
   if(fdatasync(fd) < 0)
   {
     printf("Fdatasync failed");
     int retrn = remove(file);
     return -1;
   }
  int retVal2 = fstat( fp, &buf; );
  if(!retVal2)
  {
    size_t bufsize = buf.st_size;
    if (bufsize == size)
    {
      printf("file size = %d", size);
      printf("Fdatasync passed");
      int retrn = remove(file);
      return 0;
    }
  }
}

Output

file size = 50
Fdatasync passed

Parameters

int

Return value

int

If successful the function returns 0, otherwise it returns (-1) and sets errno to indicate the error.

[Top]


readlink(const char *,char *,int)

Interface status: externallyDefinedApi

IMPORT_C int readlink(const char *, char *, int);

Description

The readlink system call places the contents of the symbolic link path in the buffer buf, which has size bufsize. The readlink system call does not append a NULL character to buf.

Examples:

/*
 Detailed description: Example to read a link file
 Precondition: "Parent.txt" should exist in c: drive with some contents
                of length atleast 25 characters.  And a link file by name           
                "C:\Link" pointing to parent file should exist.

*/
# 2009 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 2010 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
int main(void)
{
    char rdbuff[25];
    int retval;
   if((retval = (readlink("C:\Link", rdbuff, (sizeof(char)*25)))) < 0)
    {
       printf("Read through link file failed");
       perror(" ");
       return -1;
    }
    printf("Read through link file succeeded");
}

Output

Read through link file succeeded.

Limitations:

The path parameter of the readlink(const char *,char *,int)readlink(const char *,char *,int) function should not exceed 256 characters in length.

Parameters

const char *

char *

int

Return value

int

The call returns the count of characters placed in the buffer if it succeeds, or a -1 if an error occurs, placing the error code in the global variable errno.

See also:

[Top]


gethostname(char *,size_t)

Interface status: externallyDefinedApi

IMPORT_C int gethostname(char *, size_t);

Description

The gethostname(char *,size_t)gethostname(char *,size_t) function returns the standard host name for the current machine. The size argument specifies the size of the array pointed to by the name argument. The returned name is null-terminated, except that if size is an insufficient length to hold the host name, then the returned name is truncated and it is unspecified whether the returned name is null-terminated. Host names are limited to 255 bytes

Parameters

char *

size_tsize_t

Return value

int

On successful completion, 0 is returned. Otherwise, -1 is returned

See also:

[Top]


setegid(gid_t)

Interface status: externallyDefinedApi

IMPORT_C int setegid(gid_t);

Description

Parameters

gid_tgid_t

Refer to setuid(uid_t)setuid(uid_t) for the documentation

Return value

int

[Top]


seteuid(uid_t)

Interface status: externallyDefinedApi

IMPORT_C int seteuid(uid_t);

Description

Parameters

uid_tuid_t

Refer to setuid(uid_t)setuid(uid_t) for the documentation

Return value

int

[Top]


symlink(const char *,const char *)

Interface status: externallyDefinedApi

IMPORT_C int symlink(const char *, const char *);

Description

A symbolic link newpath is created to oldpath (newpath is the name of the file created, oldpath is the string used in creating the symbolic link). Either name may be an arbitrary path name.

The creation time stamp is not supported, only access and modification time stamps. Creating a link in a directory will not alter the time stamps of the directory itself.

Examples:

/*
 Detailed description  : Example to create symlink to a file.
 Precondition : "Parent.txt" should exist in c: drive.
 Remarks      : Symlink behaviour is exactly similar to link api.
*/
# 2109 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 2110 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
int main(void)
 {
    if(symlink("C:\Parent.txt","C:\Link") < 0)
    {
         printf("simulated link creation to parent file failed");
         return -1  ;
    }
    printf("simulated link to parent file created");
    return 0 ;
 }

Output

simulated link to parent file created.

Limitations:

Parameters

const char *

const char *

Return value

int

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

See also:

[Top]


fchdir(int)

Interface status: externallyDefinedApi

IMPORT_C int fchdir(int);

Description

Parameters

int

Refer to chdir(const char *)chdir(const char *) for the documentation

Return value

int

[Top]


getpgid(pid_t)

Interface status: externallyDefinedApi

IMPORT_C int getpgid(pid_t _pid);

Description

Parameters

pid_tpid_t _pid

Refer to getpgrp(void)getpgrp(void) for the documentation

Return value

int

[Top]


lchown(const char *,uid_t,gid_t)

Interface status: externallyDefinedApi

IMPORT_C int lchown(const char *, uid_t, gid_t);

Description

Parameters

const char *

uid_tuid_t

gid_tgid_t

Refer to chown(const char *,uid_t,gid_t)chown(const char *,uid_t,gid_t) for the documentation

Return value

int

[Top]


nice(int)

Interface status: externallyDefinedApi

IMPORT_C int nice(int);

Description

The nice function obtains the scheduling priority of the process from the system and sets it to the priority value specified in incr. The priority is a value in the range -20 to 20. The default priority is 0. Lower priorities cause more favorable scheduling.

Examples:

#include<unistd.h>
#include<stdio.h>
int test_nice()
{
   int retVal;
   errno = 0;
   int i = -10;
   int ret_get1 = getpriority(PRIO_PROCESS,0);
   retVal = nice(i);
   int ret_get2 = getpriority(PRIO_PROCESS,0);
   if((retVal == -1)&&(errno))
   {
      printf("failed");
      return -1;
   }
   else
   {
     if(!(i - (ret_get2 - retget1)))
     printf("Nice value: %d", i)
     printf("nice passed");
   }
   return 0;
}       

Output

Nice value: -10
nice passed

Parameters

int

Return value

int

See also:

[Top]


setpgrp(pid_t,pid_t)

Interface status: externallyDefinedApi

IMPORT_C int setpgrp(pid_t _pid, pid_t _pgrp);

Description

Parameters

pid_tpid_t _pid

pid_tpid_t _pgrp

Refer to setpgid(pid_t,pid_t)setpgid(pid_t,pid_t) for the documentation

Return value

int

[Top]


setregid(gid_t,gid_t)

Interface status: externallyDefinedApi

IMPORT_C int setregid(gid_t, gid_t);

Description

These functions are build supported but not available functionally. Symbian OS does not support multiple users and groups.

Parameters

gid_tgid_t

gid_tgid_t

Return value

int

These functions always return 0.

[Top]


setreuid(uid_t,uid_t)

Interface status: externallyDefinedApi

IMPORT_C int setreuid(uid_t, uid_t);

Description

These functions are build supported but not available functionally. Symbian OS does not support multiple users and groups.

Parameters

uid_tuid_t

uid_tuid_t

Return value

int

These functions always return 0.

[Top]


swab(const void *,void *,ssize_t)

Interface status: externallyDefinedApi

IMPORT_C void swab(const void *, void *, ssize_t);

Description

The argument len must be an even number.

Examples

#include <string.h>
#include <stdio.h>
int main()
{
    int i=0x00003366,j=0x0;
    swab((void *)&i,(void *)&j,2);
    if(j==0x6633)
       printf("Ouput val = %#x\n",j);
    return 0;
}

output

Ouput val = 0x6633

Parameters

const void *

void *

ssize_tssize_t

The function swab copies len bytes from the location referenced by from to the location referenced by to, swapping adjacent bytes.

See also:

[Top]


usleep(useconds_t)

Interface status: externallyDefinedApi

IMPORT_C int usleep(useconds_t);

Description

The usleep function suspends execution of the calling process until either microseconds microseconds have elapsed or a signal is delivered to the process and its action is to invoke a signal-catching function or to terminate the process. System activity may lengthen the sleep by an indeterminate amount.

This function is implemented using nanosleep by pausing for microseconds microseconds or until a signal occurs. Consequently, in this implementation, sleeping has no effect on the state of process timers, and there is no special handling for SIGALRM.

Limitations:

The signal related functionaities aren’t applicable to the symbian implementation as there is no support for signals from symbian.

Examples:

#include<unistd.h>
#include<stdio.h>
 
int main()
{
 unsigned long t = 2; 
 int i;
  
 i = usleep(t);
 printf("Expected: 0 usleep returned: %d", i);
  
 return 0;
}

Output

Expected: 0 usleep returned: 0

Parameters

useconds_tuseconds_t

Return value

int

The usleep function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

See also:

[Top]


brk(const void *)

Interface status: externallyDefinedApi

IMPORT_C int brk(const void *);

Description

The brk function is used to change the amount of memory allocated in a process's data segment.It does this by moving the location of the "break". This functionality is not supported by the Symbian OS platform and hence is only build supported.

Parameters

const void *

Return value

int

Function always returns 0.

See also:

[Top]


getdtablesize(void)

Interface status: externallyDefinedApi

IMPORT_C int getdtablesize(void);

Description

Each process has a fixed size descriptor table, which is guaranteed to have at least 20 slots. The entries in the descriptor table are numbered with small integers starting at 0. The getdtablesize system call returns the size of this table.

Examples:

#include <stdio.h>
int main()
{
        printf("maximum number of files that can be opened by a process is %d",getdtablesize());
}

Output

maximum number of files that can be opened by a process is 1024

Return value

int

[Top]


getpagesize(void)

Interface status: externallyDefinedApi

IMPORT_C int getpagesize(void);

Description

The getpagesize function returns the number of bytes in a page. Page granularity is the granularity of many of the memory management calls.

The page size is a system page size and may not be the same as the underlying hardware page size.

Examples:

#include<unistd.h>
#include<stdio.h>
int test_getpagesize()
{
   int retVal = 0;
   retVal = getpagesize();
   if( retVal >= 0)
   {
      printf("getpagesize passed");
      printf("
 retVal  = %d " retVal);
      return retVal;
   }
   else
   {
   printf("Failed");
   return -1;
   }
}       

Output

getpagesize passed
retVal = 4096

Return value

int

[Top]


initgroups(const char *,gid_t)

Interface status: externallyDefinedApi

IMPORT_C int initgroups(const char *, gid_t);

Description

The getgroups function is build supported but not available functionally. Symbian OS does not support multiple users and groups.

Parameters

const char *

gid_tgid_t

Return value

int

These functions always return 0.

[Top]


issetugid(void)

Interface status: externallyDefinedApi

IMPORT_C int issetugid(void);

Description

The issetugid(void)issetugid(void) function enables library functions (in lib-termlib, libc, or other libraries) to guarantee safe behavior when used in setuid or setgid programs. Some library functions might be passed insufficient informationand not know whether the current program was started setuidor setgid because a higher level calling code might have made changes to the uid, euid, gid, or egid. These low-levellibrary functions are therefore unable to determine if theyare being run with elevated or normal privileges.

Errors:

The issetugid(void)issetugid(void) function is always successful. No return value is reserved to indicate an error. g

Return value

int

The issetugid(void)issetugid(void) function returns 1 if the process was made setuid or setgid as the result of the last or a previous call to execve. Otherwise it returns 0

[Top]


setgroups(int,const gid_t *)

Interface status: externallyDefinedApi

IMPORT_C int setgroups(int, const gid_t *);

Description

Refer to getgrent(void)getgrent(void) for the documentation

Parameters

int

const gid_tgid_t *

Return value

int