---
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://new.carta.tech/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)](/newfs/8.md) and [dumpfs(8)](/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)](/berase/3.md), [bread(3)](/bread/3.md), [bwrite(3)](/bwrite/3.md), [cgget(3)](/cgget/3.md), [cgput(3)](/cgput/3.md), [cgread(3)](/cgread/3.md), [cgread1(3)](/cgread1/3.md), [cgwrite(3)](/cgwrite/3.md), [cgwrite1(3)](/cgwrite1/3.md), [getinode(3)](/getinode/3.md), [putinode(3)](/putinode/3.md), [sbget(3)](/sbget/3.md), [sbput(3)](/sbput/3.md), [sbread(3)](/sbread/3.md), [sbwrite(3)](/sbwrite/3.md), [ufs\_disk\_close(3)](/ufs_disk_close/3.md), [ufs\_disk\_fillout(3)](/ufs_disk_fillout/3.md), [ufs\_disk\_fillout\_blank(3)](/ufs_disk_fillout_blank/3.md), [ufs\_disk\_write(3)](/ufs_disk_write/3.md), [ffs(4)](/ffs/4.md)

## HISTORY

The [libufs(3)](/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*⟩.
