TOPIC   #  NAME           DESCRIPTION
-----  --- ------------   ------------------------------------------------
file    33 access         - check user's permissions for a file
file    12 chdir          - change working directory
file    15 chmod          - change permissions of a file
file   182 chown          - change ownership of a file
file    61 chroot         - change root directory
file     6 close          - close a file descriptor
file     8 creat          - create a file
file    41 dup            - duplicate a file descriptor
file    63 dup2           - duplicate a file descriptor
file   133 fchdir         - change working directory
file    94 fchmod         - change permissions of a file
file    95 fchown         - change ownership of a file
file    55 fcntl          - manipulate file descriptor
file   148 fdatasync      - synchronize a file's in-core data with that on disk
file   143 flock          - apply or remove an advisory lock on an open file
file   108 fstat          - get file status
file   100 fstatfs        - get file system statistics
file   118 fsync          - synchronize  a file's complete in-core state with
file    93 ftruncate      - truncate file to specified length
file   183 getcwd         - get current working directory
file   141 getdents       - get directory entries
file    16 lchown         - change ownership of a file
file     9 link           - make a new name for a file
file   140 llseek         - reposition read/write file offset
file    19 lseek          - reposition read/write file offset
file   107 lstat          - get file status
file    39 mkdir          - create a directory
file    14 mknod          - create a special or ordinary file
file    21 mount          - mount and unmount filesystems
file     5 open           - open and possibly create a file or device
file    42 pipe           - create pipe
file     3 read           - read from a file descriptor
file    89 readdir        - read directory entry
file    85 readlink       - read value of a symbolic link
file   145 readv          - read data into multiple buffers
file    38 rename         - change the name or location of a file
file    40 rmdir          - delete a directory
file   187 sendfile       - transfer data between file descriptors
file   106 stat           - get file status
file    99 statfs         - get file system statistics
file   115 swapoff        - stop swapping to file/device
file    87 swapon         - start/stop swapping to file/device
file    83 symlink        - make a new name for a file
file    36 sync           - commit buffer cache to disk
file    92 truncate       - truncate file to specified length
file    60 umask          - set file creation mask
file    22 umount         - mount and unmount filesystemsx
file    52 umount2        - mount and unmount filesystemsx
file    10 unlink         - delete a name and possibly the file it refers to
file    62 ustat          - get file system statistics 
file    30 utime          - chg access and/or modification times
file     4 write          - write   - write to a file descriptor
file   146 writev         - read or write a vector


----------------------------------------------------------------------------
 33 access         - check user's permissions for a file
----------------------------------------------------------------------------
  mov eax,33
  mov ebx,pathname
  mov ecx,  mode
  int 80h

       access  checks  whether  the process would be allowed to read, write or
       test for existence of the file (or other file system object) whose name
       is  pathname.   If  pathname is a symbolic link permissions of the file
       referred to by this symbolic link are tested.

       mode is a mask consisting of one or more of R_OK, W_OK, X_OK and  F_OK.

       R_OK,  W_OK  and  X_OK request checking whether the file exists and has
       read, write and execute permissions, respectively.  F_OK just  requests
       checking for the existence of the file.

       The tests depend on the permissions of the directories occurring in the
       path to the file, as given in  pathname,  and  on  the  permissions  of
       directories  and files referred to by symbolic links encountered on the
       way.

       The check is done with the process's real uid and gid, rather than with
       the  effective  ids  as  is done when actually attempting an operation.
       This is to allow set-UID programs  to  easily  determine  the  invoking
       user's authority.

       Only  access  bits  are checked, not the file type or contents.  There-
       fore, if a directory is found to be "writable," it probably means  that
       files  can  be created in the directory, and not that the directory can
       be written as a file.  Similarly, a DOS file may be found to  be  "exe-
       cutable," but the execve(2) call will still fail.

       If  the process has appropriate privileges, an implementation may indi-
       cate success for X_OK even if none of the execute file permission  bits
       are set.

RETURN VALUE
       On  success  (all requested permissions granted), zero is returned.  On
       error (at least one bit in mode asked for a permission that is  denied,
       or  some other error occurred), -1 is returned, and errno is set appro-
       priately.

ERRORS
       access shall fail if:

       EACCES The requested access would be denied to the file or search  per-
              mission is denied to one of the directories in pathname.

       ELOOP  Too  many symbolic links were encountered in resolving pathname.

       ENAMETOOLONG
              pathname is too long.

       ENOENT A directory component in pathname would have been accessible but
              does not exist or was a dangling symbolic link.

       ENOTDIR
              A  component  used as a directory in pathname is not, in fact, a
              directory.

       EROFS  Write permission  was  requested  for  a  file  on  a  read-only
              filesystem.

       access may fail if:

       EFAULT pathname points outside your accessible address space.

       EINVAL mode was incorrectly specified.

       EIO    An I/O error occurred.

       ENOMEM Insufficient kernel memory was available.

       ETXTBSY
              Write  access was requested to an executable which is being exe-
              cuted.

RESTRICTIONS
       access returns an error if any of the access  types  in  the  requested
       call fails, even if other types might be successful.

       access  may  not  work  correctly  on NFS file systems with UID mapping
       enabled, because UID mapping is done on the server and hidden from  the
       client, which checks permissions.

SEE ALSO
       stat(2), open(2), chmod(2), chown(2), setuid(2), setgid(2)


----------------------------------------------------------------------------
 12 chdir          - change working directory
----------------------------------------------------------------------------
  mov   eax,012
  mov   ebx,path
  int   80h

       chdir changes the current directory to that specified in path.

RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS
       Depending  on  the file system, other errors can be returned.  The more
       general errors for chdir are listed below:

       EFAULT path points outside your accessible address space.

       ENAMETOOLONG
              path is too long.

       ENOENT The file does not exist.

       ENOMEM Insufficient kernel memory was available.

       ENOTDIR
              A component of path is not a directory.

       EACCES Search permission is denied on a component of path.

       ELOOP  Too many symbolic links were encountered in resolving path.

       EIO    An I/O error occurred.

       The general errors for fchdir are listed below:

       EBADF  fd is not a valid file descriptor.

       EACCES Search permission was denied on the directory open on fd.

SEE ALSO
       getcwd(3), chroot(2)


----------------------------------------------------------------------------
 15 chmod          - change permissions of a file
----------------------------------------------------------------------------
  mov   eax,015         ;chmod
  mov   ebx,filename
  mov   ecx,mode
  int   80h

       The  mode of the file given by path (filename)  is changed.
       Modes are specified by or'ing the following:
              S_ISUID   04000 set user ID on execution
              S_ISGID   02000 set group ID on execution
              S_ISVTX   01000 sticky bit
              S_IRUSR (S_IREAD) 00400 read by owner
              S_IWUSR (S_IWRITE) 00200 write by owner
              S_IXUSR (S_IEXEC) 00100 execute/search by owner
              S_IRGRP   00040 read by group
              S_IWGRP   00020 write by group
              S_IXGRP   00010 execute/search by group
              S_IROTH   00004 read by others
              S_IWOTH   00002 write by others
              S_IXOTH   00001 execute/search by others


       The effective UID of the process must be zero or must match  the  owner
       of the file.

       If  the  effective  UID of the process is not zero and the group of the
       file does not match the effective group ID of the process or one of its
       supplementary  group  IDs, the S_ISGID bit will be turned off, but this
       will not cause an error to be returned.

       Depending on the file system, set user ID and set  group  ID  execution
       bits  may  be  turned  off if a file is written.  On some file systems,
       only the super-user can set the sticky bit, which may  have  a  special
       meaning.  For the sticky bit, and for set user ID and set group ID bits
       on directories, see stat(2).

       On NFS file  systems,  restricting  the  permissions  will  immediately
       influence already open files, because the access control is done on the
       server, but open files are maintained by the client.  Widening the per-
       missions  may  be  delayed  for  other  clients if attribute caching is
       enabled on them.

RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS
       Depending  on  the file system, other errors can be returned.  The more
       general errors for chmod are listed below:


       EPERM  The effective UID does not match the owner of the file,  and  is
              not zero.

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

       EFAULT path points outside your accessible address space.

       ENAMETOOLONG
              path is too long.

       ENOENT The file does not exist.

       ENOMEM Insufficient kernel memory was available.

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

       EACCES Search permission is denied on a component of the path prefix.

       ELOOP  Too many symbolic links were encountered in resolving path.

       EIO    An I/O error occurred.

       The general errors for fchmod are listed below:

       EBADF  The file descriptor fildes is not valid.

       EROFS  See above.

       EPERM  See above.

       EIO    See above.

SEE ALSO
       open(2), chown(2), execve(2), stat(2)

----------------------------------------------------------------------------
182 chown          - change ownership of a file
----------------------------------------------------------------------------
  mov   eax,182         ;chown
  mov   ebx,path
  mov   ecx,owner
  mov   edx,group
  int   80h

       The  owner of the file specified by path is changed.  Only the
       super-user may change the owner of a file.  The owner  of  a  file  may
       change the group of the file to any group of which that owner is a mem-
       ber.  The super-user may change the group arbitrarily.

       If the owner or group is specified as -1, then that ID is not  changed.

       When  the  owner  or  group of an executable file are changed by a non-
       super-user, the S_ISUID and S_ISGID mode bits are cleared.  POSIX  does
       not  specify  whether this also should happen when root does the chown;
       the Linux behaviour depends on the kernel version.  In case of  a  non-
       group-executable  file  (with  clear S_IXGRP bit) the S_ISGID bit indi-
       cates mandatory locking, and is not cleared by a chown.

RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS
       Depending  on  the file system, other errors can be returned.  The more
       general errors for chown are listed below:


       EPERM  The effective UID does not match the owner of the file,  and  is
              not zero; or the owner or group were specified incorrectly.

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

       EFAULT path points outside your accessible address space.

       ENAMETOOLONG
              path is too long.

       ENOENT The file does not exist.

       ENOMEM Insufficient kernel memory was available.

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

       EACCES Search permission is denied on a component of the path prefix.

       ELOOP  Too many symbolic links were encountered in resolving path.

       The general errors for fchown are listed below:

       ENOENT See above.

       EPERM  See above.

       EROFS  See above.

       EIO    A low-level I/O error occurred while modifying the inode.

NOTES
       In  versions of Linux prior to 2.1.81 (and distinct from 2.1.46), chown
       did not follow symbolic links.  Since Linux 2.1.81, chown  does  follow
       symbolic  links,  and  there  is a new system call lchown that does not
       follow symbolic links.  Since Linux 2.1.86, this new call (that has the
       same  semantics  as the old chown) has got the same syscall number, and
       chown got the newly introduced number.

RESTRICTIONS
       The  chown()  semantics  are  deliberately violated on NFS file systems
       which have UID mapping enabled.  Additionally,  the  semantics  of  all
       system  calls  which  access  the  file  contents are violated, because
       chown() may cause immediate access revocation on  already  open  files.
       Client  side  caching may lead to a delay between the time where owner-
       ship have been changed to allow access for a user and  the  time  where
       the file can actually be accessed by the user on other clients.

SEE ALSO
       chmod(2), flock(2) lchown fchown


----------------------------------------------------------------------------
 61 chroot         - change root directory
----------------------------------------------------------------------------
  mov   eax,061
  mov   ebx,path
  int   80h

       chroot  changes  the  root  directory  to that specified in path.  This
       directory will be used for path  names  beginning  with  /.   The  root
       directory is inherited by all children of the current process.

       Only the super-user may change the root directory.

       Note  that  this call does not change the current working directory, so
       that `.' can be outside the tree rooted at  `/'.   In  particular,  the
       super-user  can escape from a `chroot jail' by doing `mkdir foo; chroot
       foo; cd ..'.

RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS
       Depending  on  the file system, other errors can be returned.  The more
       general errors are listed below:


       EPERM  The effective UID is not zero.

       EFAULT path points outside your accessible address space.

       ENAMETOOLONG
              path is too long.

       ENOENT The file does not exist.

       ENOMEM Insufficient kernel memory was available.

       ENOTDIR
              A component of path is not a directory.

       EACCES Search permission is denied on a component of the path prefix.

       ELOOP  Too many symbolic links were encountered in resolving path.

       EIO    An I/O error occurred.

SEE ALSO
       chdir(2)

----------------------------------------------------------------------------
  6 close          - close a file descriptor
----------------------------------------------------------------------------
  mov  eax,006
  mov  ebx,fd
  int  80h

       close closes a file descriptor, so that it no longer refers to any file
       and may be reused. Any locks held on the file it was  associated  with,
       and  owned by the process, are removed (regardless of the file descrip-
       tor that was used to obtain the lock).

       If fd is the last copy of a particular file  descriptor  the  resources
       associated  with it are freed; if the descriptor was the last reference
       to a file which has been removed using unlink(2) the file is deleted.

RETURN VALUE
       close returns zero on success, or -1 if an error occurred.

ERRORS
       EBADF  fd isn't a valid open file descriptor.

       EINTR  The close() call was interrupted by a signal.

       EIO    An I/O error occurred.

NOTES
       Not  checking  the  return  value of close is a common but nevertheless
       serious programming error.  It is quite possible that errors on a  pre-
       vious  write(2)  operation  are first reported at the final close.  Not
       checking the return value when closing the file may lead to silent loss
       of data.  This can especially be observed with NFS and disk quotas.

       A  successful  close does not guarantee that the data has been success-
       fully saved to disk, as the kernel defers writes. It is not common  for
       a  filesystem  to  flush  the buffers when the stream is closed. If you
       need to be sure that the data is physically stored use  fsync(2).   (It
       will depend on the disk hardware at this point.)

SEE ALSO
       open(2), fcntl(2), shutdown(2), unlink(2), fclose(3), fsync(2)


----------------------------------------------------------------------------
 08 creat          - create a file                 
----------------------------------------------------------------------------
  mov  eax,8
  mov  ebx,filename_ptr
  mov  ecx,mode
  int  80h

       The  open()  system  call  is  used  to  convert a pathname into a file
       descriptor (a small, non-negative integer for use in subsequent I/O  as
       with  read,  write,  etc.).   When  the  call  is  successful, the file
       descriptor returned will be the lowest file  descriptor  not  currently
       open  for  the  process.  This call creates a new open file, not shared
       with any other process.  (But shared  open  files  may  arise  via  the
       fork(2)  system  call.)   The new file descriptor is set to remain open
       across exec functions (see fcntl(2)).  The file offset is  set  to  the
       beginning of the file.

       The  argument  mode specifies the permissions to use in case a new file
       is created. It is modified by the process's umask in the usual way: the
       permissions  of  the  created file are (mode & ~umask).  Note that this
       mode only applies to future accesses of the  newly  created  file;  the
       open  call  that  creates a read-only file may well return a read/write
       file descriptor.

       The following symbolic constants are provided for mode:

       S_IRWXU
              00700 user (file owner) has read, write and execute permission

       S_IRUSR (S_IREAD)
              00400 user has read permission

       S_IWUSR (S_IWRITE)
              00200 user has write permission

       S_IXUSR (S_IEXEC)
              00100 user has execute permission

       S_IRWXG
              00070 group has read, write and execute permission

       S_IRGRP
              00040 group has read permission

       S_IWGRP
              00020 group has write permission

       S_IXGRP
              00010 group has execute permission

       S_IRWXO
              00007 others have read, write and execute permission

       S_IROTH
              00004 others have read permission

       S_IWOTH
              00002 others have write permisson

       S_IXOTH
              00001 others have execute permission

       mode must be specified when O_CREAT is in the  flags,  and  is  ignored
       otherwise.

       creat    is    equivalent    to    open    with    flags    equal    to
       O_CREAT|O_WRONLY|O_TRUNC.

RETURN VALUE
       open and creat return the new  file  descriptor,  or  -1  if  an  error
       occurred  (in  which case, errno is set appropriately).  Note that open
       can open device special files, but  creat  cannot  create  them  -  use
       mknod(2) instead.

       On  NFS  file  systems with UID mapping enabled, open may return a file
       descriptor but e.g. read(2) requests are denied with EACCES.   This  is
       because  the  client performs open by checking the permissions, but UID
       mapping is performed by the server upon read and write requests.

       If the file is newly created, its atime, ctime, mtime fields are set to
       the  current  time, and so are the ctime and mtime fields of the parent
       directory.  Otherwise, if the file is modified because of  the  O_TRUNC
       flag, its ctime and mtime fields are set to the current time.


ERRORS
       EEXIST pathname already exists and O_CREAT and O_EXCL were used.

       EISDIR pathname refers to a directory and the access requested involved
              writing (that is, O_WRONLY or O_RDWR is set).

       EACCES The requested access to the file is not allowed, or one  of  the
              directories  in  pathname did not allow search (execute) permis-
              sion, or the file did not exist yet and write access to the par-
              ent directory is not allowed.

       ENAMETOOLONG
              pathname was too long.

       ENOENT O_CREAT  is  not  set  and the named file does not exist.  Or, a
              directory component in pathname does not exist or is a  dangling
              symbolic link.

       ENOTDIR
              A  component  used as a directory in pathname is not, in fact, a
              directory, or O_DIRECTORY was specified and pathname was  not  a
              directory.

       ENXIO  O_NONBLOCK  |  O_WRONLY  is set, the named file is a FIFO and no
              process has the file open for reading.  Or, the file is a device
              special file and no corresponding device exists.

       ENODEV pathname  refers  to  a device special file and no corresponding
              device exists.  (This is a Linux kernel bug - in this  situation
              ENXIO must be returned.)

       EROFS  pathname  refers  to  a file on a read-only filesystem and write
              access was requested.

       ETXTBSY
              pathname refers to an executable image which is currently  being
              executed and write access was requested.

       EFAULT pathname points outside your accessible address space.

       ELOOP  Too  many symbolic links were encountered in resolving pathname,
              or O_NOFOLLOW was specified but pathname was a symbolic link.

       ENOSPC pathname was to be created but the  device  containing  pathname
              has no room for the new file.

       ENOMEM Insufficient kernel memory was available.

       EMFILE The process already has the maximum number of files open.

       ENFILE The  limit  on  the total number of files open on the system has
              been reached.

