2 * Copyright (c) 2000-2001 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <lib/dmport.h>
25 /* See dmport.h for a description of why all these wrapper routines are
26 necessary. Because SGI defines stub routines for all functions it didn't
27 implement, no SGI-specific wrappers are required.
33 /* The Veritas version of dm_downgrade_right has two additional parameters
34 not defined in the XDSM spec. Provide values that make dm_downgrade_right
35 work according to the spec.
39 xvfs_dm_downgrade_right(
45 #undef dm_downgrade_right
46 return(dm_downgrade_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED));
50 /* The last byte in a Veritas handle is a 'pad' byte which they don't bother
51 to initialize to zero. As a result, you can't do binary compares of
52 two handles to see if they are the same. This stub (along with others)
53 forces the pad byte to zero so that binary compares are possible
62 #undef dm_fd_to_handle
65 if ((rc = dm_fd_to_handle(fd, hanpp, hlenp)) == 0) {
67 char *cp = (char *)*hanpp;
75 /* The Veritas version of dm_get_config_events has a slightly different name.
83 dm_eventset_t *eventsetp,
86 return(dm_get_config_event(hanp, hlen, nelem, eventsetp, nelemp));
90 /* In version 2.1 uflags was defined as 'int nowait', so a value of zero in
91 this field means that the caller wants to wait. In XDSM this was reversed,
92 where if the bottom bit of uflags is set then the caller wants to wait.
93 This routine makes the conversion.
108 if (uflags & DM_EV_WAIT)
111 return(dm_get_events(sid, maxmsgs, nowait, buflen, bufp, rlenp));
115 /* The Veritas version of dm_get_mountinfo has the parameters in a different
116 order than in the XDSM spec. Hide this in the wrapper.
120 xvfs_dm_get_mountinfo(
129 #undef dm_get_mountinfo
130 return(dm_get_mountinfo(sid, token, hanp, hlen, buflen, bufp, rlenp));
134 /* Veritas does not support the dm_getall_disp function. Furthermore, their
135 dm_dispinfo_t structure is missing the _link field that is needed for the
136 DM_STEP_TO_NEXT() macro to work.
150 /* Veritas does not support the dm_getall_dmattr function. Furthermore, their
151 dm_attrlist_t structure is missing the _link field that is needed for the
152 DM_STEP_TO_NEXT() macro to work.
169 /* Veritas does not support dm_handle_is_valid. We emulate it by checking
170 fields which have known values, as DMF uses this a lot.
178 char *cp = (char *)hanp;
183 if (cp[15] != '\0') {
205 /* Veritas uses a dev_t for their dm_fsid_t, and named their routines
206 accordingly. Hide this in the wrapper. Note that a dev_t is 32 bits
207 and the SGI dm_fsid_t is defined to be a uint64_t. If this gets to
208 be a problem (e.g. %x verus %llx), the Veritas dm_fsid_t could be made
209 to match SGI with a little casting here and there.
220 dev = dm_handle_to_dev(hanp, hlen);
221 *fsidp = (dm_fsid_t)dev;
226 /* The Veritas dm_handle_to_fgen returns a long which is really the
227 file's generation number. dm_igen_t is typedef'd to be a long also,
228 so the cast here is safe.
237 #undef dm_handle_to_igen
240 igen = (dm_igen_t)dm_handle_to_fgen(hanp, hlen);
241 *igenp = (dm_igen_t)igen;
246 /* Veritas uses a long for their dm_ino_t, which is really an ino_t.
247 Hide this in the wrapper. Note that a ino_t is 32 bits and the SGI
248 dm_ino_t is defined to be a uint64_t. If this gets to be a problem
249 (e.g. %x verus %llx), the Veritas dm_ino_t could be made to match SGI
250 with a little casting here and there.
255 xvfs_dm_handle_to_ino(
260 #undef dm_handle_to_ino
263 ino = (dm_ino_t)dm_handle_to_ino(hanp, hlen);
264 *inop = (dm_ino_t)ino;
269 /* Version 2.1 of the spec did not specify the versionstrpp parameter. This
270 code makes the routine appear to work correctly to the caller, but it
271 is not really able to do the runtime check that the parameter is
276 xvfs_dm_init_service(
279 #undef dm_init_service
280 *versionstrpp = DM_VER_STR_CONTENTS;
281 return(dm_init_service());
286 xvfs_dm_make_fshandle(
291 #undef dm_make_fshandle
295 return(dm_make_fshandle(dev, hanpp, hlenp));
307 #undef dm_make_handle
315 return(dm_make_handle(dev, ino, igen, hanpp, hlenp));
319 /* The last byte in a Veritas handle is a 'pad' byte which they don't bother
320 to initialize to zero. As a result, you can't do binary compares of
321 two handles to see if they are the same. This stub (along with others)
322 forces the pad byte to zero so that binary compares are possible
326 xvfs_dm_path_to_fshandle(
331 #undef dm_path_to_fshandle
334 if ((rc = dm_path_to_fshandle(path, fshanpp, fshlenp)) == 0) {
335 if (*fshlenp == 16) {
336 char *cp = (char *)*fshanpp;
344 /* The last byte in a Veritas handle is a 'pad' byte which they don't bother
345 to initialize to zero. As a result, you can't do binary compares of
346 two handles to see if they are the same. This stub (along with others)
347 forces the pad byte to zero so that binary compares are possible
351 xvfs_dm_path_to_handle(
356 #undef dm_path_to_handle
359 if ((rc = dm_path_to_handle(path, hanpp, hlenp)) == 0) {
361 char *cp = (char *)*hanpp;
369 /* Veritas has a prototype for this function even though it is not
377 dm_timestruct_t *delay)
395 return(dm_read_invis(sid, hanp, hlen, token, off, (dm_ssize_t)len, bufp));
399 /* In version 2.1 uflags was defined as 'int nowait', so a value of zero in
400 this field means that the caller wants to wait. In XDSM this was reversed,
401 where if the bottom bit of uflags is set then the caller wants to wait.
402 This routine makes the conversion.
406 xvfs_dm_request_right(
414 #undef dm_request_right
417 if (uflags & DM_RR_WAIT)
419 return(dm_request_right(sid, hanp, hlen, token, nowait, right));
429 dm_attrname_t *attrnamep,
432 #undef dm_set_inherit
433 return(dm_set_inherit(sid, hanp, hlen, token, attrnamep, (u_int)mode));
444 dm_region_t *regbufp,
445 dm_boolean_t *exactflagp)
448 return(dm_set_region(sid, hanp, hlen, token, nelem, regbufp, (u_int *)exactflagp));
453 dm_set_return_on_destroy(
458 dm_attrname_t *attrnamep,
461 return(dm_set_return_ondestroy(sid, hanp, hlen, token, attrnamep, (int)enable));
466 xvfs_dm_sync_by_handle(
472 #undef dm_sync_by_handle
473 return((int)dm_sync_by_handle(sid, hanp, hlen, token));
477 xvfs_dm_upgrade_right(
483 #undef dm_upgrade_right
484 return(dm_upgrade_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL));
499 #undef dm_write_invis
500 return(dm_write_invis(sid, hanp, hlen, token, off, (dm_ssize_t)len, bufp, flags));