xref: /freebsd/lib/libufs/sbread.3 (revision 834063202a16592e1ef5c3a9fbd04ca5f1df3ed0)
1.\" Author:	Juli Mallett <jmallett@FreeBSD.org>
2.\" Date:	June 04, 2003
3.\" Description:
4.\" 	Manual page for libufs functions:
5.\"		sbget(3)
6.\"		sbput(3)
7.\"		sbread(3)
8.\"		sbwrite(3)
9.\"
10.\" This file is in the public domain.
11.\"
12.\" $FreeBSD$
13.\"
14.Dd January 19, 2018
15.Dt SBREAD 3
16.Os
17.Sh NAME
18.Nm sbget , sbput , sbread , sbwrite
19.Nd read and write superblocks of a UFS file system
20.Sh LIBRARY
21.Lb libufs
22.Sh SYNOPSIS
23.In sys/param.h
24.In sys/mount.h
25.In ufs/ufs/ufsmount.h
26.In ufs/ufs/dinode.h
27.In ufs/ffs/fs.h
28.In libufs.h
29.Ft int
30.Fn sbget "int devfd" "struct fs **fsp" "off_t sblockloc"
31.Ft int
32.Fn sbput "int devfd" "struct fs *fs" "int numaltwrite"
33.Ft int
34.Fn sbread "struct uufsd *disk"
35.Ft int
36.Fn sbwrite "struct uufsd *disk" "int all"
37.Sh DESCRIPTION
38The
39.Fn sbget
40and
41.Fn sbread
42functions provide superblock reads for
43.Xr libufs 3
44consumers.
45The
46.Fn sbput
47and
48.Fn sbwrite
49functions provide superblock writes for
50.Xr libufs 3
51consumers.
52.Pp
53The
54.Fn sbget
55function first allocates a buffer to hold the superblock.
56Using the
57.Va devfd
58file descriptor that references the filesystem disk,
59.Fn sbget
60reads the superblock located at the byte offset specified by
61.Va sblockloc
62into the allocated buffer.
63If successful, it returns a pointer to the buffer containing the superblock in
64.Va fsp .
65The
66.Fn sbget
67function is safe to use in threaded applications.
68.Pp
69The
70.Fn sbput
71function writes the superblock specified by
72.Va fs
73to the location from which it was read on the disk referenced by the
74.Va devfd
75file descriptor.
76Additionally, the
77.Fn sbput
78function will update the first
79.Va numaltwrite
80alternate superblock locations.
81To update all the alternate superblocks,
82specify a
83.Va numaltwrite
84value of
85.Va fs->fs_ncg .
86The
87.Fn sbput
88function is safe to use in threaded applications.
89Note that the
90.Fn sbput
91function needs to be called only if the superblock has been
92modified and the on-disk copy needs to be updated.
93.Pp
94The
95.Fn sbread
96function reads the standard filesystem superblock into the
97.Va d_sb ,
98structure embedded in the given user-land UFS disk structure.
99.Pp
100The
101.Fn sbwrite
102function writes the superblock from the
103.Va d_sb ,
104structure embedded in the given user-land UFS disk structure
105to the location from which it was read.
106Additionally, the
107.Fn sbwrite
108function will write to all the alternate superblock locations if the
109.Fa all
110value is non-zero.
111.Sh RETURN VALUES
112.Rv -std sbget sbput sbread sbwrite
113.Sh ERRORS
114The
115.Fn sbget
116and
117.Fn sbread
118functions may fail and set
119.Va errno
120for any of the errors specified for the library function
121.Xr bread 3 .
122Additionally, it may follow the
123.Xr libufs 3
124error methodologies in situations where no usable superblock could be
125found.
126.Pp
127The
128.Fn sbput
129and
130.Fn sbwrite
131functions may fail and set
132.Va errno
133for any of the errors specified for the library function
134.Xr bwrite 3 .
135.Sh SEE ALSO
136.Xr bread 3 ,
137.Xr bwrite 3 ,
138.Xr libufs 3
139.Sh HISTORY
140These functions first appeared as part of
141.Xr libufs 3
142in
143.Fx 5.0 .
144.Sh AUTHORS
145.An Juli Mallett Aq Mt jmallett@FreeBSD.org
146