2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
36 #include <lib/dmport.h>
39 /* See dmport.h for a description of why all these wrapper routines are
40 necessary. Because SGI defines stub routines for all functions it didn't
41 implement, no SGI-specific wrappers are required.
47 /* The Veritas version of dm_downgrade_right has two additional parameters
48 not defined in the XDSM spec. Provide values that make dm_downgrade_right
49 work according to the spec.
53 xvfs_dm_downgrade_right(
59 #undef dm_downgrade_right
60 return(dm_downgrade_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED));
64 /* The last byte in a Veritas handle is a 'pad' byte which they don't bother
65 to initialize to zero. As a result, you can't do binary compares of
66 two handles to see if they are the same. This stub (along with others)
67 forces the pad byte to zero so that binary compares are possible
76 #undef dm_fd_to_handle
79 if ((rc = dm_fd_to_handle(fd, hanpp, hlenp)) == 0) {
81 char *cp = (char *)*hanpp;
89 /* The Veritas version of dm_get_config_events has a slightly different name.
97 dm_eventset_t *eventsetp,
100 return(dm_get_config_event(hanp, hlen, nelem, eventsetp, nelemp));
104 /* In version 2.1 uflags was defined as 'int nowait', so a value of zero in
105 this field means that the caller wants to wait. In XDSM this was reversed,
106 where if the bottom bit of uflags is set then the caller wants to wait.
107 This routine makes the conversion.
122 if (uflags & DM_EV_WAIT)
125 return(dm_get_events(sid, maxmsgs, nowait, buflen, bufp, rlenp));
129 /* The Veritas version of dm_get_mountinfo has the parameters in a different
130 order than in the XDSM spec. Hide this in the wrapper.
134 xvfs_dm_get_mountinfo(
143 #undef dm_get_mountinfo
144 return(dm_get_mountinfo(sid, token, hanp, hlen, buflen, bufp, rlenp));
148 /* Veritas does not support the dm_getall_disp function. Furthermore, their
149 dm_dispinfo_t structure is missing the _link field that is needed for the
150 DM_STEP_TO_NEXT() macro to work.
164 /* Veritas does not support the dm_getall_dmattr function. Furthermore, their
165 dm_attrlist_t structure is missing the _link field that is needed for the
166 DM_STEP_TO_NEXT() macro to work.
183 /* Veritas does not support dm_handle_is_valid. We emulate it by checking
184 fields which have known values, as DMF uses this a lot.
192 char *cp = (char *)hanp;
197 if (cp[15] != '\0') {
219 /* Veritas uses a dev_t for their dm_fsid_t, and named their routines
220 accordingly. Hide this in the wrapper. Note that a dev_t is 32 bits
221 and the SGI dm_fsid_t is defined to be a uint64_t. If this gets to
222 be a problem (e.g. %x verus %llx), the Veritas dm_fsid_t could be made
223 to match SGI with a little casting here and there.
234 dev = dm_handle_to_dev(hanp, hlen);
235 *fsidp = (dm_fsid_t)dev;
240 /* The Veritas dm_handle_to_fgen returns a long which is really the
241 file's generation number. dm_igen_t is typedef'd to be a long also,
242 so the cast here is safe.
251 #undef dm_handle_to_igen
254 igen = (dm_igen_t)dm_handle_to_fgen(hanp, hlen);
255 *igenp = (dm_igen_t)igen;
260 /* Veritas uses a long for their dm_ino_t, which is really an ino_t.
261 Hide this in the wrapper. Note that a ino_t is 32 bits and the SGI
262 dm_ino_t is defined to be a uint64_t. If this gets to be a problem
263 (e.g. %x verus %llx), the Veritas dm_ino_t could be made to match SGI
264 with a little casting here and there.
269 xvfs_dm_handle_to_ino(
274 #undef dm_handle_to_ino
277 ino = (dm_ino_t)dm_handle_to_ino(hanp, hlen);
278 *inop = (dm_ino_t)ino;
283 /* Version 2.1 of the spec did not specify the versionstrpp parameter. This
284 code makes the routine appear to work correctly to the caller, but it
285 is not really able to do the runtime check that the parameter is
290 xvfs_dm_init_service(
293 #undef dm_init_service
294 *versionstrpp = DM_VER_STR_CONTENTS;
295 return(dm_init_service());
300 xvfs_dm_make_fshandle(
305 #undef dm_make_fshandle
309 return(dm_make_fshandle(dev, hanpp, hlenp));
321 #undef dm_make_handle
329 return(dm_make_handle(dev, ino, igen, hanpp, hlenp));
333 /* The last byte in a Veritas handle is a 'pad' byte which they don't bother
334 to initialize to zero. As a result, you can't do binary compares of
335 two handles to see if they are the same. This stub (along with others)
336 forces the pad byte to zero so that binary compares are possible
340 xvfs_dm_path_to_fshandle(
345 #undef dm_path_to_fshandle
348 if ((rc = dm_path_to_fshandle(path, fshanpp, fshlenp)) == 0) {
349 if (*fshlenp == 16) {
350 char *cp = (char *)*fshanpp;
358 /* The last byte in a Veritas handle is a 'pad' byte which they don't bother
359 to initialize to zero. As a result, you can't do binary compares of
360 two handles to see if they are the same. This stub (along with others)
361 forces the pad byte to zero so that binary compares are possible
365 xvfs_dm_path_to_handle(
370 #undef dm_path_to_handle
373 if ((rc = dm_path_to_handle(path, hanpp, hlenp)) == 0) {
375 char *cp = (char *)*hanpp;
383 /* Veritas has a prototype for this function even though it is not
391 dm_timestruct_t *delay)
409 return(dm_read_invis(sid, hanp, hlen, token, off, (dm_ssize_t)len, bufp));
413 /* In version 2.1 uflags was defined as 'int nowait', so a value of zero in
414 this field means that the caller wants to wait. In XDSM this was reversed,
415 where if the bottom bit of uflags is set then the caller wants to wait.
416 This routine makes the conversion.
420 xvfs_dm_request_right(
428 #undef dm_request_right
431 if (uflags & DM_RR_WAIT)
433 return(dm_request_right(sid, hanp, hlen, token, nowait, right));
443 dm_attrname_t *attrnamep,
446 #undef dm_set_inherit
447 return(dm_set_inherit(sid, hanp, hlen, token, attrnamep, (u_int)mode));
458 dm_region_t *regbufp,
459 dm_boolean_t *exactflagp)
462 return(dm_set_region(sid, hanp, hlen, token, nelem, regbufp, (u_int *)exactflagp));
467 dm_set_return_on_destroy(
472 dm_attrname_t *attrnamep,
475 return(dm_set_return_ondestroy(sid, hanp, hlen, token, attrnamep, (int)enable));
480 xvfs_dm_sync_by_handle(
486 #undef dm_sync_by_handle
487 return((int)dm_sync_by_handle(sid, hanp, hlen, token));
491 xvfs_dm_upgrade_right(
497 #undef dm_upgrade_right
498 return(dm_upgrade_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL));
513 #undef dm_write_invis
514 return(dm_write_invis(sid, hanp, hlen, token, off, (dm_ssize_t)len, bufp, flags));