Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
SBREAD(3)		 BSD Library Functions Manual		     SBREAD(3)

NAME
     sbget, sbput, sbread, sbwrite -- read and write superblocks of a UFS file
     system

LIBRARY
     UFS File System Access Library (libufs, -lufs)

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
     sbget(int devfd, struct fs	**fsp, off_t sblockloc);

     int
     sbput(int devfd, struct fs	*fs, int numaltwrite);

     int
     sbread(struct uufsd *disk);

     int
     sbwrite(struct uufsd *disk, int all);

DESCRIPTION
     The sbget() and sbread() functions	provide	superblock reads for libufs(3)
     consumers.	 The sbput() and sbwrite() functions provide superblock	writes
     for libufs(3) consumers.

     The sbget() function first	allocates a buffer to hold the superblock.
     Using the devfd file descriptor that references the filesystem disk,
     sbget() reads the superblock located at the byte offset specified by
     sblockloc into the	allocated buffer.  If successful, it returns a pointer
     to	the buffer containing the superblock in	fsp.  The sbget() function is
     safe to use in threaded applications.

     The sbput() function writes the superblock	specified by fs	to the loca-
     tion from which it	was read on the	disk referenced	by the devfd file de-
     scriptor.	Additionally, the sbput() function will	update the first
     numaltwrite alternate superblock locations.  To update all	the alternate
     superblocks, specify a numaltwrite	value of fs-_fs_ncg.  The sbput()
     function is safe to use in	threaded applications.	Note that the sbput()
     function needs to be called only if the superblock	has been modified and
     the on-disk copy needs to be updated.

     The sbread() function reads the standard filesystem superblock into the
     d_sb, structure embedded in the given user-land UFS disk structure.

     The sbwrite() function writes the superblock from the d_sb, structure em-
     bedded in the given user-land UFS disk structure to the location from
     which it was read.	 Additionally, the sbwrite() function will write to
     all the alternate superblock locations if the all value is	non-zero.

RETURN VALUES
     The sbget(), sbput(), sbread(), and sbwrite() functions return the
     value 0 if	successful; otherwise the value	-1 is returned and the global
     variable errno is set to indicate the error.

ERRORS
     The sbget() and sbread() functions	may fail and set errno for any of the
     errors specified for the library function bread(3).  Additionally,	it may
     follow the	libufs(3) error	methodologies in situations where no usable
     superblock	could be found.

     The sbput() and sbwrite() functions may fail and set errno	for any	of the
     errors specified for the library function bwrite(3).

SEE ALSO
     bread(3), bwrite(3), libufs(3)

HISTORY
     These functions first appeared as part of libufs(3) in FreeBSD 5.0.

AUTHORS
     Juli Mallett <jmallett@FreeBSD.org>

BSD			       January 19, 2018				   BSD

NAME | LIBRARY | SYNOPSIS | DESCRIPTION | RETURN VALUES | ERRORS | SEE ALSO | HISTORY | AUTHORS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=sbget&sektion=3&manpath=FreeBSD+12.1-RELEASE+and+Ports>

home | help