NOTE
       Under Linux, the O_NONBLOCK flag indicates that one wants to  open  but
       does not necessarily have the intention to read or write.  This is typ-
       ically used to open devices in order to get a file descriptor  for  use
       with ioctl(2).

RESTRICTIONS
       There  are  many infelicities in the protocol underlying NFS, affecting
       amongst others O_SYNC and O_NDELAY.

       POSIX provides for three different variants of synchronised I/O, corre-
       sponding to the flags O_SYNC, O_DSYNC and O_RSYNC.  Currently (2.1.130)
       these are all synonymous under Linux.

SEE ALSO
       read(2), write(2), fcntl(2),  close(2),  link(2),  mknod(2),  mount(2),
       stat(2), umask(2), unlink(2), socket(2), fopen(3), fifo(4)

----------------------------------------------------------------------------
 41 dup            - duplicate a file descriptor
----------------------------------------------------------------------------
  mov  eax,041  ;dup (dupfd)
  mov   ebx,oldfd
  int   80h

       dup creates a copy of the file descriptor oldfd.
       dup uses the lowest-numbered unused descriptor for the new  descriptor.

       After successful return of dup , the old and new descriptors may
       be used interchangeably. They share locks, file position  pointers  and
       flags;  for example, if the file position is modified by using lseek on
       one of the descriptors, the position is also changed for the other.

       The two descriptors do not share the close-on-exec flag, however.

RETURN VALUE
       dup returns the new descriptor, or -1 if an error occurred  (in
       which case, errno is set appropriately).

ERRORS
       EBADF  oldfd  isn't  an  open  file  descriptor, or newfd is out of the
              allowed range for file descriptors.

       EMFILE The process already has the maximum number of  file  descriptors
              open and tried to open a new one.

       EINTR  The dup2 call was interrupted by a signal.

       EBUSY  (Linux  only)  This may be returned by dup2 during a race condi-
              tion with open() and dup().

SEE ALSO
       fcntl(2), open(2), close(2) dup2


----------------------------------------------------------------------------
 63 dup2           - duplicate a file descriptor
----------------------------------------------------------------------------
  mov   eax,063         ;dup2
  mov   ebx,oldfd
  mov   ecx,newfd
  int   80h

       dup2 create a copy of the file descriptor oldfd.

       After successful return of dup2, the old and new descriptors may
       be used interchangeably. They share locks, file position  pointers  and
       flags;  for example, if the file position is modified by using lseek on
       one of the descriptors, the position is also changed for the other.

       The two descriptors do not share the close-on-exec flag, however.

       dup2  makes  newfd  be the copy of oldfd, closing newfd first if neces-
       sary.

RETURN VALUE
       dup and dup2 return the new descriptor, or -1 if an error occurred  (in
       which case, errno is set appropriately).

ERRORS
       EBADF  oldfd  isn't  an  open  file  descriptor, or newfd is out of the
              allowed range for file descriptors.

       EMFILE The process already has the maximum number of  file  descriptors
              open and tried to open a new one.

       EINTR  The dup2 call was interrupted by a signal.

       EBUSY  (Linux  only)  This may be returned by dup2 during a race condi-
              tion with open() and dup().

WARNING
       The  error  returned  by  dup2  is  different  from  that  returned  by
       fcntl(...,  F_DUPFD,  ...)  when newfd is out of range. On some systems
       dup2 also sometimes returns EINVAL like F_DUPFD.

BUGS
       If newfd was open, any errors that would have been reported at  close()
       time,  are lost. A careful programmer will not use dup2 without closing
       newfd first.

SEE ALSO
       fcntl(2), open(2), close(2) dup


----------------------------------------------------------------------------
133 fchdir         - change working directory
----------------------------------------------------------------------------
  mov   eax,133
  mov   ebx,fd
  int   80h

       chdir changes the current directory to that specified by "fd".
       fd is an open file descriptor.

RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS
       Depending  on  the file system, other errors can be returned.  The more
       general errors for chdir are listed below:

       EFAULT path points outside your accessible address space.

       ENOMEM Insufficient kernel memory was available.

       EACCES Search permission is denied on a component of path.

       ELOOP  Too many symbolic links were encountered in resolving path.

       EIO    An I/O error occurred.

       The general errors for fchdir are listed below:

       EBADF  fd is not a valid file descriptor.

       EACCES Search permission was denied on the directory open on fd.

NOTES
       The prototype for fchdir is only available if  _BSD_SOURCE  is  defined
       (either  explicitly,  or  implicitly,  by not defining _POSIX_SOURCE or
       compiling with the -ansi flag).

CONFORMING TO
       The chdir call is compatible with SVr4, SVID,  POSIX,  X/OPEN,  4.4BSD.
       SVr4  documents  additional  EINTR, ENOLINK, and EMULTIHOP error condi-
       tions but has no ENOMEM.  POSIX.1 does not have ENOMEM or  ELOOP  error
       conditions.   X/OPEN  does  not have EFAULT, ENOMEM or EIO error condi-
       tions.

       The fchdir call is compatible with SVr4, 4.4BSD and X/OPEN.  SVr4 docu-
       ments additional EIO, EINTR, and ENOLINK error conditions.  X/OPEN doc-
       uments additional EINTR and EIO error conditions.

SEE ALSO
       getcwd(3), chroot(2)

----------------------------------------------------------------------------
 94 fchmod         - change permissions of a file
----------------------------------------------------------------------------
  mov   eax,094         ;fchmod
  mov   ebx,filedes (fd)
  mov   ecx,mode
  int   80h

       The  mode of the file given by path or referenced by fildes is changed.

       Modes are specified by or'ing the following:


              S_ISUID   04000 set user ID on execution

              S_ISGID   02000 set group ID on execution

              S_ISVTX   01000 sticky bit

              S_IRUSR (S_IREAD)
                        00400 read by owner

              S_IWUSR (S_IWRITE)
                        00200 write by owner

              S_IXUSR (S_IEXEC)
                        00100 execute/search by owner

              S_IRGRP   00040 read by group

              S_IWGRP   00020 write by group

              S_IXGRP   00010 execute/search by group

              S_IROTH   00004 read by others

              S_IWOTH   00002 write by others

              S_IXOTH   00001 execute/search by others


       The effective UID of the process must be zero or must match  the  owner
       of the file.

       If  the  effective  UID of the process is not zero and the group of the
       file does not match the effective group ID of the process or one of its
       supplementary  group  IDs, the S_ISGID bit will be turned off, but this
       will not cause an error to be returned.

       Depending on the file system, set user ID and set  group  ID  execution
       bits  may  be  turned  off if a file is written.  On some file systems,
       only the super-user can set the sticky bit, which may  have  a  special
       meaning.  For the sticky bit, and for set user ID and set group ID bits
       on directories, see stat(2).

       On NFS file  systems,  restricting  the  permissions  will  immediately
       influence already open files, because the access control is done on the
       server, but open files are maintained by the client.  Widening the per-
       missions  may  be  delayed  for  other  clients if attribute caching is
       enabled on them.

RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS
       Depending  on  the file system, other errors can be returned.  The more
       general errors for chmod are listed below:
       The general errors for fchmod are listed below:

       EBADF  The file descriptor fildes is not valid.

       EROFS  See above.

       EPERM  See above.

       EIO    See above.

SEE ALSO
       open(2), chown(2), execve(2), stat(2)

----------------------------------------------------------------------------
 95 fchown         - change ownership of a file
----------------------------------------------------------------------------
  mov   eax,095         ;fchown: changes the owner of a file.
  mov   ebx,fd
  mov   ecx,owner
  mov   edx,group
  int   80h

       The  owner of the file specified by fd is changed.  Only the
       super-user may change the owner of a file.  The owner  of  a  file  may
       change the group of the file to any group of which that owner is a mem-
       ber.  The super-user may change the group arbitrarily.

       If the owner or group is specified as -1, then that ID is not  changed.

       When  the  owner  or  group of an executable file are changed by a non-
       super-user, the S_ISUID and S_ISGID mode bits are cleared.  POSIX  does
       not  specify  whether this also should happen when root does the chown;
       the Linux behaviour depends on the kernel version.  In case of  a  non-
       group-executable  file  (with  clear S_IXGRP bit) the S_ISGID bit indi-
       cates mandatory locking, and is not cleared by a chown.


RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS
       Depending  on  the file system, other errors can be returned.  The more
       general errors for chown are listed below:


       EPERM  The effective UID does not match the owner of the file,  and  is
              not zero; or the owner or group were specified incorrectly.

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

       EFAULT path points outside your accessible address space.

       ENAMETOOLONG
              path is too long.

       ENOENT The file does not exist.

       ENOMEM Insufficient kernel memory was available.

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

       EACCES Search permission is denied on a component of the path prefix.

       ELOOP  Too many symbolic links were encountered in resolving path.

       The general errors for fchown are listed below:

       EBADF  The descriptor is not valid.

       ENOENT See above.

       EPERM  See above.

       EROFS  See above.

       EIO    A low-level I/O error occurred while modifying the inode.

NOTES
       In  versions of Linux prior to 2.1.81 (and distinct from 2.1.46), chown
       did not follow symbolic links.  Since Linux 2.1.81, chown  does  follow
       symbolic  links,  and  there  is a new system call lchown that does not
       follow symbolic links.  Since Linux 2.1.86, this new call (that has the
       same  semantics  as the old chown) has got the same syscall number, and
       chown got the newly introduced number.

RESTRICTIONS
       The  chown()  semantics  are  deliberately violated on NFS file systems
       which have UID mapping enabled.  Additionally,  the  semantics  of  all
       system  calls  which  access  the  file  contents are violated, because
       chown() may cause immediate access revocation on  already  open  files.
       Client  side  caching may lead to a delay between the time where owner-
       ship have been changed to allow access for a user and  the  time  where
       the file can actually be accessed by the user on other clients.

SEE ALSO
       chmod(2), flock(2) chown lchown


----------------------------------------------------------------------------
 55 fcntl          - manipulate file descriptor
