1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001 Silicon Graphics, Inc.
10 #include <lib/dmport.h>
13 /* See dmport.h for a description of why all these wrapper routines are
14 necessary. Because SGI defines stub routines for all functions it didn't
15 implement, no SGI-specific wrappers are required.
21 /* The Veritas version of dm_downgrade_right has two additional parameters
22 not defined in the XDSM spec. Provide values that make dm_downgrade_right
23 work according to the spec.
27 xvfs_dm_downgrade_right(
33 #undef dm_downgrade_right
34 return(dm_downgrade_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED));
38 /* The last byte in a Veritas handle is a 'pad' byte which they don't bother
39 to initialize to zero. As a result, you can't do binary compares of
40 two handles to see if they are the same. This stub (along with others)
41 forces the pad byte to zero so that binary compares are possible
50 #undef dm_fd_to_handle
53 if ((rc = dm_fd_to_handle(fd, hanpp, hlenp)) == 0) {
55 char *cp = (char *)*hanpp;
63 /* The Veritas version of dm_get_config_events has a slightly different name.
71 dm_eventset_t *eventsetp,
74 return(dm_get_config_event(hanp, hlen, nelem, eventsetp, nelemp));
78 /* In version 2.1 uflags was defined as 'int nowait', so a value of zero in
79 this field means that the caller wants to wait. In XDSM this was reversed,
80 where if the bottom bit of uflags is set then the caller wants to wait.
81 This routine makes the conversion.
96 if (uflags & DM_EV_WAIT)
99 return(dm_get_events(sid, maxmsgs, nowait, buflen, bufp, rlenp));
103 /* The Veritas version of dm_get_mountinfo has the parameters in a different
104 order than in the XDSM spec. Hide this in the wrapper.
108 xvfs_dm_get_mountinfo(
117 #undef dm_get_mountinfo
118 return(dm_get_mountinfo(sid, token, hanp, hlen, buflen, bufp, rlenp));
122 /* Veritas does not support the dm_getall_disp function. Furthermore, their
123 dm_dispinfo_t structure is missing the _link field that is needed for the
124 DM_STEP_TO_NEXT() macro to work.
138 /* Veritas does not support the dm_getall_dmattr function. Furthermore, their
139 dm_attrlist_t structure is missing the _link field that is needed for the
140 DM_STEP_TO_NEXT() macro to work.
157 /* Veritas does not support dm_handle_is_valid. We emulate it by checking
158 fields which have known values, as DMF uses this a lot.
166 char *cp = (char *)hanp;
171 if (cp[15] != '\0') {
193 /* Veritas uses a dev_t for their dm_fsid_t, and named their routines
194 accordingly. Hide this in the wrapper. Note that a dev_t is 32 bits
195 and the SGI dm_fsid_t is defined to be a uint64_t. If this gets to
196 be a problem (e.g. %x verus %llx), the Veritas dm_fsid_t could be made
197 to match SGI with a little casting here and there.
208 dev = dm_handle_to_dev(hanp, hlen);
209 *fsidp = (dm_fsid_t)dev;
214 /* The Veritas dm_handle_to_fgen returns a long which is really the
215 file's generation number. dm_igen_t is typedef'd to be a long also,
216 so the cast here is safe.
225 #undef dm_handle_to_igen
228 igen = (dm_igen_t)dm_handle_to_fgen(hanp, hlen);
229 *igenp = (dm_igen_t)igen;
234 /* Veritas uses a long for their dm_ino_t, which is really an ino_t.
235 Hide this in the wrapper. Note that a ino_t is 32 bits and the SGI
236 dm_ino_t is defined to be a uint64_t. If this gets to be a problem
237 (e.g. %x verus %llx), the Veritas dm_ino_t could be made to match SGI
238 with a little casting here and there.
243 xvfs_dm_handle_to_ino(
248 #undef dm_handle_to_ino
251 ino = (dm_ino_t)dm_handle_to_ino(hanp, hlen);
252 *inop = (dm_ino_t)ino;
257 /* Version 2.1 of the spec did not specify the versionstrpp parameter. This
258 code makes the routine appear to work correctly to the caller, but it
259 is not really able to do the runtime check that the parameter is
264 xvfs_dm_init_service(
267 #undef dm_init_service
268 *versionstrpp = DM_VER_STR_CONTENTS;
269 return(dm_init_service());
274 xvfs_dm_make_fshandle(
279 #undef dm_make_fshandle
283 return(dm_make_fshandle(dev, hanpp, hlenp));
295 #undef dm_make_handle
303 return(dm_make_handle(dev, ino, igen, hanpp, hlenp));
307 /* The last byte in a Veritas handle is a 'pad' byte which they don't bother
308 to initialize to zero. As a result, you can't do binary compares of
309 two handles to see if they are the same. This stub (along with others)
310 forces the pad byte to zero so that binary compares are possible
314 xvfs_dm_path_to_fshandle(
319 #undef dm_path_to_fshandle
322 if ((rc = dm_path_to_fshandle(path, fshanpp, fshlenp)) == 0) {
323 if (*fshlenp == 16) {
324 char *cp = (char *)*fshanpp;
332 /* The last byte in a Veritas handle is a 'pad' byte which they don't bother
333 to initialize to zero. As a result, you can't do binary compares of
334 two handles to see if they are the same. This stub (along with others)
335 forces the pad byte to zero so that binary compares are possible
339 xvfs_dm_path_to_handle(
344 #undef dm_path_to_handle
347 if ((rc = dm_path_to_handle(path, hanpp, hlenp)) == 0) {
349 char *cp = (char *)*hanpp;
357 /* Veritas has a prototype for this function even though it is not
365 dm_timestruct_t *delay)
383 return(dm_read_invis(sid, hanp, hlen, token, off, (dm_ssize_t)len, bufp));
387 /* In version 2.1 uflags was defined as 'int nowait', so a value of zero in
388 this field means that the caller wants to wait. In XDSM this was reversed,
389 where if the bottom bit of uflags is set then the caller wants to wait.
390 This routine makes the conversion.
394 xvfs_dm_request_right(
402 #undef dm_request_right
405 if (uflags & DM_RR_WAIT)
407 return(dm_request_right(sid, hanp, hlen, token, nowait, right));
417 dm_attrname_t *attrnamep,
420 #undef dm_set_inherit
421 return(dm_set_inherit(sid, hanp, hlen, token, attrnamep, (u_int)mode));
432 dm_region_t *regbufp,
433 dm_boolean_t *exactflagp)
436 return(dm_set_region(sid, hanp, hlen, token, nelem, regbufp, (u_int *)exactflagp));
441 dm_set_return_on_destroy(
446 dm_attrname_t *attrnamep,
449 return(dm_set_return_ondestroy(sid, hanp, hlen, token, attrnamep, (int)enable));
454 xvfs_dm_sync_by_handle(
460 #undef dm_sync_by_handle
461 return((int)dm_sync_by_handle(sid, hanp, hlen, token));
465 xvfs_dm_upgrade_right(
471 #undef dm_upgrade_right
472 return(dm_upgrade_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL));
487 #undef dm_write_invis
488 return(dm_write_invis(sid, hanp, hlen, token, off, (dm_ssize_t)len, bufp, flags));