1 .\" Author: Juli Mallett <jmallett@FreeBSD.org> 2 .\" Date: June 04, 2003 3 .\" Description: 4 .\" Manual page for libufs functions: 5 .\" bread(3) 6 .\" bwrite(3) 7 .\" 8 .\" This file is in the public domain. 9 .\" 10 .Dd June 4, 2003 11 .Dt BREAD 3 12 .Os 13 .Sh NAME 14 .Nm bread , bwrite 15 .Nd read and write blocks of a UFS file system 16 .Sh LIBRARY 17 .Lb libufs 18 .Sh SYNOPSIS 19 .In sys/param.h 20 .In sys/mount.h 21 .In ufs/ufs/ufsmount.h 22 .In ufs/ufs/dinode.h 23 .In ufs/ffs/fs.h 24 .In libufs.h 25 .Ft ssize_t 26 .Fn bread "struct uufsd *disk" "ufs2_daddr_t blockno" "void *data" "size_t size" 27 .Ft ssize_t 28 .Fo bwrite 29 .Fa "struct uufsd *disk" "ufs2_daddr_t blockno" 30 .Fa "const void *data" "size_t size" 31 .Fc 32 .Ft int 33 .Fo berase 34 .Fa "struct uufsd *disk" "ufs2_daddr_t blockno" "ufs2_daddr_t size" 35 .Fc 36 .Sh DESCRIPTION 37 The 38 .Fn bread , 39 .Fn bwrite 40 and 41 .Fn berase 42 functions provide a block read, write and erase API for 43 .Xr libufs 3 44 consumers. 45 They operate on a userland UFS disk structure, and perform the read 46 and write at a given block address, which uses the current 47 .Va d_bsize 48 value of the structure. 49 .Sh RETURN VALUES 50 The 51 .Fn bread 52 and 53 .Fn bwrite 54 functions return the amount read or written, or \-1 in case of any error, 55 including short read. 56 .Pp 57 The 58 .Fn berase 59 function returns non-zero on error. 60 .Sh ERRORS 61 The function 62 .Fn bread 63 may fail and set 64 .Va errno 65 for any of the errors specified for the library functions 66 .Xr ufs_disk_write 3 67 or 68 .Xr pread 2 . 69 .Pp 70 The function 71 .Fn bwrite 72 may fail and set 73 .Va errno 74 for any of the errors specified for the library function 75 .Xr pwrite 2 . 76 .Pp 77 The function 78 .Fn berase 79 may fail and set 80 .Va errno 81 for any of the errors specified for the library function 82 .Xr ioctl 2 . 83 .Pp 84 Additionally all three functions may follow the 85 .Xr libufs 3 86 error methodologies in situations where the amount of data written 87 is not equal to the amount requested, or in case of a device error. 88 .Sh SEE ALSO 89 .Xr libufs 3 , 90 .Xr ufs_disk_write 3 91 .Sh HISTORY 92 These functions first appeared as part of 93 .Xr libufs 3 94 in 95 .Fx 5.0 . 96 .Sh AUTHORS 97 .An Juli Mallett Aq Mt jmallett@FreeBSD.org 98