----------------------------------------------------------------------------
  mov  eax,055
  mov  ebx.fd
  mov  ecx,cmd
  mov   edx,arg (optional depending upon cmd)
  int  80h

       fcntl  performs  one  of  various  miscellaneous operations on fd.  The
       operation in question is determined by cmd.

   Handling close-on-exec
       F_DUPFD
              Find the lowest numbered available file descriptor greater  than
              or  equal to arg and make it be a copy of fd.  This is different
              form dup2(2) which uses exactly the descriptor specified.

              The old and new descriptors may be  used  interchangeably.  They
              share  locks,  file position pointers and flags; for example, if
              the file position is modified by  using  lseek  on  one  of  the
              descriptors, the position is also changed for the other.

              The  two  descriptors  do not share the close-on-exec flag, how-
              ever.  The close-on-exec flag of the copy is off,  meaning  that
              it will not be closed on exec.

              On success, the new descriptor is returned.

       F_GETFD
              Read  the  close-on-exec  flag.  If the FD_CLOEXEC bit is 0, the
              file will remain open across exec, otherwise it will be  closed.

       F_SETFD
              Set  the  close-on-exec  flag  to  the  value  specified  by the
              FD_CLOEXEC bit of arg.

   The file status flags
       A file descriptor has certain associated flags, initialized by  open(2)
       and possibly modified by fcntl(2).  The flags are shared between copies
       (made with dup(2), fork(2), etc.) of the same file descriptor.

       The flags and their semantics are described in open(2).

       F_GETFL
              Read the file descriptor's flags.

       F_SETFL
              Set the file status flags part of the descriptor's flags to  the
              value  specified by arg.  Remaining bits (access mode, file cre-
              ation flags) in arg are ignored.  On Linux this command can only
              change the O_APPEND, O_NONBLOCK, O_ASYNC, and O_DIRECT flags.


   Advisory locking
       F_GETLK,  F_SETLK  and  F_SETLKW are used to acquire, release, and test
       for the existence of record locks (also known as file-segment or  file-
       region  locks).   The  third  argument lock is a pointer to a structure
       that has at least the following fields (in unspecified order).

         struct flock {
             ...
             short l_type;    /* Type of lock: F_RDLCK,
                                 F_WRLCK, F_UNLCK */
             short l_whence;  /* How to interpret l_start:
                                 SEEK_SET, SEEK_CUR, SEEK_END */
             off_t l_start;   /* Starting offset for lock */
             off_t l_len;     /* Number of bytes to lock */
             pid_t l_pid;     /* PID of process blocking our lock
                                 (F_GETLK only) */
             ...
         };

       The l_whence, l_start, and l_len fields of this structure  specify  the
       range of bytes we wish to lock.  l_start is the starting offset for the
       lock, and is interpreted relative to either: the start of the file  (if
       l_whence  is  SEEK_SET);  the  current  file  offset  (if  l_whence  is
       SEEK_CUR); or the end of the file (if l_whence is  SEEK_END).   In  the
       final  two  cases, l_start can be a negative number provided the offset
       does not lie before the start of the file.   l_len  is  a  non-negative
       integer  (but see the NOTES below) specifying the number of bytes to be
       locked.  Bytes past the end of the file may be locked,  but  not  bytes
       before  the  start of the file.  Specifying 0 for l_len has the special
       meaning: lock all bytes starting at the location specified by  l_whence
       and  l_start  through  to the end of file, no matter how large the file
       grows.

       The l_type field can be used to place  a  read  (F_RDLCK)  or  a  write
       (F_WDLCK) lock on a file.  Any number of processes may hold a read lock
       (shared lock) on a file region, but only one process may hold  a  write
       lock (exclusive lock). An exclusive lock excludes all other locks, both
       shared and exclusive.  A single process can hold only one type of  lock
       on a file region; if a new lock is applied to an already-locked region,
       then the existing lock is converted to the the new  lock  type.   (Such
       conversions  may  involve  splitting,  shrinking, or coalescing with an
       existing lock if the byte range specified by the new lock does not pre-
       cisely coincide with the range of the existing lock.)

       F_SETLK
              Acquire  a lock (when l_type is F_RDLCK or F_WRLCK) or release a
              lock (when l_type is F_UNLCK) on  the  bytes  specified  by  the
              l_whence,  l_start,  and l_len fields of lock.  If a conflicting
              lock is held by another process, this call returns -1  and  sets
              errno to EACCES or EAGAIN.

       F_SETLKW
              As  for  F_SETLK, but if a conflicting lock is held on the file,
              then wait for that lock to be released.  If a signal  is  caught
              while  waiting, then the call is interrupted and (after the sig-
              nal handler has returned) returns immediately (with return value
              -1 and errno set to EINTR).

       F_GETLK
              On  input  to  this call, lock describes a lock we would like to
              place on the file.  If the lock could be  placed,  fcntl()  does
              not  actually  place it, but returns F_UNLCK in the l_type field
              of lock and leaves the other fields of the structure  unchanged.
              If  one or more incompatible locks would prevent this lock being
              placed, then fcntl() returns details about one of these locks in
              the l_type, l_whence, l_start, and l_len fields of lock and sets
              l_pid to be the PID of the process holding that lock.

       In order to place a read lock, fd must be open for reading.   In  order
       to  place  a  write  lock,  fd must be open for writing.  To place both
       types of lock, open a file read-write.

       As well as being removed by an explicit F_UNLCK, record locks are auto-
       matically released when the process terminates or if it closes any file
       descriptor referring to a file on which locks are held.  This  is  bad:
       it  means  that a process can lose the locks on a file like /etc/passwd
       or /etc/mtab when for some reason a library function decides  to  open,
       read and close it.

       Record  locks are not inherited by a child created via fork(2), but are
       preserved across an execve(2).

       Because of the buffering performed by the stdio(3) library, the use  of
       record  locking  with  routines  in that package should be avoided; use
       read(2) and write(2) instead.


   Mandatory locking
       (Non-POSIX.)  The above record locks may be either advisory  or  manda-
       tory,  and  are  advisory  by default.  To make use of mandatory locks,
       mandatory locking must be  enabled  (using  the  "-o  mand"  option  to
       mount(8))  for  the  file  system  containing the file to be locked and
       enabled on the file itself (by disabling group  execute  permission  on
       the file and enabling the set-GID permission bit).

       Advisory locks are not enforced and are useful only between cooperating
       processes. Mandatory locks are enforced for all processes.


   Managing signals
       F_GETOWN, F_SETOWN, F_GETSIG and F_SETSIG are used to manage I/O avail-
       ability signals:

       F_GETOWN
              Get  the  process  ID or process group currently receiving SIGIO
              and SIGURG signals for events on file  descriptor  fd.   Process
              groups are returned as negative values.

       F_SETOWN
              Set  the process ID or process group that will receive SIGIO and
              SIGURG signals for events on file descriptor fd.  Process groups
              are  specified  using negative values.  (F_SETSIG can be used to
              specify a different signal instead of SIGIO).

              If you set the O_ASYNC status flag on a file descriptor  (either
              by  providing  this  flag with the open(2) call, or by using the
              F_SETFL command of fcntl), a SIGIO signal is sent whenever input
              or output becomes possible on that file descriptor.

              The  process  or  process  group  to  receive  the signal can be
              selected by using the F_SETOWN command to  the  fcntl  function.
              If the file descriptor is a socket, this also selects the recip-
              ient of SIGURG signals that are delivered when out-of-band  data
              arrives  on that socket.  (SIGURG is sent in any situation where
              select(2) would report the socket as having an "exceptional con-
              dition".)   If  the  file  descriptor  corresponds to a terminal
              device, then SIGIO signals are sent to  the  foreground  process
              group of the terminal.

       F_GETSIG
              Get  the  signal  sent when input or output becomes possible.  A
              value of zero means SIGIO is sent.  Any other  value  (including
              SIGIO)  is  the signal sent instead, and in this case additional
              info is available  to  the  signal  handler  if  installed  with
              SA_SIGINFO.

       F_SETSIG
              Sets  the  signal sent when input or output becomes possible.  A
              value of zero means to send the default SIGIO signal.  Any other
              value  (including  SIGIO)  is the signal to send instead, and in
              this case additional info is available to the signal handler  if
              installed with SA_SIGINFO.

              By  using F_SETSIG with a non-zero value, and setting SA_SIGINFO
              for the signal handler  (see  sigaction(2)),  extra  information
              about  I/O events is passed to the handler in a siginfo_t struc-
              ture.  If the si_code field indicates the  source  is  SI_SIGIO,
              the  si_fd  field  gives the file descriptor associated with the
              event.  Otherwise, there is no indication which file descriptors
              are pending, and you should use the usual mechanisms (select(2),
              poll(2), read(2) with O_NONBLOCK set etc.)  to  determine  which
              file descriptors are available for I/O.

              By  selecting  a  POSIX.1b real time signal (value >= SIGRTMIN),
              multiple I/O events may be queued using the same signal numbers.
              (Queuing  is  dependent on available memory).  Extra information
              is available if SA_SIGINFO is set for  the  signal  handler,  as
              above.

       Using  these mechanisms, a program can implement fully asynchronous I/O
       without using select(2) or poll(2) most of the time.

       The use of O_ASYNC, F_GETOWN, F_SETOWN is specific to  BSD  and  Linux.
       F_GETSIG  and  F_SETSIG are Linux-specific.  POSIX has asynchronous I/O
       and the aio_sigevent structure to achieve  similar  things;  these  are
       also available in Linux as part of the GNU C Library (Glibc).


   Leases
       F_SETLEASE  and  F_GETLEASE (Linux 2.4 onwards) are used (respectively)
       to establish and retrieve the current setting of the calling  process's
       lease on the file referred to by fd.  A file lease provides a mechanism
       whereby the process holding the lease (the "lease holder") is  notified
       (via  delivery  of a signal) when another process (the "lease breaker")
       tries to open(2) or truncate(2) that file.

       F_SETLEASE
              Set or remove a file lease according to which of  the  following
              values is specified in the integer arg:


              F_RDLCK
                     Take out a read lease.  This will cause us to be notified
                     when another process opens the file for writing or  trun-
                     cates it.

              F_WRLCK
                     Take  out  a write lease.  This will cause us to be noti-
                     fied when another process opens the file (for reading  or
                     writing) or truncates it.  A write lease may be placed on
                     a file only if no other process currently  has  the  file
                     open.

              F_UNLCK
                     Remove our lease from the file.

       A process may hold only one type of lease on a file.

       Leases may only be taken out on regular files.  An unprivileged process
       may only take out a lease on a file whose UID matches the  file  system
       UID of the process.

       F_GETLEASE
              Indicates  what type of lease we hold on the file referred to by
              fd by returning either F_RDLCK, F_WRLCK, or F_UNLCK, indicating,
              respectively, that the calling process holds a read, a write, or
              no lease on the file.  (The third argument to fcntl()  is  omit-
              ted.)

       When  a  process (the "lease breaker") performs an open() or truncate()
       that conflicts with a lease established via F_SETLEASE, the system call
       is  blocked  by the kernel, unless the O_NONBLOCK flag was specified to
       open(), in which case the  system  call  will  return  with  the  error
       EWOULDBLOCK.  The kernel notifies the lease holder by sending it a sig-
       nal (SIGIO by default).  The lease holder should respond to receipt  of
       this  signal  by  doing whatever cleanup is required in preparation for
       the file to be accessed  by  another  process  (e.g.,  flushing  cached
       buffers)  and  then  either  remove or downgrade its lease.  A lease is
       removed by performing an F_SETLEASE command specifying arg as  F_UNLCK.
       If  we  currently hold a write lease on the file, and the lease breaker
       is opening the file for reading, then it is sufficient to downgrade the
       lease  to  a read lease.  This is done by performing an F_SETLEASE com-
       mand specifying arg as F_RDLCK.

       If the lease holder fails to downgrade or remove the lease  within  the
       number  of  seconds specified in /proc/sys/fs/lease-break-time then the
       kernel forcibly removes or downgrades the lease holder's lease.

       Once the lease has been voluntarily or forcibly removed or  downgraded,
       and  assuming  the lease breaker has not unblocked its system call, the
       kernel permits the lease breaker's system call to proceed.

       The default signal used to notify the lease holder is SIGIO,  but  this
       can  be  changed using the F_SETSIG command to fcntl ().  If a F_SETSIG
       command is performed (even one specifying SIGIO), and the  signal  han-
       dler  is  established using SA_SIGINFO, then the handler will receive a
       siginfo_t sructure as its second argument, and the si_fd field of  this
       argument  will  hold  the  descriptor  of the leased file that has been
       accessed by another process.  (This  is  useful  if  the  caller  holds
       leases against multiple files).

   File and directory change notification
       F_NOTIFY
              (Linux  2.4  onwards)  Provide  notification  when the directory
              referred to by fd or any  of  the  files  that  it  contains  is
              changed.   The events to be notified are specified in arg, which
              is a bit mask specified by ORing together zero or  more  of  the
              following bits:


              Bit         Description (event in directory)
              -------------------------------------------------------------
              DN_ACCESS   A file was accessed (read, pread, readv)
              DN_MODIFY   A file was modified (write, pwrite,
                          writev, truncate, ftruncate)
              DN_CREATE   A file was created (open, creat, mknod,
                          mkdir, link, symlink, rename)
              DN_DELETE   A file was unlinked (unlink, rename to
                          another directory, rmdir)
              DN_RENAME   A file was renamed within this
                          directory (rename)
              DN_ATTRIB   The attributes of a file were changed
                          (chown, chmod, utime[s])

              (In  order  to  obtain  these definitions, the _GNU_SOURCE macro
              must be defined before including <fcntl.h>.)

              Directory notifications are normally "one-shot", and the  appli-
              cation   must  re-register  to  receive  further  notifications.
              Alternatively, if DN_MULTISHOT is included in arg, then  notifi-
              cation will remain in effect until explicitly removed.

              A  series of F_NOTIFY requests is cumulative, with the events in
              arg being added to the set already monitored.  To disable  noti-
              fication  of all events, make an F_NOTIFY call specifying arg as
              0.

              Notification occurs via delivery of a signal.  The default  sig-
              nal is SIGIO, but this can be changed using the F_SETSIG command
              to fcntl().  In the latter case, the signal handler  receives  a
              siginfo_t  structure  as its second argument (if the handler was
              established using SA_SIGINFO) and the si_fd field of this struc-
              ture  contains the file descriptor which generated the notifica-
              tion (useful when establishing notification on multiple directo-
              ries).

              Especially  when using DN_MULTISHOT, a POSIX.1b real time signal
              should be used for notication, so  that  multiple  notifications
              can be queued.

RETURN VALUE
       For a successful call, the return value depends on the operation:

       F_DUPFD  The new descriptor.

       F_GETFD  Value of flag.

       F_GETFL  Value of flags.

       F_GETOWN Value of descriptor owner.

       F_GETSIG Value  of  signal sent when read or write becomes possible, or
                zero for traditional SIGIO behaviour.

       All other commands
                Zero.

       On error, -1 is returned, and errno is set appropriately.

ERRORS
       EACCES or EAGAIN
              Operation is prohibited by locks held by other  processes.   Or,
              operation  is prohibited because the file has been memory-mapped
              by another process.

       EBADF  fd is not an open file descriptor, or the command was F_SETLK or
              F_SETLKW  and  the  file descriptor open mode doesn't match with
              the type of lock requested.

       EDEADLK
              It was detected that the specified F_SETLKW command would  cause
              a deadlock.

       EFAULT lock is outside your accessible address space.

       EINTR  For  F_SETLKW,  the  command  was  interrupted by a signal.  For
              F_GETLK and F_SETLK, the command was  interrupted  by  a  signal
              before the lock was checked or acquired.  Most likely when lock-
              ing a remote file (e.g. locking over  NFS),  but  can  sometimes
              happen locally.

       EINVAL For  F_DUPFD,  arg  is  negative  or is greater than the maximum
              allowable value.  For F_SETSIG, arg is not an  allowable  signal
              number.

       EMFILE For  F_DUPFD, the process already has the maximum number of file
              descriptors open.

       ENOLCK Too many segment locks open, lock table is  full,  or  a  remote
              locking protocol failed (e.g. locking over NFS).

       EPERM  Attempted  to  clear  the  O_APPEND  flag on a file that has the
              append-only attribute set.

NOTES
       The errors returned by  dup2  are  different  from  those  returned  by
       F_DUPFD.

       Since  kernel  2.0,  there  is no interaction between the types of lock
       placed by flock(2) and fcntl(2).

       POSIX 1003.1-2001 allows l_len to be  negative.  (And  if  it  is,  the
       interval  described  by  the  lock covers bytes l_start+l_len up to and
       including l_start-1.)  This is supported by Linux  since  Linux  2.4.21
       and 2.5.49.

       Several systems have more fields in struct flock such as e.g.  l_sysid.
       Clearly, l_pid alone is not going to be  very  useful  if  the  process
       holding the lock may live on a different machine.


SEE ALSO
       dup2(2), flock(2), lockf(3), open(2), socket(2)
       See    also    locks.txt,    mandatory.txt,    and    dnotify.txt    in
       /usr/src/linux/Documentation.

----------------------------------------------------------------------------
148 fdatasync      - synchronize a file's in-core data with that on disk
----------------------------------------------------------------------------
  mov  eax,148
  mov  ebx,fd
  int  80h

       fdatasync copies all in-core parts of a file to disk, and waits  until  the
       device  reports  that all parts are on stable storage.  It does not update
       metadata stat information. It does  not  necessarily  ensure  that  the
       entry  in the directory containing the file has also reached disk.  For
       that an explicit fsync on the file descriptor of the directory is  also
       needed.

       fdatasync only flushes user data, not the
       meta data like the mtime or atime.


RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS
       EBADF  fd is not a valid file descriptor open for writing.

       EROFS, EINVAL
              fd  is  bound  to a special file which does not support synchro-
              nization.

       EIO    An error occurred during synchronization.

NOTES
       In case the hard disk has write cache enabled, the data may not  really
       be on permanent storage when fsync/fdatasync return.

       When  an  ext2  file  system is mounted with the sync option, directory
       entries are also implicitly synced by fsync.

       On kernels before 2.4, fsync on  big  files  can  be  inefficient.   An
       alternative might be to use the O_SYNC flag to open(2).

SEE ALSO
       bdflush(2), open(2), sync(2), mount(8), update(8), sync(8)


----------------------------------------------------------------------------
143 flock          - apply or remove an advisory lock on an open file
----------------------------------------------------------------------------
  mov  eax,143
  mov   ebx,fd
  mov   ecx,operation
  int   80h

       Apply or remove an advisory lock on the open file specified by fd.  The
       parameter operation is one of the following:


              LOCK_SH   Place a shared lock.  More than one process may hold a
                        shared lock for a given file at a given time.

              LOCK_EX   Place an exclusive lock.  Only one process may hold an
                        exclusive lock for a given file at a given time.

              LOCK_UN   Remove an existing lock held by this process.


       A call to flock() may block if an incompatible lock is held by  another
       process.   To  make  a non-blocking request, include LOCK_NB (by ORing)
       with any of the above operations.

       A single file may not simultaneously have  both  shared  and  exclusive
       locks.

       Locks  created  by  flock()  are  associated with a file, or, more pre-
       cisely, an open file table  entry.   This  means  that  duplicate  file
       descriptors  (created  by, for example, fork(2) or dup(2)) refer to the
       same lock, and this lock may be modified or released using any of these
       descriptors.   Furthermore,  the lock is released either by an explicit
       LOCK_UN operation on any of these duplicate descriptors,  or  when  all
       such descriptors have been closed.

       A  process  may  only  hold one type of lock (shared or exclusive) on a
       file.  Subsequent flock() calls on an already locked file will  convert
       an existing lock to the new lock mode.

       Locks created by flock() are preserved across an execve(2).

       A  shared  or  exclusive lock can be placed on a file regardless of the
       mode in which the file was opened.

RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS
       EWOULDBLOCK
              The file is locked and the LOCK_NB flag was selected.

       EBADF  fd is not a not an open file descriptor.

       EINTR  While  waiting  to  acquire  a lock, the call was interrupted by
              delivery of a signal caught by a handler.

       EINVAL operation is invalid.

       ENOLCK The kernel ran out of memory for allocating lock records.

CONFORMING TO
       4.4BSD (the flock(2) call first appeared  in  4.2BSD).   A  version  of
       flock(2),  possibly  implemented  in terms of fcntl(2), appears on most
       Unices.

NOTES
       flock(2) does not lock files over NFS.  Use fcntl(2) instead: that does
       work  over  NFS,  given  a  sufficiently  recent version of Linux and a
       server which supports locking.

       Since kernel 2.0, flock(2) is implemented as a system call in  its  own
       right  rather  than  being  emulated  in the GNU C library as a call to
       fcntl(2).  This yields true BSD  semantics:  there  is  no  interaction
       between the types of lock placed by flock(2) and fcntl(2), and flock(2)
       does not detect deadlock.

       flock(2) places advisory locks only; given suitable  permissions  on  a
       file,  a  process is free to ignore the use of flock(2) and perform I/O
       on the file.

       flock(2) and fcntl(2) locks have different semantics  with  respect  to
       forked processes and dup(2).

SEE ALSO
       open(2), close(2), dup(2), execve(2), fcntl(2), fork(2), lockf(3)

       There are also locks.txt and mandatory.txt in /usr/src/linux/Documenta-
       tion.

----------------------------------------------------------------------------
108 fstat          - get file status
----------------------------------------------------------------------------
  mov  eax,108  ; also obsolete function 028 exists
  mov  ebx.fd
  mov  ecx.buf
  int   80h

       fstat returns information about the specified file.

       returns a stat structure, which contains the following fields:

              struct stat {
                  dev_t         st_dev;      /* device */
                  ino_t         st_ino;      /* inode */
                  mode_t        st_mode;     /* protection */
                  nlink_t       st_nlink;    /* number of hard links */
                  uid_t         st_uid;      /* user ID of owner */
                  gid_t         st_gid;      /* group ID of owner */
                  dev_t         st_rdev;     /* device type (if inode device) */
                  off_t         st_size;     /* total size, in bytes */
                  blksize_t     st_blksize;  /* blocksize for filesystem I/O */
                  blkcnt_t      st_blocks;   /* number of blocks allocated */
                  time_t        st_atime;    /* time of last access */
                  time_t        st_mtime;    /* time of last modification */
                  time_t        st_ctime;    /* time of last status change */
              };

       The value st_size gives the size of the file (if it is a  regular  file
       or  a  symlink)  in  bytes.  The size of a symlink is the length of the
       pathname it contains, without trailing NUL.

       The value st_blocks gives the size of  the  file  in  512-byte  blocks.
       (This  may  be  smaller than st_size/512 e.g. when the file has holes.)
       The value st_blksize gives the "preferred" blocksize for efficient file
       system  I/O.  (Writing to a file in smaller chunks may cause an ineffi-
       cient read-modify-rewrite.)

       Not all of the Linux filesystems implement  all  of  the  time  fields.
       Some  file system types allow mounting in such a way that file accesses
       do not cause an  update  of  the  st_atime  field.  (See  `noatime'  in
       mount(8).)

       The  field  st_atime  is  changed  by file accesses, e.g. by execve(2),
       mknod(2), pipe(2), utime(2) and read(2)  (of  more  than  zero  bytes).
       Other routines, like mmap(2), may or may not update st_atime.

       The  field st_mtime is changed by file modifications, e.g. by mknod(2),
       truncate(2), utime(2) and write(2) (of more than  zero  bytes).   More-
       over, st_mtime of a directory is changed by the creation or deletion of
       files in that directory.  The st_mtime field is not changed for changes
       in owner, group, hard link count, or mode.

       The  field  st_ctime is changed by writing or by setting inode informa-
       tion (i.e., owner, group, link count, mode, etc.).

       The following POSIX macros are defined to check the file type:

              S_ISREG(m)  is it a regular file?

              S_ISDIR(m)  directory?

              S_ISCHR(m)  character device?

              S_ISBLK(m)  block device?

              S_ISFIFO(m) fifo?

              S_ISLNK(m)  symbolic link? (Not in POSIX.1-1996.)

              S_ISSOCK(m) socket? (Not in POSIX.1-1996.)

       The following flags are defined for the st_mode field:


       S_IFMT     0170000   bitmask for the file type bitfields
       S_IFSOCK   0140000   socket
       S_IFLNK    0120000   symbolic link
       S_IFREG    0100000   regular file
       S_IFBLK    0060000   block device
       S_IFDIR    0040000   directory
       S_IFCHR    0020000   character device
       S_IFIFO    0010000   fifo
       S_ISUID    0004000   set UID bit
       S_ISGID    0002000   set GID bit (see below)
       S_ISVTX    0001000   sticky bit (see below)
       S_IRWXU    00700     mask for file owner permissions
       S_IRUSR    00400     owner has read permission
       S_IWUSR    00200     owner has write permission
       S_IXUSR    00100     owner has execute permission
       S_IRWXG    00070     mask for group permissions
       S_IRGRP    00040     group has read permission
       S_IWGRP    00020     group has write permission
       S_IXGRP    00010     group has execute permission
       S_IRWXO    00007     mask for permissions for others (not in group)
       S_IROTH    00004     others have read permission
       S_IWOTH    00002     others have write permisson
       S_IXOTH    00001     others have execute permission

       The set GID bit (S_ISGID) has several special uses: For a directory  it
       indicates  that  BSD  semantics is to be used for that directory: files
       created there inherit their group ID from the directory, not  from  the
       effective  gid  of  the creating process, and directories created there
       will also get the S_ISGID bit set.  For a file that does not  have  the
       group  execution  bit (S_IXGRP) set, it indicates mandatory file/record
       locking.

       The `sticky' bit (S_ISVTX) on a directory means that  a  file  in  that
       directory  can  be renamed or deleted only by the owner of the file, by
       the owner of the directory, and by root.

RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS
       EBADF  filedes is bad.

       ENOENT A component of the path file_name does not exist, or the path is
              an empty string.

       ENOTDIR
              A component of the path is not a directory.

       ELOOP  Too many symbolic links encountered while traversing the path.

       EFAULT Bad address.

       EACCES Permission denied.

       ENOMEM Out of memory (i.e. kernel memory).

       ENAMETOOLONG
              File name too long.

SEE ALSO
       chmod(2), chown(2), readlink(2), utime(2)


----------------------------------------------------------------------------
100 fstatfs        - get file system statistics
----------------------------------------------------------------------------
  mov  eax,100
  mov  ebx.fd
  mov  ecx.buf
  int  80h

       The  function  statfs  returns information about a mounted file system.
       buf is a pointer to a statfs structure defined approximately as follows:

              struct statfs {
                 long    f_type;     /* type of filesystem (see below) */
                 long    f_bsize;    /* optimal transfer block size */
                 long    f_blocks;   /* total data blocks in file system */
                 long    f_bfree;    /* free blocks in fs */
                 long    f_bavail;   /* free blocks avail to non-superuser */
                 long    f_files;    /* total file nodes in file system */
                 long    f_ffree;    /* free file nodes in fs */
                 fsid_t  f_fsid;     /* file system id */
                 long    f_namelen;  /* maximum length of filenames */
              };

              File system types:

                 ADFS_SUPER_MAGIC      0xadf5
                 AFFS_SUPER_MAGIC      0xADFF
                 BEFS_SUPER_MAGIC      0x42465331
                 BFS_MAGIC             0x1BADFACE
                 CIFS_MAGIC_NUMBER     0xFF534D42
                 CODA_SUPER_MAGIC      0x73757245
                 COH_SUPER_MAGIC       0x012FF7B7
                 CRAMFS_MAGIC          0x28cd3d45
                 DEVFS_SUPER_MAGIC     0x1373
                 EFS_SUPER_MAGIC       0x00414A53
                 EXT_SUPER_MAGIC       0x137D
                 EXT2_OLD_SUPER_MAGIC  0xEF51
                 EXT2_SUPER_MAGIC      0xEF53
                 EXT3_SUPER_MAGIC      0xEF53
                 HFS_SUPER_MAGIC       0x4244
                 HPFS_SUPER_MAGIC      0xF995E849
                 HUGETLBFS_MAGIC       0x958458f6
                 ISOFS_SUPER_MAGIC     0x9660
                 JFFS2_SUPER_MAGIC     0x72b6
                 JFS_SUPER_MAGIC       0x3153464a
                 MINIX_SUPER_MAGIC     0x137F /* orig. minix */
                 MINIX_SUPER_MAGIC2    0x138F /* 30 char minix */
                 MINIX2_SUPER_MAGIC    0x2468 /* minix V2 */
                 MINIX2_SUPER_MAGIC2   0x2478 /* minix V2, 30 char names */
                 MSDOS_SUPER_MAGIC     0x4d44
                 NCP_SUPER_MAGIC       0x564c
                 NFS_SUPER_MAGIC       0x6969
                 NTFS_SB_MAGIC         0x5346544e
                 OPENPROM_SUPER_MAGIC  0x9fa1
                 PROC_SUPER_MAGIC      0x9fa0
                 QNX4_SUPER_MAGIC      0x002f
                 REISERFS_SUPER_MAGIC  0x52654973
                 ROMFS_MAGIC           0x7275
                 SMB_SUPER_MAGIC       0x517B
                 SYSV2_SUPER_MAGIC     0x012FF7B6
                 SYSV4_SUPER_MAGIC     0x012FF7B5
                 TMPFS_MAGIC           0x01021994
                 UDF_SUPER_MAGIC       0x15013346
                 UFS_MAGIC             0x00011954
                 USBDEVICE_SUPER_MAGIC 0x9fa2
                 VXFS_SUPER_MAGIC      0xa501FCF5
                 XENIX_SUPER_MAGIC     0x012FF7B4
                 XFS_SUPER_MAGIC       0x58465342
                 _XIAFS_SUPER_MAGIC    0x012FD16D

       Nobody knows what f_fsid is supposed to contain (but see below).

       Fields  that  are  undefined for a particular file system are set to 0.
       fstatfs returns the same information about an open file  referenced  by
       descriptor fd.

RETURN VALUE
       On  success,  zero is returned.  On error, -1 is returned, and errno is
       set appropriately.

ERRORS
       EBADF  (fstatfs) fd is not a valid open file descriptor.

       EACCES (statfs) Search permission is denied for a component of the path
              prefix of path.

       ELOOP  (statfs) Too many symbolic links were encountered in translating
              path.

       ENAMETOOLONG
              (statfs) path is too long.

       ENOENT (statfs) The file referred to by path does not exist.

       ENOTDIR
              (statfs) A component of the path prefix of path is not a  direc-
              tory.

       EFAULT buf or path points to an invalid address.

       EINTR  This call was interrupted by a signal.

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

       ENOMEM Insufficient kernel memory was available.

       ENOSYS The file system does not support this call.

       EOVERFLOW
              Some  values  were  too  large to be represented in the returned
              struct.

NOTES
       The kernel has system calls statfs,  fstatfs,  statfs64,  fstatfs64  to
       support this library call.

SEE ALSO
       stat(2), statvfs(2)

----------------------------------------------------------------------------
118 fsync          - synchronize  a file's complete in-core state with
----------------------------------------------------------------------------
  mov  eax,118
  mov  ebx,fd
  int  80h

       fsync copies all in-core parts of a file to disk, and waits  until  the
       device  reports  that all parts are on stable storage.  It also updates
       metadata stat information. It does  not  necessarily  ensure  that  the
       entry  in the directory containing the file has also reached disk.  For
       that an explicit fsync on the file descriptor of the directory is  also
       needed.

RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS
       EBADF  fd is not a valid file descriptor open for writing.

       EROFS, EINVAL
              fd  is  bound  to a special file which does not support synchro-
              nization.

       EIO    An error occurred during synchronization.

NOTES
       In case the hard disk has write cache enabled, the data may not  really
       be on permanent storage when fsync/fdatasync return.

       When  an  ext2  file  system is mounted with the sync option, directory
       entries are also implicitly synced by fsync.

       On kernels before 2.4, fsync on  big  files  can  be  inefficient.   An
       alternative might be to use the O_SYNC flag to open(2).

SEE ALSO
       bdflush(2), open(2), sync(2), mount(8), update(8), sync(8) fdatasync

----------------------------------------------------------------------------
 93 ftruncate      - truncate file to specified length
----------------------------------------------------------------------------
  mov  eax,093
  mov  ebx,fd
  mov  ecx,length
  int  80h

       The  ftruncate function causes the regular file
       referenced by fd to be truncated to a size of precisely  length
       bytes.

       If  the  file  previously  was larger than this size, the extra data is
       lost.  If the file previously was shorter,  it  is  extended,  and  the
       extended part reads as zero bytes.

       The file pointer is not changed.

       If  the  size changed, then the ctime and mtime fields for the file are
       updated, and suid and sgid mode bits may be cleared.

       With ftruncate, the file must be open for writing;

RETURN VALUE
       On  success,  zero is returned.  On error, -1 is returned, and errno is
       set appropriately.

ERRORS
       For truncate:

       EACCES Search permission is denied for a component of the path  prefix,
              or the named file is not writable by the user.

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

       EFBIG  The argument length is larger than the maximum file size. (XSI)

       EINTR  A signal was caught during execution.

       EINVAL The  argument length is negative or larger than the maximum file
              size.

       EIO    An I/O error occurred updating the inode.

       EISDIR The named file is a directory.

       ELOOP  Too many symbolic links  were  encountered  in  translating  the
              pathname.

       ENAMETOOLONG
              A  component of a pathname exceeded 255 characters, or an entire
              path name exceeded 1023 characters.

       ENOENT The named file does not exist.

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

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

       ETXTBSY
              The file is a pure procedure (shared text) file  that  is  being
              executed.

       For  ftruncate the same errors apply, but instead of things that can be
       wrong with path, we now have things that can be wrong with fd:

       EBADF  The fd is not a valid descriptor.

       EBADF or EINVAL
              The fd is not open for writing.

       EINVAL The fd does not reference a regular file.


SEE ALSO
       open(2) truncate


----------------------------------------------------------------------------
183 getcwd         - get current working directory
----------------------------------------------------------------------------
  mov  eax,183
  mov  ebx,buf
  mov  ecx,maxlen
  int  80h

       The  getcwd() function copies an absolute pathname of the current work-
       ing directory to the array pointed to by buf, which is of length  size.

       If  the  current  absolute path name would require a buffer longer than
       size elements, NULL is returned, and errno is set to ERANGE; an  appli-
       cation  should  check  for  this error, and allocate a larger buffer if
       necessary.

       If buf is NULL, the behaviour of getcwd() is undefined.

RETURN VALUE
       NULL on failure with errno set accordingly, and  buf  on  success.  The
       contents of the array pointed to by buf is undefined on error.

ERRORS
       EACCES Permission  to  read  or search a component of the file name was
              denied.

       EFAULT buf points to a bad address.

       EINVAL The size argument is zero and buf is not a null pointer.

       ENOENT The current working directory has been unlinked.

       ERANGE The size argument is less than the length of the working  direc-
              tory name.  You need to allocate a bigger array and try again.

       These functions are often used to save  the  location  of  the  current
       working directory for the purpose of returning to it later. Opening the
       current directory (".") and calling fchdir(2) to return  is  usually  a
       faster  and  more  reliable  alternative  when  sufficiently  many file
       descriptors are available, especially on platforms other than Linux.

SEE ALSO
       chdir(2), fchdir(2), open(2), unlink(2), free(3), malloc(3)


----------------------------------------------------------------------------
141 getdents       - get directory entries
----------------------------------------------------------------------------
  mov  eax,141
  mov  ebx,fd
  mov  ecx,dirp
  mov  edx,count
  int  80h

       The  system  call  getdents  reads  several  dirent structures from the
       directory pointed at by fd into the memory area  pointed  to  by  dirp.
       The parameter count is the size of the memory area.

       The dirent structure is declared as follows:

                  dirent struc
                  dd d_ino;                   /* inode number */
                  dd d_off;                   /* offset to next dirent */
                  dw d_reclen;    /* length of this dirent */
                  resb 256 d_name [NAME_MAX+1];   /* file name (null-terminated) */
                  endstruc

       d_ino  is an inode number.  d_off is the distance from the start of the
       directory to the start of the next dirent.  d_reclen  is  the  size  of
       this entire dirent.  d_name is a null-terminated file name.

       This call supersedes readdir(2).

RETURN VALUE
       On success, the number of bytes read is returned.  On end of directory,
       0 is returned.  On error, -1 is returned, and errno  is  set  appropri-
       ately.

ERRORS
       EBADF  Invalid file descriptor fd.

       EFAULT Argument points outside the calling process's address space.

       EINVAL Result buffer is too small.

       ENOENT No such directory.

       ENOTDIR
              File descriptor does not refer to a directory.

SEE ALSO
       readdir(2), readdir(3)


----------------------------------------------------------------------------
 16 lchown         - change ownership of a file
----------------------------------------------------------------------------
  mov   eax,016         ;lchown
  mov   ebx,filename
  mov   ecx,user
  mov   edx,group
  int   80h

       The  owner of the file specified by path is changed.  Only the
       super-user may change the owner of a file.  The owner  of  a  file  may
       change the group of the file to any group of which that owner is a mem-
       ber.  The super-user may change the group arbitrarily.

       If the owner or group is specified as -1, then that ID is not  changed.

       When  the  owner  or  group of an executable file are changed by a non-
       super-user, the S_ISUID and S_ISGID mode bits are cleared.  POSIX  does
       not  specify  whether this also should happen when root does the chown;
       the Linux behaviour depends on the kernel version.  In case of  a  non-
       group-executable  file  (with  clear S_IXGRP bit) the S_ISGID bit indi-
       cates mandatory locking, and is not cleared by a chown.


RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS
       Depending  on  the file system, other errors can be returned.  The more
       general errors for chown are listed below:


       EPERM  The effective UID does not match the owner of the file,  and  is
              not zero; or the owner or group were specified incorrectly.

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

       EFAULT path points outside your accessible address space.

       ENAMETOOLONG
              path is too long.

       ENOENT The file does not exist.

       ENOMEM Insufficient kernel memory was available.

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

       EACCES Search permission is denied on a component of the path prefix.

       ELOOP  Too many symbolic links were encountered in resolving path.

       The general errors for fchown are listed below:

       EBADF  The descriptor is not valid.

       ENOENT See above.

       EPERM  See above.

       EROFS  See above.

       EIO    A low-level I/O error occurred while modifying the inode.

NOTES
       In  versions of Linux prior to 2.1.81 (and distinct from 2.1.46), chown
       did not follow symbolic links.  Since Linux 2.1.81, chown  does  follow
       symbolic  links,  and  there  is a new system call lchown that does not
       follow symbolic links.  Since Linux 2.1.86, this new call (that has the
       same  semantics  as the old chown) has got the same syscall number, and
       chown got the newly introduced number.


RESTRICTIONS
       The  chown()  semantics  are  deliberately violated on NFS file systems
       which have UID mapping enabled.  Additionally,  the  semantics  of  all
       system  calls  which  access  the  file  contents are violated, because
       chown() may cause immediate access revocation on  already  open  files.
       Client  side  caching may lead to a delay between the time where owner-
       ship have been changed to allow access for a user and  the  time  where
       the file can actually be accessed by the user on other clients.

SEE ALSO
       chmod(2), flock(2) chown fchown
        
----------------------------------------------------------------------------
  9 link           - make a new name for a file
----------------------------------------------------------------------------
  mov  eax,009
  mov  ebx,oldname
  mov  ecx,newname
  int  80h

       link  creates  a  new  link  (also known as a hard link) to an existing
       file.

       If newpath exists it will not be overwritten.

       This new name may be used exactly as the old  one  for  any  operation;
       both names refer to the same file (and so have the same permissions and
       ownership) and it is impossible to tell which name was the  `original'.

RETURN VALUE
       On  success,  zero is returned.  On error, -1 is returned, and errno is
       set appropriately.

ERRORS
       EXDEV  oldpath and newpath are not on the same filesystem.

       EPERM  The filesystem containing oldpath and newpath does  not  support
              the creation of hard links.

       EFAULT oldpath or newpath points outside your accessible address space.

       EACCES Write access to the directory containing newpath is not  allowed
              for  the  process's  effective uid, or one of the directories in
              oldpath or newpath did not allow search (execute) permission.

       ENAMETOOLONG
              oldpath or newpath was too long.

       ENOENT A directory component in oldpath or newpath does not exist or is
              a dangling symbolic link.

       ENOTDIR
              A component used as a directory in oldpath or newpath is not, in
              fact, a directory.

       ENOMEM Insufficient kernel memory was available.

       EROFS  The file is on a read-only filesystem.

       EEXIST newpath already exists.

       EMLINK The file referred to by oldpath already has the  maximum  number
              of links to it.

       ELOOP  Too many symbolic links were encountered in resolving oldpath or
              newpath.

       ENOSPC The device containing the file has no room for the new directory
              entry.

       EPERM  oldpath is a directory.

       EIO    An I/O error occurred.

NOTES
       Hard links, as created by link, cannot span filesystems. Use symlink if
       this is required.

BUGS
       On NFS file systems, the return code may  be  wrong  in  case  the  NFS
       server  performs  the link creation and dies before it can say so.  Use
       stat(2) to find out if the link got created.

SEE ALSO
       symlink(2), unlink(2), rename(2), open(2), stat(2), ln(1)

----------------------------------------------------------------------------
140 llseek         - reposition read/write file offset
----------------------------------------------------------------------------
  fd dword 
  offset_high dword 
  offset_low dword 
  theResult linux.loff_t 
  whence:dword

  mov  eax,140
  mov  ebx,fd
  mov  ecx,offet_high
  mov  edx,offset_low
  mov  esi,theResult
  mov  edi,whence
  int  80h

       The  llseek  function repositions the offset of the file descriptor fd
       to (offset_high<<32) | offset_low bytes relative to  the  beginning  of
       the  file,  the  current  position in the file, or the end of the file,
       depending on whether whence is SEEK_SET, SEEK_CUR, or SEEK_END, respec-
       tively.  It returns the resulting file position in the argument result.


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

ERRORS
       EBADF  fd is not an open file descriptor.

       EINVAL whence is invalid.

       EFAULT Problem with copying results to user space.

CONFORMING TO
       This  function  is  Linux-specific,  and should not be used in programs
       intended to be portable.

SEE ALSO
       lseek(2)

----------------------------------------------------------------------------
 19 lseek          - reposition read/write file offset
----------------------------------------------------------------------------
  mov  eax,019
  mov  ebx,fd
  mov  ecx,offset
  mov  edx,origin
  int  80h

       The lseek function repositions the offset of the file descriptor fildes
       to the argument offset according to the directive whence as follows:

       SEEK_SET
              The offset is set to offset bytes.

       SEEK_CUR
              The offset is set to its current location plus offset bytes.

       SEEK_END
              The offset is set to the size of the file plus offset bytes.

       The lseek function allows the file offset to be set beyond the  end  of
       the existing end-of-file of the file (but this does not change the size
       of the file).  If data is later written at this point, subsequent reads
       of  the  data  in the gap return bytes of zeros (until data is actually
       written into the gap).

RETURN VALUE
       Upon successful completion, lseek returns the resulting offset location
       as  measured  in  bytes  from  the beginning of the file.  Otherwise, a
       value of (off_t)-1 is returned and errno is set to indicate the  error.

ERRORS
       EBADF  fildes is not an open file descriptor.

       ESPIPE fildes is associated with a pipe, socket, or FIFO.

       EINVAL whence  is  not  one  of  SEEK_SET,  SEEK_CUR,  SEEK_END, or the
              resulting file offset would be negative.

       EOVERFLOW
              The resulting file offset cannot be represented in an off_t.

RESTRICTIONS
       Some devices are incapable of seeking and POSIX does not specify  which
       devices must support it.

       Linux  specific  restrictions:  using  lseek  on  a  tty device returns
       ESPIPE.

SEE ALSO
       dup(2), fork(2), open(2), fseek(3)

----------------------------------------------------------------------------
107 lstat          - get file status
----------------------------------------------------------------------------
  mov  eax,107  ;also obsolete function 084 exists
  mov  ebx,filename
  mov  ecx,buf
  int  80h

       This function returns  information about the specified file. You do
       not need any access rights to the file to get this information but  you
       need  search rights to all directories named in the path leading to the
       file.

       lstat is identical to stat, except in the  case  of  a  symbolic  link,
       where the link itself is stat-ed, not the file that it refers to.

       lstat returns a stat structure, which contains the following fields:

              struct stat {
                  dev_t         st_dev;      /* device */
                  ino_t         st_ino;      /* inode */
                  mode_t        st_mode;     /* protection */
                  nlink_t       st_nlink;    /* number of hard links */
                  uid_t         st_uid;      /* user ID of owner */
                  gid_t         st_gid;      /* group ID of owner */
                  dev_t         st_rdev;     /* device type (if inode device) */
                  off_t         st_size;     /* total size, in bytes */
                  blksize_t     st_blksize;  /* blocksize for filesystem I/O */
                  blkcnt_t      st_blocks;   /* number of blocks allocated */
                  time_t        st_atime;    /* time of last access */
                  time_t        st_mtime;    /* time of last modification */
                  time_t        st_ctime;    /* time of last status change */
              };

       The value st_size gives the size of the file (if it is a  regular  file
       or  a  symlink)  in  bytes.  The size of a symlink is the length of the
       pathname it contains, without trailing NUL.

       The value st_blocks gives the size of  the  file  in  512-byte  blocks.
       (This  may  be  smaller than st_size/512 e.g. when the file has holes.)
       The value st_blksize gives the "preferred" blocksize for efficient file
       system  I/O.  (Writing to a file in smaller chunks may cause an ineffi-
       cient read-modify-rewrite.)

       Not all of the Linux filesystems implement  all  of  the  time  fields.
       Some  file system types allow mounting in such a way that file accesses
       do not cause an  update  of  the  st_atime  field.  (See  `noatime'  in
       mount(8).)

       The  field  st_atime  is  changed  by file accesses, e.g. by execve(2),
       mknod(2), pipe(2), utime(2) and read(2)  (of  more  than  zero  bytes).
       Other routines, like mmap(2), may or may not update st_atime.

       The  field st_mtime is changed by file modifications, e.g. by mknod(2),
       truncate(2), utime(2) and write(2) (of more than  zero  bytes).   More-
       over, st_mtime of a directory is changed by the creation or deletion of
       files in that directory.  The st_mtime field is not changed for changes
       in owner, group, hard link count, or mode.

       The  field  st_ctime is changed by writing or by setting inode informa-
       tion (i.e., owner, group, link count, mode, etc.).

       The following POSIX macros are defined to check the file type:

              S_ISREG(m)  is it a regular file?

              S_ISDIR(m)  directory?

              S_ISCHR(m)  character device?

              S_ISBLK(m)  block device?

              S_ISFIFO(m) fifo?

              S_ISLNK(m)  symbolic link? (Not in POSIX.1-1996.)

              S_ISSOCK(m) socket? (Not in POSIX.1-1996.)

       The following flags are defined for the st_mode field:


       S_IFMT     0170000   bitmask for the file type bitfields
       S_IFSOCK   0140000   socket
       S_IFLNK    0120000   symbolic link
       S_IFREG    0100000   regular file
       S_IFBLK    0060000   block device
       S_IFDIR    0040000   directory
       S_IFCHR    0020000   character device
       S_IFIFO    0010000   fifo
       S_ISUID    0004000   set UID bit
       S_ISGID    0002000   set GID bit (see below)
       S_ISVTX    0001000   sticky bit (see below)
       S_IRWXU    00700     mask for file owner permissions
       S_IRUSR    00400     owner has read permission
       S_IWUSR    00200     owner has write permission
       S_IXUSR    00100     owner has execute permission
       S_IRWXG    00070     mask for group permissions
       S_IRGRP    00040     group has read permission
       S_IWGRP    00020     group has write permission
       S_IXGRP    00010     group has execute permission
       S_IRWXO    00007     mask for permissions for others (not in group)
       S_IROTH    00004     others have read permission
       S_IWOTH    00002     others have write permisson
       S_IXOTH    00001     others have execute permission

       The set GID bit (S_ISGID) has several special uses: For a directory  it
       indicates  that  BSD  semantics is to be used for that directory: files
       created there inherit their group ID from the directory, not  from  the
       effective  gid  of  the creating process, and directories created there
       will also get the S_ISGID bit set.  For a file that does not  have  the
       group  execution  bit (S_IXGRP) set, it indicates mandatory file/record
       locking.

       The `sticky' bit (S_ISVTX) on a directory means that  a  file  in  that
       directory  can  be renamed or deleted only by the owner of the file, by
       the owner of the directory, and by root.

RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS
       EBADF  filedes is bad.

       ENOENT A component of the path file_name does not exist, or the path is
              an empty string.

       ENOTDIR
              A component of the path is not a directory.

       ELOOP  Too many symbolic links encountered while traversing the path.

       EFAULT Bad address.

       EACCES Permission denied.

       ENOMEM Out of memory (i.e. kernel memory).

       ENAMETOOLONG
              File name too long.

SEE ALSO
       chmod(2), chown(2), readlink(2), utime(2) stat fstat


----------------------------------------------------------------------------
 39 mkdir          - create a directory
----------------------------------------------------------------------------
  mov  eax,039
  mov  ebx,pathname
  mov  ecx,mode
  int  80h

       mkdir attempts to create a directory named pathname.

       The  parameter mode specifies the permissions to use. It is modified by
       the process's umask in the usual way: the permissions  of  the  created
       directory  are  (mode & ~umask & 0777).  Other mode bits of the created
       directory depend on the operating system.  For Linux, see below.

       The newly created directory will be owned by the effective uid  of  the
       process.  If the directory containing the file has the set group id bit
       set, or if the filesystem is mounted with BSD group semantics, the  new
       directory  will  inherit the group ownership from its parent; otherwise
       it will be owned by the effective gid of the process.

       If the parent directory has the set group id bit set then so  will  the
       newly created directory.


RETURN VALUE
       mkdir  returns  zero  on  success, or -1 if an error occurred (in which
       case, errno is set appropriately).

ERRORS
       EPERM  The filesystem containing pathname does not support the creation
              of directories.

       EEXIST pathname  already exists (not necessarily as a directory).  This
              includes the case where pathname is a symbolic link, dangling or
              not.

       EFAULT pathname points outside your accessible address space.

       EACCES The  parent  directory  does  not  allow write permission to the
              process, or one of the directories in  pathname  did  not  allow
              search (execute) permission.

       ENAMETOOLONG
              pathname was too long.

       ENOENT A  directory  component  in pathname does not exist or is a dan-
              gling symbolic link.

       ENOTDIR
              A component used as a directory in pathname is not, in  fact,  a
              directory.

       ENOMEM Insufficient kernel memory was available.

       EROFS  pathname refers to a file on a read-only filesystem.

       ELOOP  Too  many symbolic links were encountered in resolving pathname.

       ENOSPC The device containing pathname has no room for  the  new  direc-
              tory.

       ENOSPC The  new  directory  cannot  be  created because the user's disk
              quota is exhausted.

CONFORMING TO
       SVr4, POSIX, BSD, SYSV, X/OPEN.  SVr4 documents additional EIO, EMULTI-
       HOP and ENOLINK error conditions; POSIX.1 omits ELOOP.

NOTES
       Under  Linux  apart from the permission bits, only the S_ISVTX mode bit
       is honored. That is, under Linux the created  directory  actually  gets
       mode (mode & ~umask & 01777).  See also stat(2).

       There  are  many  infelicities in the protocol underlying NFS.  Some of
       these affect mkdir.

SEE ALSO
       mkdir(1), chmod(2), mknod(2), mount(2),  rmdir(2),  stat(2),  umask(2),
       unlink(2)


----------------------------------------------------------------------------
 14 mknod          - create a special or ordinary file
----------------------------------------------------------------------------
  mov  eax,014
  mov  ebx,filename
  mov  ecx,mode
  mov  edx,dev
  int  80h

       The  system  call mknod creates a filesystem node (file, device special
       file or named pipe) named pathname, with attributes specified  by  mode
       and dev.

       The mode argument specifies both the permissions to use and the type of
       node to be created.  It should be a combination (using bitwise  OR)  of
       one  of  the  file  types  listed below and the permissions for the new
       node.

       The permissions are modified by the process's umask in the  usual  way:
       the permissions of the created node are (mode & ~umask).

       The  file  type  must  be  one of S_IFREG, S_IFCHR, S_IFBLK, S_IFIFO or
       S_IFSOCK to specify a normal file (which will be created empty),  char-
       acter  special  file,  block  special  file, FIFO (named pipe), or Unix
       domain socket, respectively.  (Zero file type  is  equivalent  to  type
       S_IFREG.)

       If the file type is S_IFCHR or S_IFBLK then dev specifies the major and
       minor numbers of the newly created device special file; otherwise it is
       ignored.

       If pathname already exists, or is a symbolic link, this call fails with
       an EEXIST error.

       The newly created node will be  owned  by  the  effective  uid  of  the
       process.  If the directory containing the node has the set group id bit
       set, or if the filesystem is mounted with BSD group semantics, the  new
       node will inherit the group ownership from its parent directory; other-
       wise it will be owned by the effective gid of the process.

RETURN VALUE
       mknod returns zero on success, or -1 if an  error  occurred  (in  which
       case, errno is set appropriately).

ERRORS
       EPERM  mode  requested creation of something other than a regular file,
              FIFO (named pipe), or Unix domain socket, and the caller is  not
              the  superuser; also returned if the filesystem containing path-
              name does not support the type of node requested.

       EINVAL mode requested creation of something other than a  normal  file,
              device special file, FIFO or socket.

       EEXIST pathname already exists.

       EFAULT pathname points outside your accessible address space.

       EACCES The  parent  directory  does  not  allow write permission to the
              process, or one of the directories in  pathname  did  not  allow
              search (execute) permission.

       ENAMETOOLONG
              pathname was too long.

       ENOENT A  directory  component  in pathname does not exist or is a dan-
              gling symbolic link.

       ENOTDIR
              A component used as a directory in pathname is not, in  fact,  a
              directory.

       ENOMEM Insufficient kernel memory was available.

       EROFS  pathname refers to a file on a read-only filesystem.

       ELOOP  Too  many symbolic links were encountered in resolving pathname.

       ENOSPC The device containing pathname has no room for the new node.

       Under  Linux,  this  call  cannot  be  used to create directories.  One
       should make directories with mkdir, and FIFOs with mkfifo.

       There are many infelicities in the protocol underlying  NFS.   Some  of
       these affect mknod.

SEE ALSO
       fcntl(2),  mkdir(2), mount(2), socket(2), stat(2), umask(2), unlink(2),
       mkfifo(3)

----------------------------------------------------------------------------
 21 mount          - mount and unmount filesystems
----------------------------------------------------------------------------
  specialfile string
  dir string    
  filesystemtype string    
  new_flags dword
  data dword

  mov  eax,021
  mov  ebx,dev_name
  mov  ecx,dir_name
  mov  edx,theType
  mov  esi,new_flags
  mov  edi,data
  int  80h

       mount attaches the filesystem specified by source  (which  is  often  a
       device name, but can also be a directory name or a dummy) to the direc-
       tory specified by target.

       Only the super-user may mount and unmount filesystems.  Since Linux 2.4
       a single filesystem can be visible at multiple mount points, and multi-
       ple mounts can be stacked on the same mount point.

       Values  for  the  filesystemtype  argument  supported by the kernel are
       listed in /proc/filesystems (like  "minix",  "ext2",  "msdos",  "proc",
       "nfs",  "iso9660"  etc.).   Further types may become available when the
       appropriate modules are loaded.

       The mountflags argument may have the magic number  0xC0ED  (MS_MGC_VAL)
       in  the top 16 bits (this was required in kernel versions prior to 2.4,
       but is no longer required and ignored if specified), and various  mount
       flags   (as  defined  in  <linux/fs.h>  for  libc4  and  libc5  and  in
       <sys/mount.h> for glibc2) in the low order 16 bits:

       MS_BIND
              (Linux 2.4 onwards) Perform a bind mount, making  a  file  or  a
              directory subtree visible at another point within a file system.
              Bind mounts may cross file system boundaries and span  chroot(2)
              jails.   The  filesystemtype, mountflags, and data arguments are
              ignored.

       MS_DIRSYNC
              (Since Linux 2.5.19.)  Make directory changes on this file  sys-
              tem  synchronous.  (This property can be obtained for individual
              directories or subtrees using chattr(8).)

       MS_MANDLOCK
              Permit mandatory locking on files in this file system.   (Manda-
              tory  locking  must  still  be  enabled  on a per-file basis, as
              described in fcntl(2).)

       MS_MOVE
              Move a subtree.  source specifies an existing  mount  point  and
              target  specifies  the  new location.  The move is atomic: at no
              point is the subtree unmounted.  The filesystemtype, mountflags,
              and data arguments are ignored.

       MS_NOATIME
              Do not update access times for (all types of) files on this file
              system.

       MS_NODEV
              Do not allow access to devices (special files) on this file sys-
              tem.

       MS_NODIRATIME
              Do  not update access times for directories on this file system.

       MS_NOEXEC
              Do not allow programs to be executed from this file system.

       MS_NOSUID
              Do not honour set-UID and set-GID bits when  executing  programs
              from this file system.

       MS_RDONLY
              Mount file system read-only.

       MS_REMOUNT
              Remount  an  existing  mount.   This is allows you to change the
              mountflags and data of  an  existing  mount  without  having  to
              unmount  and  remount the file system.  source and target should
              be the same  values  specified  in  the  initial  mount()  call;
              filesystemtype is ignored.

       MS_SYNCHRONOUS
              Make  writes  on  this  file  system  synchronous (as though the
              O_SYNC flag to open(2) was specified for all file opens to  this
              file system).

       From  Linux  2.4  onwards, the MS_NODEV, MS_NOEXEC, and MS_NOSUID flags
       are settable on a per-mount point basis.

       The data argument is interpreted by the different file systems.   Typi-
       cally it is a string of comma-separated options understood by this file
       system.  See mount(8) for details of the  options  available  for  each
       filesystem type.

       Linux  2.1.116  added  the umount2() system call, which, like umount(),
       unmounts a target, but allows additional flags controlling  the  behav-
       iour of the operation:

       MNT_FORCE
              Force  unmount  even  if  busy.   (Since  2.1.116.  Only for NFS
              mounts.)

       MNT_DETACH
              Perform a lazy unmount: make the mount point unavailable for new
              accesses,  and actually perform the unmount when the mount point
              ceases to be busy. (Since 2.4.11.)

RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS
       The  error  values  given below result from filesystem type independent
       errors. Each filesystem type may have its own special  errors  and  its
       own special behavior.  See the kernel source code for details.


       EPERM  The user is not the super-user.

       ENODEV Filesystemtype not configured in the kernel.

       ENOTBLK
              Source is not a block device (and a device was required).

       EBUSY  Source is already mounted. Or, it cannot be remounted read-only,
              because it still holds files open for writing.  Or, it cannot be
              mounted  on target because target is still busy (it is the work-
              ing directory of some task, the mount point of  another  device,
              has open files, etc.).  Or, it could not be unmounted because it
              is busy.

       EINVAL Source had an invalid superblock.  Or, a remount was  attempted,
              while  source was not already mounted on target.  Or, a move was
              attempted, while source was not a mount point, or was '/'.   Or,
              an umount was attempted, while target was not a mount point.

       ENOTDIR
              The second argument, or a prefix of the first argument, is not a
              directory.

       EFAULT One of the pointer arguments points  outside  the  user  address
              space.

       ENOMEM The  kernel  could not allocate a free page to copy filenames or
              data into.

       ENAMETOOLONG
              A pathname was longer than MAXPATHLEN.

       ENOENT A pathname was empty or had a nonexistent component.

       ELOOP  Too many link encountered during  pathname  resolution.   Or,  a
              move was attempted, while target is a descendant of source.

       EACCES A component of a path was not searchable.
              Or, mounting a read-only filesystem was attempted without giving
              the MS_RDONLY flag.
              Or, the block device Source is located on a  filesystem  mounted
              with the MS_NODEV option.

       ENXIO  The major number of the block device source is out of range.

       EMFILE (In case no block device is required:) Table of dummy devices is
              full.

SEE ALSO
       mount(8), umount(8)

----------------------------------------------------------------------------
  5 open           - open and possibly create a file or device
----------------------------------------------------------------------------
  mov   eax,005         ;open
  mov   ebx,filename
  mov   ecx,flags
  mov   edx,mode
  int   80h


       The  open()  system  call  is  used  to  convert a pathname into a file
       descriptor (a small, non-negative integer for use in subsequent I/O  as
       with  read,  write,  etc.).   When  the  call  is  successful, the file
       descriptor returned will be the lowest file  descriptor  not  currently
       open  for  the  process.  This call creates a new open file, not shared
       with any other process.  (But shared  open  files  may  arise  via  the
       fork(2)  system  call.)   The new file descriptor is set to remain open
       across exec functions (see fcntl(2)).  The file offset is  set  to  the
       beginning of the file.

       The  parameter  flags  is  one  of  O_RDONLY,  O_WRONLY or O_RDWR which
       request opening the file read-only, write-only or  read/write,  respec-
       tively, bitwise-or'd with zero or more of the following:

       O_CREAT
              If  the file does not exist it will be created.  The owner (user
              ID) of the file is set to the effective user ID of the  process.
              The  group  ownership  (group ID) is set either to the effective
              group ID of the process or to the group ID of the parent  direc-
              tory  (depending  on  filesystem type and mount options, and the
              mode of the parent directory, see, e.g., the mount options  bsd-
              groups  and  sysvgroups  of the ext2 filesystem, as described in
              mount(8)).

       O_EXCL When used with O_CREAT, if the file  already  exists  it  is  an
              error  and  the open will fail. In this context, a symbolic link
              exists, regardless of where its points to.  O_EXCL is broken  on
              NFS file systems, programs which rely on it for performing lock-
              ing tasks will contain a race condition.  The solution for  per-
              forming  atomic  file  locking  using  a lockfile is to create a
              unique file on the same fs  (e.g.,  incorporating  hostname  and
              pid),  use  link(2)  to  make  a link to the lockfile. If link()
              returns 0, the lock is successful.  Otherwise,  use  stat(2)  on
              the  unique  file to check if its link count has increased to 2,
              in which case the lock is also successful.

       O_NOCTTY
              If pathname refers to a terminal device -- see tty(4) -- it will
              not  become  the  process's  controlling  terminal  even  if the
              process does not have one.

       O_TRUNC
              If the file already exists and is a regular file  and  the  open
              mode  allows  writing  (i.e.,  is O_RDWR or O_WRONLY) it will be
              truncated to length 0.  If the file is a FIFO or terminal device
              file,  the  O_TRUNC  flag  is  ignored.  Otherwise the effect of
              O_TRUNC is unspecified.

       O_APPEND
              The file is opened in append mode. Before each write,  the  file
              pointer  is positioned at the end of the file, as if with lseek.
              O_APPEND may lead to corrupted files on NFS file systems if more
              than  one  process  appends  data  to  a  file at once.  This is
              because NFS does not support appending to a file, so the  client
              kernel  has  to  simulate it, which can't be done without a race
              condition.

       O_NONBLOCK or O_NDELAY
              When possible, the file is opened in non-blocking mode.  Neither
              the  open  nor  any subsequent operations on the file descriptor
              which is returned will cause the calling process to  wait.   For
              the  handling  of  FIFOs  (named pipes), see also fifo(4).  This
              mode need not have any effect on files other than FIFOs.

       O_SYNC The file is opened  for  synchronous  I/O.  Any  writes  on  the
              resulting  file  descriptor will block the calling process until
              the data has been physically written to the underlying hardware.
              See RESTRICTIONS below, though.

       O_NOFOLLOW
              If  pathname is a symbolic link, then the open fails.  This is a
              FreeBSD extension, which was added to Linux in version  2.1.126.
              Symbolic  links in earlier components of the pathname will still
              be followed.  The headers from glibc 2.0.100 and later include a
              definition  of  this flag; kernels before 2.1.126 will ignore it
              if used.

       O_DIRECTORY
              If pathname is not a directory, cause the open  to  fail.   This
              flag is Linux-specific, and was added in kernel version 2.1.126,
              to avoid denial-of-service problems if opendir(3) is called on a
              FIFO  or  tape  device,  but  should  not be used outside of the
              implementation of opendir.

       O_DIRECT
              Try to minimize cache effects of the I/O to and from this  file.
              In  general  this  will degrade performance, but it is useful in
              special situations, such  as  when  applications  do  their  own
              caching.   File I/O is done directly to/from user space buffers.
              The I/O is synchronous, i.e., at the completion of  the  read(2)
              or  write(2) system call, data is guaranteed to have been trans-
              ferred.  Under Linux 2.4 transfer sizes, and  the  alignment  of
              user buffer and file offset must all be multiples of the logical
              block size of the file system.  Under  Linux  2.6  alignment  to
              512-byte boundaries suffices.
              A  semantically similar interface for block devices is described
              in raw(8).

       O_ASYNC
              Generate a signal (SIGIO by default, but this can be changed via
              fcntl(2))  when  input  or  output becomes possible on this file
              descriptor.  This  feature  is  only  available  for  terminals,
              pseudo-terminals, and sockets. See fcntl(2) for further details.

       O_LARGEFILE
              On 32-bit systems that support the  Large  Files  System,  allow
              files whose sizes cannot be represented in 31 bits to be opened.

       Some of these optional flags can be altered using fcntl after the  file
       has been opened.

       The  argument  mode specifies the permissions to use in case a new file
       is created. It is modified by the process's umask in the usual way: the
       permissions  of  the  created file are (mode & ~umask).  Note that this
       mode only applies to future accesses of the  newly  created  file;  the
       open  call  that  creates a read-only file may well return a read/write
       file descriptor.

       The following symbolic constants are provided for mode:

       S_IRWXU
              00700 user (file owner) has read, write and execute permission

       S_IRUSR (S_IREAD)
              00400 user has read permission

       S_IWUSR (S_IWRITE)
              00200 user has write permission

       S_IXUSR (S_IEXEC)
              00100 user has execute permission

       S_IRWXG
              00070 group has read, write and execute permission

       S_IRGRP
              00040 group has read permission

       S_IWGRP
              00020 group has write permission

       S_IXGRP
              00010 group has execute permission

       S_IRWXO
              00007 others have read, write and execute permission

       S_IROTH
              00004 others have read permission

       S_IWOTH
              00002 others have write permisson

       S_IXOTH
              00001 others have execute permission

       mode must be specified when O_CREAT is in the  flags,  and  is  ignored
       otherwise.

RETURN VALUE
       open returns the new  file  descriptor,   or  -1  if  an  error
       occurred  (in  which case, errno is set appropriately).  Note that open
       can open device special files, but  creat  cannot  create  them  -  use
       mknod(2) instead.

       On  NFS  file  systems with UID mapping enabled, open may return a file
       descriptor but e.g. read(2) requests are denied with EACCES.   This  is
       because  the  client performs open by checking the permissions, but UID
       mapping is performed by the server upon read and write requests.

       If the file is newly created, its atime, ctime, mtime fields are set to
       the  current  time, and so are the ctime and mtime fields of the parent
       directory.  Otherwise, if the file is modified because of  the  O_TRUNC
       flag, its ctime and mtime fields are set to the current time.


ERRORS
       EEXIST pathname already exists and O_CREAT and O_EXCL were used.

       EISDIR pathname refers to a directory and the access requested involved
              writing (that is, O_WRONLY or O_RDWR is set).

       EACCES The requested access to the file is not allowed, or one  of  the
              directories  in  pathname did not allow search (execute) permis-
              sion, or the file did not exist yet and write access to the par-
              ent directory is not allowed.

       ENAMETOOLONG
              pathname was too long.

       ENOENT O_CREAT  is  not  set  and the named file does not exist.  Or, a
              directory component in pathname does not exist or is a  dangling
              symbolic link.

       ENOTDIR
              A  component  used as a directory in pathname is not, in fact, a
              directory, or O_DIRECTORY was specified and pathname was  not  a
              directory.

       ENXIO  O_NONBLOCK  |  O_WRONLY  is set, the named file is a FIFO and no
              process has the file open for reading.  Or, the file is a device
              special file and no corresponding device exists.

       ENODEV pathname  refers  to  a device special file and no corresponding
              device exists.  (This is a Linux kernel bug - in this  situation
              ENXIO must be returned.)

       EROFS  pathname  refers  to  a file on a read-only filesystem and write
              access was requested.

       ETXTBSY
              pathname refers to an executable image which is currently  being
              executed and write access was requested.

       EFAULT pathname points outside your accessible address space.

       ELOOP  Too  many symbolic links were encountered in resolving pathname,
              or O_NOFOLLOW was specified but pathname was a symbolic link.

       ENOSPC pathname was to be created but the  device  containing  pathname
              has no room for the new file.

       ENOMEM Insufficient kernel memory was available.

       EMFILE The process already has the maximum number of files open.

       ENFILE The  limit  on  the total number of files open on the system has
              been reached.

NOTE
       Under Linux, the O_NONBLOCK flag indicates that one wants to  open  but
       does not necessarily have the intention to read or write.  This is typ-
       ically used to open devices in order to get a file descriptor  for  use
       with ioctl(2).

SEE ALSO
       read(2), write(2), fcntl(2),  close(2),  link(2),  mknod(2),  mount(2),
       stat(2), umask(2), unlink(2), socket(2), fopen(3), fifo(4) create


----------------------------------------------------------------------------
 42 pipe           - create pipe
----------------------------------------------------------------------------
  mov  eax,042
  mov  ebx,fd
  int  80h

       pipe  creates a pair of file descriptors, pointing to a pipe inode, and
       places them in the array pointed to  by  filedes.   filedes[0]  is  for
       reading, filedes[1] is for writing.

RETURN VALUE
       On  success,  zero is returned.  On error, -1 is returned, and errno is
       set appropriately.

ERRORS
       EMFILE Too many file descriptors are in use by the process.

       ENFILE The system file table is full.

       EFAULT filedes is not valid.

SEE ALSO
       read(2), write(2), fork(2), socketpair(2)


----------------------------------------------------------------------------
  3 read           - read from a file descriptor
----------------------------------------------------------------------------
  mov  eax,003
  mov  ebx,fd
  mov  ecx,buf
  mov  edx,count
  int  80h

       read()  attempts to read up to count bytes from file descriptor fd into
       the buffer starting at buf.

       If count is zero, read() returns zero and has  no  other  results.   If
       count is greater than SSIZE_MAX, the result is unspecified.


RETURN VALUE
       On success, the number of bytes read is returned (zero indicates end of
       file), and the file position is advanced by this number.  It is not  an
       error  if  this  number  is smaller than the number of bytes requested;
       this may happen for example because fewer bytes are actually  available
       right  now  (maybe  because we were close to end-of-file, or because we
       are reading from a pipe, or from a terminal),  or  because  read()  was
       interrupted  by  a  signal.  On error, -1 is returned, and errno is set
       appropriately. In this case it is left  unspecified  whether  the  file
       position (if any) changes.

ERRORS
       EINTR  The call was interrupted by a signal before any data was read.

       EAGAIN Non-blocking  I/O has been selected using O_NONBLOCK and no data
              was immediately available for reading.

       EIO    I/O error. This will happen for example when the process is in a
              background  process  group,  tries  to read from its controlling
              tty, and either it  is  ignoring  or  blocking  SIGTTIN  or  its
              process  group  is  orphaned.  It may also occur when there is a
              low-level I/O error while reading from a disk or tape.

       EISDIR fd refers to a directory.

       EBADF  fd is not a valid file descriptor or is not open for reading.

       EINVAL fd is attached to an object which is unsuitable for reading.

       EFAULT buf is outside your accessible address space.

       Other errors may occur, depending on the object connected to fd.  POSIX
       allows  a read that is interrupted after reading some data to return -1
       (with errno set to EINTR) or to return  the  number  of  bytes  already
       read.

RESTRICTIONS
       On NFS file systems, reading small amounts of data will only update the
       time stamp the first time, subsequent calls may not  do  so.   This  is
       caused  by  client  side attribute caching, because most if not all NFS
       clients leave atime updates to the server and client side reads  satis-
       fied from the client's cache will not cause atime updates on the server
       as there are no server side reads.  UNIX semantics can be  obtained  by
       disabling  client  side  attribute caching, but in most situations this
       will substantially increase server load and decrease performance.

       Many filesystems and disks were considered to be fast enough  that  the
       implementation of O_NONBLOCK was deemed unneccesary. So, O_NONBLOCK may
       not be available on files and/or disks.

SEE ALSO
       close(2),  fcntl(2),  ioctl(2),  lseek(2),   readdir(2),   readlink(2),
       select(2), write(2), fread(3), readv(3)

----------------------------------------------------------------------------
 89 readdir        - read directory entry
----------------------------------------------------------------------------
       int readdir(unsigned int fd, struct dirent *dirp, unsigned int count);
   mov eax,89
   mov ebx,fd
   mov ecx,dirp ;ptr to structure   

       This is not the function you are interested in.  it is superseeded by
       getdents.

       readdir reads one dirent structure from the directory pointed at by  fd
       into  the  memory  area  pointed  to  by  dirp.  The parameter count is
       ignored; at most one dirent structure is read.

       The dirent structure is declared as follows:

              struct dirent
              {
                  long d_ino;                 /* inode number */
                  off_t d_off;                /* offset to this dirent */
                  unsigned short d_reclen;    /* length of this d_name */
                  char d_name [NAME_MAX+1];   /* file name (null-terminated) */
              }

       d_ino is an inode number.  d_off is the distance from the start of  the
       directory to this dirent.  d_reclen is the size of d_name, not counting
       the null terminator.  d_name is a null-terminated file name.


RETURN VALUE
       On success, 1 is returned.  On end of directory,  0  is  returned.   On
       error, -1 is returned, and errno is set appropriately.

ERRORS
       EBADF  Invalid file descriptor fd.

       EFAULT Argument points outside the calling process's address space.

       EINVAL Result buffer is too small.

       ENOENT No such directory.

       ENOTDIR
              File descriptor does not refer to a directory.

CONFORMING TO
       This system call is Linux specific.

SEE ALSO
       getdents(2), readdir(3)


----------------------------------------------------------------------------
 85 readlink       - read value of a symbolic link
----------------------------------------------------------------------------
  mov  eax,085
  mov  ebx,path
  mov  ecx,buf
  mov  edx,bufsize
  int  80h

       readlink  places  the  contents of the symbolic link path in the buffer
       buf, which has size bufsiz.  readlink does not append a  NUL  character
       to  buf.   It will truncate the contents (to a length of bufsiz charac-
       ters), in case the buffer is too small to hold all of the contents.

RETURN VALUE
       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 errno.

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

       EINVAL bufsiz is not positive.

       ENAMETOOLONG
              A pathname, or a component of a pathname, was too long.

       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.

       EINVAL The named file is not a symbolic link.

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

       EFAULT buf extends outside the process's allocated address space.

       ENOMEM Insufficient kernel memory was available.

CONFORMING TO
       X/OPEN, 4.4BSD (the readlink function call appeared in 4.2BSD).

SEE ALSO
       stat(2), lstat(2), symlink(2)


----------------------------------------------------------------------------
145 readv          - read data into multiple buffers
----------------------------------------------------------------------------
  mov  eax,145
  mov  ebx,fd
  mov  ecx,vector
  mov  edx,count
  int  80h

       The  readv()  function reads count blocks from the file associated with
       the file descriptor fd into the multiple buffers described by vector.

       The pointer vector points to a struct iovec defined in <sys/uio.h> as

          struct iovec {
              void *iov_base;   /* Starting address */
              size_t iov_len;   /* Number of bytes */
          };

       Buffers are processed in the order specified.

       The  readv()  function  works  just  like  read(2) except that multiple
       buffers are filled.


RETURN VALUE
       On  success, the readv() function returns the number of bytes read; the
       writev() function returns the number of bytes written.  On error, -1 is
       returned, and errno is set appropriately.

ERRORS
       The  errors  are  as  given for read(2) and write(2).  Additionally the
       following error is defined.

       EINVAL The sum of the iov_len values overflows an  ssize_t  value.  Or,
              the vector count count is zero or greater than MAX_IOVEC.

SEE ALSO
       read(2), write(2)

----------------------------------------------------------------------------
 38 rename         - change the name or location of a file
----------------------------------------------------------------------------
  mov  eax,038
  mov  ebx,oldpath
  mov  ecx,newpath
  int  80h

       rename renames a file, moving it between directories if required.

       Any  other  hard links to the file (as created using link(2)) are unaf-
       fected.

       If newpath already exists it will be atomically replaced (subject to  a
       few  conditions - see ERRORS below), so that there is no point at which
       another process attempting to access newpath will find it missing.

       If newpath exists but the operation fails for some reason rename  guar-
       antees to leave an instance of newpath in place.

       However, when overwriting there will probably be a window in which both
       oldpath and newpath refer to the file being renamed.

       If oldpath refers to a symbolic link the link is  renamed;  if  newpath
       refers to a symbolic link the link will be overwritten.

RETURN VALUE
       On  success,  zero is returned.  On error, -1 is returned, and errno is
       set appropriately.

ERRORS
       EISDIR newpath is an existing directory, but oldpath is  not  a  direc-
              tory.

       EXDEV  oldpath and newpath are not on the same filesystem.

       ENOTEMPTY or EEXIST
              newpath  is  a non-empty directory, i.e., contains entries other
              than "." and "..".

       EBUSY  The rename fails because oldpath or newpath is a directory  that
              is in use by some process (perhaps as current working directory,
              or as root directory, or because it was open for reading) or  is
              in  use  by  the  system (for example as mount point), while the
              system considers this an error.  (Note that there is no require-
              ment to return EBUSY in such cases - there is nothing wrong with
              doing the rename anyway - but it is allowed to return  EBUSY  if
              the system cannot otherwise handle such situations.)

       EINVAL The  new  pathname  contained a path prefix of the old, or, more
              generally, an attempt was made to make a directory  a  subdirec-
              tory of itself.

       EMLINK oldpath already has the maximum number of links to it, or it was
              a directory and the directory containing newpath has the maximum
              number of links.

       ENOTDIR
              A component used as a directory in oldpath or newpath is not, in
              fact, a directory.  Or, oldpath  is  a  directory,  and  newpath
              exists but is not a directory.

       EFAULT oldpath or newpath points outside your accessible address space.

       EACCES Write access to the directory containing oldpath or  newpath  is
              not  allowed  for  the  process's  effective  uid, or one of the
              directories in oldpath or newpath did not allow search (execute)
              permission,  or  oldpath was a directory and did not allow write
              permission (needed to update the ..  entry).

       EPERM or EACCES
              The directory containing oldpath has the sticky bit set and  the
              process's  effective  uid is neither that of root nor the uid of
              the file to be deleted nor that of the directory containing  it,
              or  newpath  is an existing file and the directory containing it
              has the sticky bit set and the process's effective uid  is  nei-
              ther  that  of  root  nor the uid of the file to be replaced nor
              that of the directory containing it, or the filesystem  contain-
              ing pathname does not support renaming of the type requested.

       ENAMETOOLONG
              oldpath or newpath was too long.

       ENOENT A  directory component in oldpath  or  newpath does not exist or
              is a dangling symbolic link.

       ENOMEM Insufficient kernel memory was available.

       EROFS  The file is on a read-only filesystem.

       ELOOP  Too many symbolic links were encountered in resolving oldpath or
              newpath.

       ENOSPC The device containing the file has no room for the new directory
              entry.

BUGS
       On NFS filesystems, you can not assume that if the operation failed the
       file was not renamed.  If the server does the rename operation and then
       crashes, the retransmitted RPC which will be processed when the  server
       is up again causes a failure.  The application is expected to deal with
       this.  See link(2) for a similar problem.

SEE ALSO
       link(2), unlink(2), symlink(2), mv(1)

----------------------------------------------------------------------------
 40 rmdir          - delete a directory
----------------------------------------------------------------------------
  mov  eax,040
  mov  ebx,pathname
  int  80h

       rmdir deletes a directory, which must be empty.

RETURN VALUE
       On  success,  zero is returned.  On error, -1 is returned, and errno is
       set appropriately.

ERRORS
       EPERM  The filesystem containing pathname does not support the  removal
              of directories.

       EFAULT pathname points outside your accessible address space.

       EACCES Write  access  to  the  directory  containing  pathname  was not
              allowed for the process's effective uid, or one of the  directo-
              ries in pathname did not allow search (execute) permission.

       EPERM  The  directory  containing pathname has the sticky-bit (S_ISVTX)
              set and the process's effective uid is neither the  uid  of  the
              file to be deleted nor that of the directory containing it.

       ENAMETOOLONG
              pathname was too long.

       ENOENT A  directory  component  in pathname does not exist or is a dan-
              gling symbolic link.

       ENOTDIR
              pathname, or a component used as a  directory  in  pathname,  is
              not, in fact, a directory.

       ENOTEMPTY
              pathname contains entries other than . and .. .

       EINVAL pathname has .  as last component.

       EBUSY  pathname  is  the current working directory or root directory of
              some process.

       ENOMEM Insufficient kernel memory was available.

       EROFS  pathname refers to a file on a read-only filesystem.

       ELOOP  Too many symbolic links were encountered in resolving  pathname.

SEE ALSO
       rename(2), mkdir(2), chdir(2), unlink(2), rmdir(1), rm(1)


----------------------------------------------------------------------------
187 sendfile       - transfer data between file descriptors
----------------------------------------------------------------------------
  mov  eax,187
  mov  ebx,out_fd
  mov  ecx,in_fd
  mov  edx,offset
  mov  esi,count
  int  80h

       This  call copies data between one file descriptor and another.  Either
       or both of these file descriptors  may  refer  to  a  socket  (but  see
       below).   in_fd  should  be  a  file  descriptor opened for reading and
       out_fd should be a descriptor opened for writing.  offset is a  pointer
       to  a variable holding the input file pointer position from which send-
       file() will start reading data.  When sendfile() returns, this variable
       will  be set to the offset of the byte following the last byte that was
       read.  count is the number of bytes to copy between file descriptors.

       Because this copying is done within the  kernel,  sendfile()  does  not
       need to spend time transferring data to and from user space.


NOTES
       Sendfile  does  not  modify the current file pointer of in_fd, but does
       for out_fd.

       If you plan to use sendfile for sending files to a TCP socket, but need
       to  send some header data in front of the file contents, please see the
       TCP_CORK option in tcp(7) to minimize the number of packets and to tune
       performance.

       Presently the descriptor from which data is read cannot correspond to a
       socket, it must correspond to a file which supports mmap()-like  opera-
       tions.


RETURN VALUE
       If  the  transfer was successful, the number of bytes written to out_fd
       is returned.  On error, -1 is returned, and errno is set appropriately.


ERRORS
       EBADF  The input file was not opened for reading or the output file was
              not opened for writing.

       EAGAIN Non-blocking I/O has been  selected  using  O_NONBLOCK  and  the
              write would block.

       EINVAL Descriptor is not valid or locked.

       ENOMEM Insufficient memory to read from in_fd.

       EIO    Unspecified error while reading from in_fd.

       EFAULT Bad address.

SEE ALSO
       socket(2), open(2)



----------------------------------------------------------------------------
106 stat           - get file status
----------------------------------------------------------------------------
  mov  eax,106  ;also obsolete funciton 018 exists
  mov   ebx,filename
  mov   ecx,buf
  int   80h

       These  functions  return  information about the specified file.  You do
       not need any access rights to the file to get this information but  you
       need  search rights to all directories named in the path leading to the
       file.

       stat stats the file pointed to by file_name and fills in buf.

       lstat is identical to stat, except in the  case  of  a  symbolic  link,
       where the link itself is stat-ed, not the file that it refers to.

       fstat  is  identical  to stat, only the open file pointed to by filedes
       (as returned by open(2)) is stat-ed in place of file_name.


       They all return a stat structure, which contains the following fields:

              struct stat {
                  dev_t         st_dev;      /* device */
                  ino_t         st_ino;      /* inode */
                  mode_t        st_mode;     /* protection */
                  nlink_t       st_nlink;    /* number of hard links */
                  uid_t         st_uid;      /* user ID of owner */
                  gid_t         st_gid;      /* group ID of owner */
                  dev_t         st_rdev;     /* device type (if inode device) */
                  off_t         st_size;     /* total size, in bytes */
                  blksize_t     st_blksize;  /* blocksize for filesystem I/O */
                  blkcnt_t      st_blocks;   /* number of blocks allocated */
                  time_t        st_atime;    /* time of last access */
                  time_t        st_mtime;    /* time of last modification */
                  time_t        st_ctime;    /* time of last status change */
              };

       The value st_size gives the size of the file (if it is a  regular  file
       or  a  symlink)  in  bytes.  The size of a symlink is the length of the
       pathname it contains, without trailing NUL.

       The value st_blocks gives the size of  the  file  in  512-byte  blocks.
       (This  may  be  smaller than st_size/512 e.g. when the file has holes.)
       The value st_blksize gives the "preferred" blocksize for efficient file
       system  I/O.  (Writing to a file in smaller chunks may cause an ineffi-
       cient read-modify-rewrite.)

       Not all of the Linux filesystems implement  all  of  the  time  fields.
       Some  file system types allow mounting in such a way that file accesses
       do not cause an  update  of  the  st_atime  field.  (See  `noatime'  in
       mount(8).)

       The  field  st_atime  is  changed  by file accesses, e.g. by execve(2),
       mknod(2), pipe(2), utime(2) and read(2)  (of  more  than  zero  bytes).
       Other routines, like mmap(2), may or may not update st_atime.

       The  field st_mtime is changed by file modifications, e.g. by mknod(2),
       truncate(2), utime(2) and write(2) (of more than  zero  bytes).   More-
       over, st_mtime of a directory is changed by the creation or deletion of
       files in that directory.  The st_mtime field is not changed for changes
       in owner, group, hard link count, or mode.

       The  field  st_ctime is changed by writing or by setting inode informa-
       tion (i.e., owner, group, link count, mode, etc.).

       The following POSIX macros are defined to check the file type:

              S_ISREG(m)  is it a regular file?

              S_ISDIR(m)  directory?

              S_ISCHR(m)  character device?

              S_ISBLK(m)  block device?

              S_ISFIFO(m) fifo?

              S_ISLNK(m)  symbolic link? (Not in POSIX.1-1996.)

              S_ISSOCK(m) socket? (Not in POSIX.1-1996.)

       The following flags are defined for the st_mode field:


       S_IFMT     0170000   bitmask for the file type bitfields
       S_IFSOCK   0140000   socket
       S_IFLNK    0120000   symbolic link
       S_IFREG    0100000   regular file
       S_IFBLK    0060000   block device
       S_IFDIR    0040000   directory
       S_IFCHR    0020000   character device
       S_IFIFO    0010000   fifo
       S_ISUID    0004000   set UID bit
       S_ISGID    0002000   set GID bit (see below)
       S_ISVTX    0001000   sticky bit (see below)
       S_IRWXU    00700     mask for file owner permissions
       S_IRUSR    00400     owner has read permission
       S_IWUSR    00200     owner has write permission
       S_IXUSR    00100     owner has execute permission
       S_IRWXG    00070     mask for group permissions
       S_IRGRP    00040     group has read permission
       S_IWGRP    00020     group has write permission
       S_IXGRP    00010     group has execute permission
       S_IRWXO    00007     mask for permissions for others (not in group)
       S_IROTH    00004     others have read permission
       S_IWOTH    00002     others have write permisson
       S_IXOTH    00001     others have execute permission

       The set GID bit (S_ISGID) has several special uses: For a directory  it
       indicates  that  BSD  semantics is to be used for that directory: files
       created there inherit their group ID from the directory, not  from  the
       effective  gid  of  the creating process, and directories created there
       will also get the S_ISGID bit set.  For a file that does not  have  the
       group  execution  bit (S_IXGRP) set, it indicates mandatory file/record
       locking.

       The `sticky' bit (S_ISVTX) on a directory means that  a  file  in  that
       directory  can  be renamed or deleted only by the owner of the file, by
       the owner of the directory, and by root.

RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS
       EBADF  filedes is bad.

       ENOENT A component of the path file_name does not exist, or the path is
              an empty string.

       ENOTDIR
              A component of the path is not a directory.

       ELOOP  Too many symbolic links encountered while traversing the path.

       EFAULT Bad address.

       EACCES Permission denied.

       ENOMEM Out of memory (i.e. kernel memory).

       ENAMETOOLONG
              File name too long.


SEE ALSO
       chmod(2), chown(2), readlink(2), utime(2) lstat fstat
  
----------------------------------------------------------------------------
 99 statfs         - get file system statistics
----------------------------------------------------------------------------
  mov  eax,098
  mov  ebx,path
  mov  ecx,buf
  int  80h

       The  function  statfs  returns information about a mounted file system.
       path is the path name of any file within the mounted  filesystem.   buf
       is a pointer to a statfs structure defined approximately as follows:

              struct statfs {
                 long    f_type;     /* type of filesystem (see below) */
                 long    f_bsize;    /* optimal transfer block size */
                 long    f_blocks;   /* total data blocks in file system */
                 long    f_bfree;    /* free blocks in fs */
                 long    f_bavail;   /* free blocks avail to non-superuser */
                 long    f_files;    /* total file nodes in file system */
                 long    f_ffree;    /* free file nodes in fs */
                 fsid_t  f_fsid;     /* file system id */
                 long    f_namelen;  /* maximum length of filenames */
              };

              File system types:

                 ADFS_SUPER_MAGIC      0xadf5
                 AFFS_SUPER_MAGIC      0xADFF
                 BEFS_SUPER_MAGIC      0x42465331
                 BFS_MAGIC             0x1BADFACE
                 CIFS_MAGIC_NUMBER     0xFF534D42
                 CODA_SUPER_MAGIC      0x73757245
                 COH_SUPER_MAGIC       0x012FF7B7
                 CRAMFS_MAGIC          0x28cd3d45
                 DEVFS_SUPER_MAGIC     0x1373
                 EFS_SUPER_MAGIC       0x00414A53
                 EXT_SUPER_MAGIC       0x137D
                 EXT2_OLD_SUPER_MAGIC  0xEF51
                 EXT2_SUPER_MAGIC      0xEF53
                 EXT3_SUPER_MAGIC      0xEF53
                 HFS_SUPER_MAGIC       0x4244
                 HPFS_SUPER_MAGIC      0xF995E849
                 HUGETLBFS_MAGIC       0x958458f6
                 ISOFS_SUPER_MAGIC     0x9660
                 JFFS2_SUPER_MAGIC     0x72b6
                 JFS_SUPER_MAGIC       0x3153464a
                 MINIX_SUPER_MAGIC     0x137F /* orig. minix */
                 MINIX_SUPER_MAGIC2    0x138F /* 30 char minix */
                 MINIX2_SUPER_MAGIC    0x2468 /* minix V2 */
                 MINIX2_SUPER_MAGIC2   0x2478 /* minix V2, 30 char names */
                 MSDOS_SUPER_MAGIC     0x4d44
                 NCP_SUPER_MAGIC       0x564c
                 NFS_SUPER_MAGIC       0x6969
                 NTFS_SB_MAGIC         0x5346544e
                 OPENPROM_SUPER_MAGIC  0x9fa1
                 PROC_SUPER_MAGIC      0x9fa0
                 QNX4_SUPER_MAGIC      0x002f
                 REISERFS_SUPER_MAGIC  0x52654973
                 ROMFS_MAGIC           0x7275
                 SMB_SUPER_MAGIC       0x517B
                 SYSV2_SUPER_MAGIC     0x012FF7B6
                 SYSV4_SUPER_MAGIC     0x012FF7B5
                 TMPFS_MAGIC           0x01021994
                 UDF_SUPER_MAGIC       0x15013346
                 UFS_MAGIC             0x00011954
                 USBDEVICE_SUPER_MAGIC 0x9fa2
                 VXFS_SUPER_MAGIC      0xa501FCF5
                 XENIX_SUPER_MAGIC     0x012FF7B4
                 XFS_SUPER_MAGIC       0x58465342
                 _XIAFS_SUPER_MAGIC    0x012FD16D

       Nobody knows what f_fsid is supposed to contain (but see below).

       Fields  that  are  undefined for a particular file system are set to 0.
       fstatfs returns the same information about an open file  referenced  by
       descriptor fd.

RETURN VALUE
       On  success,  zero is returned.  On error, -1 is returned, and errno is
       set appropriately.

ERRORS
       EBADF  (fstatfs) fd is not a valid open file descriptor.

       EACCES (statfs) Search permission is denied for a component of the path
              prefix of path.

       ELOOP  (statfs) Too many symbolic links were encountered in translating
              path.

       ENAMETOOLONG
              (statfs) path is too long.

       ENOENT (statfs) The file referred to by path does not exist.

       ENOTDIR
              (statfs) A component of the path prefix of path is not a  direc-
              tory.

       EFAULT buf or path points to an invalid address.

       EINTR  This call was interrupted by a signal.

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

       ENOMEM Insufficient kernel memory was available.

       ENOSYS The file system does not support this call.

       EOVERFLOW
              Some  values  were  too  large to be represented in the returned
              struct.



NOTES
       The kernel has system calls statfs,  fstatfs,  statfs64,  fstatfs64  to
       support this function.

SEE ALSO
       stat(2), statvfs(2)


----------------------------------------------------------------------------
115 swapoff        - stop swapping to file/device
----------------------------------------------------------------------------
  mov  eax,115
  mov  ebx,path
  int  80h

       swapoff stops swapping to the file or block device specified  by
       path.

RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS
       Many other errors can occur if path is not valid.

       EPERM  The  user  is  not  the  super-user,  or more than MAX_SWAPFILES
              (defined to be 8 in Linux 1.3.6) are in use.


SEE ALSO
       mkswap(8), swapon(8), swapoff(8)


----------------------------------------------------------------------------
 87 swapon         - start/stop swapping to file/device
----------------------------------------------------------------------------
  mov  eax,087
  mov  ebx,path
  mov  ecx,swapflags
  int  80h

       swapon  sets  the  swap  area  to the file or block device specified by
       path.  swapoff stops swapping to the file or block device specified  by
       path.

       swapon takes a swapflags argument.  If swapflags has the SWAP_FLAG_PRE-
       FER bit turned on, the new swap area will have a higher  priority  than
       default.  The priority is encoded as:

           (prio << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK

       These functions may only be used by the super-user.

PRIORITY
       Each  swap area has a priority, either high or low.  The default prior-
       ity is low.  Within the low-priority areas, newer areas are even  lower
       priority than older areas.

       All  priorities  set  with  swapflags  are  high-priority,  higher than
       default.  They may have any non-negative value chosen  by  the  caller.
       Higher numbers mean higher priority.

       Swap pages are allocated from areas in priority order, highest priority
       first.  For areas with different priorities, a higher-priority area  is
       exhausted  before  using  a  lower-priority area.  If two or more areas
       have the same priority, and it is the highest priority available, pages
       are allocated on a round-robin basis between them.

       As  of  Linux  1.3.6, the kernel usually follows these rules, but there
       are exceptions.

RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS
       Many other errors can occur if path is not valid.


       EPERM  The  user  is  not  the  super-user,  or more than MAX_SWAPFILES
              (defined to be 8 in Linux 1.3.6) are in use.

       EINVAL is returned if path exists, but is neither a regular path nor  a
              block device.

       ENOENT is returned if path does not exist.

       ENOMEM is returned if there is insufficient memory to start swapping.

CONFORMING TO
       These  functions  are Linux specific and should not be used in programs
       intended to be portable.  The second `swapflags'  argument  was  intro-
       duced in Linux 1.3.2.

