xref: /freebsd/lib/libufs/ufs_disk_close.3 (revision e9ac41698b2f322d55ccf9da50a3596edb2c1800)
1.\" Author:	Juli Mallett <jmallett@FreeBSD.org>
2.\" Date:	June 04, 2003
3.\" Description:
4.\" 	Manual page for libufs functions:
5.\"		ufs_disk_close(3)
6.\"		ufs_disk_fillout(3)
7.\"		ufs_disk_fillout_blank(3)
8.\"		ufs_disk_write(3)
9.\"
10.\" This file is in the public domain.
11.\"
12.Dd November 17, 2023
13.Dt UFS_DISK_CLOSE 3
14.Os
15.Sh NAME
16.Nm ufs_disk_close ,
17.Nm ufs_disk_fillout ,
18.Nm ufs_disk_fillout_blank ,
19.Nm ufs_disk_write
20.Nd open and close userland UFS disks
21.Sh LIBRARY
22.Lb libufs
23.Sh SYNOPSIS
24.In sys/param.h
25.In sys/mount.h
26.In ufs/ufs/ufsmount.h
27.In ufs/ufs/dinode.h
28.In ufs/ffs/fs.h
29.In libufs.h
30.Ft int
31.Fn ufs_disk_close "struct uufsd *disk"
32.Ft int
33.Fn ufs_disk_fillout "struct uufsd *disk" "const char *name"
34.Ft int
35.Fn ufs_disk_fillout_blank "struct uufsd *disk" "const char *name"
36.Ft int
37.Fn ufs_disk_write "struct uufsd *disk"
38.Sh DESCRIPTION
39The
40.Fn ufs_disk_close
41function closes a disk and frees internal memory related to it.
42It does not free the
43.Fa disk
44structure.
45.Pp
46The
47.Fn ufs_disk_fillout
48and
49.Fn ufs_disk_fillout_blank
50functions open a disk specified by
51.Fa name
52and populate the structure pointed to by
53.Fa disk .
54The structure referenced by the
55.Fa disk
56pointer must be aligned to at least the alignment specified by
57.Dv LIBUFS_ALIGN
58that is defined in the
59.Lb libufs.h
60header file.
61The disk is opened read-only.
62The specified
63.Fa name
64may be either a mountpoint, a device name or a filesystem image.
65The
66.Fn ufs_disk_fillout
67function assumes there is a valid superblock and will fail if not,
68whereas the
69.Fn ufs_disk_fillout_blank
70function makes no assumptions of that sort.
71.Pp
72The
73.Fn ufs_disk_write
74function attempts to re-open a disk as writable if it is not currently.
75.Sh ERRORS
76The function
77.Fn ufs_disk_close
78has no failure points.
79.Pp
80The function
81.Fn ufs_disk_fillout
82may fail for any of the reasons
83.Fn ufs_disk_fillout_blank
84might, as well as for any reason
85.Xr sbread 3
86might.
87.Pp
88The
89.Fn ufs_disk_fillout_blank
90may fail and set
91.Va errno
92for any of the errors specified for the library functions
93.Xr open 2 ,
94.Xr strdup 3 .
95Additionally, it may follow the
96.Xr libufs 3
97error methodologies in situations where no device could be found to
98open.
99.Pp
100The function
101.Fn ufs_disk_write
102may fail and set
103.Va errno
104for any of the errors specified for the library functions
105.Xr open 2
106and
107.Xr stat 2 .
108Namely, it will fail if the disk in question may not be written to.
109.Sh SEE ALSO
110.Xr open 2 ,
111.Xr getfsfile 3 ,
112.Xr libufs 3 ,
113.Xr sbread 3
114.Sh HISTORY
115These functions first appeared as part of
116.Xr libufs 3
117in
118.Fx 5.0 .
119.Sh AUTHORS
120.An Juli Mallett Aq Mt jmallett@FreeBSD.org
121