xref: /freebsd/lib/libufs/bread.3 (revision 2008043f386721d58158e37e0d7e50df8095942d)
1.\" Author:	Juli Mallett <jmallett@FreeBSD.org>
2.\" Date:	June 04, 2003
3.\" Description:
4.\" 	Manual page for libufs functions:
5.\"		bread(3)
6.\"		bwrite(3)
7.\"
8.\" This file is in the public domain.
9.\"
10.Dd June 4, 2003
11.Dt BREAD 3
12.Os
13.Sh NAME
14.Nm bread , bwrite
15.Nd read and write blocks of a UFS file system
16.Sh LIBRARY
17.Lb libufs
18.Sh SYNOPSIS
19.In sys/param.h
20.In sys/mount.h
21.In ufs/ufs/ufsmount.h
22.In ufs/ufs/dinode.h
23.In ufs/ffs/fs.h
24.In libufs.h
25.Ft ssize_t
26.Fn bread "struct uufsd *disk" "ufs2_daddr_t blockno" "void *data" "size_t size"
27.Ft ssize_t
28.Fo bwrite
29.Fa "struct uufsd *disk" "ufs2_daddr_t blockno"
30.Fa "const void *data" "size_t size"
31.Fc
32.Ft int
33.Fo berase
34.Fa "struct uufsd *disk" "ufs2_daddr_t blockno" "ufs2_daddr_t size"
35.Fc
36.Sh DESCRIPTION
37The
38.Fn bread ,
39.Fn bwrite
40and
41.Fn berase
42functions provide a block read, write and erase API for
43.Xr libufs 3
44consumers.
45They operate on a userland UFS disk structure, and perform the read
46and write at a given block address, which uses the current
47.Va d_bsize
48value of the structure.
49.Sh RETURN VALUES
50The
51.Fn bread
52and
53.Fn bwrite
54functions return the amount read or written, or \-1 in case of any error,
55including short read.
56.Pp
57The
58.Fn berase
59function returns non-zero on error.
60.Sh ERRORS
61The function
62.Fn bread
63may fail and set
64.Va errno
65for any of the errors specified for the library functions
66.Xr ufs_disk_write 3
67or
68.Xr pread 2 .
69.Pp
70The function
71.Fn bwrite
72may fail and set
73.Va errno
74for any of the errors specified for the library function
75.Xr pwrite 2 .
76.Pp
77The function
78.Fn berase
79may fail and set
80.Va errno
81for any of the errors specified for the library function
82.Xr ioctl 2 .
83.Pp
84Additionally all three functions may follow the
85.Xr libufs 3
86error methodologies in situations where the amount of data written
87is not equal to the amount requested, or in case of a device error.
88.Sh SEE ALSO
89.Xr libufs 3 ,
90.Xr ufs_disk_write 3
91.Sh HISTORY
92These functions first appeared as part of
93.Xr libufs 3
94in
95.Fx 5.0 .
96.Sh AUTHORS
97.An Juli Mallett Aq Mt jmallett@FreeBSD.org
98