NOTES
       The partition or path must be prepared with mkswap(8).

SEE ALSO
       mkswap(8), swapon(8), swapoff(8)


----------------------------------------------------------------------------
 83 symlink        - make a new name for a file
----------------------------------------------------------------------------
  mov  eax,083
  mov  ebx,oldpath
  mov  ecx,newpath
  int  80h

       symlink creates a symbolic link named newpath which contains the string
       oldpath.

       Symbolic links are interpreted at run-time as if the  contents  of  the
       link  had  been substituted into the path being followed to find a file
       or directory.

       Symbolic links may contain ..  path components, which (if used  at  the
       start of the link) refer to the parent directories of that in which the
       link resides.

       A symbolic link (also known as a soft link) may point  to  an  existing
       file  or  to  a nonexistent one; the latter case is known as a dangling
       link.

       The permissions of a symbolic link are  irrelevant;  the  ownership  is
       ignored  when following the link, but is checked when removal or renam-
       ing of the link is requested and the link is in a  directory  with  the
       sticky bit set.

       If newpath exists it will not be overwritten.

RETURN VALUE
       On  success,  zero is returned.  On error, -1 is returned, and errno is
       set appropriately.

ERRORS
       EPERM  The filesystem containing newpath does not support the  creation
              of symbolic links.

       EFAULT oldpath or newpath points outside your accessible address space.

       EACCES Write access to the directory containing newpath is not  allowed
              for  the  process's  effective uid, or one of the directories in
              newpath did not allow search (execute) permission.

       ENAMETOOLONG
              oldpath or newpath was too long.

       ENOENT A directory component in newpath does not exist or is a dangling
              symbolic link, or oldpath is the empty string.

       ENOTDIR
              A  component  used  as a directory in newpath is not, in fact, a
              directory.

       ENOMEM Insufficient kernel memory was available.

       EROFS  newpath is on a read-only filesystem.

       EEXIST newpath already exists.

       ELOOP  Too many symbolic links were encountered in resolving newpath.

       ENOSPC The device containing the file has no room for the new directory
              entry.

       EIO    An I/O error occurred.

