---
name: "rfio_open"
section: "3"
platform: "linux"
package: "libdpm-dev"
version: "1.10.0-2+b3"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/rfio_open"
---

# rfio\_open(3)

opens a file

## NAME

rfio\_open - opens a file

## SYNOPSIS

**#include \<sys/types.h\>**\
 **#include "rfio\_api.h"**

**int rfio\_open (const char \****path***, int** *flags***, int** *mode***);**\

Under Linux, for large files:\
 **#define \_LARGEFILE64\_SOURCE**\
 **#include \<sys/types.h\>**\
 **#include "rfio\_api.h"**

**int rfio\_open64 (const char \****path***, int** *flags***, int** *mode***);**

For large files, under other systems:\
 **#include \<sys/types.h\>**\
 **#include "rfio\_api.h"**

**int rfio\_open64 (const char \****path***, int** *flags***, int** *mode***);**

## DESCRIPTION

**rfio\_open** opens the file whose name is the string pointed to by **path**, a character string containing the filename specification, and associates a FILE stream with it.\
 **flags** are formed by ORing the following values:

```

        O_RDONLY        Open for reading only
        O_WRONLY        Open for writing only
        O_RDWR          Open for reading and writing
        O_NDELAY        Do not block on open
        O_APPEND        Append on each write
        O_CREAT         Create file if it does not exist
        O_TRUNC         Truncate size to 0
        O_EXCL          Error if create and file exists
        O_LARGEFILE     When size can be superior to 2GB-1.
                        See NOTES
```

**mode** specifies the permission bits to be set if the file is created.

Opening a file with O\_APPEND set causes each write on the file to be appended to the end.  If O\_TRUNC is specified and the file exists, the file is truncated to zero length.  If O\_EXCL is set with O\_CREAT, then if the file already exists, the open returns an error.  This can be used to implement a simple exclusive access locking mechanism.  If O\_EXCL is set and the last component of the pathname is a symbolic link, the open will succeed even if the symbolic link points to an existing name.  If the O\_NDELAY flag is specified and the open call would result in the process being blocked for some reason (for example waiting for a carrier on a dial-up line), the open returns immediately. The first time the process attempts to perform IO on the open file, it will block (not currently implemented). On systems that support the Large Files, O\_LARGEFILE in rfio\_open allows files whose sizes cannot be represented in 31 bits to be opened.

## RETURN VALUE

If successful, returns a non-negative integer which may be used to refer to the file on subsequent **rfio\_write**, **rfio\_read** and **rfio\_close** calls. On failure, **rfio\_open** returns -1 and the error code is stored in serrno.

## ERRORS

- **ENOENT**

  The named file/directory does not exist or is a null pathname.

- **EACCES**

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

- **EBUSY**

  Device or resource busy. Happens if you try to open in write mode a LCG file that is in an active migration stream.

- **EFAULT**

  *path* is a NULL pointer.

- **ENOTDIR**

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

- **ENAMETOOLONG**

  The length of *path* exceeds **CA\_MAXPATHLEN** or the length of a *path* component exceeds **CA\_MAXNAMELEN**.

- **SENOSHOST**

  Host unknown.

- **SENOSSERV**

  Service unknown.

- **SECOMERR**

  Communication error.

## SEE ALSO

**[Castor\_limits(4)](/Castor_limits/4.md)**,**[rfio\_write(3)](/rfio_write/3.md)**,**[rfio\_read(3)](/rfio_read/3.md)**,**[rfio\_close(3)](/rfio_close/3.md)**

## NOTES

On Irix, Tru64 and IA64 the 64 bit mode is the default one, open and open64 are identical. The  *flag* O\_LARGEFILE is accepted on Irix and IA64 (where it has no effect) but not on Tru64. On all other platforms, rfio\_open with O\_LARGEFILE is equivalent to a call to rfio\_open64.

## AUTHOR

**LCG Grid Deployment** Team
