fd_open

fd_open --  opens a file or device and assigns it a file descriptor.

Syntax

fd_open (name, mode)

		

Arguments

name

The name of a file, as a string.

mode

The mode for opening the file.

Returns

A non-negative integer representing the lowest numbered unused file descriptor if successful. If an error occurs, the function returns -1 and sets the errno.

Description

This function opens a file for reading and/or writing, and assigns it a file descriptor which is used as an argument by other functions such as fd_read and fd_write. The file that is opened could be a regular file, a directory, or a block or character device. Legal mode values are:

Any combination of the following flags may be bitwise OR-ed with the open mode to modify how the file is accessed:

If an error occurs -1 is returned and errno is set to one of the following:

Example

    Gamma> require_lisp("const/filesys");
    "/usr/cogent/lib/const/filesys.lsp"
    Gamma> ptr = fd_open("/fd/ttyp8",O_WRONLY);
    4
    Gamma> fd_write(ptr,"\nhello\n");
    7
    		

See Also

fd_close, fd_data_function, fd_eof_function, fd_read, fd_write ser_setup, Referencing Files

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.