]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - share/man/man9/g_data.9
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / share / man / man9 / g_data.9
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 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 .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
45 The
46 .Fn g_read_data
47 function reads
48 .Fa length
49 bytes of data from the provider attached to consumer
50 .Fa cp ,
51 starting at offset
52 .Fa offset .
53 The buffer returned from
54 .Fn g_read_data
55 is allocated with
56 .Fn g_malloc ,
57 so it should be freed by the caller with
58 .Fn g_free
59 after use.
60 If the operation fails, an error value will be stored in the
61 .Fa error
62 argument if it is not
63 .Dv NULL .
64 .Pp
65 The
66 .Fn g_write_data
67 function writes
68 .Fa length
69 bytes of data from the buffer pointed to by
70 .Fa ptr
71 to the provider attached to consumer
72 .Fa cp ,
73 starting at offset
74 .Fa offset .
75 .Sh RESTRICTIONS/CONDITIONS
76 The
77 .Fa length
78 argument
79 should be a multiple of the provider's sectorsize
80 and less than or equal to
81 .Dv DFLTPHYS
82 .Dv ( DFLTPHYS
83 is defined in
84 .In sys/param.h ) .
85 .Pp
86 The topology lock must not be held.
87 .Sh RETURN VALUES
88 The
89 .Fn g_read_data
90 function returns a pointer to a data buffer or
91 .Dv NULL
92 if an error occurred.
93 In that case an error value is stored in the
94 .Fa error
95 argument unless it is
96 .Dv NULL .
97 .Pp
98 The
99 .Fn g_write_data
100 function returns 0 if successful; otherwise an error code is returned.
101 .Sh ERRORS
102 Possible errors:
103 .Bl -tag -width Er
104 .It Bq Er EIO
105 An I/O error occurred while reading from or writing to 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
121 This manual page was written by
122 .An Pawel Jakub Dawidek Aq pjd@FreeBSD.org .