NOTES
       No checking of oldpath is done.

       Deleting  the  name  referred  to by a symlink will actually delete the
       file (unless it also has other hard links). If this  behaviour  is  not
       desired, use link.

CONFORMING TO
       SVr4,  SVID,  POSIX,  BSD  4.3.   SVr4 documents additional error codes
       SVr4, SVID, BSD 4.3, X/OPEN.  SVr4  documents  additional  error  codes
       EDQUOT  and  ENOSYS.  See open(2) re multiple files with the same name,
       and NFS.

SEE ALSO
       readlink(2), link(2), unlink(2), rename(2), open(2), lstat(2), ln(1)



----------------------------------------------------------------------------
 36 sync           - commit buffer cache to disk
----------------------------------------------------------------------------
  mov  eax,036
  int  80h

       sync first commits inodes to buffers, and then buffers to disk.

ERRORS
       This function is always successful.

BUGS
       According  to the standard specification (e.g., SVID), sync() schedules
       the writes, but may return before the actual writing is done.  However,
       since  version  1.3.20  Linux does actually wait.  (This still does not
       guarantee data integrity: modern disks have large caches.)

SEE ALSO
       bdflush(2), fsync(2), fdatasync(2), update(8), sync(8)

----------------------------------------------------------------------------
 92 truncate       - truncate file to specified length
