1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001 Silicon Graphics, Inc.
7 #ifndef _DMFSAPI_DMPORT_H
8 #define _DMFSAPI_DMPORT_H
14 /**************************************************************************
16 * DMF's use of DMAPI is based upon the X/Open document *
17 * Systems Management: Data Storage Managment (XDSM) API *
18 * dated February 1997. However, no implementation of DMAPI perfectly *
19 * matches the spec. Each implementation has some functions that it *
20 * didn't implement, non-standard functions that it added, differences *
21 * in function parameter types, return value types, number and order of *
22 * parameters, etc. There are also differences in the formats of some *
23 * of the DMAPI structures used by those functions. Finally, there are *
24 * many scalar values for which DMAPI assigned no particular size. For *
25 * example, a dm_fsid_t is 32 bits under Veritas and 64 bits under SGI. *
27 * To hide the differences as much as possible, this include file tries *
28 * to shoehorn each DMAPI implementation into the XDSM mold as much as *
29 * possible. Functions which are not compatible with the XDSM spec are *
30 * redefined using wrapper routines to make them conform to the spec. *
31 * Functions which were not implemented have stubs defined which return *
32 * ENOSYS (see file stubs.c for all wrappers and stubs). In dmport.h, *
33 * missing structures and scalers are defined, incompatible typedefs are *
36 * The goal is to reduce as much as possible the number of #ifdefs that *
37 * have to be added to DMF to handle specific DMAPI implementations. *
38 * Some #ifdefs may still be required because of semantic differences *
39 * between the XDSM spec definition and the actual implementation. *
41 * Following all the implementation-specific definitions, dmport.h *
42 * includes a complete set of prototypes for all functions that are part *
43 * of the XDSM specification. This is done as a double-check. Should *
44 * any of the actual implementations change, the compiler should tip us *
45 * off by complaining about imcompatible function redefinitions. *
47 **************************************************************************/
50 /* ---------------- Veritas-specific hack documentation -----------------
52 The following functions have no prototypes in the Veritas include file
53 <sys/dmapi/dmapi.h>. They do not link either.
55 extern int dm_handle_is_valid(void *, size_t);
58 The following functions have prototypes in <sys/dmapi/dmapi.h>, but
61 extern int dm_getall_disp(dm_sessid_t, size_t, void *, size_t *);
62 extern int dm_getall_dmattr(dm_sessid_t, void *, size_t,
63 dm_token_t, size_t, void *, size_t *);
66 The following functions have no prototypes in <sys/dmapi/dmapi.h> but do link.
68 extern int dm_obj_ref_hold(dm_sessid_t, dm_token_t, void *, size_t);
69 extern int dm_obj_ref_rele(dm_sessid_t, dm_token_t, void *, size_t);
70 extern int dm_obj_ref_query(dm_sessid_t, dm_token_t, void *, size_t);
73 The following Veritas prototypes are different in some way from the
74 spec prototypes, either in parameter types, return value types, or in
75 some semantic way. Look below to see the spec versions of the prototypes.
77 extern int dm_downgrade_right(dm_sessid_t, void *, size_t,
78 dm_token_t, int, dm_right_t);
79 extern int dm_get_config_events(void *, size_t, u_int,
80 dm_eventset_t *, u_int *);
81 extern int dm_get_events(dm_sessid_t, u_int, int, size_t, void *, size_t *);
82 extern int dm_get_mountinfo(dm_sessid_t, dm_token_t, void *, size_t,
83 size_t, void *, size_t *);
84 extern int dm_init_service(void);
85 extern int dm_make_handle(dev_t , long, long, void **, size_t *);
86 extern int dm_make_fshandle(dev_t , void **, size_t *);
87 extern dev_t dm_handle_to_dev(void *, size_t);
88 extern long dm_handle_to_fgen(void *, size_t);
89 extern long dm_handle_to_ino(void *, size_t);
90 extern int dm_pending(dm_sessid_t, void *, size_t, dm_token_t, int);
91 extern dm_ssize_t dm_read_invis(dm_sessid_t, void *, size_t,
92 dm_token_t, dm_off_t, dm_ssize_t, void *);
93 extern dm_ssize_t dm_write_invis(dm_sessid_t, void *, size_t,
94 dm_token_t, dm_off_t, dm_ssize_t, void *, int);
95 extern int dm_request_right(dm_sessid_t, void *, size_t,
96 dm_token_t, int, dm_right_t);
97 extern int dm_set_inherit(dm_sessid_t, void *, size_t,
98 dm_token_t, dm_attrname_t *, u_int);
99 extern int dm_set_return_ondestroy(dm_sessid_t, void *, size_t,
100 dm_token_t, dm_attrname_t *, int);
101 extern int dm_upgrade_right(dm_sessid_t, void *, size_t,
102 dm_token_t, int, dm_right_t);
103 extern int dm_set_region(dm_sessid_t, void *, size_t,
104 dm_token_t, u_int, dm_region_t *, u_int *);
105 extern dm_ssize_t dm_sync_by_handle(dm_sessid_t, void *, size_t, dm_token_t);
108 The following Veritas prototype exists in <sys/dmapi/dmapi.h> but
109 does not appear in the spec.
111 extern void dm_attach_event(dm_sessid_t, dm_token_t);
113 The following functions exist in the Veritas library libdmi.a, but have no
114 prototypes within <sys/dmapi/dmapi.h>. Their function is unknown.
116 dm_attach_event_nofork
125 -------------- end of Veritas-specific hack documentation --------------- */
129 #include <sys/types.h>
131 #include <sys/dmapi/dmapi.h>
133 /* Rename functions whose prototypes clash with the XDSM standard. (Library
134 routines map from XDSM functions back to Veritas functions.)
137 #define dm_downgrade_right xvfs_dm_downgrade_right
138 #define dm_fd_to_handle xvfs_dm_fd_to_handle
139 #define dm_get_events xvfs_dm_get_events
140 #define dm_get_mountinfo xvfs_dm_get_mountinfo
141 #define dm_handle_to_ino xvfs_dm_handle_to_ino
142 #define dm_init_service xvfs_dm_init_service
143 #define dm_make_fshandle xvfs_dm_make_fshandle
144 #define dm_make_handle xvfs_dm_make_handle
145 #define dm_path_to_fshandle xvfs_dm_path_to_fshandle
146 #define dm_path_to_handle xvfs_dm_path_to_handle
147 #define dm_pending xvfs_dm_pending
148 #define dm_read_invis xvfs_dm_read_invis
149 #define dm_write_invis xvfs_dm_write_invis
150 #define dm_request_right xvfs_dm_request_right
151 #define dm_set_inherit xvfs_dm_set_inherit
152 #define dm_set_region xvfs_dm_set_region
153 #define dm_sync_by_handle xvfs_dm_sync_by_handle
154 #define dm_upgrade_right xvfs_dm_upgrade_right
157 #define DM_ATTR_NAME_SIZE 8
158 #undef DM_ATTRNAME_SIZE
159 #define DM_VER_STR_CONTENTS "Veritas DMAPI V1.0"
161 #define DM_EV_WAIT 0x1
162 #define DM_RR_WAIT 0x1
165 #undef DM_EVENT_NOWAIT
167 #define DM_CONFIG_INHERIT_ATTRIBS (DM_CONFIG_LOCK_UPGRADE + 1)
168 #undef DM_CONFIG_INHERIT
169 #define DM_CONFIG_MAX_HANDLE_SIZE (DM_CONFIG_INHERIT_ATTRIBS + 1)
170 #undef DM_CONFIG_MAX_FILE_HANDLE_SIZE
171 #define DM_CONFIG_MAX_ATTR_ON_DESTROY (DM_CONFIG_MAX_HANDLE_SIZE + 1)
172 #undef DM_CONFIG_MAX_ATTR_BYTES_ON_DESTROY
173 #define DM_CONFIG_OBJ_REF (DM_CONFIG_MAX_ATTR_ON_DESTROY + 1)
174 #define DM_CONFIG_DTIME_OVERLOAD (DM_CONFIG_OBJ_REF + 1)
177 #define DM_AT_DTIME DM_AT_DTIMES
179 /* In the dm_fileattr_t structure, Veritas used 'timeval' structures for all
180 the time fields while XDSM uses 'time_t' structures. Define some symbols
181 that can be used for the time fields with all implementation types.
184 #define FA_ATIME fa_atime.tv_sec
185 #define FA_MTIME fa_atime.tv_sec
186 #define FA_CTIME fa_ctime.tv_sec
187 #define FA_DTIME fa_dtime.tv_sec
189 #define DM_WRITE_SYNC 0x1 /* used in dm_write_invis() */
191 #define DM_UNMOUNT_FORCE 0x1 /* ne_mode field in dm_namesp_event_t */
193 /* Rename one event to match the XDSM standard. */
195 #define DM_EVENT_CLOSE (DM_EVENT_DESTROY + 1)
196 #undef DM_EVENT_CLOSED
198 /* DM_EVENT_CANCEL is defined above DM_EVENT_MAX, and is unsupported. */
200 #undef DM_REGION_VALIDFLAG
202 /* Add missing typedefs */
204 typedef u_int dm_boolean_t;
205 typedef dev_t dm_fsid_t; /* This could be made a uint64_t with work! */
206 typedef long dm_igen_t;
207 typedef long dm_ino_t;
208 typedef u_int dm_sequence_t;
211 /* Define missing fields within the various event structures. */
213 #define ev_sequence ev_token /* for compilation only! Won't work! */
215 #define ds_handle te_handle /* fix fields in dm_destroy_event_t */
216 #define ds_attrname te_attrname
217 #define ds_attrcopy te_attrdata
220 struct dm_cancel_event { /* define missing dm_cancel_event_t */
221 dm_sequence_t ce_sequence;
224 typedef struct dm_cancel_event dm_cancel_event_t;
227 struct dm_mount_event { /* define missing dm_mount_event_t */
229 dm_vardata_t me_handle1;
230 dm_vardata_t me_handle2;
231 dm_vardata_t me_name1;
232 dm_vardata_t me_name2;
233 dm_vardata_t me_roothandle;
235 typedef struct dm_mount_event dm_mount_event_t;
238 /* Add the missing dm_timestruct_t structure used by dm_pending. */
240 struct dm_timestruct {
244 typedef struct dm_timestruct dm_timestruct_t;
250 /* -------------------- SGI-specific hack documentation -------------------
252 There are various fields within DMAPI structures that are not supported.
253 Fill in this information someday.
255 The following functions have prototypes defined in <sys/dmi.h> and have
256 entry points defined in libdm.so, but they are not actually implemented
257 within the kernel. They all return ENOSYS if called.
267 The DMAPI functions which deal with rights do not work as described in
268 the specification. While the functions exist and are callable, they
269 always return successfully without actually obtaining any locks within
278 The following non-standard SGI prototype is added to the DMAPI interface
279 so that real-time files may be migrated and recalled.
283 -------------- end of SGI-specific hack documentation --------------- */
289 /* In the dm_fileattr_t structure, Veritas used 'timeval' structures for all
290 the time fields while XDSM uses 'time_t' structures. Define some symbols
291 that can be used for the time fields with all implementation types.
294 #define FA_ATIME fa_atime
295 #define FA_MTIME fa_mtime
296 #define FA_CTIME fa_ctime
297 #define FA_DTIME fa_dtime
301 /* ----------------------- XDSM standard prototypes ----------------------- */
303 /* The following list provides the prototypes for all functions defined in
304 the DMAPI interface spec from X/Open (XDSM) dated February 1997. They
305 are here to force compiler errors in case the Veritas or SGI DMAPI
306 prototypes should ever change without our knowing about it.
315 dm_attrname_t *attrnamep);
331 dm_sessid_t *newsidp);
373 dm_extent_t *extentp,
383 dm_attrname_t *attrnamep,
405 dm_config_t flagname,
409 dm_get_config_events(
413 dm_eventset_t *eventsetp,
434 dm_attrname_t *attrnamep,
446 dm_eventset_t *eventsetp,
484 dm_region_t *regbufp,
511 dm_inherit_t *inheritbufp,
517 dm_sessid_t *sidbufp,
524 dm_token_t *tokenbufp,
550 dm_handle_to_fshandle(
594 char **versionstrpp);
624 dm_sessid_t targetsid,
625 dm_token_t *rtokenp);
664 dm_timestruct_t *delay);
725 dm_attrname_t *attrnamep);
740 dm_response_t response,
747 dm_sessid_t targetsid,
748 dm_msgtype_t msgtype,
758 dm_eventset_t *eventsetp,
767 dm_attrname_t *attrnamep,
778 dm_eventset_t *eventsetp,
788 dm_fileattr_t *attrp);
796 dm_attrname_t *attrnamep,
806 dm_region_t *regbufp,
807 dm_boolean_t *exactflagp);
810 dm_set_return_on_destroy(
815 dm_attrname_t *attrnamep,
816 dm_boolean_t enable);
819 dm_symlink_by_handle(
859 #endif /* _DMFSAPI_DMPORT_H */