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 sbread sbwrite 113The 114.Fn sbget 115and 116.Fn sbput 117functions return the value 0 if successful; 118otherwise they return one of the errors described below. 119.Sh ERRORS 120The errors returned by 121.Fn sbget 122and 123.Fn sbread 124include any of the errors specified for the library function 125.Xr bread 3 . 126Additionally, they may follow the 127.Xr libufs 3 128error methodologies in situations where no usable superblock could be 129found. 130.Pp 131The errors returned by 132.Fn sbput 133and 134.Fn sbwrite 135include any of the errors specified for the library function 136.Xr bwrite 3 . 137.Sh SEE ALSO 138.Xr bread 3 , 139.Xr bwrite 3 , 140.Xr libufs 3 141.Sh HISTORY 142These functions first appeared as part of 143.Xr libufs 3 144in 145.Fx 5.0 . 146.Sh AUTHORS 147.An Juli Mallett Aq Mt jmallett@FreeBSD.org 148