1.\" Author: Juli Mallett <jmallett@FreeBSD.org> 2.\" Date: June 04, 2003 3.\" Description: 4.\" Manual page for libufs functions: 5.\" cgget(3) 6.\" cgput(3) 7.\" cgread(3) 8.\" cgread1(3) 9.\" cgwrite(3) 10.\" cgwrite1(3) 11.\" 12.\" This file is in the public domain. 13.\" 14.\" $FreeBSD$ 15.\" 16.Dd January 19, 2018 17.Dt CGREAD 3 18.Os 19.Sh NAME 20.Nm cgget , cgput , cgread , cgread1 , cgwrite , cgwrite1 21.Nd read/write cylinder groups of UFS disks 22.Sh LIBRARY 23.Lb libufs 24.Sh SYNOPSIS 25.In sys/param.h 26.In sys/mount.h 27.In ufs/ufs/ufsmount.h 28.In ufs/ufs/dinode.h 29.In ufs/ffs/fs.h 30.In libufs.h 31.Ft int 32.Fn cgget "struct uufsd *disk" "int cg" "struct cg *cgp" 33.Ft int 34.Fn cgput "struct uufsd *disk" "struct cg *cgp" 35.Ft int 36.Fn cgread "struct uufsd *disk" 37.Ft int 38.Fn cgread1 "struct uufsd *disk" "int cg" 39.Ft int 40.Fn cgwrite "struct uufsd *disk" 41.Ft int 42.Fn cgwrite1 "struct uufsd *disk" "int cg" 43.Sh DESCRIPTION 44The 45.Fn cgget , 46.Fn cgread , 47and 48.Fn cgread1 49functions provide cylinder group reads for 50.Xr libufs 3 51consumers. 52The 53.Fn cgput , 54.Fn cgwrite , 55and 56.Fn cgwrite1 57functions provide cylinder group writes for 58.Xr libufs 3 59consumers. 60.Pp 61The 62.Fn cgget 63function reads the cylinder group specified by 64.Fa cg 65into the buffer pointed to by 66.Fa cgp 67from the disk referenced by the user-land UFS-disk structure. 68The 69.Fn cgget 70function is the only cylinder group read function that is safe to use 71in threaded applications. 72.Pp 73The 74.Fn cgput 75function writes the cylinder group specified by 76.Va cgp 77to the disk referenced by the user-land UFS-disk structure. 78The 79.Fn cgput 80function is the only cylinder group write function that is safe to use 81in threaded applications. 82Note that the 83.Fn cgput 84function needs to be called only if the cylinder group has been 85modified and the on-disk copy needs to be updated. 86.Pp 87The 88.Fn cgread1 89function reads from the cylinder group specified by 90.Fa cg 91into the 92.Va d_cg 93cylinder-group structure in a user-land UFS-disk structure. 94It sets the 95.Va d_lcg 96field to the cylinder group number 97.Fa cg . 98.Pp 99The 100.Fn cgread 101function operates on sequential cylinder groups. 102Calling the 103.Fn cgread 104function is equivalent to calling 105.Fn cgread1 106with a cylinder group specifier equivalent to the value of the current 107.Va d_ccg 108field, and then incrementing the 109.Va d_ccg 110field. 111.Pp 112The 113.Fn cgwrite 114function stores on disk the cylinder group held in the 115.Va d_cg 116cylinder-group structure in a user-land UFS-disk structure. 117.Pp 118The 119.Fn cgwrite1 120function provides no additional functionality over the 121.Fn cgwrite 122function as there is only one place that a given cylinder group 123can correctly be written. 124If the caller gets the 125.Fa cg 126parameter wrong, the function fails with the error 127.Er EDOOFUS . 128This function remains only to provide backward compatibility. 129.Sh RETURN VALUES 130The 131.Fn cgread 132function returns 0 if there are no more cylinder groups to read, 1331 if there are more cylinder groups, and \-1 on error. 134The 135.Fn cgread1 136function returns 1 on success and \-1 on error. 137The other functions return 0 on success and \-1 on error. 138.Sh ERRORS 139The 140.Fn cgget , 141.Fn cgread , 142and 143.Fn cgread1 144functions may fail and set 145.Va errno 146for any of the errors specified for the library function 147.Xr bread 3 . 148.Pp 149The 150.Fn cgput , 151.Fn cgwrite , 152and 153.Fn cgwrite1 154functions may fail and set 155.Va errno 156for any of the errors specified for the library function 157.Xr bwrite 3 . 158Additionally the 159.Fn cgwrite1 160will return the 161.Er EDOOFUS 162error if the cylinder group specified does not match the 163cylinder group that it is requesting to write. 164.Sh SEE ALSO 165.Xr bread 3 , 166.Xr bwrite 3 , 167.Xr libufs 3 168.Sh HISTORY 169These functions first appeared as part of 170.Xr libufs 3 171in 172.Fx 5.1 . 173.Sh AUTHORS 174.An Juli Mallett Aq Mt jmallett@FreeBSD.org 175