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

# libufs(3)

operate on UFS file systems from userland

## NAME

**libufs** – operate on UFS file systems from userland

## LIBRARY

library “libufs”

## SYNOPSIS

**#include \<sys/param.h\>**

**#include \<sys/mount.h\>**

**#include \<ufs/ufs/ufsmount.h\>**

**#include \<ufs/ufs/dinode.h\>**

**#include \<ufs/ffs/fs.h\>**

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

## DESCRIPTION

The **libufs** library and the functions it provides are used for implementing utilities which need to access a UFS file system at a low level from userland. Facilities provided are used to implement utilities such as [newfs(8)](/man/newfs/8.md) and [dumpfs(8)](/man/dumpfs/8.md). The **libufs** library is designed to be simple, and to provide functions that are traditionally useful to have.

A disk is represented as the type *struct uufsd* as defined in ⟨libufs.h⟩. The structure is filled out, operations are performed, and the disk is closed.

## ERRORS

Functions provided by **libufs** return -1 in every functional error situation. They also set the *d\_error* field of *struct uufsd* to a string describing the error.

## SEE ALSO

[berase(3)](/man/berase/3.md), [bread(3)](/man/bread/3.md), [bwrite(3)](/man/bwrite/3.md), [cgget(3)](/man/cgget/3.md), [cgput(3)](/man/cgput/3.md), [cgread(3)](/man/cgread/3.md), [cgread1(3)](/man/cgread1/3.md), [cgwrite(3)](/man/cgwrite/3.md), [cgwrite1(3)](/man/cgwrite1/3.md), [getinode(3)](/man/getinode/3.md), [putinode(3)](/man/putinode/3.md), [sbget(3)](/man/sbget/3.md), [sbput(3)](/man/sbput/3.md), [sbread(3)](/man/sbread/3.md), [sbwrite(3)](/man/sbwrite/3.md), [ufs\_disk\_close(3)](/man/ufs_disk_close/3.md), [ufs\_disk\_fillout(3)](/man/ufs_disk_fillout/3.md), [ufs\_disk\_fillout\_blank(3)](/man/ufs_disk_fillout_blank/3.md), [ufs\_disk\_write(3)](/man/ufs_disk_write/3.md), [ffs(4)](/man/ffs/4.md)

## HISTORY

The [libufs(3)](/man/libufs/3.md) library first appeared in FreeBSD 5.0.

## AUTHORS

Juli Mallett ⟨*jmallett@FreeBSD.org*⟩ Marshall Kirk McKusick ⟨*mckusick@FreeBSD.org*⟩

Additional design, feedback, and ideas were provided by Poul-Henning Kamp ⟨*phk@FreeBSD.org*⟩.
