CGREAD(3)
π CGREAD(3) β the cylinder group read/write glow-up
okay so bestie, welcome to the cgread(3) page β literally the whole cgget, cgput, cgread, cgread1, cgwrite, cgwrite1 situation. it's the read/write cylinder groups of UFS disks manual, and yes we're gonna get through all of it together, no cap. π¦
πΈ LIBRARY
UFS File System Access Library (libufs, -lufs) β that's the one, that's the vibe.
β¨ 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>
int
cgget(int devfd, struct fs *fs, int cg, struct cg *cgp);
int
cgput(int devfd, struct fs *fs, struct cg *cgp);
int
cgread(struct uufsd *disk);
int
cgread1(struct uufsd *disk, int cg);
int
cgwrite(struct uufsd *disk);
int
cgwrite1(struct uufsd *disk, int cg);
like, look at all those headers. iconic. π
π DESCRIPTION
so the tl;dr: cgget(), cgread(), and cgread1() are your cylinder group reads for libufs(3) consumers. and cgput(), cgwrite(), and cgwrite1() are your cylinder group writes for libufs(3) consumers. reads and writes, matching sets, we love to see it.
π§ the read girlies
cgget()β reads the cylinder group specified bycginto the buffer pointed to bycgp, from the filesystem described by thefssuperblock, using thedevfdfile descriptor that references the filesystem disk. and here's the main character fact:cgget()is the only cylinder group read function that is safe to use in threaded applications. periodt. π
π₯ the write girlies
cgput()β writes the cylinder group specified bycgpto the filesystem described by thefssuperblock, using thedevfdfile descriptor that references the filesystem disk. and same deal on the write side:cgput()is the only cylinder group write function that is safe to use in threaded applications. also lowkey important βcgput()only needs to be called if the cylinder group has been modified and the on-disk copy needs to be updated. don't do it for funsies. π
π«Ά the struct uufsd girlies
cgread1()β reads from the cylinder group specified bycginto thed_cgcylinder-group structure in a user-land UFS-disk structure. it sets thed_lcgfield to the cylinder group numbercg. slay, bookkeeping.cgread()β operates on sequential cylinder groups. callingcgread()is equivalent to callingcgread1()with a cylinder group specifier equivalent to the value of the currentd_ccgfield, and then incrementing thed_ccgfield. it's giving "one at a time, in order, no skipping." β¨cgwrite()β stores on disk the cylinder group held in thed_cgcylinder-group structure in a user-land UFS-disk structure. that's it, that's the whole job.cgwrite1()β provides no additional functionality overcgwrite(), because there is only one place that a given cylinder group can correctly be written. π and if the caller gets thecgparameter wrong? the function fails with the errorEDOOFUS. yeah.EDOOFUS. we're being so serious. this function remains only to provide backward compatibility β it's legacy, it's vintage, it's staying for the lore. π
β RETURN VALUES
pay attention bestie, the numbers are different per function:
cgread()β returns0if there are no more cylinder groups to read,1if there are more cylinder groups, and-1on error. three whole outcomes, main character energy.cgread1()β returns1on success and-1on error.- everything else (all the other functions) β returns
0on success and-1on error.
π ERRORS
cgget(),cgread(), andcgread1()may fail and seterrnofor any of the errors specified for the library functionbread(3).cgput(),cgwrite(), andcgwrite1()may fail and seterrnofor any of the errors specified for the library functionbwrite(3).
π¨ and additionally:cgwrite1()will return theEDOOFUSerror if the cylinder group specified does not match the cylinder group that it is requesting to write. so like, get thecgparameter right or getEDOOFUS'd. your call. πΈ
π SEE ALSO
bread(3), bwrite(3), libufs(3)
π HISTORY
these functions first appeared as part of libufs(3) in FreeBSD 5.1. ancient. legendary. still here.
π AUTHORS
- Juli Mallett
<jmallett@FreeBSD.org> - Marshall Kirk McKusick
<mckusick@FreeBSD.org>
okay that's the whole page, you ate that fr fr π this lil masterpiece comes to you from the Debian edition, dated September 2, 2020 β mwah, bye bestie! π§ββοΈβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms