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