xref: /freebsd/share/man/man9/g_data.9 (revision 2e3507c25e42292b45a5482e116d278f5515d04d)
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.Dd March 30, 2020
26.Dt G_DATA 9
27.Os
28.Sh NAME
29.Nm g_read_data ,
30.Nm g_write_data
31.Nd "read/write data from/to GEOM consumer"
32.Sh SYNOPSIS
33.In geom/geom.h
34.Ft "void *"
35.Fo g_read_data
36.Fa "struct g_consumer *cp" "off_t offset" "off_t length" "int *error"
37.Fc
38.Ft int
39.Fo g_write_data
40.Fa "struct g_consumer *cp" "off_t offset" "void *ptr" "off_t length"
41.Fc
42.Sh DESCRIPTION
43The
44.Fn g_read_data
45function reads
46.Fa length
47bytes of data from the provider attached to consumer
48.Fa cp ,
49starting at offset
50.Fa offset .
51The buffer returned from
52.Fn g_read_data
53is allocated with
54.Fn g_malloc ,
55so it should be freed by the caller with
56.Fn g_free
57after use.
58If the operation fails, an error value will be stored in the
59.Fa error
60argument if it is not
61.Dv NULL .
62.Pp
63The
64.Fn g_write_data
65function writes
66.Fa length
67bytes of data from the buffer pointed to by
68.Fa ptr
69to the provider attached to consumer
70.Fa cp ,
71starting at offset
72.Fa offset .
73.Sh RESTRICTIONS/CONDITIONS
74The
75.Fa length
76argument
77should be a multiple of the provider's sectorsize
78and less than or equal to
79.Dv DFLTPHYS
80.Dv ( DFLTPHYS
81is defined in
82.In sys/param.h ) .
83.Pp
84The topology lock must not be held.
85.Sh RETURN VALUES
86The
87.Fn g_read_data
88function returns a pointer to a data buffer or
89.Dv NULL
90if an error occurred.
91In that case an error value is stored in the
92.Fa error
93argument unless it is
94.Dv NULL .
95.Pp
96The
97.Fn g_write_data
98function returns 0 if successful; otherwise an error code is returned.
99.Sh ERRORS
100Possible errors:
101.Bl -tag -width Er
102.It Bq Er EIO
103An I/O error occurred while reading from or writing to the consumer.
104.It Bq Er EINTEGRITY
105Corrupted data was detected while reading from the consumer.
106.El
107.Sh SEE ALSO
108.Xr geom 4 ,
109.Xr DECLARE_GEOM_CLASS 9 ,
110.Xr g_access 9 ,
111.Xr g_attach 9 ,
112.Xr g_bio 9 ,
113.Xr g_consumer 9 ,
114.Xr g_event 9 ,
115.Xr g_geom 9 ,
116.Xr g_provider 9 ,
117.Xr g_provider_by_name 9 ,
118.Xr g_wither_geom 9
119.Sh AUTHORS
120.An -nosplit
121This manual page was written by
122.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org .
123