diff options
author | Nathan Scott <nathans@sgi.com> | 2001-01-17 01:27:02 +0000 |
---|---|---|
committer | Nathan Scott <nathans@sgi.com> | 2001-01-17 01:27:02 +0000 |
commit | d1b950542468933ef017c11a858647c06da3d874 (patch) | |
tree | f7159953ff7f5bd09b795a389a7ee5851bc65243 | |
download | dmapi-dev-d1b950542468933ef017c11a858647c06da3d874.tar.gz |
cmd/xfsprogs/libdm/Makefile 1.1 Renamed to cmd/dmapi/libdm/Makefile
-rw-r--r-- | libdm/Makefile | 63 | ||||
-rw-r--r-- | libdm/dm_attr.c | 60 | ||||
-rw-r--r-- | libdm/dm_bulkattr.c | 93 | ||||
-rw-r--r-- | libdm/dm_config.c | 57 | ||||
-rw-r--r-- | libdm/dm_dmattr.c | 149 | ||||
-rw-r--r-- | libdm/dm_event.c | 149 | ||||
-rw-r--r-- | libdm/dm_handle.c | 377 | ||||
-rw-r--r-- | libdm/dm_handle2path.c | 269 | ||||
-rw-r--r-- | libdm/dm_hole.c | 76 | ||||
-rw-r--r-- | libdm/dm_mountinfo.c | 49 | ||||
-rw-r--r-- | libdm/dm_rdwr.c | 84 | ||||
-rw-r--r-- | libdm/dm_region.c | 63 | ||||
-rw-r--r-- | libdm/dm_right.c | 125 | ||||
-rw-r--r-- | libdm/dm_session.c | 103 |
14 files changed, 1717 insertions, 0 deletions
diff --git a/libdm/Makefile b/libdm/Makefile new file mode 100644 index 0000000..b91b73f --- /dev/null +++ b/libdm/Makefile @@ -0,0 +1,63 @@ +# +# Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# Further, this software is distributed without any warranty that it is +# free of the rightful claim of any third person regarding infringement +# or the like. Any license provided herein, whether implied or +# otherwise, applies only to this software file. Patent licenses, if +# any, provided herein do not apply to combinations of this program with +# other software, or any other product whatsoever. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write the Free Software Foundation, Inc., 59 +# Temple Place - Suite 330, Boston MA 02111-1307, USA. +# +# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, +# Mountain View, CA 94043, or: +# +# http://www.sgi.com +# +# For further information regarding this notice, see: +# +# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ +# + +TOPDIR = .. +include $(TOPDIR)/include/builddefs + +CFLAGS += -Ilinux + +STATICLIBTARGET = libdm.a +LIBTARGET = libdm.so +CFILES = \ + dm_attr.c \ + dm_bulkattr.c \ + dm_config.c \ + dm_dmattr.c \ + dm_event.c \ + dm_handle.c \ + dm_handle2path.c \ + dm_hole.c \ + dm_mountinfo.c \ + dm_rdwr.c \ + dm_region.c \ + dm_right.c \ + dm_session.c \ + linux/dmapi_lib.c + + +default: $(LIBTARGET) $(STATICLIBTARGET) + +include $(BUILDRULES) + +install: default + #$(INSTALL) -m 755 -d $(XFS_CMDS_LIB_DIR) + #$(INSTALL) -m 755 $(STATICLIBTARGET) $(XFS_CMDS_LIB_DIR) diff --git a/libdm/dm_attr.c b/libdm/dm_attr.c new file mode 100644 index 0000000..7ce4a3c --- /dev/null +++ b/libdm/dm_attr.c @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it is + * free of the rightful claim of any third person regarding infringement + * or the like. Any license provided herein, whether implied or + * otherwise, applies only to this software file. Patent licenses, if + * any, provided herein do not apply to combinations of this program with + * other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston MA 02111-1307, USA. + * + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, + * Mountain View, CA 94043, or: + * + * http://www.sgi.com + * + * For further information regarding this notice, see: + * + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ + */ + +#include <linux/dmapi_kern.h> +#include <dmapi_lib.h> + + +extern int +dm_get_fileattr( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + u_int mask, + dm_stat_t *statp) +{ + return dmi(DM_GET_FILEATTR, sid, hanp, hlen, token, mask, statp); +} + + +extern int +dm_set_fileattr( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + u_int mask, + dm_fileattr_t *attrp) +{ + return dmi(DM_SET_FILEATTR, sid, hanp, hlen, token, mask, attrp); +} diff --git a/libdm/dm_bulkattr.c b/libdm/dm_bulkattr.c new file mode 100644 index 0000000..ca9d4a8 --- /dev/null +++ b/libdm/dm_bulkattr.c @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it is + * free of the rightful claim of any third person regarding infringement + * or the like. Any license provided herein, whether implied or + * otherwise, applies only to this software file. Patent licenses, if + * any, provided herein do not apply to combinations of this program with + * other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston MA 02111-1307, USA. + * + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, + * Mountain View, CA 94043, or: + * + * http://www.sgi.com + * + * For further information regarding this notice, see: + * + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ + */ + +#include <linux/dmapi_kern.h> +#include <dmapi_lib.h> + + +extern int +dm_init_attrloc( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + dm_attrloc_t *locp) +{ + return dmi(DM_INIT_ATTRLOC, sid, hanp, hlen, token, locp); +} + +extern int +dm_get_bulkattr( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + u_int mask, + dm_attrloc_t *locp, + size_t buflen, + void *bufp, + size_t *rlenp) +{ + return dmi(DM_GET_BULKATTR, sid, hanp, hlen, token, mask, locp, buflen, bufp, rlenp); +} + +extern int +dm_get_dirattrs( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + u_int mask, + dm_attrloc_t *locp, + size_t buflen, + void *bufp, + size_t *rlenp) +{ + return dmi(DM_GET_DIRATTRS, sid, hanp, hlen, token, mask, locp, buflen, bufp, rlenp); +} + +extern int +dm_get_bulkall( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + u_int mask, + dm_attrname_t *attrnamep, + dm_attrloc_t *locp, + size_t buflen, + void *bufp, + size_t *rlenp) +{ + return dmi(DM_GET_BULKALL, sid, hanp, hlen, token, mask, + attrnamep, locp, buflen, bufp, rlenp); +} diff --git a/libdm/dm_config.c b/libdm/dm_config.c new file mode 100644 index 0000000..27a33fc --- /dev/null +++ b/libdm/dm_config.c @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it is + * free of the rightful claim of any third person regarding infringement + * or the like. Any license provided herein, whether implied or + * otherwise, applies only to this software file. Patent licenses, if + * any, provided herein do not apply to combinations of this program with + * other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston MA 02111-1307, USA. + * + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, + * Mountain View, CA 94043, or: + * + * http://www.sgi.com + * + * For further information regarding this notice, see: + * + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ + */ + +#include <linux/dmapi_kern.h> +#include <dmapi_lib.h> + + +extern int +dm_get_config( + void *hanp, + size_t hlen, + dm_config_t flagname, + dm_size_t *retvalp) +{ + return dmi(DM_GET_CONFIG, hanp, hlen, flagname, retvalp); +} + + +extern int +dm_get_config_events( + void *hanp, + size_t hlen, + u_int nelem, + dm_eventset_t *eventsetp, + u_int *nelemp) +{ + return dmi(DM_GET_CONFIG_EVENTS, hanp, hlen, nelem, eventsetp, nelemp); +} diff --git a/libdm/dm_dmattr.c b/libdm/dm_dmattr.c new file mode 100644 index 0000000..ad7c9b4 --- /dev/null +++ b/libdm/dm_dmattr.c @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it is + * free of the rightful claim of any third person regarding infringement + * or the like. Any license provided herein, whether implied or + * otherwise, applies only to this software file. Patent licenses, if + * any, provided herein do not apply to combinations of this program with + * other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston MA 02111-1307, USA. + * + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, + * Mountain View, CA 94043, or: + * + * http://www.sgi.com + * + * For further information regarding this notice, see: + * + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ + */ + +#include <linux/dmapi_kern.h> +#include <dmapi_lib.h> + + +extern int +dm_clear_inherit( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + dm_attrname_t *attrnamep) +{ + return dmi(DM_CLEAR_INHERIT, sid, hanp, hlen, token, attrnamep); +} + + +extern int +dm_get_dmattr ( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + dm_attrname_t *attrnamep, + size_t buflen, + void *bufp, + size_t *rlenp) +{ + return dmi(DM_GET_DMATTR, sid, hanp, hlen, token, attrnamep, + buflen, bufp, rlenp); +} + + +extern int +dm_getall_dmattr ( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + size_t buflen, + void *bufp, + size_t *rlenp) +{ + return dmi(DM_GETALL_DMATTR, sid, hanp, hlen, token, buflen, + bufp, rlenp); +} + + +extern int +dm_getall_inherit( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + u_int nelem, + dm_inherit_t *inheritbufp, + u_int *nelemp) +{ + return dmi(DM_GETALL_INHERIT, sid, hanp, hlen, token, nelem, + inheritbufp, nelemp); +} + + +extern int +dm_remove_dmattr ( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + int setdtime, + dm_attrname_t *attrnamep) +{ + return dmi(DM_REMOVE_DMATTR, sid, hanp, hlen, token, setdtime, + attrnamep); +} + + +extern int +dm_set_dmattr ( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + dm_attrname_t *attrnamep, + int setdtime, + size_t buflen, + void *bufp) +{ + return dmi(DM_SET_DMATTR, sid, hanp, hlen, token, attrnamep, + setdtime, buflen, bufp); +} + + +extern int +dm_set_inherit( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + dm_attrname_t *attrnamep, + mode_t mode) +{ + return dmi(DM_SET_INHERIT, sid, hanp, hlen, token, attrnamep, mode); +} + + +extern int +dm_set_return_on_destroy ( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + dm_attrname_t *attrnamep, + dm_boolean_t enable) +{ + return dmi(DM_SET_RETURN_ON_DESTROY, sid, hanp, hlen, token, + attrnamep, enable); +} diff --git a/libdm/dm_event.c b/libdm/dm_event.c new file mode 100644 index 0000000..ff30355 --- /dev/null +++ b/libdm/dm_event.c @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it is + * free of the rightful claim of any third person regarding infringement + * or the like. Any license provided herein, whether implied or + * otherwise, applies only to this software file. Patent licenses, if + * any, provided herein do not apply to combinations of this program with + * other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston MA 02111-1307, USA. + * + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, + * Mountain View, CA 94043, or: + * + * http://www.sgi.com + * + * For further information regarding this notice, see: + * + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ + */ + +#include <linux/dmapi_kern.h> +#include <dmapi_lib.h> + + +extern int +dm_get_events( + dm_sessid_t sid, + u_int maxmsgs, + u_int flags, + size_t buflen, + void *bufp, + size_t *rlenp) +{ + return dmi(DM_GET_EVENTS, sid, maxmsgs, flags, buflen, bufp, rlenp); +} + +extern int +dm_respond_event( + dm_sessid_t sid, + dm_token_t token, + dm_response_t response, + int reterror, + size_t buflen, + void *respbufp) +{ + return dmi(DM_RESPOND_EVENT, sid, token, response, reterror, + buflen, respbufp); +} + + +extern int +dm_get_eventlist( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + u_int nelem, + dm_eventset_t *eventsetp, + u_int *nelemp) +{ + return dmi(DM_GET_EVENTLIST, sid, hanp, hlen, token, nelem, + eventsetp, nelemp); +} + +extern int +dm_set_eventlist( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + dm_eventset_t *eventsetp, + u_int maxevent) +{ + return dmi(DM_SET_EVENTLIST, sid, hanp, hlen, token, + eventsetp, maxevent); +} + +extern int +dm_set_disp( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + dm_eventset_t *eventsetp, + u_int maxevent) +{ + return dmi(DM_SET_DISP, sid, hanp, hlen, token, eventsetp, maxevent); +} + +extern int +dm_create_userevent( + dm_sessid_t sid, + size_t msglen, + void *msgdatap, + dm_token_t *tokenp) +{ + return dmi(DM_CREATE_USEREVENT, sid, msglen, msgdatap, tokenp); +} + +extern int +dm_send_msg( + dm_sessid_t targetsid, + dm_msgtype_t msgtype, + size_t buflen, + void *bufp) +{ + return dmi(DM_SEND_MSG, targetsid, msgtype, buflen, bufp); +} + +extern int +dm_move_event( + dm_sessid_t srcsid, + dm_token_t token, + dm_sessid_t targetsid, + dm_token_t *rtokenp) +{ + return dmi(DM_MOVE_EVENT, srcsid, token, targetsid, rtokenp); +} + +extern int +dm_pending( + dm_sessid_t sid, + dm_token_t token, + dm_timestruct_t *delay) +{ + return dmi(DM_PENDING, sid, token, delay); +} + +extern int +dm_getall_disp( + dm_sessid_t sid, + size_t buflen, + void *bufp, + size_t *rlenp) +{ + return dmi(DM_GETALL_DISP, sid, buflen, bufp, rlenp); +} diff --git a/libdm/dm_handle.c b/libdm/dm_handle.c new file mode 100644 index 0000000..e0b7cc8 --- /dev/null +++ b/libdm/dm_handle.c @@ -0,0 +1,377 @@ +/* + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it is + * free of the rightful claim of any third person regarding infringement + * or the like. Any license provided herein, whether implied or + * otherwise, applies only to this software file. Patent licenses, if + * any, provided herein do not apply to combinations of this program with + * other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston MA 02111-1307, USA. + * + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, + * Mountain View, CA 94043, or: + * + * http://www.sgi.com + * + * For further information regarding this notice, see: + * + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ + */ + +#include <errno.h> +#include <stdlib.h> +#include <string.h> + +#include <linux/dmapi_kern.h> +#include <dmapi_lib.h> + +#ifdef linux +#include <xfs_fs.h> +#else +#include <sys/handle.h> +#endif + +typedef enum { + DM_HANDLE_GLOBAL, + DM_HANDLE_FILESYSTEM, + DM_HANDLE_FILE, + DM_HANDLE_BAD +} dm_handletype_t; + + +extern int +dm_path_to_handle ( + char *path, + void **hanpp, + size_t *hlenp) +{ + char hbuf[DM_MAX_HANDLE_SIZE]; + + if (dmi(DM_PATH_TO_HANDLE, path, hbuf, hlenp)) + return(-1); + + if ((*hanpp = malloc(*hlenp)) == NULL) { + errno = ENOMEM; + return -1; + } + memcpy(*hanpp, hbuf, *hlenp); + return(0); +} + + +extern int +dm_path_to_fshandle ( + char *path, + void **hanpp, + size_t *hlenp) +{ + char hbuf[DM_MAX_HANDLE_SIZE]; + + if (dmi(DM_PATH_TO_FSHANDLE, path, hbuf, hlenp)) + return(-1); + + if ((*hanpp = malloc(*hlenp)) == NULL) { + errno = ENOMEM; + return -1; + } + memcpy(*hanpp, hbuf, *hlenp); + return(0); +} + + +extern int +dm_fd_to_handle ( + int fd, + void **hanpp, + size_t *hlenp) +{ + char hbuf[DM_MAX_HANDLE_SIZE]; + + if (dmi(DM_FD_TO_HANDLE, fd, hbuf, hlenp)) + return(-1); + + if ((*hanpp = malloc(*hlenp)) == NULL) { + errno = ENOMEM; + return -1; + } + memcpy(*hanpp, hbuf, *hlenp); + return(0); +} + + +extern int +dm_handle_to_fshandle ( + void *hanp, + size_t hlen, + void **fshanp, + size_t *fshlen) +{ + dm_fsid_t fsid; + + if (dm_handle_to_fsid(hanp, hlen, &fsid)) + return(-1); + + *fshlen = sizeof(fsid); + if ((*fshanp = malloc(*fshlen)) == NULL) { + errno = ENOMEM; + return(-1); + } + memcpy(*fshanp, &fsid, *fshlen); + return(0); +} + + +/* ARGSUSED */ +extern void +dm_handle_free( + void *hanp, + size_t hlen) +{ + free(hanp); +} + + +static dm_handletype_t +parse_handle( + void *hanp, + size_t hlen, + dm_fsid_t *fsidp, + dm_ino_t *inop, + dm_igen_t *igenp) +{ +/* XXX */ + xfs_handle_t handle; + xfs_fid2_t *xfid2; + fid_t *fidp; + + if (hanp == DM_GLOBAL_HANP && hlen == DM_GLOBAL_HLEN) + return(DM_HANDLE_GLOBAL); + + if (hlen < sizeof(handle.ha_fsid) || hlen > sizeof(handle)) + return(DM_HANDLE_BAD); + + memcpy(&handle, hanp, hlen); + if (!handle.ha_fsid.val[0] || !handle.ha_fsid.val[1]) + return(DM_HANDLE_BAD); + if (fsidp) + memcpy(fsidp, &handle.ha_fsid, sizeof(handle.ha_fsid)); + if (hlen == sizeof(handle.ha_fsid)) + return(DM_HANDLE_FILESYSTEM); + +#if 0 + if (handle.ha_fid.fid_len != (hlen - sizeof(handle.ha_fsid) - sizeof(handle.ha_fid.fid_len))) + return(DM_HANDLE_BAD); +#else + fidp = (fid_t*)&handle.ha_fid; + if (fidp->fid_len != (hlen - sizeof(handle.ha_fsid) - sizeof(fidp->fid_len))) + return(DM_HANDLE_BAD); +#endif + + xfid2 = (struct xfs_fid2 *)&handle.ha_fid; + if (xfid2->fid_len == sizeof *xfid2 - sizeof xfid2->fid_len) { + if (xfid2->fid_pad) + return(DM_HANDLE_BAD); + if (inop) + *inop = xfid2->fid_ino; + if (igenp) + *igenp = xfid2->fid_gen; + } else { + return(DM_HANDLE_BAD); + } + return(DM_HANDLE_FILE); +} + + +extern dm_boolean_t +dm_handle_is_valid( + void *hanp, + size_t hlen) +{ + if (parse_handle(hanp, hlen, NULL, NULL, NULL) != DM_HANDLE_BAD) + return(DM_TRUE); + return(DM_FALSE); +} + + +extern int +dm_handle_cmp( + void *hanp1, + size_t hlen1, + void *hanp2, + size_t hlen2) +{ + int diff; + + /* If the handles don't have the same length, then this is an + apples-and-oranges comparison. For lack of a better option, + use the handle lengths to sort them into an arbitrary order. + */ + if ((diff = (int)(hlen1 - hlen2)) != 0) + return diff; + return(memcmp(hanp1, hanp2, hlen1)); +} + + +extern u_int +dm_handle_hash( + void *hanp, + size_t hlen) +{ + size_t i; + u_int hash = 0; + u_char *ip = (u_char *)hanp; + + for (i = 0; i < hlen; i++) { + hash += *ip++; + } + return(hash); +} + + +extern int +dm_handle_to_fsid( + void *hanp, + size_t hlen, + dm_fsid_t *fsidp) +{ + dm_handletype_t htype; + + htype = parse_handle(hanp, hlen, fsidp, NULL, NULL); + if (htype == DM_HANDLE_FILE || htype == DM_HANDLE_FILESYSTEM) + return(0); + errno = EBADF; + return(-1); +} + + +extern int +dm_handle_to_ino( + void *hanp, + size_t hlen, + dm_ino_t *inop) +{ + if (parse_handle(hanp, hlen, NULL, inop, NULL) == DM_HANDLE_FILE) + return(0); + errno = EBADF; + return(-1); +} + + +extern int +dm_handle_to_igen( + void *hanp, + size_t hlen, + dm_igen_t *igenp) +{ + if (parse_handle(hanp, hlen, NULL, NULL, igenp) == DM_HANDLE_FILE) + return(0); + errno = EBADF; + return(-1); +} + + +extern int +dm_make_handle( + dm_fsid_t *fsidp, + dm_ino_t *inop, + dm_igen_t *igenp, + void **hanpp, + size_t *hlenp) +{ + xfs_fid2_t *xfid2; +/* XXX */ + xfs_handle_t handle; + + memcpy(&handle.ha_fsid, fsidp, sizeof(handle.ha_fsid)); + xfid2 = (struct xfs_fid2 *)&handle.ha_fid; + xfid2->fid_pad = 0; + xfid2->fid_gen = (__u32)*igenp; + xfid2->fid_ino = *inop; + xfid2->fid_len = sizeof(*xfid2) - sizeof(xfid2->fid_len); + *hlenp = sizeof(*xfid2) + sizeof(handle.ha_fsid); + if ((*hanpp = malloc(*hlenp)) == NULL) { + errno = ENOMEM; + return -1; + } + memcpy(*hanpp, &handle, *hlenp); + return(0); +} + + +extern int +dm_make_fshandle( + dm_fsid_t *fsidp, + void **hanpp, + size_t *hlenp) +{ +/* XXX */ +#if 0 + *hlenp = sizeof(fsid_t); +#else + *hlenp = sizeof(__kernel_fsid_t); +#endif + if ((*hanpp = malloc(*hlenp)) == NULL) { + errno = ENOMEM; + return -1; + } + memcpy(*hanpp, fsidp, *hlenp); + return(0); +} + + +extern int +dm_create_by_handle( + dm_sessid_t sid, + void *dirhanp, + size_t dirhlen, + dm_token_t token, + void *hanp, + size_t hlen, + char *cname) +{ + return dmi(DM_CREATE_BY_HANDLE, sid, dirhanp, dirhlen, token, + hanp, hlen, cname); +} + + +extern int +dm_mkdir_by_handle( + dm_sessid_t sid, + void *dirhanp, + size_t dirhlen, + dm_token_t token, + void *hanp, + size_t hlen, + char *cname) +{ + return dmi(DM_MKDIR_BY_HANDLE, sid, dirhanp, dirhlen, token, hanp, + hlen, cname); +} + + +extern int +dm_symlink_by_handle( + dm_sessid_t sid, + void *dirhanp, + size_t dirhlen, + dm_token_t token, + void *hanp, + size_t hlen, + char *cname, + char *path) +{ + return dmi(DM_SYMLINK_BY_HANDLE, sid, dirhanp, dirhlen, token, hanp, + hlen, cname, path); +} diff --git a/libdm/dm_handle2path.c b/libdm/dm_handle2path.c new file mode 100644 index 0000000..e4d0c4c --- /dev/null +++ b/libdm/dm_handle2path.c @@ -0,0 +1,269 @@ +/* + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it is + * free of the rightful claim of any third person regarding infringement + * or the like. Any license provided herein, whether implied or + * otherwise, applies only to this software file. Patent licenses, if + * any, provided herein do not apply to combinations of this program with + * other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston MA 02111-1307, USA. + * + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, + * Mountain View, CA 94043, or: + * + * http://www.sgi.com + * + * For further information regarding this notice, see: + * + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ + */ + +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#ifdef linux +#include <linux/unistd.h> +#endif + +#include <linux/dmapi_kern.h> +#include <dmapi_lib.h> +#include <handle.h> + +#include <asm/posix_types.h> +#include <linux/dirent.h> + + +/* Originally this routine called SGI_OPEN_BY_HANDLE on the target object, did + a fstat on it, then searched for the matching inode number in the directory + pointed to by dirhanp. There were a couple of problems with this. + 1. dm_handle_to_path is supposed to work for symlink target objects, but + didn't because SGI_OPEN_BY_HANDLE only works for files and directories. + 2. The wrong pathname was sometimes returned if dirhanp and targhanp pointed + to the same directory (a common request) because ".", ".." and/or various + subdirectories could all be mount points and therefore all have the same + inode number of 128. + 3. dm_handle_to_path wouldn't work if targhanp was a mount point because + routine getcomp() sees only the mounted-on directory, not the mount point. + + This rework of dm_handle_to_path fixes all these problems, but at a price, + because routine getcomp() must make one system call per directory entry. + Someday these two methods should be combined. If an SGI_OPEN_BY_HANDLE of + targhanp works and if both dirhanp and targhanp have the same dev_t, then + use the old method, otherwise use the current method. This will remove + the system call overhead in nearly all cases. +*/ + +static int getcomp(int dirfd, void *targhanp, size_t targhlen, + char *bufp, size_t buflen, size_t *rlenp); + + +extern int +dm_handle_to_path( + void *dirhanp, /* parent directory handle and length */ + size_t dirhlen, + void *targhanp, /* target object handle and length */ + size_t targhlen, + size_t buflen, /* length of pathbufp */ + char *pathbufp, /* buffer in which name is returned */ + size_t *rlenp) /* length of resultant pathname */ +{ + int dirfd = -1; /* fd for parent directory */ + int origfd = -1; /* fd for current working directory */ + int err; /* a place to save errno */ + + if (buflen == 0) { + errno = EINVAL; + return -1; + } + if (pathbufp == NULL || rlenp == NULL) { + errno = EFAULT; + return -1; + } + if ((origfd = open(".", O_RDONLY)) < 0) + return -1; /* leave errno set from open */ + +#if 0 + dirfd = (int)syssgi(SGI_OPEN_BY_HANDLE, dirhanp, dirhlen, O_RDONLY); +#else + dirfd = open_by_handle(dirhanp, dirhlen, O_RDONLY); +#endif + if (dirfd < 0) { + err = errno; + } else if (fchdir(dirfd)) { + err = errno; + } else { + /* From here on the fchdir must always be undone! */ + + if (!getcwd(pathbufp, buflen)) { + if ((err = errno) == ERANGE) /* buffer too small */ + err = E2BIG; + } else { + err = getcomp(dirfd, targhanp, targhlen, pathbufp, + buflen, rlenp); + } + (void) fchdir(origfd); /* can't do anything about a failure */ + } + + if (origfd >= 0) + (void)close(origfd); + if (dirfd >= 0) + (void)close(dirfd); + if (!err) + return(0); + + if (err == E2BIG) + *rlenp = 2 * buflen; /* guess since we don't know */ + errno = err; + return(-1); +} + + +/* Append the basename of the open file referenced by targfd found in the + directory dirfd to dirfd's pathname in bufp. The length of the entire + path (including the NULL) is returned in *rlenp. + + Returns zero if successful, an appropriate errno if not. +*/ + +#define READDIRSZ 16384 /* 6.x kernels use 16k buffer */ + +static int +getcomp( + int dirfd, + void *targhanp, + size_t targhlen, + char *bufp, + size_t buflen, + size_t *rlenp) +{ + char buf[READDIRSZ]; /* directory entry data buffer */ + int loc = 0; /* byte offset of entry in the buffer */ + int size = 0; /* number of bytes of data in buffer */ + int eof = 0; /* did last ngetdents exhaust dir.? */ +#if 0 +/* XXX */ + struct dirent64 *dp; /* pointer to directory entry */ +#else + struct dirent *dp; +#endif + char hbuf[DM_MAX_HANDLE_SIZE]; + size_t hlen; + size_t dirlen; /* length of dirfd's pathname */ + size_t totlen; /* length of targfd's pathname */ + dm_ino_t ino; /* target object's inode # */ + + if (dm_handle_to_ino(targhanp, targhlen, &ino)) + return -1; /* leave errno set from dm_handle_to_ino */ + + /* Append a "/" to the directory name unless the directory is root. */ + + dirlen = strlen(bufp); + if (dirlen > 1) { + if (buflen < dirlen + 1 + 1) + return(E2BIG); + bufp[dirlen++] = '/'; + } + + /* Examine each entry in the directory looking for one with a + matching target handle. + */ + + for(;;) { + if (size > 0) { + dp = (struct dirent *)&buf[loc]; + loc += dp->d_reclen; + } + if (loc >= size) { + if (eof) { + return(ENOENT); + } + loc = size = 0; + } + if (size == 0) { /* refill buffer */ +#ifdef linux + int cnt; + +/* XXX */ +_syscall3(int, getdents, uint, fd, struct dirent *, dirp, uint, count); + + + do { + cnt = getdents(dirfd, (struct dirent *)buf, + sizeof(buf) ); + if (cnt > 0 ) + size += cnt; + if (cnt < 0) + size = cnt; + } while( cnt > 0 ); + +#else + size = ngetdents64(dirfd, (struct dirent *)buf, + sizeof(buf), &eof); +#endif + if (size == 0) { /* This also means EOF */ + return(ENOENT); + } + if (size < 0) { /* error */ + return(errno); + } + } + dp = (struct dirent *)&buf[loc]; + + if (dp->d_ino != ino) + continue; /* wrong inode; try again */ + totlen = dirlen + strlen(dp->d_name) + 1; + if (buflen < totlen) + return(E2BIG); + (void)strcpy(bufp + dirlen, dp->d_name); + + if (dmi(DM_PATH_TO_HANDLE, bufp, hbuf, &hlen)) + continue; /* must have been removed/renamed */ + if (!dm_handle_cmp(targhanp, targhlen, hbuf, hlen)) + break; + } + + /* We have a match based upon the target handle. Clean up the end + cases before returning the path to the caller. + */ + + if (!strcmp(dp->d_name, ".")) { /* the directory itself */ + if (dirlen > 1) + dirlen--; + bufp[dirlen] = '\0'; /* trim the trailing "/." */ + *rlenp = dirlen + 1; + return(0); + } + if (!strcmp(dp->d_name, "..")) { /* the parent directory */ + char *slash; + + if (dirlen > 1) + dirlen--; + bufp[dirlen] = '\0'; + if ((slash = strrchr(bufp, '/')) == NULL) + return(ENXIO); /* getcwd screwed up */ + if (slash == bufp) /* don't whack "/" */ + slash++; + *slash = '\0'; /* remove the last component */ + *rlenp = strlen(bufp) + 1; + return(0); + } + + *rlenp = totlen; /* success! */ + return(0); +} diff --git a/libdm/dm_hole.c b/libdm/dm_hole.c new file mode 100644 index 0000000..15b4f78 --- /dev/null +++ b/libdm/dm_hole.c @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it is + * free of the rightful claim of any third person regarding infringement + * or the like. Any license provided herein, whether implied or + * otherwise, applies only to this software file. Patent licenses, if + * any, provided herein do not apply to combinations of this program with + * other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston MA 02111-1307, USA. + * + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, + * Mountain View, CA 94043, or: + * + * http://www.sgi.com + * + * For further information regarding this notice, see: + * + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ + */ + +#include <linux/dmapi_kern.h> +#include <dmapi_lib.h> + + +extern int +dm_get_allocinfo ( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + dm_off_t *offp, + u_int nelem, + dm_extent_t *extentp, + u_int *nelemp) +{ + return dmi(DM_GET_ALLOCINFO, sid, hanp, hlen, token, offp, nelem, + extentp, nelemp); +} + +extern int +dm_probe_hole( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + dm_off_t off, + dm_size_t len, + dm_off_t *roffp, + dm_size_t *rlenp) +{ + return dmi(DM_PROBE_HOLE, sid, hanp, hlen, token, off, len, roffp, rlenp); +} + +extern int +dm_punch_hole( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + dm_off_t off, + dm_size_t len) +{ + return dmi(DM_PUNCH_HOLE, sid, hanp, hlen, token, off, len); +} diff --git a/libdm/dm_mountinfo.c b/libdm/dm_mountinfo.c new file mode 100644 index 0000000..e250e5b --- /dev/null +++ b/libdm/dm_mountinfo.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it is + * free of the rightful claim of any third person regarding infringement + * or the like. Any license provided herein, whether implied or + * otherwise, applies only to this software file. Patent licenses, if + * any, provided herein do not apply to combinations of this program with + * other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston MA 02111-1307, USA. + * + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, + * Mountain View, CA 94043, or: + * + * http://www.sgi.com + * + * For further information regarding this notice, see: + * + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ + */ + +#include <linux/dmapi_kern.h> +#include <dmapi_lib.h> + + +extern int +dm_get_mountinfo( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + size_t buflen, + void *bufp, + size_t *rlenp) +{ + return dmi(DM_GET_MOUNTINFO, sid, hanp, hlen, token, buflen, + bufp, rlenp); +} diff --git a/libdm/dm_rdwr.c b/libdm/dm_rdwr.c new file mode 100644 index 0000000..f24d1e1 --- /dev/null +++ b/libdm/dm_rdwr.c @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it is + * free of the rightful claim of any third person regarding infringement + * or the like. Any license provided herein, whether implied or + * otherwise, applies only to this software file. Patent licenses, if + * any, provided herein do not apply to combinations of this program with + * other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston MA 02111-1307, USA. + * + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, + * Mountain View, CA 94043, or: + * + * http://www.sgi.com + * + * For further information regarding this notice, see: + * + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ + */ + +#include <linux/dmapi_kern.h> +#include <dmapi_lib.h> + + +extern dm_ssize_t +dm_read_invis( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + dm_off_t off, + dm_size_t len, + void *bufp) +{ + return dmi(DM_READ_INVIS, sid, hanp, hlen, token, off, len, bufp); +} + +extern dm_ssize_t +dm_write_invis( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + int flags, + dm_off_t off, + dm_size_t len, + void *bufp) +{ + return dmi(DM_WRITE_INVIS, sid, hanp, hlen, token, flags, off, len, bufp); +} + +extern int +dm_sync_by_handle( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token) +{ + return dmi(DM_SYNC_BY_HANDLE, sid, hanp, hlen, token); +} + + +extern int +dm_get_dioinfo( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + dm_dioinfo_t *diop) +{ + return dmi(DM_GET_DIOINFO, sid, hanp, hlen, token, diop); +} diff --git a/libdm/dm_region.c b/libdm/dm_region.c new file mode 100644 index 0000000..7758718 --- /dev/null +++ b/libdm/dm_region.c @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it is + * free of the rightful claim of any third person regarding infringement + * or the like. Any license provided herein, whether implied or + * otherwise, applies only to this software file. Patent licenses, if + * any, provided herein do not apply to combinations of this program with + * other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston MA 02111-1307, USA. + * + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, + * Mountain View, CA 94043, or: + * + * http://www.sgi.com + * + * For further information regarding this notice, see: + * + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ + */ + +#include <linux/dmapi_kern.h> +#include <dmapi_lib.h> + + +extern int +dm_get_region( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + u_int nelem, + dm_region_t *regbufp, + u_int *nelemp) +{ + return dmi(DM_GET_REGION, sid, hanp, hlen, token, nelem, + regbufp, nelemp); +} + +extern int +dm_set_region( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + u_int nelem, + dm_region_t *regbufp, + dm_boolean_t *exactflagp) +{ + return dmi(DM_SET_REGION, sid, hanp, hlen, token, nelem, + regbufp, exactflagp); +} diff --git a/libdm/dm_right.c b/libdm/dm_right.c new file mode 100644 index 0000000..ab92ebd --- /dev/null +++ b/libdm/dm_right.c @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it is + * free of the rightful claim of any third person regarding infringement + * or the like. Any license provided herein, whether implied or + * otherwise, applies only to this software file. Patent licenses, if + * any, provided herein do not apply to combinations of this program with + * other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston MA 02111-1307, USA. + * + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, + * Mountain View, CA 94043, or: + * + * http://www.sgi.com + * + * For further information regarding this notice, see: + * + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ + */ + +#include <linux/dmapi_kern.h> +#include <dmapi_lib.h> + + +extern int +dm_downgrade_right( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token) +{ + return dmi(DM_DOWNGRADE_RIGHT, sid, hanp, hlen, token); +} + + +extern int +dm_obj_ref_hold( + dm_sessid_t sid, + dm_token_t token, + void *hanp, + size_t hlen) +{ + return dmi(DM_OBJ_REF_HOLD, sid, token, hanp, hlen); +} + + +extern int +dm_obj_ref_query( + dm_sessid_t sid, + dm_token_t token, + void *hanp, + size_t hlen) +{ + return dmi(DM_OBJ_REF_QUERY, sid, token, hanp, hlen); +} + + +extern int +dm_obj_ref_rele( + dm_sessid_t sid, + dm_token_t token, + void *hanp, + size_t hlen) +{ + return dmi(DM_OBJ_REF_RELE, sid, token, hanp, hlen); +} + + +extern int +dm_query_right( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + dm_right_t *rightp) +{ + return dmi(DM_QUERY_RIGHT, sid, hanp, hlen, token, rightp); +} + + +extern int +dm_release_right( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token) +{ + return dmi(DM_RELEASE_RIGHT, sid, hanp, hlen, token); +} + + +extern int +dm_request_right( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token, + u_int flags, + dm_right_t right) +{ + return dmi(DM_REQUEST_RIGHT, sid, hanp, hlen, token, flags, right); +} + + +extern int +dm_upgrade_right( + dm_sessid_t sid, + void *hanp, + size_t hlen, + dm_token_t token) +{ + return dmi(DM_UPGRADE_RIGHT, sid, hanp, hlen, token); +} diff --git a/libdm/dm_session.c b/libdm/dm_session.c new file mode 100644 index 0000000..8eff0d8 --- /dev/null +++ b/libdm/dm_session.c @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it is + * free of the rightful claim of any third person regarding infringement + * or the like. Any license provided herein, whether implied or + * otherwise, applies only to this software file. Patent licenses, if + * any, provided herein do not apply to combinations of this program with + * other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston MA 02111-1307, USA. + * + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, + * Mountain View, CA 94043, or: + * + * http://www.sgi.com + * + * For further information regarding this notice, see: + * + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ + */ + +#include <linux/dmapi_kern.h> +#include <dmapi_lib.h> + + + +extern int +dm_init_service( + char **versionstrpp) +{ + int ret; + + *versionstrpp = DM_VER_STR_CONTENTS; + ret = dmi_init_service( *versionstrpp ); + return(ret); +} + +extern int +dm_create_session( + dm_sessid_t oldsid, + char *sessinfop, + dm_sessid_t *newsidp) +{ + return dmi(DM_CREATE_SESSION, oldsid, sessinfop, newsidp); +} + +extern int +dm_destroy_session( + dm_sessid_t sid) +{ + return dmi(DM_DESTROY_SESSION, sid); +} + +extern int +dm_getall_sessions( + u_int nelem, + dm_sessid_t *sidbufp, + u_int *nelemp) +{ + return dmi(DM_GETALL_SESSIONS, nelem, sidbufp, nelemp); +} + +extern int +dm_query_session( + dm_sessid_t sid, + size_t buflen, + void *bufp, + size_t *rlenp) +{ + return dmi(DM_QUERY_SESSION, sid, buflen, bufp, rlenp); +} + +extern int +dm_getall_tokens( + dm_sessid_t sid, + u_int nelem, + dm_token_t *tokenbufp, + u_int *nelemp) +{ + return dmi(DM_GETALL_TOKENS, sid, nelem, tokenbufp, nelemp); +} + +extern int +dm_find_eventmsg( + dm_sessid_t sid, + dm_token_t token, + size_t buflen, + void *bufp, + size_t *rlenp) +{ + return dmi(DM_FIND_EVENTMSG, sid, token, buflen, bufp, rlenp); +} |