----------------------------------------------------------------------------
  mov  eax,092
  mov  ebx,path
  mov  ecx,length
  int  80h

       truncate  causes the regular file named by
       path to be truncated to a size of precisely length
       bytes.

       If  the  file  previously  was larger than this size, the extra data is
       lost.  If the file previously was shorter,  it  is  extended,  and  the
       extended part reads as zero bytes.

       The file pointer is not changed.

       If  the  size changed, then the ctime and mtime fields for the file are
       updated, and suid and sgid mode bits may be cleared.

       the file must be writable.

RETURN VALUE
       On  success,  zero is returned.  On error, -1 is returned, and errno is
       set appropriately.

ERRORS
       For truncate:

       EACCES Search permission is denied for a component of the path  prefix,
              or the named file is not writable by the user.

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

       EFBIG  The argument length is larger than the maximum file size. (XSI)

       EINTR  A signal was caught during execution.

       EINVAL The  argument length is negative or larger than the maximum file
              size.

       EIO    An I/O error occurred updating the inode.

       EISDIR The named file is a directory.

       ELOOP  Too many symbolic links  were  encountered  in  translating  the
              pathname.

       ENAMETOOLONG
              A  component of a pathname exceeded 255 characters, or an entire
              path name exceeded 1023 characters.

       ENOENT The named file does not exist.

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

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

       ETXTBSY
              The file is a pure procedure (shared text) file  that  is  being
              executed.

       For  ftruncate the same errors apply, but instead of things that can be
       wrong with path, we now have things that can be wrong with fd:

       EBADF  The fd is not a valid descriptor.

       EBADF or EINVAL
              The fd is not open for writing.

       EINVAL The fd does not reference a regular file.


