xref: /freebsd/share/man/man9/g_data.9 (revision ec0ea6efa1ad229d75c394c1a9b9cac33af2b1d3)
1.\"
2.\" Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
15.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
18.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd March 30, 2020
28.Dt G_DATA 9
29.Os
30.Sh NAME
31.Nm g_read_data ,
32.Nm g_write_data
33.Nd "read/write data from/to GEOM consumer"
34.Sh SYNOPSIS
35.In geom/geom.h
36.Ft "void *"
37.Fo g_read_data
38.Fa "struct g_consumer *cp" "off_t offset" "off_t length" "int *error"
39.Fc
40.Ft int
41.Fo g_write_data
42.Fa "struct g_consumer *cp" "off_t offset" "void *ptr" "off_t length"
43.Fc
44.Sh DESCRIPTION
45The
46.Fn g_read_data
47function reads
48.Fa length
49bytes of data from the provider attached to consumer
50.Fa cp ,
51starting at offset
52.Fa offset .
53The buffer returned from
54.Fn g_read_data
55is allocated with
56.Fn g_malloc ,
57so it should be freed by the caller with
58.Fn g_free
59after use.
60If the operation fails, an error value will be stored in the
61.Fa error
62argument if it is not
63.Dv NULL .
64.Pp
65The
66.Fn g_write_data
67function writes
68.Fa length
69bytes of data from the buffer pointed to by
70.Fa ptr
71to the provider attached to consumer
72.Fa cp ,
73starting at offset
74.Fa offset .
75.Sh RESTRICTIONS/CONDITIONS
76The
77.Fa length
78argument
79should be a multiple of the provider's sectorsize
80and less than or equal to
81.Dv DFLTPHYS
82.Dv ( DFLTPHYS
83is defined in
84.In sys/param.h ) .
85.Pp
86The topology lock must not be held.
87.Sh RETURN VALUES
88The
89.Fn g_read_data
90function returns a pointer to a data buffer or
91.Dv NULL
92if an error occurred.
93In that case an error value is stored in the
94.Fa error
95argument unless it is
96.Dv NULL .
97.Pp
98The
99.Fn g_write_data
100function returns 0 if successful; otherwise an error code is returned.
101.Sh ERRORS
102Possible errors:
103.Bl -tag -width Er
104.It Bq Er EIO
105An I/O error occurred while reading from or writing to the consumer.
106.It Bq Er EINTEGRITY
107Corrupted data was detected while reading from the consumer.
108.El
109.Sh SEE ALSO
110.Xr geom 4 ,
111.Xr DECLARE_GEOM_CLASS 9 ,
112.Xr g_access 9 ,
113.Xr g_attach 9 ,
114.Xr g_bio 9 ,
115.Xr g_consumer 9 ,
116.Xr g_event 9 ,
117.Xr g_geom 9 ,
118.Xr g_provider 9 ,
119.Xr g_provider_by_name 9 ,
120.Xr g_wither_geom 9
121.Sh AUTHORS
122.An -nosplit
123This manual page was written by
124.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org .
125