---
name: "elftc_copyfile"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/elftc_copyfile"
---

# elftc\_copyfile(3)

convenience function to copy data

## NAME

**elftc\_copyfile** – convenience function to copy data

## LIBRARY

library “libelftc”

## SYNOPSIS

**#include \<libelftc.h\>**

*in*\

**elftc\_copyfile**(*int ifd*, *int ofd*);

## DESCRIPTION

The function **elftc\_copyfile**() copies the contents of the file referenced by argument *ifd* to the file referenced by argument *ofd*.

The argument *ifd* should contain a file descriptor opened for reading, with its file offset at the beginning of the file.

The argument *ofd* should contain a file descriptor opened for writing.

## RETURN VALUES

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

## ERRORS

The function **elftc\_copyfile**() may fail with any of the errors returned by [fstat(2)](/fstat/2.md), [mmap(2)](/mmap/2.md), [munmap(2)](/munmap/2.md), [read(2)](/read/2.md), [write(2)](/write/2.md), or [malloc(3)](/malloc/3.md).

## SEE ALSO

[fstat(2)](/fstat/2.md), [mmap(2)](/mmap/2.md), [munmap(2)](/munmap/2.md), [read(2)](/read/2.md), [write(2)](/write/2.md), [malloc(3)](/malloc/3.md)