SEE ALSO
       open(2) ftruncate

----------------------------------------------------------------------------
 60 umask          - set file creation mask
----------------------------------------------------------------------------
  mov  eax,060
  mov  ebx,mask
  int  80h

       umask sets the umask to mask & 0777.

       The  umask  is  used  by  open(2)  to set initial file permissions on a
       newly-created file.  Specifically, permissions in the umask are  turned
       off  from  the  mode  argument  to open(2) (so, for example, the common
       umask default value of 022 results in new files being created with per-
       missions  0666  &  ~022  = 0644 = rw-r--r-- in the usual case where the
       mode is specified as 0666).

RETURN VALUE
       This system call always succeeds and the previous value of the mask  is
       returned.

CONFORMING TO
       SVr4, SVID, POSIX, X/OPEN, BSD 4.3

SEE ALSO
       creat(2), open(2)


----------------------------------------------------------------------------
 22 umount         - mount and unmount filesystems
----------------------------------------------------------------------------
  specialfile string
  dir string
  filesystemtype string
  mountflags dword
  data dword

  mov  eax,052
  mov  ebx,specialfile
  mov  ecx,dir
  mov  edx,filesystemtype
  mov  esi,mountflags
  mov  edi,data
  int  80h

       umount and umount2 remove the attachment of  the  (topmost)  filesystem
       mounted on target.

       Only the super-user may mount and unmount filesystems.  Since Linux 2.4
       a single filesystem can be visible at multiple mount points, and multi-
       ple mounts can be stacked on the same mount point.

       Values  for  the  filesystemtype  argument  supported by the kernel are
       listed in /proc/filesystems (like  "minix",  "ext2",  "msdos",  "proc",
       "nfs",  "iso9660"  etc.).   Further types may become available when the
       appropriate modules are loaded.

       The mountflags argument may have the magic number  0xC0ED  (MS_MGC_VAL)
       in  the top 16 bits (this was required in kernel versions prior to 2.4,
       but is no longer required and ignored if specified), and various  mount
       flags   (as  defined  in  <linux/fs.h>  for  libc4  and  libc5  and  in
       <sys/mount.h> for glibc2) in the low order 16 bits:


       From  Linux  2.4  onwards, the MS_NODEV, MS_NOEXEC, and MS_NOSUID flags
       are settable on a per-mount point basis.

       The data argument is interpreted by the different file systems.   Typi-
       cally it is a string of comma-separated options understood by this file
       system.  See mount(8) for details of the  options  available  for  each
       filesystem type.

       Linux  2.1.116  added  the umount2() system call, which, like umount(),
       unmounts a target, but allows additional flags controlling  the  behav-
       iour of the operation:

       MNT_FORCE
              Force  unmount  even  if  busy.   (Since  2.1.116.  Only for NFS
              mounts.)

       MNT_DETACH
              Perform a lazy unmount: make the mount point unavailable for new
              accesses,  and actually perform the unmount when the mount point
              ceases to be busy. (Since 2.4.11.)

RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS
       The  error  values  given below result from filesystem type independent
       errors. Each filesystem type may have its own special  errors  and  its
       own special behavior.  See the kernel source code for details.


       EPERM  The user is not the super-user.

       ENODEV Filesystemtype not configured in the kernel.

       ENOTBLK
              Source is not a block device (and a device was required).

       EBUSY  Source is already mounted. Or, it cannot be remounted read-only,
              because it still holds files open for writing.  Or, it cannot be
              mounted  on target because target is still busy (it is the work-
              ing directory of some task, the mount point of  another  device,
              has open files, etc.).  Or, it could not be unmounted because it
              is busy.

       EINVAL Source had an invalid superblock.  Or, a remount was  attempted,
              while  source was not already mounted on target.  Or, a move was
              attempted, while source was not a mount point, or was '/'.   Or,
              an umount was attempted, while target was not a mount point.

       ENOTDIR
              The second argument, or a prefix of the first argument, is not a
              directory.

       EFAULT One of the pointer arguments points  outside  the  user  address
              space.

       ENOMEM The  kernel  could not allocate a free page to copy filenames or
              data into.

       ENAMETOOLONG
              A pathname was longer than MAXPATHLEN.

       ENOENT A pathname was empty or had a nonexistent component.

       ELOOP  Too many link encountered during  pathname  resolution.   Or,  a
              move was attempted, while target is a descendant of source.

       EACCES A component of a path was not searchable.
              Or, mounting a read-only filesystem was attempted without giving
              the MS_RDONLY flag.
              Or, the block device Source is located on a  filesystem  mounted
              with the MS_NODEV option.

       ENXIO  The major number of the block device source is out of range.

       EMFILE (In case no block device is required:) Table of dummy devices is
              full.


SEE ALSO
       mount(8), umount(8)


----------------------------------------------------------------------------
 52 umount2        - mount and unmount filesystems
----------------------------------------------------------------------------
  see umount above

----------------------------------------------------------------------------
 10 unlink         - delete a name and possibly the file it refers to
----------------------------------------------------------------------------
  mov  eax,10
  mov  ebx,pathname
  int  80h

       unlink  deletes  a  name from the filesystem. If that name was the last
       link to a file and no processes have the file open the file is  deleted
       and the space it was using is made available for reuse.

       If  the  name  was the last link to a file but any processes still have
       the file open the file will remain in existence  until  the  last  file
       descriptor referring to it is closed.

       If the name referred to a symbolic link the link is removed.

       If  the  name  referred  to a socket, fifo or device the name for it is
       removed but processes which have the object open may  continue  to  use
       it.

RETURN VALUE
       On  success,  zero is returned.  On error, -1 is returned, and errno is
       set appropriately.

ERRORS
       EACCES Write access to the directory containing pathname is not allowed
              for  the  process's  effective uid, or one of the directories in
              pathname did not allow search (execute) permission.

       EPERM or EACCES
              The directory containing pathname has the  sticky-bit  (S_ISVTX)
              set  and  the  process's effective uid is neither the uid of the
              file to be deleted nor that of the directory containing it.

       EPERM (Linux only)
              The filesystem does not allow unlinking of files.

       EPERM  The system does not allow unlinking of directories, or unlinking
              of  directories  requires  privileges  that  the current process
              doesn't have.  (This is the POSIX prescribed error return.)

       EISDIR pathname refers to a directory.  (This is  the  non-POSIX  value
              returned by Linux since 2.1.132.)

       EBUSY (not on Linux)
              The file pathname cannot be unlinked because it is being used by
              the system or another process and the  implementation  considers
              this an error.

       EFAULT pathname points outside your accessible address space.

       ENAMETOOLONG
              pathname was too long.

       ENOENT A component in pathname does not exist or is a dangling symbolic
              link, or pathname is empty.

       ENOTDIR
              A component used as a directory in pathname is not, in  fact,  a
              directory.

       ENOMEM Insufficient kernel memory was available.

       EROFS  pathname refers to a file on a read-only filesystem.

       ELOOP  Too  many  symbolic  links were encountered in translating path-
              name.

       EIO    An I/O error occurred.

BUGS
       Infelicities  in  the  protocol underlying NFS can cause the unexpected
       disappearance of files which are still being used.

SEE ALSO
       link(2), rename(2), open(2), rmdir(2), mknod(2), mkfifo(3),  remove(3),
       rm(1)


----------------------------------------------------------------------------
 62 ustat          - get file system statistics 
----------------------------------------------------------------------------
  mov  eax,062
  mov  ebx,dev
  mov  ecx,ubuf
  int  80h

       ustat returns information about a mounted file system.  dev is a device
       number identifying a device containing a mounted file system.  ubuf  is
       a pointer to a ustat structure that contains the following members:


              daddr_t f_tfree;                /* Total free blocks */
              ino_t   f_tinode;               /* Number of free inodes */
              char    f_fname[6];             /* Filsys name */
              char    f_fpack[6];             /* Filsys pack name */


       The  last two fields, f_fname and f_fpack, are not implemented and will
       always be filled with null characters.

RETURN VALUE
       On success, zero is returned and the ustat structure pointed to by ubuf
       will  be  filled in.  On error, -1 is returned, and errno is set appro-
       priately.

ERRORS
       EINVAL dev does not refer to a device containing a mounted file system.

       EFAULT ubuf points outside of your accessible address space.

       ENOSYS The  mounted file system referenced by dev does not support this
              operation, or any version of Linux before 1.3.16.

NOTES
       ustat  is deprecated and has only been provided for compatibility.  All
       new programs should use statfs(2) instead.

SEE ALSO
       statfs(2), stat(2)


----------------------------------------------------------------------------
 30 utime          - chg access and/or modification times
----------------------------------------------------------------------------
  mov  eax,030
  mov  ebx,filename
  mov  ecx,times
  int  80h

       utime  changes the access and modification times of the inode specified
       by filename to the actime and modtime fields of buf  respectively.   If
       buf is NULL, then the access and modification times of the file are set
       to the current time.  The utimbuf structure is:

              struct utimbuf {
                      time_t actime;  /* access time */
                      time_t modtime; /* modification time */
              };

       In the Linux DLL 4.4.1 libraries, utimes is just a wrapper  for  utime:
       tvp[0].tv_sec  is  actime,  and  tvp[1].tv_sec is modtime.  The timeval
       structure is:

              struct timeval {
                      long    tv_sec;         /* seconds */
                      long    tv_usec;        /* microseconds */
              };

RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS
       Other errors may occur.


       EACCES Permission to write the file is denied.

       ENOENT filename does not exist.

SEE ALSO
       stat(2)


----------------------------------------------------------------------------
  4 write          - write   - write to a file descriptor
----------------------------------------------------------------------------
  mov   eax,4
  mov   ebx,fd
  mov   ecx,buffer
  mov   edx,lenght
  int   80h

       write  writes  up  to  count  bytes  to the file referenced by the file
       descriptor fd from the buffer starting at buf.  POSIX requires  that  a
       read()  which  can  be  proved  to  occur  after a write() has returned
       returns the new data.  Note that not all file systems  are  POSIX  con-
       forming.

RETURN VALUE
       On  success,  the  number of bytes written are returned (zero indicates
       nothing was written).  On error, -1  is  returned,  and  errno  is  set
       appropriately.   If  count  is zero and the file descriptor refers to a
       regular file, 0 will be returned without causing any other effect.  For
       a special file, the results are not portable.

ERRORS
       EBADF  fd is not a valid file descriptor or is not open for writing.

       EINVAL fd is attached to an object which is unsuitable for writing.

       EFAULT buf is outside your accessible address space.

       EFBIG  An attempt was made to write a file that exceeds the implementa-
              tion-defined maximum file size or the process' file size  limit,
              or  to write at a position past than the maximum allowed offset.

       EPIPE  fd is connected to a pipe or socket whose reading end is closed.
              When  this  happens the writing process will also receive a SIG-
              PIPE signal.  (Thus, the write return value is seen only if  the
              program catches, blocks or ignores this signal.)

       EAGAIN Non-blocking  I/O  has  been  selected  using O_NONBLOCK and the
              write would block.

       EINTR  The call was interrupted by a signal before any data  was  writ-
              ten.

       ENOSPC The device containing the file referred to by fd has no room for
              the data.

       EIO    A low-level I/O error occurred while modifying the inode.

       Other errors may occur, depending on the object connected to fd.

CONFORMING TO
       SVr4, SVID, POSIX, X/OPEN, 4.3BSD.   SVr4  documents  additional  error
       conditions  EDEADLK,  ENOLCK,  ENOLNK,  ENOSR, ENXIO, or ERANGE.  Under
       SVr4 a write may be interrupted and return EINTR at any point, not just
       before any data is written.

NOTES
       A  successful  return  from write does not make any guarantee that data
       has been committed to disk.  In fact, on some buggy implementations, it
       does  not  even guarantee that space has successfully been reserved for
       the data.  The only way to be sure is to call fsync(2)  after  you  are
       done writing all your data.

SEE ALSO
       close(2),  fcntl(2),  fsync(2),  ioctl(2),  lseek(2), open(2), read(2),
       select(2), fwrite(3), writev(3)

----------------------------------------------------------------------------
146 writev         - read or write a vector
----------------------------------------------------------------------------
  mov  eax,146
  mov  ebx,fd
  mov  ecx,vector
  mov  edx,count
  int  80h

       The writev() function writes at most count blocks described  by  vector
       to the file associated with the file descriptor fd.

       The pointer vector points to a struct iovec defined in <sys/uio.h> as

          struct iovec {
              void *iov_base;   /* Starting address */
              size_t iov_len;   /* Number of bytes */
          };

       Buffers are processed in the order specified.

       The writev() function works just like  write(2)  except  that  multiple
       buffers are written out.


RETURN VALUE
       On  success, the readv() function returns the number of bytes read; the
       writev() function returns the number of bytes written.  On error, -1 is
       returned, and errno is set appropriately.

ERRORS
       The  errors  are  as  given for read(2) and write(2).  Additionally the
       following error is defined.

       EINVAL The sum of the iov_len values overflows an  ssize_t  value.  Or,
              the vector count count is zero or greater than MAX_IOVEC.

BUGS
       It is not advisable to mix calls to functions like readv() or writev(),
       which operate on file descriptors, with the functions  from  the  stdio
       library;  the results will be undefined and probably not what you want.

SEE ALSO
       read(2), write(2)

