fstests: remove DMAPI tests
authorDarrick J. Wong <djwong@kernel.org>
Thu, 11 Feb 2021 21:33:38 +0000 (13:33 -0800)
committerEryu Guan <guaneryu@gmail.com>
Sun, 14 Mar 2021 14:24:48 +0000 (22:24 +0800)
Upstream XFS has never supported DMAPI, so remove the tests for this
feature.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
183 files changed:
.gitignore
Makefile
common/dmapi [deleted file]
common/punch
common/rc
dmapi/Makefile [deleted file]
dmapi/README [deleted file]
dmapi/src/Makefile [deleted file]
dmapi/src/common/Makefile [deleted file]
dmapi/src/common/cmd/Makefile [deleted file]
dmapi/src/common/cmd/read_invis.c [deleted file]
dmapi/src/common/cmd/set_region.c [deleted file]
dmapi/src/common/cmd/set_return_on_destroy.c [deleted file]
dmapi/src/common/cmd/write_invis.c [deleted file]
dmapi/src/common/lib/Makefile [deleted file]
dmapi/src/common/lib/dmport.h [deleted file]
dmapi/src/common/lib/find_session.c [deleted file]
dmapi/src/common/lib/hsm.h [deleted file]
dmapi/src/common/lib/print.c [deleted file]
dmapi/src/common/lib/stubs.c [deleted file]
dmapi/src/common/lib/util.c [deleted file]
dmapi/src/sample_hsm/Makefile [deleted file]
dmapi/src/sample_hsm/README [deleted file]
dmapi/src/sample_hsm/migfind.c [deleted file]
dmapi/src/sample_hsm/migin.c [deleted file]
dmapi/src/sample_hsm/migout.c [deleted file]
dmapi/src/sample_hsm/mls.c [deleted file]
dmapi/src/sample_hsm/mrmean.c [deleted file]
dmapi/src/sample_hsm/wbee.c [deleted file]
dmapi/src/simple/Makefile [deleted file]
dmapi/src/simple/dm_create_session.c [deleted file]
dmapi/src/simple/dm_destroy_session.c [deleted file]
dmapi/src/simple/dm_find_eventmsg.c [deleted file]
dmapi/src/simple/dm_getall_sessions.c [deleted file]
dmapi/src/simple/dm_getall_tokens.c [deleted file]
dmapi/src/simple/dm_query_session.c [deleted file]
dmapi/src/suite1/Makefile [deleted file]
dmapi/src/suite1/cmd/Makefile [deleted file]
dmapi/src/suite1/cmd/create_userevent.c [deleted file]
dmapi/src/suite1/cmd/dm_handle.c [deleted file]
dmapi/src/suite1/cmd/downgrade_right.c [deleted file]
dmapi/src/suite1/cmd/fd_to_handle.c [deleted file]
dmapi/src/suite1/cmd/get_allocinfo.c [deleted file]
dmapi/src/suite1/cmd/get_config_events.c [deleted file]
dmapi/src/suite1/cmd/get_dirattrs.c [deleted file]
dmapi/src/suite1/cmd/get_dmattr.c [deleted file]
dmapi/src/suite1/cmd/get_eventlist.c [deleted file]
dmapi/src/suite1/cmd/get_events.c [deleted file]
dmapi/src/suite1/cmd/get_fileattr.c [deleted file]
dmapi/src/suite1/cmd/get_mountinfo.c [deleted file]
dmapi/src/suite1/cmd/get_region.c [deleted file]
dmapi/src/suite1/cmd/getall_disp.c [deleted file]
dmapi/src/suite1/cmd/getall_dmattr.c [deleted file]
dmapi/src/suite1/cmd/handle_to_fshandle.c [deleted file]
dmapi/src/suite1/cmd/handle_to_path.c [deleted file]
dmapi/src/suite1/cmd/init_service.c [deleted file]
dmapi/src/suite1/cmd/link_test.c [deleted file]
dmapi/src/suite1/cmd/make_rt_sparse.c [deleted file]
dmapi/src/suite1/cmd/make_sparse.c [deleted file]
dmapi/src/suite1/cmd/obj_ref_hold.c [deleted file]
dmapi/src/suite1/cmd/obj_ref_query.c [deleted file]
dmapi/src/suite1/cmd/obj_ref_rele.c [deleted file]
dmapi/src/suite1/cmd/path_to_fshandle.c [deleted file]
dmapi/src/suite1/cmd/path_to_handle.c [deleted file]
dmapi/src/suite1/cmd/pending.c [deleted file]
dmapi/src/suite1/cmd/print_event.c [deleted file]
dmapi/src/suite1/cmd/print_fshandle.c [deleted file]
dmapi/src/suite1/cmd/probe_hole.c [deleted file]
dmapi/src/suite1/cmd/probe_punch_xfsctl_hole.c [deleted file]
dmapi/src/suite1/cmd/punch_hole.c [deleted file]
dmapi/src/suite1/cmd/query_right.c [deleted file]
dmapi/src/suite1/cmd/randomize_file.c [deleted file]
dmapi/src/suite1/cmd/release_right.c [deleted file]
dmapi/src/suite1/cmd/remove_dmattr.c [deleted file]
dmapi/src/suite1/cmd/request_right.c [deleted file]
dmapi/src/suite1/cmd/respond_event.c [deleted file]
dmapi/src/suite1/cmd/rwt.c [deleted file]
dmapi/src/suite1/cmd/security_hole.c [deleted file]
dmapi/src/suite1/cmd/security_hole2.c [deleted file]
dmapi/src/suite1/cmd/set_disp.c [deleted file]
dmapi/src/suite1/cmd/set_dmattr.c [deleted file]
dmapi/src/suite1/cmd/set_eventlist.c [deleted file]
dmapi/src/suite1/cmd/set_fileattr.c [deleted file]
dmapi/src/suite1/cmd/struct_test.c [deleted file]
dmapi/src/suite1/cmd/sync_by_handle.c [deleted file]
dmapi/src/suite1/cmd/test_assumption.c [deleted file]
dmapi/src/suite1/cmd/upgrade_right.c [deleted file]
dmapi/src/suite1/function_coverage [deleted file]
dmapi/src/suite2/DMAPI_aliases [deleted file]
dmapi/src/suite2/Makefile [deleted file]
dmapi/src/suite2/README [deleted file]
dmapi/src/suite2/README_for_check_dmapi [deleted file]
dmapi/src/suite2/bindir/crttf [deleted file]
dmapi/src/suite2/bindir/ctf [deleted file]
dmapi/src/suite2/bindir/ls_to_copy [deleted file]
dmapi/src/suite2/bindir/make_holey [deleted file]
dmapi/src/suite2/bindir/run_test [deleted file]
dmapi/src/suite2/bindir/stf [deleted file]
dmapi/src/suite2/bindir/test_allocinfo_1 [deleted file]
dmapi/src/suite2/bindir/test_allocinfo_2 [deleted file]
dmapi/src/suite2/create_cpio [deleted file]
dmapi/src/suite2/data/fail.dat [deleted file]
dmapi/src/suite2/data/main.dat [deleted file]
dmapi/src/suite2/data/nfs.dat [deleted file]
dmapi/src/suite2/data/pending.dat [deleted file]
dmapi/src/suite2/data/pending_nfs.dat [deleted file]
dmapi/src/suite2/data/realtime.dat [deleted file]
dmapi/src/suite2/data/smallq.dat [deleted file]
dmapi/src/suite2/data/standard.dat [deleted file]
dmapi/src/suite2/data/standard_nfs.dat [deleted file]
dmapi/src/suite2/dist/README [deleted file]
dmapi/src/suite2/lib/errtest.h [deleted file]
dmapi/src/suite2/menu_test [deleted file]
dmapi/src/suite2/src/Makefile [deleted file]
dmapi/src/suite2/src/check_dmapi.c [deleted file]
dmapi/src/suite2/src/dm_test_daemon.c [deleted file]
dmapi/src/suite2/src/invis_test.c [deleted file]
dmapi/src/suite2/src/mm_fill.c [deleted file]
dmapi/src/suite2/src/mmap.c [deleted file]
dmapi/src/suite2/src/mmap_cp.c [deleted file]
dmapi/src/suite2/src/region_test.c [deleted file]
dmapi/src/suite2/src/send_msg.c [deleted file]
dmapi/src/suite2/src/test_bulkall.c [deleted file]
dmapi/src/suite2/src/test_bulkattr.c [deleted file]
dmapi/src/suite2/src/test_dmattr.c [deleted file]
dmapi/src/suite2/src/test_efault.c [deleted file]
dmapi/src/suite2/src/test_eventlist.c [deleted file]
dmapi/src/suite2/src/test_fileattr.c [deleted file]
dmapi/src/suite2/src/test_hole.c [deleted file]
dmapi/src/suite2/src/test_invis.c [deleted file]
dmapi/src/suite2/src/test_region.c [deleted file]
dmapi/src/suite2/src/test_rights.c [deleted file]
tests/xfs/142 [deleted file]
tests/xfs/142.out [deleted file]
tests/xfs/143 [deleted file]
tests/xfs/143.out [deleted file]
tests/xfs/144 [deleted file]
tests/xfs/144.out [deleted file]
tests/xfs/145 [deleted file]
tests/xfs/145.out [deleted file]
tests/xfs/146 [deleted file]
tests/xfs/146.out [deleted file]
tests/xfs/147 [deleted file]
tests/xfs/147.out [deleted file]
tests/xfs/150 [deleted file]
tests/xfs/150.out [deleted file]
tests/xfs/151 [deleted file]
tests/xfs/151.out [deleted file]
tests/xfs/152 [deleted file]
tests/xfs/152.out [deleted file]
tests/xfs/153 [deleted file]
tests/xfs/153.out [deleted file]
tests/xfs/154 [deleted file]
tests/xfs/154.out [deleted file]
tests/xfs/155 [deleted file]
tests/xfs/155.out [deleted file]
tests/xfs/156 [deleted file]
tests/xfs/156.out [deleted file]
tests/xfs/157 [deleted file]
tests/xfs/157.out [deleted file]
tests/xfs/158 [deleted file]
tests/xfs/158.out [deleted file]
tests/xfs/159 [deleted file]
tests/xfs/159.out [deleted file]
tests/xfs/160 [deleted file]
tests/xfs/160.out [deleted file]
tests/xfs/161 [deleted file]
tests/xfs/161.out [deleted file]
tests/xfs/162 [deleted file]
tests/xfs/162.out [deleted file]
tests/xfs/163 [deleted file]
tests/xfs/163.out [deleted file]
tests/xfs/168 [deleted file]
tests/xfs/168.out [deleted file]
tests/xfs/175 [deleted file]
tests/xfs/175.out [deleted file]
tests/xfs/176 [deleted file]
tests/xfs/176.out [deleted file]
tests/xfs/177 [deleted file]
tests/xfs/177.out [deleted file]
tests/xfs/185 [deleted file]
tests/xfs/185.out [deleted file]
tests/xfs/group

index f988a44..03c03be 100644 (file)
 /src/log-writes/replay-log
 /src/perf/*.pyc
 
-# dmapi/ binaries
-/dmapi/src/common/cmd/read_invis
-/dmapi/src/common/cmd/set_region
-/dmapi/src/common/cmd/set_return_on_destroy
-/dmapi/src/common/cmd/write_invis
-/dmapi/src/sample_hsm/migfind
-/dmapi/src/sample_hsm/migin
-/dmapi/src/sample_hsm/migout
-/dmapi/src/sample_hsm/mls
-/dmapi/src/sample_hsm/mrmean
-/dmapi/src/sample_hsm/wbee
-/dmapi/src/simple/dm_create_session
-/dmapi/src/simple/dm_destroy_session
-/dmapi/src/simple/dm_find_eventmsg
-/dmapi/src/simple/dm_getall_sessions
-/dmapi/src/simple/dm_getall_tokens
-/dmapi/src/simple/dm_query_session
-/dmapi/src/suite1/cmd/create_userevent
-/dmapi/src/suite1/cmd/dm_handle
-/dmapi/src/suite1/cmd/downgrade_right
-/dmapi/src/suite1/cmd/fd_to_handle
-/dmapi/src/suite1/cmd/get_allocinfo
-/dmapi/src/suite1/cmd/get_config_events
-/dmapi/src/suite1/cmd/get_dirattrs
-/dmapi/src/suite1/cmd/get_dmattr
-/dmapi/src/suite1/cmd/get_eventlist
-/dmapi/src/suite1/cmd/get_events
-/dmapi/src/suite1/cmd/get_fileattr
-/dmapi/src/suite1/cmd/get_mountinfo
-/dmapi/src/suite1/cmd/get_region
-/dmapi/src/suite1/cmd/getall_disp
-/dmapi/src/suite1/cmd/getall_dmattr
-/dmapi/src/suite1/cmd/handle_to_fshandle
-/dmapi/src/suite1/cmd/handle_to_path
-/dmapi/src/suite1/cmd/init_service
-/dmapi/src/suite1/cmd/link_test
-/dmapi/src/suite1/cmd/make_sparse
-/dmapi/src/suite1/cmd/obj_ref_hold
-/dmapi/src/suite1/cmd/obj_ref_query
-/dmapi/src/suite1/cmd/obj_ref_rele
-/dmapi/src/suite1/cmd/path_to_fshandle
-/dmapi/src/suite1/cmd/path_to_handle
-/dmapi/src/suite1/cmd/pending
-/dmapi/src/suite1/cmd/print_event
-/dmapi/src/suite1/cmd/print_fshandle
-/dmapi/src/suite1/cmd/probe_hole
-/dmapi/src/suite1/cmd/probe_punch_xfsctl_hole
-/dmapi/src/suite1/cmd/punch_hole
-/dmapi/src/suite1/cmd/query_right
-/dmapi/src/suite1/cmd/randomize_file
-/dmapi/src/suite1/cmd/release_right
-/dmapi/src/suite1/cmd/remove_dmattr
-/dmapi/src/suite1/cmd/request_right
-/dmapi/src/suite1/cmd/respond_event
-/dmapi/src/suite1/cmd/rwt
-/dmapi/src/suite1/cmd/set_disp
-/dmapi/src/suite1/cmd/set_dmattr
-/dmapi/src/suite1/cmd/set_eventlist
-/dmapi/src/suite1/cmd/set_fileattr
-/dmapi/src/suite1/cmd/struct_test
-/dmapi/src/suite1/cmd/sync_by_handle
-/dmapi/src/suite1/cmd/test_assumption
-/dmapi/src/suite1/cmd/upgrade_right
-/dmapi/src/suite2/src/dm_test_daemon
-/dmapi/src/suite2/src/invis_test
-/dmapi/src/suite2/src/mmap
-/dmapi/src/suite2/src/region_test
-/dmapi/src/suite2/src/send_msg
-/dmapi/src/suite2/src/test_bulkall
-/dmapi/src/suite2/src/test_bulkattr
-/dmapi/src/suite2/src/test_dmattr
-/dmapi/src/suite2/src/test_efault
-/dmapi/src/suite2/src/test_eventlist
-/dmapi/src/suite2/src/test_fileattr
-/dmapi/src/suite2/src/test_hole
-/dmapi/src/suite2/src/test_invis
-/dmapi/src/suite2/src/test_region
-/dmapi/src/suite2/src/test_rights
-
 # Symlinked files
 /tests/generic/035.out
 /tests/generic/050.out
index 9fd37e0..48927bc 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -39,9 +39,6 @@ endif
 
 LIB_SUBDIRS = include lib
 TOOL_SUBDIRS = ltp src m4 common
-ifeq ($(HAVE_DMAPI), true)
-TOOL_SUBDIRS += dmapi
-endif
 
 export TESTS_DIR = tests
 SUBDIRS = $(LIB_SUBDIRS) $(TOOL_SUBDIRS) $(TESTS_DIR)
diff --git a/common/dmapi b/common/dmapi
deleted file mode 100644 (file)
index 5f7e56f..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-##/bin/bash
-# SPDX-License-Identifier: GPL-2.0
-# Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
-#
-# dmapi functions
-
-# Commands relitive to dmapi qa
-
-DMAPI_QASUITE1_DIR=$here/dmapi/src/suite1/
-DMAPI_QASUITE2_DIR=$here/dmapi/src/suite2/
-DMAPI_COMMON_DIR=$here/dmapi/src/common/
-
-DMAPI_LS_TO_COPY_PATH=$DMAPI_QASUITE2_DIR/bindir/ls_to_copy
-
-_dmapi_scratch_mount () {
-    if [ `echo "$MOUNT_OPTIONS" | grep -c dmapi` -gt 0 -o \
-        `echo "$MOUNT_OPTIONS" | grep -c dmi` -gt 0 ] ; then
-        #already got dmapi options set
-        _try_scratch_mount
-        dmapi_mount_result=$?
-    else
-        _try_scratch_mount "-o dmapi,mtpt=$SCRATCH_MNT"
-        dmapi_mount_result=$?
-    fi
-
-    if [ $dmapi_mount_result -ne 0 ] ; then
-        _notrun "Assuming DMAPI modules are not loaded"
-    fi
-}
-
-
index 391d439..b6c337e 100644 (file)
@@ -4,9 +4,6 @@
 #
 # common functions for excersizing hole punches with extent size hints etc.
 
-# source dmap_scratch_mount etc.
-. ./common/dmapi
-
 _spawn_test_file() {
        echo "# spawning test file with $*"
        local blksize=$1
@@ -39,28 +36,6 @@ _spawn_test_file() {
        fi
 }
 
-_do_punch() {
-       echo "# punching with $*"
-       # punch or bite the ear off $test_file to create a hole
-       local blksize=$1
-       local punch_offset=`expr $2 \* $blksize`
-       local punch_size=`expr $3 \* $blksize`
-       local punch_type=$4             # u for unresvsp, d for dm_punch
-       local test_file=$5
-
-       if [ "$punch_type" == "u" ]; then
-               echo "+ hole punch using unresvsp"
-               $XFS_IO_PROG -f \
-               -c "unresvsp $punch_offset $punch_size" \
-               $test_file
-       fi
-       if [ "$punch_type" == "d" ]; then
-               echo "+ hole punch using dmapi punch_hole"
-               ${DMAPI_QASUITE1_DIR}cmd/punch_hole -o $punch_offset -l $punch_size \
-                       ${SCRATCH_MNT}/$test_file
-       fi
-}
-
 _do_write() {
        echo "# writing with $*"
        local blksize=$1
@@ -82,87 +57,6 @@ _do_bmap() {
        $test_file
 }
 
-_test_punch() {
-       echo "# testing $* ..."
-       local blksize=$1
-       # all points and sizes below are in terms of filesystem blocks
-       local extsize_hint_blks=$2              # extent size hint in FS blocks, 0=do not set
-       local file_size_blks=$3                 # the file size in blocks
-       local punch_points_blks=( $4 )  # array of places to punch holes in the file
-       local punch_sizes_blks=( $5 )   # array of size of each punch in blocks
-       local punch_types=( $6  )               # array of u=unresvsp or d=dm_punch
-       local write_points_blks=( $7 )  # array of places to pwrite in the file
-       local write_sizes_blks=( $8 )   # array of size of each write
-
-       local punch_write_order=( $9 )  # array of punch/write operation order
-                                                                       # e.g. "w p w w p" means: do 1st write...
-                                                                       # then 1st punch, 2nd & 3rd write, 2nd punch
-       local resvsp=${10}                              # if "noresv" then don't resvsp on file create
-       local filename=punch_test_file
-
-       cd /
-       _scratch_unmount >/dev/null 2>&1
-
-       _scratch_mkfs_xfs -bsize=$blksize >/dev/null 2>&1 \
-               || _fail "mkfs failed"
-
-       local this_punch_type=""
-       local dmap_punch_used=0
-       for this_punch_type in "${punch_types[@]}"; do
-               [ "$this_punch_type" == "d" ] && dmap_punch_used=1
-       done
-       if [ $dmap_punch_used -ne 0 ]; then
-               # a punch type of dm_punch has been specified, do a dmapi mount
-               echo "+ mounting with dmapi enabled"
-               _dmapi_scratch_mount
-       else
-               # only unresvsp punch type is used, just do a normal mount
-               _scratch_mount
-       fi
-
-       cd $SCRATCH_MNT
-
-       # check a size is specified for each punch
-       [ ${#punch_points_blks[*]} -eq ${#punch_sizes_blks[*]} ] \
-               || _fail "num punch points given does not equal num punch sizes"
-
-       # check a type is specified for each punch
-       [ ${#punch_points_blks[*]} -eq ${#punch_types[*]} ] \
-               || _fail "num punch points given does not equal num punch types"
-
-       # check a size is specified for each write
-       [ ${#write_points_blks[*]} -eq ${#write_sizes_blks[*]} ] \
-               || _fail "num write points given does not equal num write sizes"
-
-       # check punch_write_order operations match number of punches + writes
-       local total_pw_operations=`expr ${#punch_points_blks[*]} + ${#write_points_blks[*]}`
-       [ $total_pw_operations -eq ${#punch_write_order[*]} ] \
-               || _fail "punch_write_order ops doesn't match number of punches + writes"
-
-       # create the file and setup extent size hint
-       _spawn_test_file $blksize $file_size_blks $extsize_hint_blks $filename $resvsp
-
-       # do the writes and punches
-       local operation=""
-       local punch_index=0
-       local write_index=0
-       for operation in "${punch_write_order[@]}"; do
-               if [ "$operation" == "p" ]; then
-                       _do_punch $blksize ${punch_points_blks[$punch_index]} \
-                               ${punch_sizes_blks[$punch_index]} ${punch_types[$punch_index]} \
-                               $filename
-                       punch_index=`expr $punch_index + 1`
-               fi
-               if [ "$operation" == "w" ]; then
-                       _do_write $blksize ${write_points_blks[$write_index]} \
-                               ${write_sizes_blks[$write_index]} $filename
-                       write_index=`expr $write_index + 1`
-               fi
-               sync
-               _do_bmap $filename              # print out the state of the file
-       done
-}
-
 _coalesce_extents()
 {
        block_size=$1
index 0ce3cb0..aa9962c 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -281,8 +281,8 @@ _mount_ops_filter()
     [ $last_index -gt 0 ] && shift $last_index
     local fs_escaped=$1
 
-    echo $params | sed -e 's/dmapi/dmi/' \
-        $PERL_PROG -ne "s#mtpt=[^,|^\n|^\s]*#mtpt=$fs_escaped\1\2#; print;"
+    echo $params | \
+        $PERL_PROG -ne "s#mtpt=[^,|^\n|^\s]*#mtpt=$fs_escaped\1\2#; print;"
 
 }
 
diff --git a/dmapi/Makefile b/dmapi/Makefile
deleted file mode 100644 (file)
index 88da5b3..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-# Copyright (C) 2011 SGI  All Rights Reserved.
-#
-#
-#
-TOPDIR = ..
-
-include $(TOPDIR)/include/builddefs
-
-SUBDIRS = src
-
-default: $(SUBDIRS)
-
-include $(BUILDRULES)
-
-install: default
diff --git a/dmapi/README b/dmapi/README
deleted file mode 100644 (file)
index 259cdee..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-
-The tests in this directory are a collection of suites that were developed
-over the time the DMAPI spec was being created and when DMAPI was being
-implemented on Irix.  In many cases, each suite was built on an earlier suite.
-Many of these tests have been ported to work with XFS/DMAPI on linux 2.4; many
-are untouched from their Irix versions.
diff --git a/dmapi/src/Makefile b/dmapi/src/Makefile
deleted file mode 100644 (file)
index 6220b96..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-# Copyright (C) 2011 SGI  All Rights Reserved.
-#
-#
-#
-TOPDIR = ../..
-
-include $(TOPDIR)/include/builddefs
-
-LIB_SUBDIRS = common
-TOOL_SUBDIRS = sample_hsm simple suite1 suite2
-
-SUBDIRS = $(LIB_SUBDIRS) $(TOOL_SUBDIRS)
-
-default: $(SUBDIRS)
-
-$(TOOL_SUBDIRS): $(LIB_SUBDIRS)
-
-include $(BUILDRULES)
-
-install: default
diff --git a/dmapi/src/common/Makefile b/dmapi/src/common/Makefile
deleted file mode 100644 (file)
index 0441324..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-# Copyright (C) 2011 SGI  All Rights Reserved.
-#
-#
-#
-TOPDIR = ../../..
-
-include $(TOPDIR)/include/builddefs
-
-LIB_SUBDIRS = lib
-TOOL_SUBDIRS = cmd
-
-SUBDIRS = $(LIB_SUBDIRS) $(TOOL_SUBDIRS)
-
-default: $(SUBDIRS)
-
-$(TOOL_SUBDIRS): $(LIB_SUBDIRS)
-
-include $(BUILDRULES)
-
-install: default
-
-install-dev:
diff --git a/dmapi/src/common/cmd/Makefile b/dmapi/src/common/cmd/Makefile
deleted file mode 100644 (file)
index 909f139..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-# Copyright (C) 2011 SGI  All Rights Reserved.
-#
-#
-#
-TOPDIR = ../../../..
-
-include $(TOPDIR)/include/builddefs
-
-TARGETS = read_invis set_region set_return_on_destroy write_invis
-
-CFILES = $(TARGETS:=.c)
-LDIRT = $(TARGETS)
-
-CFLAGS += -I.. -I/usr/include/xfs
-
-LLDLIBS = $(TOPDIR)/dmapi/src/common/lib/libdmtest.la $(LIBDM)
-
-default: depend $(TARGETS)
-
-depend: .dep
-
-include $(BUILDRULES)
-
-install install-dev: default
-
-$(TARGETS):
-       @echo "    [CC]    $@"
-       $(Q)$(LTLINK) $@.c -o $@ $(CFLAGS) $(LDFLAGS) $(LDLIBS)
-
--include .dep
diff --git a/dmapi/src/common/cmd/read_invis.c b/dmapi/src/common/cmd/read_invis.c
deleted file mode 100644 (file)
index 4ea3c05..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-
-#include <ctype.h>
-
-#include <lib/hsm.h>
-
-#include <string.h>
-#include <malloc.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-/*---------------------------------------------------------------------------
-
-Test program used to test the DMAPI function dm_read_invis().  The
-command line is:
-
-       read_invis [-o offset] [-l length] [-s sid] [-c char] \
-               [-S storefile] {pathname|handle}
-
-where:
-'offset' is the offset of the start of the write (0 is the default),
-'length' is the length of the write in bytes (1 is the default),
-'sid' is the session ID whose events you you are interested in.
-'pathname' is the name of the file to be written.
-'char' is ignored--it just allows read_invis and write_invis to have
-    interchangeable commandlines without having to fuss with the params.
-
-----------------------------------------------------------------------------*/
-
-#ifndef linux
-extern char    *sys_errlist[];
-#endif
-extern  int     optind;
-extern  char    *optarg;
-
-
-char   *Progname;
-
-
-static void
-usage(void)
-{
-       fprintf(stderr, "usage:\t%s [-o offset] [-l length] "
-               "[-s sid] [-c char] "
-               "[-S storefile] {pathname|handle}\n", Progname);
-       exit(1);
-}
-
-
-int
-main(
-       int     argc, 
-       char    **argv)
-{
-       dm_sessid_t     sid = DM_NO_SESSION;
-       char            *object = NULL;
-       dm_off_t        offset = 0;
-       long long       lltemp;
-       dm_size_t       length = 1;
-       unsigned long long      ulltemp;
-       char            *bufp = NULL;
-       void            *hanp;
-       size_t          hlen;
-       dm_ssize_t      rc;
-       char            *name;
-       int             opt;
-       int             i;
-       char            *storefile = NULL;
-       int             storefd = 0;
-       int             exit_status = 0;
-
-       Progname = strrchr(argv[0], '/');
-       if (Progname) {
-               Progname++;
-       } else {
-               Progname = argv[0];
-       }
-
-       /* Crack and validate the command line options. */
-
-       while ((opt = getopt(argc, argv, "o:l:s:c:S:")) != EOF) {
-               switch (opt) {
-               case 'o':
-                       sscanf(optarg, "%lld", &lltemp);
-                       offset = (dm_off_t) lltemp;
-                       break;
-               case 'l':
-                       sscanf(optarg, "%llu", &ulltemp);
-                       length = (dm_size_t) ulltemp;
-                       break;
-               case 's':
-                       sid = atol(optarg);
-                       break;
-               case 'c':
-                       /* This is a no-op, it just allows read_invis
-                        * and write_invis to have interchangeable
-                        * commandlines, without having to fuss with
-                        * the params.
-                        */
-                       break;
-               case 'S':
-                       storefile = optarg;
-                       break;
-               case '?':
-                       usage();
-               }
-       }
-       if (optind + 1 != argc)
-               usage();
-       object = argv[optind];
-
-       if (dm_init_service(&name) == -1)  {
-               fprintf(stderr, "Can't initialize the DMAPI\n");
-               exit(1);
-       }
-       if (sid == DM_NO_SESSION)
-               find_test_session(&sid);
-
-       /* Get the file's handle. */
-
-       if (opaque_to_handle(object, &hanp, &hlen)) {
-               fprintf(stderr, "can't get handle for %s\n", object);
-               exit(1);
-       }
-
-       if (length > 0) {
-               /* In case it is a realtime file, align the buffer on a
-                  sufficiently big boundary.
-               */
-               if ((bufp = memalign(4096, length)) == NULL) {
-                       fprintf(stderr, "malloc of %llu bytes failed\n",
-                               (unsigned long long) length);
-                       exit(1);
-               }
-               memset(bufp, '\0', length);
-       }
-
-       if (storefile) {
-               off_t   lret;
-
-               if ((storefd = open(storefile, O_WRONLY|O_CREAT, 0777)) == -1) {
-                       fprintf(stderr, "unable to open store file for write (%s), errno = %d\n", storefile, errno);
-                       exit(1);
-               }
-               lret = lseek(storefd, offset, SEEK_SET);
-               if (lret < 0) {
-                       fprintf(stderr, "unable to lseek(%s) to offset %lld, errno = %d\n",
-                               storefile, (long long)lret, errno);
-                       exit(1);
-               }
-       }
-
-       rc = dm_read_invis(sid, hanp, hlen, DM_NO_TOKEN, offset, length, bufp);
-
-       if (rc < 0) {
-               fprintf(stderr, "dm_read_invis failed, %s\n", strerror(errno));
-               exit_status++;
-       } else if (rc != length) {
-               fprintf(stderr, "dm_read_invis expected to read %llu bytes, actually "
-                       "read %lld\n", (unsigned long long) length,
-                       (long long) rc);
-               exit_status++;
-       }
-
-       if (storefile) {
-               ssize_t sret;
-               sret = write(storefd, bufp, rc);
-               if (sret < 0) {
-                       fprintf(stderr, "unable to write to store file (%s), errno = %d\n", storefile, errno);
-                       exit_status++;
-               }
-               else if (sret != rc) {
-                       fprintf(stderr, "write(%s) returned %lld, expected %lld\n",
-                               storefile, (long long)sret, (long long)rc);
-                       exit_status++;
-               }
-               close(storefd);
-       }
-       else {
-               for (i = 0; i < rc; i++) {
-                       if (isprint(bufp[i])) {
-                               fprintf(stdout, "%c", bufp[i]);
-                       } else {
-                               fprintf(stdout, "\\%03d", bufp[i]);
-                       }
-               }
-       }
-       dm_handle_free(hanp, hlen);
-       exit(exit_status);
-}
diff --git a/dmapi/src/common/cmd/set_region.c b/dmapi/src/common/cmd/set_region.c
deleted file mode 100644 (file)
index c0ac28c..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-
-#include <lib/hsm.h>
-
-#include <string.h>
-#include <getopt.h>
-
-/*---------------------------------------------------------------------------
-
-Test program used to test the DMAPI function dm_set_region().  The
-command line is:
-
-       set_region [-n nelem] [-o offset] [-l length] [-s sid] {pathname|handle} [event...]
-
-where pathname is the name of a file, nelem is the number of regions to pass
-in the call, offset is the offset of the start of
-the managed region, and length is the length.  sid is the session ID whose
-events you you are interested in, and event is zero or more managed region
-events to set.
-
-----------------------------------------------------------------------------*/
-
-#ifndef linux
-extern char    *sys_errlist[];
-#endif
-extern  int     optind;
-extern  char    *optarg;
-
-
-char   *Progname;
-
-static struct  {
-       char    *name;
-       int     value;
-} rg_events[3] = {
-       { "DM_REGION_READ", DM_REGION_READ },
-       { "DM_REGION_WRITE", DM_REGION_WRITE },
-       { "DM_REGION_TRUNCATE", DM_REGION_TRUNCATE }
-};
-static int     nevents = sizeof(rg_events)/sizeof(rg_events[0]);
-
-
-static void
-usage(void)
-{
-       int     i;
-
-       fprintf(stderr, "usage:\t%s [-n nelem] [-o offset] [-l length] "
-               "[-s sid] {pathname|handle} [event...]\n", Progname);
-       fprintf(stderr, "possible events are:\n");
-       for (i = 0; i < nevents; i++)
-               fprintf(stderr, "%s (0x%x)\n", rg_events[i].name, rg_events[i].value);
-       exit(1);
-}
-
-
-int
-main(
-       int     argc, 
-       char    **argv)
-{
-       dm_region_t     region = { 0, 0, 0 };
-       dm_sessid_t     sid = DM_NO_SESSION;
-       char            *object = NULL;
-       u_int           exactflag;
-       u_int           nelem = 1;
-       void            *hanp;
-       size_t           hlen;
-       char            *name;
-       int             opt;
-       int             i;
-
-       Progname = strrchr(argv[0], '/');
-       if (Progname) {
-               Progname++;
-       } else {
-               Progname = argv[0];
-       }
-
-       /* Crack and validate the command line options. */
-
-       while ((opt = getopt(argc, argv, "n:o:l:s:")) != EOF) {
-               switch (opt) {
-               case 'n':
-                       nelem = atol(optarg);
-                       break;
-               case 'o':
-                       region.rg_offset = atol(optarg);
-                       break;
-               case 'l':
-                       region.rg_size = atol(optarg);
-                       break;
-               case 's':
-                       sid = atol(optarg);
-                       break;
-               case '?':
-                       usage();
-               }
-       }
-       if (optind + 1 > argc)
-               usage();
-       object = argv[optind++];
-
-       if (dm_init_service(&name) == -1)  {
-               fprintf(stderr, "Can't initialize the DMAPI\n");
-               exit(1);
-       }
-       if (sid == DM_NO_SESSION)
-               find_test_session(&sid);
-
-       /* Get the file's handle. */
-
-       if (opaque_to_handle(object, &hanp, &hlen)) {
-               fprintf(stderr, "can't get handle for %s\n", object);
-               exit(1);
-       }
-
-       for (; optind < argc; optind++) {
-               if (strspn(argv[optind], "0123456789") == strlen(argv[optind])){
-                       region.rg_flags |= atol(argv[optind]);
-                       continue;
-               }
-               for (i = 0; i < nevents; i++) {
-                       if (!strcmp(argv[optind], rg_events[i].name))
-                               break;
-               }
-               if (i == nevents) {
-                       fprintf(stderr, "invalid event %s\n", argv[optind]);
-                       exit(1);
-               }
-               region.rg_flags |= rg_events[i].value;
-       }
-
-       if (dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem, &region,
-           &exactflag)) {
-               fprintf(stderr, "dm_set_region failed, %s\n",
-                       strerror(errno));
-               exit(1);
-       }
-       fprintf(stdout, "exactflag is %s\n",
-               exactflag == DM_TRUE ? "True" : "False");
-       dm_handle_free(hanp, hlen);
-       exit(0);
-}
diff --git a/dmapi/src/common/cmd/set_return_on_destroy.c b/dmapi/src/common/cmd/set_return_on_destroy.c
deleted file mode 100644 (file)
index 078cc93..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-
-#include <lib/hsm.h>
-
-#include <string.h>
-#include <getopt.h>
-
-/*---------------------------------------------------------------------------
-
-Test program used to test the DMAPI function dm_set_return_on_destroy().  The
-command line is:
-
-       set_return_on_destroy [-F] [-s sid] [-t token] {pathname|fshandle} [attr]
-
-where pathname is the name of a file which resides in the filesystem of
-interest.  attr is the name of the DMAPI attribute; if none is specified,
-then set-return-on-destroy will be disabled for the filesystem.
-sid is the session ID whose attribute you are interested in setting.
-
-Use -F if you want the program to find the fshandle based on the pathname.
-
-----------------------------------------------------------------------------*/
-
-#ifndef linux
-extern char    *sys_errlist[];
-#endif
-extern  int     optind;
-extern  char    *optarg;
-
-
-char   *Progname;
-
-static void
-usage(void)
-{
-       fprintf(stderr, "usage:\t%s [-F] [-s sid] [-t token] {pathname|fshandle} [attr]\n", Progname);
-       exit(1);
-}
-
-
-int
-main(
-       int     argc, 
-       char    **argv)
-{
-       dm_sessid_t     sid = DM_NO_SESSION;
-       dm_token_t      token = DM_NO_TOKEN;
-       char            *pathname;
-       dm_attrname_t   *attrnamep = NULL;
-       dm_boolean_t    enable = DM_FALSE;
-       void            *hanp;
-       size_t          hlen;
-       char            *name;
-       int             opt;
-       int             Fflag = 0;
-
-       Progname = strrchr(argv[0], '/');
-       if (Progname) {
-               Progname++;
-       } else {
-               Progname = argv[0];
-       }
-
-       /* Crack and validate the command line options. */
-
-       while ((opt = getopt(argc, argv, "Fs:t:")) != EOF) {
-               switch (opt) {
-               case 's':
-                       sid = atol(optarg);
-                       break;
-               case 't':
-                       token = atol(optarg);
-                       break;
-               case 'F':
-                       Fflag++;
-                       break;
-               case '?':
-                       usage();
-               }
-       }
-       if (optind == argc || optind + 2 < argc)
-               usage();
-       pathname = argv[optind++];
-       if (optind < argc) {
-               enable = DM_TRUE;
-               attrnamep = (dm_attrname_t *)argv[optind++];
-       }
-
-       if (dm_init_service(&name) == -1)  {
-               fprintf(stderr, "Can't initialize the DMAPI\n");
-               exit(1);
-       }
-       if (sid == DM_NO_SESSION)
-               find_test_session(&sid);
-
-       if (opaque_to_handle(pathname, &hanp, &hlen)) {
-               fprintf(stderr, "can't get handle for %s\n", pathname);
-               exit(1);
-       }
-
-       /* Get the file's handle. */
-
-       if (Fflag) {
-               void *fshanp;
-               size_t fshlen;
-
-               if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
-                       fprintf(stderr, "can't get filesystem handle for file %s, %s\n",
-                               pathname, strerror(errno));
-                       exit(1);
-               }
-               dm_handle_free(hanp, hlen);
-               hanp = fshanp;
-               hlen = fshlen;
-       }
-
-       if (dm_set_return_on_destroy(sid, hanp, hlen, token,
-           attrnamep, enable)) {
-               fprintf(stderr, "dm_set_return_on_destroy failed, %s\n",
-                       strerror(errno));
-               exit(1);
-       }
-
-       dm_handle_free(hanp, hlen);
-       exit(0);
-}
diff --git a/dmapi/src/common/cmd/write_invis.c b/dmapi/src/common/cmd/write_invis.c
deleted file mode 100644 (file)
index aab74e8..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-
-#include <lib/hsm.h>
-
-#include <unistd.h>
-#include <string.h>
-#include <malloc.h>
-#include <getopt.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-/*---------------------------------------------------------------------------
-
-Test program used to test the DMAPI function dm_write_invis().  The
-command line is:
-
-       write_invis [-c char] [-o offset] [-l length] [-s sid] \
-               [-S storefile] {pathname|handle}
-
-where:
-'char' is the character to use as a repeated pattern ('X' is the default),
-'offset' is the offset of the start of the write (0 is the default),
-'length' is the length of the write in bytes (1 is the default),
-'sid' is the session ID whose events you you are interested in.
-'pathname' is the name of the file to be written.
-
-DM_WRITE_SYNC is is not supported.
-
-----------------------------------------------------------------------------*/
-
-#ifndef linux
-extern char    *sys_errlist[];
-#endif
-extern  int     optind;
-extern  char    *optarg;
-
-
-char   *Progname;
-
-
-static void
-usage(void)
-{
-       fprintf(stderr, "usage:\t%s [-c char] [-o offset] [-l length] "
-               "[-s sid] [-S storefile] {pathname|handle}\n", Progname);
-       exit(1);
-}
-
-
-int
-main(
-       int     argc, 
-       char    **argv)
-{
-       dm_sessid_t     sid = DM_NO_SESSION;
-       char            *object = NULL;
-       dm_off_t        offset = 0;
-       long long       lltemp;
-       dm_size_t       length = 1;
-       unsigned long long      ulltemp;
-       u_char          ch = 'X';
-       void            *bufp = NULL;
-       void            *hanp;
-       size_t          hlen;
-       dm_ssize_t      rc;
-       char            *name;
-       int             opt;
-       char            *storefile = NULL;
-       int             storefd;
-       int             exit_status = 0;
-
-       Progname = strrchr(argv[0], '/');
-       if (Progname) {
-               Progname++;
-       } else {
-               Progname = argv[0];
-       }
-
-       /* Crack and validate the command line options. */
-
-       while ((opt = getopt(argc, argv, "c:o:l:s:S:")) != EOF) {
-               switch (opt) {
-               case 'c':
-                       ch = *optarg;
-                       break;
-               case 'o':
-                       sscanf(optarg, "%lld", &lltemp);
-                       offset = (dm_off_t) offset;
-                       break;
-               case 'l':
-                       sscanf(optarg, "%llu", &ulltemp);
-                       length = (dm_size_t) ulltemp;
-                       break;
-               case 's':
-                       sid = atol(optarg);
-                       break;
-               case 'S':
-                       storefile = optarg;
-                       break;
-               case '?':
-                       usage();
-               }
-       }
-       if (optind + 1 != argc)
-               usage();
-       object = argv[optind];
-
-       if (dm_init_service(&name) == -1)  {
-               fprintf(stderr, "Can't initialize the DMAPI\n");
-               exit(1);
-       }
-       if (sid == DM_NO_SESSION)
-               find_test_session(&sid);
-
-       /* Get the file's handle. */
-
-       if (opaque_to_handle(object, &hanp, &hlen)) {
-               fprintf(stderr, "can't get handle for %s\n", object);
-               exit(1);
-       }
-
-       if (length > 0) {
-               /* In case it is a realtime file, align the buffer on a
-                  sufficiently big boundary.
-               */
-               if ((bufp = memalign(4096, length)) == NULL) {
-                       fprintf(stderr, "malloc of %llu bytes failed\n",
-                               (unsigned long long) length);
-                       exit(1);
-               }
-               memset(bufp, ch, length);
-       }
-
-       if (storefile) {
-               ssize_t sret;
-               size_t len;
-
-               if ((storefd = open(storefile, O_RDONLY)) == -1) {
-                       fprintf(stderr, "unable to open store file for read (%s), errno = %d\n", storefile, errno);
-                       exit(1);
-               }
-
-               len = length;
-               sret = read(storefd, bufp, len);
-               if (sret < 0) {
-                       fprintf(stderr, "unable to read store file (%s), errno = %d\n", storefile, errno);
-                       exit(1);
-               }
-               else if (sret != length) {
-                       fprintf(stderr, "read(%s) returned %lld, expected %lld\n",
-                               storefile, (long long)sret, (long long)length);
-                       exit(1);
-               }
-               close(storefd);
-       }
-
-       rc = dm_write_invis(sid, hanp, hlen, DM_NO_TOKEN, 0, offset, length, bufp);
-
-       if (rc < 0) {
-               fprintf(stderr, "dm_write_invis failed, %s\n", strerror(errno));
-               exit_status++;
-       } else if (rc != length) {
-               fprintf(stderr, "dm_write_invis expected to write %llu bytes, "
-                       "actually wrote %lld\n",
-                       (unsigned long long) length, (long long)rc);
-               exit_status++;
-       }
-       dm_handle_free(hanp, hlen);
-       exit(exit_status);
-}
diff --git a/dmapi/src/common/lib/Makefile b/dmapi/src/common/lib/Makefile
deleted file mode 100644 (file)
index 463bf78..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-# Copyright (C) 2011 SGI  All Rights Reserved.
-#
-#
-#
-TOPDIR = ../../../..
-
-include $(TOPDIR)/include/builddefs
-
-LTLIBRARY = libdmtest.la
-
-LTLDFLAGS = -static
-
-LT_CURRENT = 1
-LT_REVISION = 0
-LT_AGE = 0
-
-CFILES = find_session.c print.c stubs.c util.c
-HFILES = hsm.h dmport.h
-
-CFLAGS += -I$(TOPDIR)/dmapi/src/common -I/usr/include/xfs
-
-default: depend $(LTLIBRARY)
-
-depend: .ltdep
-
-include $(BUILDRULES)
-
-install install-dev: default
-
--include .ltdep
diff --git a/dmapi/src/common/lib/dmport.h b/dmapi/src/common/lib/dmport.h
deleted file mode 100644 (file)
index 0aac506..0000000
+++ /dev/null
@@ -1,859 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-
-#ifndef        _DMFSAPI_DMPORT_H
-#define        _DMFSAPI_DMPORT_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**************************************************************************
- *                                                                        *
- * DMF's use of DMAPI is based upon the X/Open document                  *
- *      Systems Management: Data Storage Managment (XDSM) API             *
- * dated February 1997.  However, no implementation of DMAPI perfectly   *
- * matches the spec.  Each implementation has some functions that it     *
- * didn't implement, non-standard functions that it added, differences   *
- * in function parameter types, return value types, number and order of          *
- * parameters, etc.  There are also differences in the formats of some   *
- * of the DMAPI structures used by those functions.  Finally, there are          *
- * many scalar values for which DMAPI assigned no particular size.  For          *
- * example, a dm_fsid_t is 32 bits under Veritas and 64 bits under SGI.   *
- *                                                                       *
- * To hide the differences as much as possible, this include file tries          *
- * to shoehorn each DMAPI implementation into the XDSM mold as much as   *
- * possible.  Functions which are not compatible with the XDSM spec are   *
- * redefined using wrapper routines to make them conform to the spec.    *
- * Functions which were not implemented have stubs defined which return   *
- * ENOSYS (see file stubs.c for all wrappers and stubs).  In dmport.h,   *
- * missing structures and scalers are defined, incompatible typedefs are  *
- * redefined, etc.                                                       *
- *                                                                       *
- * The goal is to reduce as much as possible the number of #ifdefs that   *
- * have to be added to DMF to handle specific DMAPI implementations.      *
- * Some #ifdefs may still be required because of semantic differences     *
- * between the XDSM spec definition and the actual implementation.       *
- *                                                                       *
- * Following all the implementation-specific definitions, dmport.h       *
- * includes a complete set of prototypes for all functions that are part  *
- * of  the XDSM specification.  This is done as a double-check.  Should   *
- * any of the actual implementations change, the compiler should tip us   *
- * off by complaining about imcompatible function redefinitions.         *
- *                                                                        *
- **************************************************************************/
-
-
-/* ---------------- Veritas-specific hack documentation -----------------
-
-The following functions have no prototypes in the Veritas include file
-<sys/dmapi/dmapi.h>.  They do not link either.
-
-extern int dm_handle_is_valid(void *, size_t);
-
-
-The following functions have prototypes in <sys/dmapi/dmapi.h>, but
-they do not link.
-
-extern int dm_getall_disp(dm_sessid_t, size_t, void *, size_t *);
-extern int dm_getall_dmattr(dm_sessid_t, void *, size_t, 
-               dm_token_t, size_t, void *, size_t *);
-
-
-The following functions have no prototypes in <sys/dmapi/dmapi.h> but do link.
-
-extern int dm_obj_ref_hold(dm_sessid_t, dm_token_t, void *, size_t);
-extern int dm_obj_ref_rele(dm_sessid_t, dm_token_t, void *, size_t);
-extern int dm_obj_ref_query(dm_sessid_t, dm_token_t, void *, size_t);
-
-
-The following Veritas prototypes are different in some way from the
-spec prototypes, either in parameter types, return value types, or in
-some semantic way.  Look below to see the spec versions of the prototypes.
-
-extern int dm_downgrade_right(dm_sessid_t, void *, size_t, 
-               dm_token_t, int, dm_right_t);
-extern int dm_get_config_events(void *, size_t, u_int,
-               dm_eventset_t *, u_int *);
-extern int dm_get_events(dm_sessid_t, u_int, int, size_t, void *, size_t *);
-extern int dm_get_mountinfo(dm_sessid_t, dm_token_t, void *, size_t, 
-               size_t, void *, size_t *);
-extern int dm_init_service(void);
-extern int dm_make_handle(dev_t , long, long, void **, size_t *);
-extern int dm_make_fshandle(dev_t , void **, size_t *);
-extern dev_t dm_handle_to_dev(void *, size_t);
-extern long dm_handle_to_fgen(void *, size_t);
-extern long dm_handle_to_ino(void *, size_t);
-extern int dm_pending(dm_sessid_t, void *, size_t, dm_token_t, int);
-extern dm_ssize_t dm_read_invis(dm_sessid_t, void *, size_t,
-               dm_token_t, dm_off_t, dm_ssize_t, void *);
-extern dm_ssize_t dm_write_invis(dm_sessid_t, void *, size_t,
-               dm_token_t, dm_off_t, dm_ssize_t, void *, int);
-extern int dm_request_right(dm_sessid_t, void *, size_t, 
-               dm_token_t, int, dm_right_t);
-extern int dm_set_inherit(dm_sessid_t, void *, size_t,
-               dm_token_t, dm_attrname_t *, u_int);
-extern int dm_set_return_ondestroy(dm_sessid_t, void *, size_t,
-               dm_token_t,  dm_attrname_t *, int);
-extern int dm_upgrade_right(dm_sessid_t, void *, size_t, 
-               dm_token_t, int, dm_right_t);
-extern int dm_set_region(dm_sessid_t, void *, size_t,
-               dm_token_t, u_int, dm_region_t *, u_int *);
-extern dm_ssize_t dm_sync_by_handle(dm_sessid_t, void *, size_t, dm_token_t);
-
-
-The following Veritas prototype exists in <sys/dmapi/dmapi.h> but
-does not appear in the spec.
-
-extern void dm_attach_event(dm_sessid_t, dm_token_t);
-
-The following functions exist in the Veritas library libdmi.a, but have no
-prototypes within <sys/dmapi/dmapi.h>.  Their function is unknown.
-
-dm_attach_event_nofork
-dm_event_query
-dm_event_valid
-dm_get_disp
-dm_set_resident
-dmregion_compare
-kdm_get_eventinfo
-kdm_get_sessioninfo
-
--------------- end of Veritas-specific hack documentation --------------- */
-
-#ifdef VERITAS_21
-
-#include <sys/types.h>
-
-#include <sys/dmapi/dmapi.h>
-
-/* Rename functions whose prototypes clash with the XDSM standard.  (Library
-   routines map from XDSM functions back to Veritas functions.)
-*/
-
-#define        dm_downgrade_right      xvfs_dm_downgrade_right
-#define dm_fd_to_handle                xvfs_dm_fd_to_handle
-#define        dm_get_events           xvfs_dm_get_events
-#define        dm_get_mountinfo        xvfs_dm_get_mountinfo
-#define        dm_handle_to_ino        xvfs_dm_handle_to_ino
-#define        dm_init_service         xvfs_dm_init_service
-#define        dm_make_fshandle        xvfs_dm_make_fshandle
-#define        dm_make_handle          xvfs_dm_make_handle
-#define dm_path_to_fshandle    xvfs_dm_path_to_fshandle
-#define dm_path_to_handle      xvfs_dm_path_to_handle
-#define        dm_pending              xvfs_dm_pending
-#define        dm_read_invis           xvfs_dm_read_invis
-#define        dm_write_invis          xvfs_dm_write_invis
-#define        dm_request_right        xvfs_dm_request_right
-#define        dm_set_inherit          xvfs_dm_set_inherit
-#define        dm_set_region           xvfs_dm_set_region
-#define        dm_sync_by_handle       xvfs_dm_sync_by_handle
-#define        dm_upgrade_right        xvfs_dm_upgrade_right
-
-
-#define        DM_ATTR_NAME_SIZE       8
-#undef DM_ATTRNAME_SIZE
-#define        DM_VER_STR_CONTENTS     "Veritas DMAPI V1.0"
-
-#define        DM_EV_WAIT      0x1
-#define        DM_RR_WAIT      0x1
-#undef DM_WAIT
-#undef DM_NOWAIT
-#undef DM_EVENT_NOWAIT
-
-#define        DM_CONFIG_INHERIT_ATTRIBS       (DM_CONFIG_LOCK_UPGRADE + 1)
-#undef DM_CONFIG_INHERIT
-#define        DM_CONFIG_MAX_HANDLE_SIZE       (DM_CONFIG_INHERIT_ATTRIBS + 1)
-#undef DM_CONFIG_MAX_FILE_HANDLE_SIZE
-#define        DM_CONFIG_MAX_ATTR_ON_DESTROY   (DM_CONFIG_MAX_HANDLE_SIZE + 1)
-#undef DM_CONFIG_MAX_ATTR_BYTES_ON_DESTROY
-#define        DM_CONFIG_OBJ_REF               (DM_CONFIG_MAX_ATTR_ON_DESTROY + 1)
-#define        DM_CONFIG_DTIME_OVERLOAD        (DM_CONFIG_OBJ_REF + 1)
-#undef DM_CONFIG_MAX
-
-#define        DM_AT_DTIME     DM_AT_DTIMES
-
-/* In the dm_fileattr_t structure, Veritas used 'timeval' structures for all
-   the time fields while XDSM uses 'time_t' structures.  Define some symbols
-   that can be used for the time fields with all implementation types.
-*/
-
-#define FA_ATIME       fa_atime.tv_sec
-#define FA_MTIME       fa_atime.tv_sec
-#define FA_CTIME       fa_ctime.tv_sec
-#define FA_DTIME       fa_dtime.tv_sec
-
-#define        DM_WRITE_SYNC   0x1     /* used in dm_write_invis() */
-
-#define        DM_UNMOUNT_FORCE 0x1    /* ne_mode field in dm_namesp_event_t */
-
-/* Rename one event to match the XDSM standard. */
-
-#define        DM_EVENT_CLOSE          (DM_EVENT_DESTROY + 1)
-#undef DM_EVENT_CLOSED
-
-/* DM_EVENT_CANCEL is defined above DM_EVENT_MAX, and is unsupported. */
-
-#undef DM_REGION_VALIDFLAG
-
-/* Add missing typedefs */
-
-typedef        u_int   dm_boolean_t;
-typedef        dev_t   dm_fsid_t;      /* This could be made a uint64_t with work! */
-typedef        long    dm_igen_t;
-typedef        long    dm_ino_t;
-typedef        u_int   dm_sequence_t;
-
-
-/* Define missing fields within the various event structures. */
-
-#define ev_sequence     ev_token       /* for compilation only!  Won't work! */
-
-#define        ds_handle       te_handle       /* fix fields in dm_destroy_event_t */
-#define        ds_attrname     te_attrname
-#define        ds_attrcopy     te_attrdata
-
-
-struct dm_cancel_event {               /* define missing dm_cancel_event_t */
-       dm_sequence_t   ce_sequence;
-       dm_token_t      ce_token;
-};
-typedef        struct dm_cancel_event  dm_cancel_event_t;
-
-
-struct dm_mount_event {                /* define missing dm_mount_event_t */
-       mode_t          me_mode;
-       dm_vardata_t    me_handle1;
-       dm_vardata_t    me_handle2;
-       dm_vardata_t    me_name1;
-       dm_vardata_t    me_name2;
-       dm_vardata_t    me_roothandle;
-};
-typedef        struct dm_mount_event   dm_mount_event_t;
-
-
-/* Add the missing dm_timestruct_t structure used by dm_pending. */
-
-struct dm_timestruct {
-       time_t          dm_tv_sec;
-       int             dm_tv_nsec;
-};
-typedef        struct dm_timestruct dm_timestruct_t;
-
-#endif
-
-
-
-/* -------------------- SGI-specific hack documentation -------------------
-
-   There are various fields within DMAPI structures that are not supported.
-   Fill in this information someday.
-
-   The following functions have prototypes defined in <sys/dmi.h> and have
-   entry points defined in libdm.so, but they are not actually implemented
-   within the kernel.  They all return ENOSYS if called.
-
-       dm_clear_inherit
-       dm_create_by_handle
-       dm_get_bulkall
-       dm_getall_inherit
-       dm_mkdir_by_handle
-       dm_set_inherit
-       dm_symlink_by_handle
-
-   The DMAPI functions which deal with rights do not work as described in
-   the specification.  While the functions exist and are callable, they
-   always return successfully without actually obtaining any locks within
-   the filesystem.                        
-
-       dm_downgrade_right
-       dm_query_right
-       dm_release_right
-       dm_request_right
-       dm_upgrade_right
-
-   The following non-standard SGI prototype is added to the DMAPI interface
-   so that real-time files may be migrated and recalled.
-
-       dm_get_dioinfo
-
--------------- end of SGI-specific hack documentation --------------- */
-
-#ifdef linux
-
-#include <dmapi.h>
-
-/* In the dm_fileattr_t structure, Veritas used 'timeval' structures for all
-   the time fields while XDSM uses 'time_t' structures.  Define some symbols
-   that can be used for the time fields with all implementation types.
-*/
-
-#define FA_ATIME       fa_atime
-#define FA_MTIME       fa_mtime
-#define FA_CTIME       fa_ctime
-#define FA_DTIME       fa_dtime
-
-#endif /* linux */
-
-/* ----------------------- XDSM standard prototypes ----------------------- */
-
-/* The following list provides the prototypes for all functions defined in
-   the DMAPI interface spec from X/Open (XDSM) dated February 1997.  They
-   are here to force compiler errors in case the Veritas or SGI DMAPI
-   prototypes should ever change without our knowing about it.
-*/
-
-extern int
-dm_clear_inherit(
-       dm_sessid_t     sid,
-       void            *hanp,
-       size_t          hlen,
-       dm_token_t      token,
-       dm_attrname_t   *attrnamep);
-
-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);
-
-extern int
-dm_create_session(
-       dm_sessid_t     oldsid,
-       char            *sessinfop,
-       dm_sessid_t     *newsidp);
-
-extern int
-dm_create_userevent(
-       dm_sessid_t     sid,
-       size_t          msglen,
-       void            *msgdatap,
-       dm_token_t      *tokenp);
-
-extern int
-dm_destroy_session(
-       dm_sessid_t     sid);
-
-extern int
-dm_downgrade_right(
-       dm_sessid_t     sid,
-       void            *hanp,
-       size_t          hlen,
-       dm_token_t      token);
-
-extern int
-dm_fd_to_handle(
-       int             fd,
-       void            **hanpp,
-       size_t          *hlenp);
-
-extern int
-dm_find_eventmsg(
-       dm_sessid_t     sid,
-       dm_token_t      token,
-       size_t          buflen,
-       void            *bufp,
-       size_t          *rlenp);
-
-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);
-
-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);
-
-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);
-
-extern int
-dm_get_config(
-       void            *hanp,
-       size_t          hlen,
-       dm_config_t     flagname,
-       dm_size_t       *retvalp);
-
-extern int
-dm_get_config_events(
-       void            *hanp,
-       size_t          hlen,
-       u_int           nelem,
-       dm_eventset_t   *eventsetp,
-       u_int           *nelemp);
-
-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);
-
-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);
-
-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);
-
-extern int
-dm_get_events(
-       dm_sessid_t     sid,
-       u_int           maxmsgs,
-       u_int           flags,
-       size_t          buflen,
-       void            *bufp,
-       size_t          *rlenp);
-
-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);
-
-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);
-
-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);
-
-extern int
-dm_getall_disp(
-       dm_sessid_t     sid,
-       size_t          buflen,
-       void            *bufp,
-       size_t          *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);
-
-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);
-
-extern int
-dm_getall_sessions(
-       u_int           nelem,
-       dm_sessid_t     *sidbufp,
-       u_int           *nelemp);
-
-extern int
-dm_getall_tokens(
-       dm_sessid_t     sid,
-       u_int           nelem,
-       dm_token_t      *tokenbufp,
-       u_int           *nelemp);
-
-extern int
-dm_handle_cmp(
-       void            *hanp1,
-       size_t          hlen1,
-       void            *hanp2,
-       size_t          hlen2);
-
-extern void
-dm_handle_free(
-       void            *hanp,
-       size_t          hlen);
-
-extern u_int
-dm_handle_hash(
-       void            *hanp,
-       size_t          hlen);
-
-extern dm_boolean_t
-dm_handle_is_valid(
-       void            *hanp,
-       size_t          hlen);
-
-extern int
-dm_handle_to_fshandle(
-       void            *hanp,
-       size_t          hlen,
-       void            **fshanpp,
-       size_t          *fshlenp);
-
-extern int
-dm_handle_to_fsid(
-       void            *hanp,
-       size_t          hlen,
-       dm_fsid_t       *fsidp);
-
-extern int
-dm_handle_to_igen(
-       void            *hanp,
-       size_t          hlen,
-       dm_igen_t       *igenp);
-
-extern int
-dm_handle_to_ino(
-       void            *hanp,
-       size_t          hlen,
-       dm_ino_t        *inop);
-
-extern int
-dm_handle_to_path(
-       void            *dirhanp,
-       size_t          dirhlen,
-       void            *targhanp,
-       size_t          targhlen,
-       size_t          buflen,
-       char            *pathbufp,
-       size_t          *rlenp);
-
-extern int
-dm_init_attrloc(
-       dm_sessid_t     sid,
-       void            *hanp,
-       size_t          hlen,
-       dm_token_t      token,
-       dm_attrloc_t    *locp);
-
-extern int
-dm_init_service(
-       char            **versionstrpp);
-
-extern int
-dm_make_fshandle(
-       dm_fsid_t       *fsidp,
-       void            **hanpp,
-       size_t          *hlenp);
-
-extern int
-dm_make_handle(
-       dm_fsid_t       *fsidp,
-       dm_ino_t        *inop,
-       dm_igen_t       *igenp,
-       void            **hanpp,
-       size_t          *hlenp);
-
-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);
-
-extern int
-dm_move_event(
-       dm_sessid_t     srcsid,
-       dm_token_t      token,
-       dm_sessid_t     targetsid,
-       dm_token_t      *rtokenp);
-
-extern int
-dm_obj_ref_hold(
-       dm_sessid_t     sid,
-       dm_token_t      token,
-       void            *hanp,
-       size_t          hlen);
-
-extern int
-dm_obj_ref_query(
-       dm_sessid_t     sid,
-       dm_token_t      token,
-       void            *hanp,
-       size_t          hlen);
-
-extern int
-dm_obj_ref_rele(
-       dm_sessid_t     sid,
-       dm_token_t      token,
-       void            *hanp,
-       size_t          hlen);
-
-extern int
-dm_path_to_fshandle(
-       char            *path,
-       void            **hanpp,
-       size_t          *hlenp);
-
-extern int
-dm_path_to_handle(
-       char            *path,
-       void            **hanpp,
-       size_t          *hlenp);
-
-extern int
-dm_pending(
-       dm_sessid_t     sid,
-       dm_token_t      token,
-       dm_timestruct_t *delay);
-
-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);
-
-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);
-
-extern int
-dm_query_right(
-       dm_sessid_t     sid,
-       void            *hanp,
-       size_t          hlen,
-       dm_token_t      token,
-       dm_right_t      *rightp);
-
-extern int
-dm_query_session(
-       dm_sessid_t     sid,
-       size_t          buflen,
-       void            *bufp,
-       size_t          *rlenp);
-
-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);
-
-extern int
-dm_release_right(
-       dm_sessid_t     sid,
-       void            *hanp,
-       size_t          hlen,
-       dm_token_t      token);
-
-extern int
-dm_remove_dmattr(
-       dm_sessid_t     sid,
-       void            *hanp,
-       size_t          hlen,
-       dm_token_t      token,
-       int             setdtime,
-       dm_attrname_t   *attrnamep);
-
-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);
-
-extern int
-dm_respond_event(
-       dm_sessid_t     sid,
-       dm_token_t      token,
-       dm_response_t   response,
-       int             reterror,
-       size_t          buflen,
-       void            *respbufp);
-
-extern int
-dm_send_msg(
-       dm_sessid_t     targetsid,
-       dm_msgtype_t    msgtype,
-       size_t          buflen,
-       void            *bufp);
-
-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);
-
-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);
-
-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);
-
-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);
-
-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);
-
-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);
-
-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);
-
-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);
-
-extern int
-dm_sync_by_handle(
-       dm_sessid_t     sid,
-       void            *hanp,
-       size_t          hlen,
-       dm_token_t      token);
-
-extern int
-dm_upgrade_right(
-       dm_sessid_t     sid,
-       void            *hanp,
-       size_t          hlen,
-       dm_token_t      token);
-
-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);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _DMFSAPI_DMPORT_H */
diff --git a/dmapi/src/common/lib/find_session.c b/dmapi/src/common/lib/find_session.c
deleted file mode 100644 (file)
index 01a7af3..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-
-#include <lib/hsm.h>
-
-#include <string.h>
-
-/*******************************************************************************
-*
-* NAME
-*      find_test_session - find or create a test DMAPI session.
-*
-* DESCRIPTION
-*      find_test_session() is used to find a test DMAPI session to
-*      use.  There is only one test session per host; all test processes
-*      share the same session.  If the session does not already exist,
-*      then the first process to call find_test_session() causes
-*      the session to be created.
-*
-*      Note: It is possible for N different programs to call this routine
-*      at the same time.  Each would find that a test session does not
-*      exist, and each one would then create a new test session.  Since
-*      excess test sessions are not automatically released on death of
-*      process, we need to make sure that we don't leave such excess
-*      sessions around.  So, after creating a session we go back and find
-*      the test session with the lowest session number.  If it is ours,
-*      great; we are done.  If not, then we must destroy our session
-*      and use the one with the lower session ID.  There is still a risk
-*      here of creating a session and crashing before it can be removed
-*      again.  To deal with this, the daemon will periodically remove all
-*      test sessions except for the one with the lowest ID value.
-*
-* RETURN VALUE
-*      None.
-*
-*******************************************************************************/
-
-#define        TEST_MSG        "DMAPI test session"
-
-static int
-session_compare(
-const  void    *a,
-const  void    *b)
-{
-       return(*((dm_sessid_t *)a) - *((dm_sessid_t *)b));
-}
-
-extern void
-find_test_session(
-       dm_sessid_t     *session)
-{
-       char            buffer[DM_SESSION_INFO_LEN];
-       dm_sessid_t     *sidbuf = NULL;
-       dm_sessid_t     new_session;
-       u_int           allocelem = 0;
-       u_int           nelem;
-       size_t          rlen;
-       int             error;
-       u_int           i;
-
-       /* Retrieve the list of all active sessions on the host. */
-
-       nelem = 100;            /* a reasonable first guess */
-       do {
-               if (allocelem < nelem) {
-                       allocelem = nelem;
-                       sidbuf = realloc(sidbuf, nelem * sizeof(*sidbuf));
-                       if (sidbuf == NULL) {
-                               fprintf(stderr, "realloc of %lu bytes failed\n",
-                                       (unsigned long) nelem * sizeof(*sidbuf));
-                               exit(1);
-                       }
-               }
-               error = dm_getall_sessions(allocelem, sidbuf, &nelem);
-       } while (error < 0 && errno == E2BIG);
-
-       /* If an error occurred, translate it into something meaningful. */
-
-       if (error < 0) {
-               fprintf(stderr, "unexpected dm_getall_sessions failure, %s\n",
-                       strerror(errno));
-               free(sidbuf);
-               exit(1);
-       }
-
-       /* We have the list of all active sessions.  Scan the list looking
-          for an existing "test" session that we can use.  The list must
-          first be sorted in case other processes happen to be creating test
-          sessions at the same time; we need to make sure that we pick the one
-          with the lowest session ID.
-       */
-
-       qsort(sidbuf, nelem, sizeof(sidbuf[0]), session_compare);
-
-       for (i = 0; i < nelem; i++) {
-               error = dm_query_session(sidbuf[i], sizeof(buffer),
-                               buffer, &rlen);
-               if (error < 0) {
-                       fprintf(stderr, "unexpected dm_query_session "
-                               "failure, %s\n", strerror(errno));
-                       free(sidbuf);
-                       exit(1);
-               }
-
-               if (!strncmp(buffer, TEST_MSG, strlen(TEST_MSG)))
-                       break;
-       }
-       if (i < nelem) {
-               *session = (dm_sessid_t)sidbuf[i];
-               free(sidbuf);
-               return;
-       }
-
-       /* No test session exists, so we have to create one ourselves. */
-
-       if (dm_create_session(DM_NO_SESSION, TEST_MSG, &new_session) != 0) {
-               fprintf(stderr, "dm_create_session failed, %s\n",
-                       strerror(errno));
-               free(sidbuf);
-               exit(1);
-       }
-
-       /* Now re-retrieve the list of active sessions. */
-
-       do {
-               if (allocelem < nelem) {
-                       allocelem = nelem;
-                       sidbuf = realloc(sidbuf, nelem * sizeof(*sidbuf));
-                       if (sidbuf == NULL) {
-                               fprintf(stderr, "realloc of %lu bytes failed\n",
-                                       (unsigned long) nelem * sizeof(*sidbuf));
-                               exit(1);
-                       }
-               }
-               error = dm_getall_sessions(allocelem, sidbuf, &nelem);
-       } while (error < 0 && errno == E2BIG);
-
-       if (error < 0) {
-               fprintf(stderr, "dm_getall_sessions failed, %s\n",
-                       strerror(errno));
-               free(sidbuf);
-               exit(1);
-       }
-
-       /* Sort the session ID list into ascending ID order, then find the
-          test session with the lowest session ID.  We better find at
-          least one since we created one!
-       */
-
-       qsort(sidbuf, nelem, sizeof(sidbuf[0]), session_compare);
-
-       for (i = 0; i < nelem; i++) {
-               error = dm_query_session(sidbuf[i], sizeof(buffer),
-                               buffer, &rlen);
-               if (error < 0) {
-                       fprintf(stderr, "dm_query_session failed, %s\n",
-                               strerror(errno));
-                       free(sidbuf);
-                       exit(1);
-               }
-               if (!strncmp(buffer, TEST_MSG, strlen(TEST_MSG)))
-                       break;
-       }
-       if (i == nelem) {
-               fprintf(stderr, "can't find the session we created\n");
-               free(sidbuf);
-               exit(1);
-       }
-       *session = (dm_sessid_t)sidbuf[i];
-       free(sidbuf);
-
-       /* If the session we are going to use is not the one we created,
-          then we need to get rid of the created one.
-       */
-
-       if (*session != new_session) {
-               if ((new_session) != 0) {
-                       fprintf(stderr, "dm_destroy_session failed, %s\n",
-                               strerror(errno));
-                       exit(1);
-               }
-       }
-}
diff --git a/dmapi/src/common/lib/hsm.h b/dmapi/src/common/lib/hsm.h
deleted file mode 100644 (file)
index e09c1f9..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Defines and structures for our pseudo HSM example
- *
- * This code was written by Peter Lawthers, and placed in the public
- * domain for use by DMAPI implementors and app writers.
- *
- * Standard disclaimer:
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef        _LIB_HSM_H
-#define        _LIB_HSM_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <sys/types.h>
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <strings.h>
-
-#include <lib/dmport.h>
-
-#define HANDLE_LEN      64                      /* Swag for this example */
-#define HANDLE_STR      ((HANDLE_LEN * 2) + 1)  /* handle as ascii, plus null */
-#define IBUFSIZE         1024                  /* input buffer size */
-#define CHUNKSIZE      (1024*1024*4)           /* write size */
-#define FENCEPOST_SIZE  ((dm_size_t)(1024*8))
-#define ALL_AVAIL_MSGS 0
-
-/*
- * Actions to be performed by the worker bees
- */
-#define RESTORE_FILE   "-r"
-#define INVAL_FILE     "-i"
-
-#define WORKER_BEE     "wbee"
-
-
-/*
- * Names of DM attribute used for storing location of a file's data.
- * DM attributes are 8 bytes, including NULL.
- */
-
-#define DLOC_HAN       "dhanloc"               /* staging file handle */
-#define DLOC_HANLEN    "dhanlen"               /* staging handle length */
-
-/*
- * Default log file
- */
-#define LOG_DEFAULT    "/tmp/dmig_log"
-
-struct ev_name_to_value {
-        char            *name;         /* name of event */
-        dm_eventtype_t  value;         /* value of event */
-};
-
-extern struct  ev_name_to_value        ev_names[];
-extern int     ev_namecnt;
-
-
-struct rt_name_to_value {
-        char            *name;         /* name of right */
-        dm_right_t     value;          /* value of right */
-};
-
-extern struct  rt_name_to_value        rt_names[];
-extern int     rt_namecnt;
-
-
-extern void hantoa(void *hanp, size_t hlen, char *handle_str);
-extern int atohan(char *handle_str, void **hanpp, size_t *hlenp);
-extern void print_handle(void *hanp, size_t hlen);
-extern void print_victim(void *hanp, size_t hlen, dm_off_t fsize);
-extern void errno_msg(char *fmt, ...);
-extern void err_msg(char *fmt, ...);
-extern int setup_dmapi(dm_sessid_t *sid);
-extern int get_dmchange(dm_sessid_t sid, void *hanp, size_t hlen,
-        dm_token_t token, u_int *change_start);
-extern int save_filedata(dm_sessid_t sid, void *hanp, size_t hlen,
-        int stg_fd, dm_size_t fsize);
-extern int restore_filedata(dm_sessid_t sid, void *hanp, size_t hlen,
-        dm_token_t token, void *stg_hanp, size_t stg_hlen, dm_off_t off);
-
-extern void find_test_session(dm_sessid_t *session);
-
-void
-print_one_mount_event(
-       void            *msg);
-
-int
-print_one_message(
-       dm_eventmsg_t   *msg);
-
-int
-handle_message(
-       dm_sessid_t     sid,
-       dm_eventmsg_t   *msg);
-
-extern char *date_to_string(
-       time_t          timeval);
-
-extern char *mode_to_string(
-       mode_t          mode);
-
-extern mode_t field_to_mode(
-       mode_t          mode);
-
-extern int validate_state(
-       dm_stat_t       *dmstat,
-       char            *pathname,
-       int             report_errors);
-
-extern char *emask_to_string(
-       dm_eventset_t   emask);
-
-extern char *xflags_to_string(
-       u_int           xflags);
-
-extern void print_state(
-       dm_stat_t       *dmstat);
-
-extern void print_line(
-       dm_stat_t       *dmstat);
-
-extern dm_eventtype_t
-ev_name_to_value(
-       char            *name);
-
-extern char *
-ev_value_to_name(
-       dm_eventtype_t  event);
-
-extern int
-rt_name_to_value(
-       char            *name,
-       dm_right_t      *rightp);
-
-extern char *
-rt_value_to_name(
-       dm_right_t      right);
-
-extern int
-opaque_to_handle(
-       char            *name,
-       void            **hanpp,
-       size_t          *hlenp);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _LIB_HSM_H */
diff --git a/dmapi/src/common/lib/print.c b/dmapi/src/common/lib/print.c
deleted file mode 100644 (file)
index f6c4a04..0000000
+++ /dev/null
@@ -1,589 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-
-#include <ctype.h>
-
-#include <lib/hsm.h>
-
-#include <string.h>
-
-  /*
-   * Define some standard formats for the printf statements below.
-   */
-
-#define HDR  "type=%s token=%d sequence=%d\n"
-#define VALS "\t%s=%s\n"
-#define VALD "\t%s=%d\n"
-#define VALLLD "\t%s=%lld\n"
-
-
-/*
-       Convert a mode_t field into a printable string.
-
-       Returns non-zero if the mode_t is invalid.  The string is
-       returned in *ptr, whether there is an error or not.
-*/
-
-int
-format_mode(
-       mode_t  mode,
-       char    **ptr)
-{
-static char    modestr[100];
-       char    *typestr;
-       int     error = 0;
-
-       if     (S_ISFIFO(mode)) typestr = "FIFO";
-       else if(S_ISCHR (mode)) typestr = "Character Device";
-       else if(S_ISBLK (mode)) typestr = "Block Device";
-       else if(S_ISDIR (mode)) typestr = "Directory";
-       else if(S_ISREG (mode)) typestr = "Regular File";
-       else if(S_ISLNK (mode)) typestr = "Symbolic Link";
-       else if(S_ISSOCK(mode)) typestr = "Socket";
-       else {
-               typestr = "<unknown type>"; 
-               error++;
-       }
-
-       sprintf(modestr, "mode %06o: perm %c%c%c %c%c%c %c%c%c %c%c%c, type %s",
-               mode,
-               mode & S_ISUID ? 's':' ',
-               mode & S_ISGID ? 'g':' ',
-               mode & S_ISVTX ? 't':' ',
-               mode & S_IRUSR ? 'r':'-',
-               mode & S_IWUSR ? 'w':'-',
-               mode & S_IXUSR ? 'x':'-',
-               mode & S_IRGRP ? 'r':'-',
-               mode & S_IWGRP ? 'w':'-',
-               mode & S_IXGRP ? 'x':'-',
-               mode & S_IROTH ? 'r':'-',
-               mode & S_IWOTH ? 'w':'-',
-               mode & S_IXOTH ? 'x':'-',
-               typestr);
-       *ptr = modestr;
-       return(error);
-}
-
-
-void
-print_one_mount_event(
-       void            *msg)
-{
-       void            *hanp1, *hanp2, *hanp3;
-       size_t          hlen1, hlen2, hlen3;
-       char            hans1[HANDLE_STR], hans2[HANDLE_STR], hans3[HANDLE_STR];
-       void            *namp1, *namp2;
-       size_t          nlen1, nlen2;
-       char            nams1[NAME_MAX + 1], nams2[NAME_MAX + 1];
-       mode_t          mode;
-
-#if    VERITAS_21
-       dm_namesp_event_t  *msg_ne = (dm_namesp_event_t *)msg;
-
-/*
-       msg_ne = DM_GET_VALUE(msg, ev_data, dm_namesp_event_t *);
-*/
-       hanp1  = DM_GET_VALUE(msg_ne, ne_handle1, void *);
-       hlen1  = DM_GET_LEN  (msg_ne, ne_handle1);
-       hanp2  = DM_GET_VALUE(msg_ne, ne_handle2, void *);
-       hlen2  = DM_GET_LEN  (msg_ne, ne_handle2);
-       namp1  = DM_GET_VALUE(msg_ne, ne_name1, void *);
-       nlen1  = DM_GET_LEN  (msg_ne, ne_name1);
-       namp2  = DM_GET_VALUE(msg_ne, ne_name2, void *);
-       nlen2  = DM_GET_LEN  (msg_ne, ne_name2);
-       hanp3  = NULL;
-       hlen3  = 0;
-       mode   = msg_ne->ne_mode;
-#else
-       dm_mount_event_t  *msg_me = (dm_mount_event_t *)msg;
-
-       hanp1 = DM_GET_VALUE(msg_me, me_handle1, void *);
-       hlen1 = DM_GET_LEN(msg_me, me_handle1);
-       hanp2 = DM_GET_VALUE(msg_me, me_handle2, void *);
-       hlen2 = DM_GET_LEN(msg_me, me_handle2);
-       namp1  = DM_GET_VALUE(msg_me, me_name1, void *);
-       nlen1 = DM_GET_LEN(msg_me, me_name1);
-       namp2 = DM_GET_VALUE(msg_me, me_name2, void *);
-       nlen2 = DM_GET_LEN(msg_me, me_name2);
-       hanp3 = DM_GET_VALUE(msg_me, me_roothandle, void *);
-       hlen3 = DM_GET_LEN(msg_me, me_roothandle);
-       mode  = msg_me->me_mode;
-#endif /* VERITAS_21 */
-
-       if (hanp1 && hlen1) {
-               hantoa(hanp1, hlen1, hans1);
-       } else {
-               sprintf(hans1, "<BAD HANDLE, hlen %zd>", hlen1);
-       }
-       if (hanp2 && hlen2) {
-               hantoa(hanp2, hlen2, hans2);
-       } else {
-               sprintf(hans2, "<BAD HANDLE, hlen %zd>", hlen2);
-       }
-       if (hanp3 && hlen3) {
-               hantoa(hanp3, hlen3, hans3);
-       } else {
-               sprintf(hans3, "<BAD HANDLE, hlen %zd>", hlen3);
-       }
-       if (namp1 && nlen1) {
-               strncpy(nams1, namp1, nlen1);
-               if (nlen1 != sizeof(nams1))
-                       nams1[nlen1] = '\0';
-       } else {
-               sprintf(nams1, "<BAD STRING, nlen %zd>", nlen1);
-       }
-       if (namp2 && nlen2) {
-               strncpy(nams2, namp2, nlen2);
-               if (nlen2 != sizeof(nams2))
-                       nams2[nlen2] = '\0';
-       } else {
-               sprintf(nams2, "<BAD STRING, nlen %zd>", nlen2);
-       }
-
-       printf(VALS VALS VALS VALS VALS VALD,
-            "fs handle",       hans1,
-            "mtpt handle",     hans2,
-            "mtpt path",       nams1,
-            "media desig",     nams2,
-            "root handle",     hans3,
-            "mode",            mode);
-}
-
-
-static int
-print_one_data_event(
-       dm_data_event_t *msg_de)
-{
-       char            handle[HANDLE_STR];
-       void            *hanp;
-       size_t          hlen;
-
-       hanp  = DM_GET_VALUE(msg_de, de_handle, void *);
-       hlen  = DM_GET_LEN  (msg_de, de_handle);
-
-       if (hanp && hlen) {
-               hantoa(hanp, hlen, handle);
-       } else {
-               sprintf(handle, "<BAD HANDLE, hlen %zd>", hlen);
-       }
-
-       printf(VALS VALLLD VALLLD,
-               "file_handle",  handle,
-               "offset", (long long) msg_de->de_offset,
-               "length", (long long) msg_de->de_length);
-
-       return(0);
-}
-
-
-int
-print_one_message(
-       dm_eventmsg_t   *msg)
-{
-       int             pkt_error = 0;
-       dm_namesp_event_t  *msg_ne;
-       void            *hanp1, *hanp2, *namp1, *namp2;
-       u_int           hlen1, hlen2, nlen1, nlen2;
-       char            hans1[HANDLE_STR], hans2[HANDLE_STR];
-       char            nams1[NAME_MAX + 1], nams2[NAME_MAX + 1];
-
-       /***** USER EVENTS *****/
-
-       if (msg->ev_type == DM_EVENT_USER) {
-    char       *privp;
-    u_int      plen, i;
-
-    printf(HDR,
-               "user", msg->ev_token, msg->ev_sequence);
-
-    /* print private data as ascii or hex if it exists DM_CONFIG_MAX_MESSAGE_DATA */
-
-    privp = DM_GET_VALUE(msg, ev_data, char *);
-    plen  = DM_GET_LEN  (msg, ev_data);
-    if (plen) {
-       for (i = 0; i < plen; i++) {
-               if (!isprint(privp[i]) && !isspace(privp[i]))
-                       break;
-       }
-       if (i == plen - 1 && privp[i] == '\0') {
-         printf(VALS,
-                       "privdata", privp);
-       } else {
-          printf("\t%-15s ", "privdata");
-          for (i = 0; i < plen; i++) {
-           printf("%.2x", privp[i]);
-          }
-          printf("\n");
-       }
-    } else {
-       printf(VALS,
-               "privdata", "<NONE>");
-    }
-
-       /***** CANCEL EVENT *****/
-
-/* Not implemented on SGI or Veritas */
-
-       } else if (msg->ev_type == DM_EVENT_CANCEL) {
-               dm_cancel_event_t       *msg_ce;
-
-               msg_ce = DM_GET_VALUE(msg, ev_data, dm_cancel_event_t *);
-               printf(HDR VALD VALD,
-                       "cancel", msg->ev_token, msg->ev_sequence,
-                       "sequence", msg_ce->ce_sequence,
-                       "token", msg_ce->ce_token);
-
-       /***** DATA EVENTS *****/
-
-       } else if (msg->ev_type == DM_EVENT_READ ||
-                  msg->ev_type == DM_EVENT_WRITE ||
-                  msg->ev_type == DM_EVENT_TRUNCATE) {
-               dm_data_event_t *msg_de;
-
-               msg_de = DM_GET_VALUE(msg, ev_data, dm_data_event_t *);
-
-               switch (msg->ev_type) {
-               case DM_EVENT_READ:
-                       printf(HDR, "read", msg->ev_token, msg->ev_sequence);
-                       break;
-
-               case DM_EVENT_WRITE:
-                       printf(HDR, "write", msg->ev_token, msg->ev_sequence);
-                       break;
-
-               case DM_EVENT_TRUNCATE:
-                       printf(HDR, "truncate", msg->ev_token,
-                               msg->ev_sequence);
-                       break;
-               default: break;
-               }
-               print_one_data_event(msg_de);
-
-  /***** DESTROY EVENT *****/
-
-       } else if (msg->ev_type == DM_EVENT_DESTROY) {
-    dm_destroy_event_t *msg_ds;
-    char               attrname[DM_ATTR_NAME_SIZE + 1];
-    u_char             *copy;
-    u_int              clen;
-    u_int              i;
-
-    msg_ds= DM_GET_VALUE(msg, ev_data, dm_destroy_event_t *);
-    hanp1  = DM_GET_VALUE(msg_ds, ds_handle, void *);
-    hlen1  = DM_GET_LEN  (msg_ds, ds_handle);
-    if (hanp1 && hlen1) {
-      hantoa(hanp1, hlen1, hans1);
-    } else {
-      sprintf(hans1, "<BAD HANDLE, hlen %d>", hlen1);
-    }
-    if (msg_ds->ds_attrname.an_chars[0] != '\0') {
-      strncpy(attrname, (char *)msg_ds->ds_attrname.an_chars, sizeof(attrname));
-    } else {
-      strcpy(attrname, "<NONE>");
-    }
-    printf(HDR VALS VALS,
-            "destroy", msg->ev_token, msg->ev_sequence,
-            "handle",          hans1,
-            "attrname",        attrname);
-    copy  = DM_GET_VALUE(msg_ds, ds_attrcopy, u_char *);
-    clen  = DM_GET_LEN  (msg_ds, ds_attrcopy);
-    if (copy && clen) {
-      printf("\t%-15s ", "attrcopy");
-      for (i = 0; i < clen; i++) {
-       printf("%.2x", copy[i]);
-      }
-      printf("\n");
-    } else {
-      printf(VALS, "attrcopy", "<NONE>");
-    }
-
-  /***** MOUNT EVENT *****/
-
-       } else if (msg->ev_type == DM_EVENT_MOUNT) {
-               void    *msg_body;
-
-               printf(HDR, "mount", msg->ev_token, msg->ev_sequence);
-#if    !VERITAS_21
-               msg_body = DM_GET_VALUE(msg, ev_data, dm_mount_event_t *);
-#else  /* VERITAS_21 */
-               msg_body = DM_GET_VALUE(msg, ev_data, dm_namesp_event_t *);
-#endif /* VERITAS_21 */
-               print_one_mount_event(msg_body);
-
-  /***** NAMESPACE EVENTS *****/
-
-       } else {
-    char       *type;
-
-    msg_ne = DM_GET_VALUE(msg, ev_data, dm_namesp_event_t *);
-    hanp1  = DM_GET_VALUE(msg_ne, ne_handle1, void *);
-    hlen1  = DM_GET_LEN  (msg_ne, ne_handle1);
-    hanp2  = DM_GET_VALUE(msg_ne, ne_handle2, void *);
-    hlen2  = DM_GET_LEN  (msg_ne, ne_handle2);
-    namp1  = DM_GET_VALUE(msg_ne, ne_name1, void *);
-    nlen1  = DM_GET_LEN  (msg_ne, ne_name1);
-    namp2  = DM_GET_VALUE(msg_ne, ne_name2, void *);
-    nlen2  = DM_GET_LEN  (msg_ne, ne_name2);
-
-    if (hanp1 && hlen1) {
-      hantoa(hanp1, hlen1, hans1);
-    }
-    if (hanp2 && hlen2) {
-      hantoa(hanp2, hlen2, hans2);
-    }
-    if (namp1 && nlen1) {
-      strncpy(nams1, namp1, nlen1);
-      if (nlen1 != sizeof(nams1))
-       nams1[nlen1] = '\0';
-    }
-    if (namp2 && nlen2) {
-      strncpy(nams2, namp2, nlen2);
-      if (nlen2 != sizeof(nams2))
-       nams2[nlen2] = '\0';
-    }
-
-    if (msg->ev_type == DM_EVENT_PREUNMOUNT ||
-       msg->ev_type == DM_EVENT_UNMOUNT) {
-      if (msg_ne->ne_mode == 0) {
-       type = "NOFORCE";
-#if    !VERITAS_21
-      } else if (msg_ne->ne_mode == DM_UNMOUNT_FORCE) {
-#else
-      } else if (msg_ne->ne_mode > 0) {
-#endif
-       type = "FORCE";
-      } else {
-       type = "UNKNOWN";
-       pkt_error++;
-      }
-    } else if (msg->ev_type == DM_EVENT_CREATE ||
-               msg->ev_type == DM_EVENT_POSTCREATE ||
-              msg->ev_type == DM_EVENT_REMOVE ||
-               msg->ev_type == DM_EVENT_POSTREMOVE) {
-       if (format_mode(msg_ne->ne_mode, &type)) {
-         pkt_error++;
-        }
-    }
-
-    switch(msg->ev_type) {
-
-    case DM_EVENT_PREUNMOUNT:
-      printf(HDR VALS VALS VALS,
-            "preunmount", msg->ev_token, msg->ev_sequence,
-            "fs handle",       hans1,
-            "root dir",        hans2,
-            "unmount mode",    type);
-      break;
-
-    case DM_EVENT_UNMOUNT:
-      printf(HDR VALS VALS VALD,
-            "unmount", msg->ev_token, msg->ev_sequence,
-            "fs handle",       hans1,
-            "unmount mode",    type,
-            "retcode",         msg_ne->ne_retcode);
-      break;
-
-    case DM_EVENT_NOSPACE:
-      printf(HDR VALS,
-            "nospace", msg->ev_token, msg->ev_sequence,
-            "fs handle",       hans1);
-      break;
-
-    case DM_EVENT_DEBUT:               /* not supported on SGI */
-      printf(HDR VALS,
-            "debut", msg->ev_token, msg->ev_sequence,
-            "object",          hans1);
-      break;
-
-    case DM_EVENT_CREATE:
-      printf(HDR VALS VALS VALS,
-            "create", msg->ev_token, msg->ev_sequence,
-            "parent dir",      hans1,
-            "name",            nams1,
-            "mode bits",       type);
-      break;
-
-    case DM_EVENT_POSTCREATE:
-      printf(HDR VALS VALS VALS VALS VALD,
-            "postcreate", msg->ev_token, msg->ev_sequence,
-            "parent dir",      hans1,
-            "new object",      hans2,
-            "name",            nams1,
-            "mode bits",       type,
-            "retcode",         msg_ne->ne_retcode);
-      break;
-
-    case DM_EVENT_REMOVE:
-      printf(HDR VALS VALS VALS,
-            "remove", msg->ev_token, msg->ev_sequence,
-            "parent dir",      hans1,
-            "name",            nams1,
-            "mode bits",       type);
-      break;
-
-    case DM_EVENT_POSTREMOVE:
-      printf(HDR VALS VALS VALS VALD,
-            "postremove", msg->ev_token, msg->ev_sequence,
-            "parent dir",      hans1,
-            "name",            nams1,
-            "mode bits",       type,
-            "retcode",         msg_ne->ne_retcode);
-      break;
-
-    case DM_EVENT_RENAME:
-      printf(HDR VALS VALS VALS VALS,
-            "rename", msg->ev_token, msg->ev_sequence,
-            "old parent",      hans1,
-            "new parent",      hans2,
-            "old name",        nams1,
-            "new name",        nams2);
-      break;
-
-    case DM_EVENT_POSTRENAME:
-      printf(HDR VALS VALS VALS VALS VALD,
-            "postrename", msg->ev_token, msg->ev_sequence,
-            "old parent",      hans1,
-            "new parent",      hans2,
-            "old name",        nams1,
-            "new name",        nams2,
-            "retcode",         msg_ne->ne_retcode);
-      break;
-
-    case DM_EVENT_SYMLINK:
-      printf(HDR VALS VALS VALS,
-            "symlink", msg->ev_token, msg->ev_sequence,
-            "parent dir",      hans1,
-            "name",            nams1,
-            "contents",        nams2);
-      break;
-
-    case DM_EVENT_POSTSYMLINK:
-      printf(HDR VALS VALS VALS VALS VALD,
-            "postsymlink", msg->ev_token, msg->ev_sequence,
-            "parent dir",      hans1,
-            "new object",      hans2,
-            "name",            nams1,
-            "contents",        nams2,
-            "retcode",         msg_ne->ne_retcode);
-      break;
-
-    case DM_EVENT_LINK:
-      printf(HDR VALS VALS VALS,
-            "link", msg->ev_token, msg->ev_sequence,
-            "parent dir",      hans1,
-            "source",          hans2,
-            "name",            nams1);
-      break;
-
-    case DM_EVENT_POSTLINK:
-      printf(HDR VALS VALS VALS VALD,
-            "postlink", msg->ev_token, msg->ev_sequence,
-            "parent dir",      hans1,
-            "source",          hans2,
-            "name",            nams1,
-            "retcode",         msg_ne->ne_retcode);
-      break;
-
-    case DM_EVENT_ATTRIBUTE:
-      printf(HDR VALS,
-            "attribute", msg->ev_token, msg->ev_sequence,
-            "object",          hans1);
-      break;
-
-    case DM_EVENT_CLOSE:       /* not supported on SGI */
-      printf(HDR VALS,
-            "close", msg->ev_token, msg->ev_sequence,
-            "object",          hans1);
-      break;
-
-    default:
-      pkt_error++;
-      printf(HDR VALD,
-            "<UNKNOWN>", msg->ev_token, msg->ev_sequence,
-            "ev_type",         msg->ev_type);
-      break;
-    }
-       }
-       return(pkt_error);
-}
-
-
-int
-handle_message(
-       dm_sessid_t     sid,
-       dm_eventmsg_t   *msg)
-{
-       dm_response_t   response;
-       int             respond, respcode;
-       int             error = 0;
-
-       if (print_one_message(msg))
-               error++;
-
-       /* Set the defaults for responding to events. */
-
-       respond = 1;
-       response = DM_RESP_CONTINUE;
-       respcode = 0;
-
-       /***** USER EVENTS *****/
-
-       switch (msg->ev_type) {
-       case DM_EVENT_USER:
-               if (msg->ev_token == DM_INVALID_TOKEN)
-                       respond = 0;
-               break;
-
-       case DM_EVENT_CANCEL:
-       case DM_EVENT_DESTROY:
-       case DM_EVENT_POSTCREATE:
-       case DM_EVENT_POSTREMOVE:
-       case DM_EVENT_POSTRENAME:
-       case DM_EVENT_POSTSYMLINK:
-       case DM_EVENT_POSTLINK:
-       case DM_EVENT_ATTRIBUTE:
-       case DM_EVENT_CLOSE:
-               respond = 0;
-               break;
-
-       case DM_EVENT_MOUNT:
-       case DM_EVENT_READ:
-       case DM_EVENT_WRITE:
-       case DM_EVENT_TRUNCATE:
-       case DM_EVENT_PREUNMOUNT:
-       case DM_EVENT_UNMOUNT:
-       case DM_EVENT_DEBUT:
-       case DM_EVENT_CREATE:
-       case DM_EVENT_REMOVE:
-       case DM_EVENT_RENAME:
-       case DM_EVENT_SYMLINK:
-       case DM_EVENT_LINK:
-               break;
-
-       case DM_EVENT_NOSPACE:
-               response = DM_RESP_ABORT;
-               respcode = ENOSPC;
-               break;
-
-       default:
-               if (msg->ev_token == DM_INVALID_TOKEN)
-                       respond = 0;
-               break;
-       }
-
-       /* Respond to those messages which require a response. */
-
-       if (respond) {
-               if (dm_respond_event(sid, msg->ev_token, response, respcode, 0, 0)) {
-                       errno_msg("Can't respond to event");
-               }
-       }
-       return(error);
-}
diff --git a/dmapi/src/common/lib/stubs.c b/dmapi/src/common/lib/stubs.c
deleted file mode 100644 (file)
index c6588a0..0000000
+++ /dev/null
@@ -1,491 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-
-#include <errno.h>
-
-#include <stdlib.h>
-#include <lib/dmport.h>
-
-
-/* See dmport.h for a description of why all these wrapper routines are
-   necessary.  Because SGI defines stub routines for all functions it didn't
-   implement, no SGI-specific wrappers are required.
-*/
-
-
-#ifdef VERITAS_21
-
-/* The Veritas version of dm_downgrade_right has two additional parameters
-   not defined in the XDSM spec.  Provide values that make dm_downgrade_right
-   work according to the spec.
-*/
-
-extern int
-xvfs_dm_downgrade_right(
-       dm_sessid_t     sid,
-       void            *hanp,
-       size_t          hlen,
-       dm_token_t      token)
-{
-#undef dm_downgrade_right
-       return(dm_downgrade_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED));
-}
-
-
-/* The last byte in a Veritas handle is a 'pad' byte which they don't bother
-   to initialize to zero.  As a result, you can't do binary compares of
-   two handles to see if they are the same.  This stub (along with others)
-   forces the pad byte to zero so that binary compares are possible
-*/
-
-extern int
-xvfs_dm_fd_to_handle(
-       int             fd,
-       void            **hanpp,
-       size_t          *hlenp)
-{
-#undef dm_fd_to_handle
-       int             rc;
-
-       if ((rc = dm_fd_to_handle(fd, hanpp, hlenp)) == 0) {
-               if (*hlenp == 16) {
-                       char    *cp = (char *)*hanpp;
-                       cp[15] = '\0';
-               }
-       }
-       return(rc);
-}
-
-
-/* The Veritas version of dm_get_config_events has a slightly different name.
-*/
-
-extern int
-dm_get_config_events(
-       void            *hanp,
-       size_t          hlen,
-       u_int           nelem,
-       dm_eventset_t   *eventsetp,
-       u_int           *nelemp)
-{
-       return(dm_get_config_event(hanp, hlen, nelem, eventsetp, nelemp));
-}
-
-
-/* In version 2.1 uflags was defined as 'int nowait', so a value of zero in
-   this field means that the caller wants to wait.  In XDSM this was reversed,
-   where if the bottom bit of uflags is set then the caller wants to wait.
-   This routine makes the conversion.
-*/
-
-extern int
-xvfs_dm_get_events(
-       dm_sessid_t     sid,
-       u_int           maxmsgs,
-       u_int           uflags,
-       size_t          buflen,
-       void            *bufp,
-       size_t          *rlenp)
-{
-#undef dm_get_events
-       int     nowait = 1;
-
-       if (uflags & DM_EV_WAIT)
-               nowait = 0;
-
-       return(dm_get_events(sid, maxmsgs, nowait, buflen, bufp, rlenp));
-}
-
-
-/* The Veritas version of dm_get_mountinfo has the parameters in a different
-   order than in the XDSM spec.  Hide this in the wrapper.
-*/
-
-extern int
-xvfs_dm_get_mountinfo(
-       dm_sessid_t     sid,
-       void            *hanp,
-       size_t          hlen,
-       dm_token_t      token,
-       size_t          buflen,
-       void            *bufp,
-       size_t          *rlenp)
-{
-#undef dm_get_mountinfo
-       return(dm_get_mountinfo(sid, token, hanp, hlen, buflen, bufp, rlenp));
-}
-
-
-/* Veritas does not support the dm_getall_disp function.  Furthermore, their
-   dm_dispinfo_t structure is missing the _link field that is needed for the
-   DM_STEP_TO_NEXT() macro to work.
-*/
-
-extern int
-dm_getall_disp(
-       dm_sessid_t     sid,
-       size_t          buflen,
-       void            *bufp,
-       size_t          *rlenp)
-{
-       return(ENOSYS);
-}
-
-
-/* Veritas does not support the dm_getall_dmattr function.  Furthermore, their
-   dm_attrlist_t structure is missing the _link field that is needed for the
-   DM_STEP_TO_NEXT() macro to work.
-*/
-
-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(ENOSYS);
-}
-
-
-/* Veritas does not support dm_handle_is_valid.  We emulate it by checking
-   fields which have known values, as DMF uses this a lot.
-*/
-
-extern dm_boolean_t
-dm_handle_is_valid(
-       void            *hanp,
-       size_t          hlen)
-{
-       char            *cp = (char *)hanp;
-
-       if (hlen != 16) {
-               return(DM_FALSE);
-       }
-       if (cp[15] != '\0') {
-               return(DM_FALSE);
-       }
-       switch (cp[14]) {
-       case 1:
-       case 2:
-       case 4:
-               break;
-       default:
-               return(DM_FALSE);
-       }
-       switch (cp[13]) {
-       case 0:
-       case 1:
-               break;
-       default:
-               return(DM_FALSE);
-       }
-       return(DM_TRUE);
-}
-
-
-/* Veritas uses a dev_t for their dm_fsid_t, and named their routines
-   accordingly.  Hide this in the wrapper.  Note that a dev_t is 32 bits
-   and the SGI dm_fsid_t is defined to be a uint64_t.  If this gets to
-   be a problem (e.g. %x verus %llx), the Veritas dm_fsid_t could be made
-   to match SGI with a little casting here and there.
-*/
-
-extern int
-dm_handle_to_fsid(
-       void            *hanp,
-       size_t          hlen,
-       dm_fsid_t       *fsidp)
-{
-       dev_t           dev;
-
-       dev = dm_handle_to_dev(hanp, hlen);
-       *fsidp = (dm_fsid_t)dev;
-       return(0);
-}
-
-
-/* The Veritas dm_handle_to_fgen returns a long which is really the
-   file's generation number.  dm_igen_t is typedef'd to be a long also,
-   so the cast here is safe.
-*/
-
-extern int
-dm_handle_to_igen(
-       void            *hanp,
-       size_t          hlen,
-       dm_igen_t       *igenp)
-{
-#undef dm_handle_to_igen
-       long            igen;
-
-       igen = (dm_igen_t)dm_handle_to_fgen(hanp, hlen);
-       *igenp = (dm_igen_t)igen;
-       return(0);
-}
-
-
-/* Veritas uses a long for their dm_ino_t, which is really an ino_t.
-   Hide this in the wrapper.  Note that a ino_t is 32 bits and the SGI
-   dm_ino_t is defined to be a uint64_t.  If this gets to be a problem
-   (e.g. %x verus %llx), the Veritas dm_ino_t could be made to match SGI
-   with a little casting here and there.
-*/
-
-
-extern int
-xvfs_dm_handle_to_ino(
-       void            *hanp,
-       size_t          hlen,
-       dm_ino_t        *inop)
-{
-#undef dm_handle_to_ino
-       long            ino;
-
-       ino = (dm_ino_t)dm_handle_to_ino(hanp, hlen);
-       *inop = (dm_ino_t)ino;
-       return(0);
-}
-
-
-/* Version 2.1 of the spec did not specify the versionstrpp parameter.  This
-   code makes the routine appear to work correctly to the caller, but it
-   is not really able to do the runtime check that the parameter is
-   supposed to provide.
-*/
-
-extern int
-xvfs_dm_init_service(
-       char            **versionstrpp)
-{
-#undef dm_init_service
-       *versionstrpp = DM_VER_STR_CONTENTS;
-       return(dm_init_service());
-}
-
-
-extern int
-xvfs_dm_make_fshandle(
-       dm_fsid_t       *fsidp,
-       void            **hanpp,
-       size_t    *hlenp)
-{
-#undef dm_make_fshandle
-       dev_t           dev;
-
-       dev = (dev_t)*fsidp;
-       return(dm_make_fshandle(dev, hanpp, hlenp));
-}
-
-
-extern int
-xvfs_dm_make_handle(
-       dm_fsid_t       *fsidp,
-       dm_ino_t        *inop,
-       dm_igen_t       *igenp,
-       void            **hanpp,
-       size_t    *hlenp)
-{
-#undef dm_make_handle
-       dev_t           dev;
-       long            ino;
-       long            igen;
-
-       dev = (dev_t)*fsidp;
-       ino = (long)*inop;
-       igen = (long)*igenp;
-       return(dm_make_handle(dev, ino, igen, hanpp, hlenp));
-}
-
-
-/* The last byte in a Veritas handle is a 'pad' byte which they don't bother
-   to initialize to zero.  As a result, you can't do binary compares of
-   two handles to see if they are the same.  This stub (along with others)
-   forces the pad byte to zero so that binary compares are possible
-*/
-
-extern int
-xvfs_dm_path_to_fshandle(
-       char            *path,
-       void            **fshanpp,
-       size_t          *fshlenp)
-{
-#undef dm_path_to_fshandle
-       int             rc;
-
-       if ((rc = dm_path_to_fshandle(path, fshanpp, fshlenp)) == 0) {
-               if (*fshlenp == 16) {
-                       char    *cp = (char *)*fshanpp;
-                       cp[15] = '\0';
-               }
-       }
-       return(rc);
-}
-
-
-/* The last byte in a Veritas handle is a 'pad' byte which they don't bother
-   to initialize to zero.  As a result, you can't do binary compares of
-   two handles to see if they are the same.  This stub (along with others)
-   forces the pad byte to zero so that binary compares are possible
-*/
-
-extern int
-xvfs_dm_path_to_handle(
-       char            *path,
-       void            **hanpp,
-       size_t          *hlenp)
-{
-#undef dm_path_to_handle
-       int             rc;
-
-       if ((rc = dm_path_to_handle(path, hanpp, hlenp)) == 0) {
-               if (*hlenp == 16) {
-                       char    *cp = (char *)*hanpp;
-                       cp[15] = '\0';
-               }
-       }
-       return(rc);
-}
-
-
-/* Veritas has a prototype for this function even though it is not
-   implemented.
-*/
-
-extern int
-xvfs_dm_pending(
-       dm_sessid_t     sid,
-       dm_token_t      token,
-       dm_timestruct_t *delay)
-{
-#undef dm_pending
-       return(ENOSYS);
-}
-
-
-extern int
-xvfs_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)
-{
-#undef dm_read_invis
-       return(dm_read_invis(sid, hanp, hlen, token, off, (dm_ssize_t)len, bufp));
-}
-
-
-/* In version 2.1 uflags was defined as 'int nowait', so a value of zero in
-   this field means that the caller wants to wait.  In XDSM this was reversed,
-   where if the bottom bit of uflags is set then the caller wants to wait.
-   This routine makes the conversion.
-*/
-
-extern int
-xvfs_dm_request_right(
-       dm_sessid_t     sid,
-       void            *hanp,
-       size_t          hlen,
-       dm_token_t      token,
-       u_int           uflags,
-       dm_right_t      right)
-{
-#undef dm_request_right
-       int     nowait = 1;
-
-       if (uflags & DM_RR_WAIT)
-               nowait = 0;
-       return(dm_request_right(sid, hanp, hlen, token, nowait, right));
-}
-
-
-extern int
-xvfs_dm_set_inherit(
-       dm_sessid_t     sid,
-       void            *hanp,
-       size_t          hlen,
-       dm_token_t      token,
-       dm_attrname_t   *attrnamep,
-       mode_t          mode)
-{
-#undef dm_set_inherit
-       return(dm_set_inherit(sid, hanp, hlen, token, attrnamep, (u_int)mode));
-}
-
-
-extern int
-xvfs_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)
-{
-#undef dm_set_region
-       return(dm_set_region(sid, hanp, hlen, token, nelem, regbufp, (u_int *)exactflagp));
-}
-
-
-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(dm_set_return_ondestroy(sid, hanp, hlen, token,  attrnamep, (int)enable));
-}
-
-
-extern int
-xvfs_dm_sync_by_handle(
-       dm_sessid_t     sid,
-       void            *hanp,
-       size_t          hlen,
-       dm_token_t      token)
-{
-#undef dm_sync_by_handle
-       return((int)dm_sync_by_handle(sid, hanp, hlen, token));
-}
-
-extern int
-xvfs_dm_upgrade_right(
-       dm_sessid_t     sid,
-       void            *hanp,
-       size_t          hlen,
-       dm_token_t      token)
-{
-#undef dm_upgrade_right
-       return(dm_upgrade_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL));
-}
-
-
-extern int
-xvfs_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)
-{
-#undef dm_write_invis
-       return(dm_write_invis(sid, hanp, hlen, token, off, (dm_ssize_t)len, bufp, flags));
-}
-
-#endif
diff --git a/dmapi/src/common/lib/util.c b/dmapi/src/common/lib/util.c
deleted file mode 100644 (file)
index 8a256b3..0000000
+++ /dev/null
@@ -1,966 +0,0 @@
-/*
- * Utility routines
- *
- * This code was written by Peter Lawthers, and placed in the public
- * domain for use by DMAPI implementors and app writers.
- *
- * Standard disclaimer:
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <unistd.h>
-#include <stdarg.h>
-#include <ctype.h>
-
-#include <lib/hsm.h>
-
-#include <string.h>
-#include <time.h>
-#ifdef linux
-#include <stdint.h>
-#define S_IAMB (S_IRWXU|S_IRWXG|S_IRWXO)
-#endif
-
-#define        S_MASK  (S_ISUID|S_ISGID|S_ISVTX|S_IAMB)
-
-extern char    *Progname;
-extern int      errno;
-
-void            err_msg(char *, ...);
-void            errno_msg(char *, ...);
-
-struct ev_name_to_value ev_names[] = {
-       { "DM_EVENT_CANCEL",            DM_EVENT_CANCEL         },
-       { "DM_EVENT_MOUNT",             DM_EVENT_MOUNT          },
-       { "DM_EVENT_PREUNMOUNT",        DM_EVENT_PREUNMOUNT     },
-       { "DM_EVENT_UNMOUNT",           DM_EVENT_UNMOUNT        },
-       { "DM_EVENT_DEBUT",             DM_EVENT_DEBUT          },
-       { "DM_EVENT_CREATE",            DM_EVENT_CREATE         },
-       { "DM_EVENT_CLOSE",             DM_EVENT_CLOSE          },
-       { "DM_EVENT_POSTCREATE",        DM_EVENT_POSTCREATE     },
-       { "DM_EVENT_REMOVE",            DM_EVENT_REMOVE         },
-       { "DM_EVENT_POSTREMOVE",        DM_EVENT_POSTREMOVE     },
-       { "DM_EVENT_RENAME",            DM_EVENT_RENAME         },
-       { "DM_EVENT_POSTRENAME",        DM_EVENT_POSTRENAME     },
-       { "DM_EVENT_LINK",              DM_EVENT_LINK           },
-       { "DM_EVENT_POSTLINK",          DM_EVENT_POSTLINK       },
-       { "DM_EVENT_SYMLINK",           DM_EVENT_SYMLINK        },
-       { "DM_EVENT_POSTSYMLINK",       DM_EVENT_POSTSYMLINK    },
-       { "DM_EVENT_READ",              DM_EVENT_READ           },
-       { "DM_EVENT_WRITE",             DM_EVENT_WRITE          },
-       { "DM_EVENT_TRUNCATE",          DM_EVENT_TRUNCATE       },
-       { "DM_EVENT_ATTRIBUTE",         DM_EVENT_ATTRIBUTE      },
-       { "DM_EVENT_DESTROY",           DM_EVENT_DESTROY        },
-       { "DM_EVENT_NOSPACE",           DM_EVENT_NOSPACE        },
-       { "DM_EVENT_USER",              DM_EVENT_USER           }
-};
-
-int    ev_namecnt = sizeof(ev_names) / sizeof(ev_names[0]);
-
-dm_eventtype_t
-ev_name_to_value(
-       char            *name)
-{
-       int             i;
-
-       for (i = 0; i < ev_namecnt; i++) {
-               if (!strcmp(name, ev_names[i].name)) 
-                       return(ev_names[i].value);
-       }
-       return(DM_EVENT_INVALID);
-}
-
-char *
-ev_value_to_name(
-       dm_eventtype_t  event)
-{
-       static char             buffer[100];
-       int             i;
-
-       for (i = 0; i < ev_namecnt; i++) {
-               if (event == ev_names[i].value)
-                       return(ev_names[i].name);
-       }
-       sprintf(buffer, "Unknown Event Number %d\n", event);
-       return(buffer);
-}
-
-
-
-struct rt_name_to_value rt_names[] = {
-       { "DM_RIGHT_NULL",              DM_RIGHT_NULL           },
-       { "DM_RIGHT_SHARED",            DM_RIGHT_SHARED         },
-       { "DM_RIGHT_EXCL",              DM_RIGHT_EXCL           }
-};
-
-int    rt_namecnt = sizeof(rt_names) / sizeof(rt_names[0]);
-
-int
-rt_name_to_value(
-       char            *name,
-       dm_right_t      *rightp)
-{
-       int             i;
-
-       for (i = 0; i < rt_namecnt; i++) {
-               if (!strcmp(name, rt_names[i].name)) {
-                       *rightp = rt_names[i].value;
-                       return(0);
-               }
-       }
-       return(1);
-}
-
-
-char *
-rt_value_to_name(
-       dm_right_t      right)
-{
-       int             i;
-
-       for (i = 0; i < rt_namecnt; i++) {
-               if (right == rt_names[i].value)
-                       return(rt_names[i].name);
-       }
-       return(NULL);
-}
-/*
- * Convert a handle from (possibly) binary to ascii. 
- */
-void
-hantoa(
-       void    *hanp,
-       size_t   hlen,
-       char    *handle_str)
-{
-       int     i;
-       u_char  *cp;
-
-       cp = (u_char *)hanp;
-       for (i=0;i<hlen; i++)  {
-               sprintf(handle_str, "%.2x", *cp++);
-               handle_str += 2;
-       }
-       *handle_str = '\0';     /* Null-terminate to make it printable */
-}
-
-/*
- * Convert a handle from ascii back to it's native binary representation
- */
-
-int
-atohan(
-       char    *handle_str,
-       void    **hanpp,
-       size_t   *hlenp) 
-{
-       u_char  handle[HANDLE_LEN];
-       char    cur_char[3];
-       int     i = 0;
-       u_long  num;
-
-       if (strlen(handle_str) > HANDLE_LEN * 2){
-               return(EBADF);
-       }
-
-       while (*handle_str && *(handle_str + 1)) {
-               if (i == HANDLE_LEN){
-                       return(EBADF);
-               }
-               if( ! (isxdigit(*handle_str) && (isxdigit(*(handle_str +1))))) {
-                       return(EBADF);
-               }
-               cur_char[0] = *handle_str;
-               cur_char[1] = *(handle_str + 1);
-               cur_char[2] = '\0';
-               num = strtol(cur_char, (char **)0, 16);
-               handle[i++] = num & 0xff;
-               handle_str += 2;
-       }
-       if (*handle_str){
-               return(EBADF);
-       }
-       *hlenp = i;
-       if ((*hanpp = malloc(*hlenp)) == NULL)
-               return(ENOMEM);
-       memcpy(*hanpp, handle, *hlenp);
-       return(0);
-}
-
-
-int
-opaque_to_handle(
-       char            *name,
-       void            **hanpp,
-       size_t          *hlenp)
-{
-       if (atohan(name, hanpp, hlenp)) {
-               /* not a handle */
-       } else if (dm_handle_is_valid(*hanpp, *hlenp) == DM_FALSE) {
-               dm_handle_free(*hanpp, *hlenp);
-               /* not a handle */
-       } else {
-               return(0);
-       }
-
-       /* Perhaps it is a pathname */
-
-       if (dm_path_to_handle(name, hanpp, hlenp)) {
-               return(errno);
-       }
-       return(0);
-}
-
-
-void
-print_handle(
-       void    *hanp,
-       size_t   hlen)
-{
-       char    handle_str[HANDLE_STR];
-
-       if (hlen > HANDLE_LEN)  {
-               printf("-- invalid hlen length %zd --\n", hlen);
-               return;
-       }
-
-       printf("print_handle: ");
-       printf("%zd\t", hlen);
-       hantoa(hanp, hlen, handle_str);
-       printf("%s\n ", handle_str);
-}
-
-void
-print_victim(
-       void            *hanp, 
-       size_t           hlen,
-       dm_off_t         fsize)
-{
-       char    handle_str[HANDLE_STR];
-
-       if (hlen > HANDLE_LEN)  {
-               printf("-- invalid length --\n");
-               return;
-       }
-
-       printf("%zd\t", hlen);
-       hantoa(hanp, hlen, handle_str);
-       printf("%s ", handle_str);
-       printf("\t%lld \n", (long long) fsize);
-}
-
-
-/*
- * Print out a simple error message, and include the errno
- * string with it.
- */
-void
-errno_msg(char *fmt, ...)
-{
-       va_list         ap;
-       int             old_errno;
-
-       old_errno = errno;
-       fprintf(stderr, "%s: ", Progname);
-
-       va_start(ap, fmt );
-       vfprintf(stderr, fmt, ap);
-       va_end(ap);
-
-       errno = old_errno;
-       perror("\n\tError");
-}
-
-/*
- * Print out a simple error message
- */
-void
-err_msg(char *fmt, ...)
-{
-       va_list         ap;
-       
-       fprintf(stderr, "%s: ", Progname);
-
-       va_start(ap, fmt );
-       vfprintf(stderr, fmt, ap);
-       va_end(ap);
-
-}
-
-
-/*
- * Initialize the interface to the DMAPI
- */
-int
-setup_dmapi(dm_sessid_t         *sidp)
-{
-       char    *cp;
-
-       if (dm_init_service(&cp) == -1)  {
-               err_msg("%s/%d: Can't init dmapi\n", __FILE__, __LINE__);
-               return(1);
-       }
-       if (strcmp(cp, DM_VER_STR_CONTENTS)) {
-               err_msg("%s/%d: Compiled for a different version\n", __FILE__, __LINE__);
-               return(1);
-       }
-
-       find_test_session(sidp);
-       return(0);
-}
-
-/*
- * Get the file's change indicator
- */
-int
-get_dmchange(
-       dm_sessid_t      sid,
-       void            *hanp, 
-       size_t           hlen, 
-       dm_token_t       token,
-       u_int           *change_start)
-{
-       int             error;
-       dm_stat_t       statbuf;
-
-
-       error = dm_get_fileattr(sid, hanp, hlen, token, DM_AT_CFLAG, &statbuf);
-       if (error == -1) {
-               errno_msg("%s/%d: Can't stat file (%d)", __FILE__, __LINE__, errno);
-               return(1);
-       }
-       *change_start = statbuf.dt_change;
-       return(0);
-}
-
-
-/*
- * Write a file's data to the staging file. We write the file out
- * in 4meg chunks.
- */
-int
-save_filedata(
-       dm_sessid_t      sid, 
-       void            *hanp, 
-       size_t           hlen, 
-       int              stg_fd, 
-       dm_size_t        fsize)
-{
-       char            *filebuf;
-       int              i, nbufs;
-       int              retval;
-       dm_ssize_t       nread, lastbuf;
-       ssize_t          nwrite;
-       dm_off_t         off;
-
-        nbufs  = fsize / CHUNKSIZE;
-       off    = 0;
-       retval = 0;
-       filebuf = malloc(CHUNKSIZE);
-       if (filebuf == NULL) {
-               err_msg("%s/%d: Can't alloc memory for file buffer\n", __FILE__, __LINE__);
-               goto out;
-       }
-
-        for (i = 0; i<nbufs; i++) {
-               nread = dm_read_invis(sid, hanp, hlen, DM_NO_TOKEN, off, 
-                                       (dm_ssize_t)CHUNKSIZE, filebuf);
-               if (nread != CHUNKSIZE) {
-                       errno_msg("%s/%d: invis read err: got %d, expected %d, buf %d",
-                               __FILE__, __LINE__,
-                               nread, (dm_ssize_t)CHUNKSIZE, i);
-                       retval = 1;
-                       goto out;
-               }
-               off += nread;
-
-                nwrite = write(stg_fd, filebuf, CHUNKSIZE);
-               if (nwrite != CHUNKSIZE) {
-                       errno_msg("%s/%d: write err %d, expected %d, buf %d",
-                                 __FILE__, __LINE__,
-                                 nwrite, CHUNKSIZE, i);
-                       retval = 1;
-                       goto out;
-               }
-        }
-
-        lastbuf = fsize % CHUNKSIZE;
-       nread  = dm_read_invis(sid, hanp, hlen, DM_NO_TOKEN, off, 
-                               (dm_ssize_t)lastbuf, filebuf);
-       if (nread != lastbuf) {
-               errno_msg("%s/%d: invis read error- got %d, expected %d, last buf",
-                               __FILE__, __LINE__,
-                               nread, lastbuf);
-               retval = 1;
-               goto out;
-       }
-
-       nwrite = write(stg_fd, filebuf, (int)lastbuf);
-       if (nwrite != lastbuf) {
-               errno_msg("%s/%d: write error %d, expected %d, last buffer", 
-                               __FILE__, __LINE__,
-                               nwrite, lastbuf);
-               retval = 1;
-       }
-out:
-       if (filebuf)
-               free(filebuf);
-
-       close(stg_fd);
-       return(retval);
-}
-
-
-
-/*
- * Read a file's data from the staging file. 
- * Since we only have the staging file handle (not a file descriptor)
- * we use dm_read_invis() to read the data. 
- *
- * We stage the entire file in, regardless of how much was asked for, 
- * starting at the faulting offset.
- */
-int
-restore_filedata(
-       dm_sessid_t      sid, 
-       void            *hanp, 
-       size_t           hlen, 
-       dm_token_t       token,
-       void            *stg_hanp,
-       size_t           stg_hlen,
-       dm_off_t         off)
-{
-       char            *filebuf;
-       int              i, nbufs;
-       int              error, retval;
-       dm_ssize_t       nread, nwrite, lastbuf;
-       dm_off_t         fsize;
-       dm_stat_t        dm_statbuf;
-
-       error = dm_get_fileattr(sid, hanp, hlen, token, DM_AT_STAT,
-                               &dm_statbuf);
-       if (error == -1) {
-               errno_msg("%s/%d: Can't get dm stats of file (%d)", __FILE__, __LINE__, errno);
-               return(1);
-       }
-
-       fsize  = dm_statbuf.dt_size;
-        nbufs  = fsize / CHUNKSIZE;
-       retval = 0;
-
-       filebuf = malloc(CHUNKSIZE);
-       if (filebuf == NULL) {
-               err_msg("%s/%d: Can't alloc memory for file buffer\n", __FILE__, __LINE__);
-               goto out;
-       }
-
-        for (i = 0; i<nbufs; i++) {
-               nread = dm_read_invis(sid, stg_hanp, stg_hlen, DM_NO_TOKEN, 
-                                       off, (dm_ssize_t)CHUNKSIZE, filebuf);
-               if (nread != CHUNKSIZE) {
-                       errno_msg("%s/%d: invis read err: got %d, expected %d, buf %d",
-                                 __FILE__, __LINE__,
-                               nread, CHUNKSIZE, i);
-                       retval = 1;
-                       goto out;
-               }
-
-                nwrite = dm_write_invis(sid, hanp, hlen, token, 0, off, nread,
-                                       filebuf);
-               if (nwrite != nread) {
-                       errno_msg("%s/%d: write error -got %d, expected %d, buf %d", 
-                                 __FILE__, __LINE__,
-                               nwrite, nread, i);
-                       retval = 1;
-                       goto out;
-               }
-               off += CHUNKSIZE;
-        }
-
-        lastbuf = fsize % CHUNKSIZE;
-       nread  = dm_read_invis(sid, stg_hanp, stg_hlen, DM_NO_TOKEN, off, 
-                               (dm_ssize_t)lastbuf, filebuf);
-       if (nread != lastbuf) {
-               errno_msg("%s/%d: invis read error- got %d, expected %d, last buf",
-                               __FILE__, __LINE__,
-                               nread, lastbuf);
-               retval = 1;
-               goto out;
-       }
-
-       nwrite = dm_write_invis(sid, hanp, hlen, token, 0, off, lastbuf, filebuf);
-       if (nwrite != lastbuf) {
-               errno_msg("%s/%d: write error - got %d, expected %d, last buffer", 
-                               __FILE__, __LINE__,
-                               nwrite, lastbuf);
-               retval = 1;
-       }
-out:
-       if (filebuf)
-               free(filebuf);
-       return(retval);
-}
-
-
-extern mode_t
-field_to_mode(
-       mode_t  mode)
-{
-       switch (mode & S_IFMT) {
-
-       case S_IFBLK:
-               return(S_IFBLK);
-
-       case S_IFREG:
-               return(S_IFREG);
-
-       case S_IFDIR:
-               return(S_IFDIR);
-
-       case S_IFCHR:
-               return(S_IFCHR);
-
-       case S_IFIFO:
-               return(S_IFIFO);
-
-       case S_IFLNK:
-               return(S_IFLNK);
-
-       case S_IFSOCK:
-               return(S_IFSOCK);
-
-       default:
-               return(0);
-       }
-}
-
-
-extern int
-validate_state(
-       dm_stat_t       *dmstat,
-       char            *pathname,
-       int             report_errors)
-{
-       struct  stat    statb;
-       int             errors = 0;
-
-       /* Get the stat block for the file. */
-
-       if (lstat(pathname, &statb)) {
-               perror("stat failed");
-               exit(1);
-       }
-
-       /* Compare its fields against the dm_stat_t structure. */
-
-       if (dmstat->dt_dev != statb.st_dev) {
-               if (report_errors) {
-                       fprintf(stdout, "ERROR:dmstat->dt_dev 0x%llx, "
-                               "statb.st_dev 0x%llx\n",
-                               (unsigned long long) dmstat->dt_dev,
-                               (unsigned long long) statb.st_dev);
-               }
-               errors++;
-       }
-       if (dmstat->dt_ino != statb.st_ino) {
-               if (report_errors) {
-                       fprintf(stdout, "ERROR:dmstat->dt_ino %llx, "
-                               "statb.st_ino %llx\n",
-                               (unsigned long long) dmstat->dt_ino,
-                               (unsigned long long) statb.st_ino);
-               }
-               errors++;
-       }
-       if ((dmstat->dt_mode & S_IFMT) != field_to_mode(statb.st_mode)) {
-               if (report_errors) {
-                       fprintf(stdout, "ERROR:dmstat->dt_mode (mode) %s, "
-                               "statb.st_mode (mode) %s\n",
-                               mode_to_string(dmstat->dt_mode),
-                               mode_to_string(field_to_mode(statb.st_mode)));
-               }
-               errors++;
-       }
-       if ((dmstat->dt_mode & S_MASK) != (statb.st_mode & S_MASK)) {
-               if (report_errors) {
-                       fprintf(stdout, "ERROR:dmstat->dt_mode (perm) 0%o, "
-                               "statb.st_mode (perm) 0%o\n",
-                               dmstat->dt_mode & S_MASK,
-                               statb.st_mode & S_MASK);
-               }
-               errors++;
-       }
-       if (dmstat->dt_nlink != statb.st_nlink) {
-               if (report_errors) {
-                       fprintf(stdout, "ERROR:dmstat->dt_nlink %u, "
-                               "statb.st_nlink %u\n",
-                               (unsigned int) dmstat->dt_nlink,
-                               (unsigned int) statb.st_nlink);
-               }
-               errors++;
-       }
-       if (dmstat->dt_uid !=  statb.st_uid) {
-               if (report_errors) {
-                       fprintf(stdout, "ERROR:dmstat->dt_uid %d, "
-                               "statb.st_uid %d\n", dmstat->dt_uid,
-                               statb.st_uid);
-               }
-               errors++;
-       }
-       if (dmstat->dt_gid != statb.st_gid) {
-               if (report_errors) {
-                       fprintf(stdout, "ERROR:dmstat->dt_gid %d, "
-                               "statb.st_gid %d\n", dmstat->dt_gid,
-                               statb.st_gid);
-               }
-               errors++;
-       }
-       if (dmstat->dt_rdev != statb.st_rdev) {
-               if (report_errors) {
-                       fprintf(stdout, "ERROR:dmstat->dt_rdev 0x%llx, "
-                               "statb.st_rdev 0x%llx\n",
-                               (unsigned long long) dmstat->dt_rdev,
-                               (unsigned long long) statb.st_rdev);
-               }
-               errors++;
-       }
-       if (dmstat->dt_size != statb.st_size) {
-               if (report_errors) {
-                       fprintf(stdout, "ERROR:dmstat->dt_size %lld, "
-                               "statb.st_size %lld\n",
-                               (long long) dmstat->dt_size,
-                               (long long) statb.st_size);
-               }
-               errors++;
-       }
-       if (dmstat->dt_atime != statb.st_atime) {
-               if (report_errors) {
-                       fprintf(stdout, "ERROR:dmstat->dt_atime %ld, "
-                               "statb.st_atime %ld\n", dmstat->dt_atime,
-                               statb.st_atime);
-               }
-               errors++;
-       }
-       if (dmstat->dt_mtime != statb.st_mtime) {
-               if (report_errors) {
-                       fprintf(stdout, "ERROR:dmstat->dt_mtime %ld, "
-                               "statb.st_mtime %ld\n", dmstat->dt_mtime,
-                               statb.st_mtime);
-               }
-               errors++;
-       }
-       if (dmstat->dt_ctime != statb.st_ctime) {
-               if (report_errors) {
-                       fprintf(stdout, "ERROR:dmstat->dt_ctime %ld, "
-                               "statb.st_ctime %ld\n", dmstat->dt_ctime,
-                               statb.st_ctime);
-               }
-               errors++;
-       }
-       if (dmstat->dt_dtime != statb.st_ctime) {
-               if (report_errors) {
-                       fprintf(stdout, "ERROR:dmstat->dt_dtime %ld, "
-                               "statb.st_ctime %ld\n", dmstat->dt_dtime,
-                               statb.st_ctime);
-               }
-               errors++;
-       }
-       if (dmstat->dt_blksize != statb.st_blksize) {
-               if (report_errors) {
-                       fprintf(stdout, "ERROR:dmstat->dt_blksize %d, "
-                               "statb.st_blksize %ld\n", dmstat->dt_blksize,
-                               statb.st_blksize);
-               }
-               errors++;
-       }
-       if (dmstat->dt_blocks != statb.st_blocks) {
-               if (report_errors) {
-                       fprintf(stdout, "ERROR:dmstat->dt_blocks %lld, "
-                               "statb.st_blocks %lld\n",
-                               (long long) dmstat->dt_blocks,
-                               (long long) statb.st_blocks);
-               }
-               errors++;
-       }
-
-       if (errors && report_errors)
-               fprintf(stdout, "There were %d differences\n", errors);
-       return(errors);
-}
-
-
-extern char *
-date_to_string(
-       time_t          timeval)
-{
-static char            buffer[21];
-       char            *tmstr;
-
-       if (timeval == (time_t)0) {
-               strcpy(buffer, "0");
-       } else {
-               tmstr = asctime(localtime(&timeval));
-               tmstr += 4;
-               strncpy(buffer, tmstr, 20);
-               buffer[20] = '\0';
-       }
-       return(buffer);
-}
-
-
-extern char *
-mode_to_string(
-       mode_t  mode)
-{
-static char            buffer[256];
-
-       switch (mode & S_IFMT) {
-
-       case S_IFBLK:
-               return("S_IFBLK");
-
-       case S_IFREG:
-               return("S_IFREG");
-
-       case S_IFDIR:
-               return("S_IFDIR");
-
-       case S_IFCHR:
-               return("S_IFCHR");
-
-       case S_IFIFO:
-               return("S_IFIFO");
-
-       case S_IFLNK:
-               return("S_IFLNK");
-
-       case S_IFSOCK:
-               return("S_IFSOCK");
-
-       default:
-               sprintf(buffer, "Invalid mode 0%o", mode & S_IFMT);
-               return(buffer);
-       }
-}
-
-
-extern char *
-emask_to_string(
-       dm_eventset_t   emask)
-{
-static char            buffer[256];
-       char            *name;
-       int             len = 0;
-       int             i;
-
-       for (i = 0; i < 32; i++) {
-               if (!DMEV_ISSET(i, emask))
-                       continue;
-
-               switch (i) {
-               case DM_EVENT_CREATE:
-                       name = "DM_EVENT_CREATE";
-                       break;
-               case DM_EVENT_POSTCREATE:
-                       name = "DM_EVENT_POSTCREATE";
-                       break;
-               case DM_EVENT_REMOVE:
-                       name = "DM_EVENT_REMOVE";
-                       break;
-               case DM_EVENT_POSTREMOVE:
-                       name = "DM_EVENT_POSTREMOVE";
-                       break;
-               case DM_EVENT_RENAME:
-                       name = "DM_EVENT_RENAME";
-                       break;
-               case DM_EVENT_POSTRENAME:
-                       name = "DM_EVENT_POSTRENAME";
-                       break;
-               case DM_EVENT_LINK:
-                       name = "DM_EVENT_LINK";
-                       break;
-               case DM_EVENT_POSTLINK:
-                       name = "DM_EVENT_POSTLINK";
-                       break;
-               case DM_EVENT_SYMLINK:
-                       name = "DM_EVENT_SYMLINK";
-                       break;
-               case DM_EVENT_POSTSYMLINK:
-                       name = "DM_EVENT_POSTSYMLINK";
-                       break;
-               case DM_EVENT_READ:
-                       name = "DM_EVENT_READ";
-                       break;
-               case DM_EVENT_WRITE:
-                       name = "DM_EVENT_WRITE";
-                       break;
-               case DM_EVENT_TRUNCATE:
-                       name = "DM_EVENT_TRUNCATE";
-                       break;
-               case DM_EVENT_ATTRIBUTE:
-                       name = "DM_EVENT_ATTRIBUTE";
-                       break;
-               case DM_EVENT_DESTROY:
-                       name = "DM_EVENT_DESTROY";
-                       break;
-               default:
-                       fprintf(stderr, "Unknown event type %d\n", i);
-                       exit(1);
-               }
-               sprintf(buffer + len, "%c%s", (len ? '|' : '('), name);
-               len = strlen(buffer);
-       }
-
-       if (len == 0) {
-               sprintf(buffer, "(none)");
-       } else {
-               sprintf(buffer + len, ")");
-       }
-       return(buffer);
-}
-
-
-#if defined(linux)
-
-extern char *
-xflags_to_string(
-       u_int           xflags)
-{
-static char            buffer[256];
-       int             len = 0;
-
-       if (xflags & ~(DM_XFLAG_REALTIME|DM_XFLAG_PREALLOC|DM_XFLAG_HASATTR)) {
-               sprintf(buffer, "Invalid xflags 0%o", xflags);
-               return(buffer);
-       }
-
-       if (xflags & DM_XFLAG_REALTIME) {
-               sprintf(buffer + len, "%cREALTIME", (len ? '|' : '('));
-               len = strlen(buffer);
-       }
-       if (xflags & DM_XFLAG_PREALLOC) {
-               sprintf(buffer + len, "%cPREALLOC", (len ? '|' : '('));
-               len = strlen(buffer);
-       }
-       if (xflags & DM_XFLAG_HASATTR) {
-               sprintf(buffer + len, "%cHASATTR", (len ? '|' : '('));
-               len = strlen(buffer);
-       }
-       if (len == 0) {
-               sprintf(buffer, "(none)");
-       } else {
-               sprintf(buffer + len, ")");
-       }
-       return(buffer);
-}
-
-#endif
-
-
-extern void
-print_state(
-       dm_stat_t       *dmstat)
-{
-       /* Print all the stat block fields. */
-
-       fprintf(stdout, "dt_dev         0x%llx\n",
-               (unsigned long long) dmstat->dt_dev);
-       fprintf(stdout, "dt_ino         %llx\n",
-               (unsigned long long) dmstat->dt_ino);
-       fprintf(stdout, "dt_mode (type) %s\n",
-               mode_to_string(dmstat->dt_mode));
-       fprintf(stdout, "dt_mode (perm) 0%o\n", dmstat->dt_mode & S_MASK);
-       fprintf(stdout, "dt_nlink       %d\n",  dmstat->dt_nlink);
-       fprintf(stdout, "dt_uid         %d\n",  dmstat->dt_uid);
-       fprintf(stdout, "dt_gid         %d\n", dmstat->dt_gid);
-       fprintf(stdout, "dt_rdev        0x%llx\n",
-               (unsigned long long) dmstat->dt_rdev);
-       fprintf(stdout, "dt_size        %lld\n",
-               (unsigned long long) dmstat->dt_size);
-
-       fprintf(stdout, "dt_atime       %s\n",
-               date_to_string(dmstat->dt_atime));
-       fprintf(stdout, "dt_mtime       %s\n",
-               date_to_string(dmstat->dt_mtime));
-       fprintf(stdout, "dt_ctime       %s\n",
-               date_to_string(dmstat->dt_ctime));
-
-       fprintf(stdout, "dt_blksize     %d\n", dmstat->dt_blksize);
-       fprintf(stdout, "dt_blocks      %lld\n", (long long) dmstat->dt_blocks);
-
-#if defined(linux)
-       fprintf(stdout, "dt_xfs_igen    %d\n",  dmstat->dt_xfs_igen);
-       fprintf(stdout, "dt_xfs_xflags  %s\n",
-               xflags_to_string(dmstat->dt_xfs_xflags));
-       fprintf(stdout, "dt_xfs_extsize %d\n", dmstat->dt_xfs_extsize);
-       fprintf(stdout, "dt_xfs_extents %d\n", dmstat->dt_xfs_extents);
-       fprintf(stdout, "dt_xfs_aextents %d\n", dmstat->dt_xfs_aextents);
-#endif
-
-       fputc('\n', stdout);
-
-       /* Print all other fields. */
-
-       fprintf(stdout, "emask           %s\n",
-               emask_to_string(dmstat->dt_emask));
-       fprintf(stdout, "nevents         %d\n", dmstat->dt_nevents);
-       fprintf(stdout, "pmanreg         %d\n", dmstat->dt_pmanreg);
-       fprintf(stdout, "pers            %d\n", dmstat->dt_pers);
-       fprintf(stdout, "dt_dtime        %s\n",
-               date_to_string(dmstat->dt_dtime));
-       fprintf(stdout, "change          %d\n", dmstat->dt_change);
-}
-
-
-extern void
-print_line(
-       dm_stat_t       *dmstat)
-{
-       fprintf(stdout, "0x%llx|",  (unsigned long long) dmstat->dt_dev);
-       fprintf(stdout, "%llx|",  (unsigned long long) dmstat->dt_ino);
-       fprintf(stdout, "%s|", mode_to_string(dmstat->dt_mode));
-       fprintf(stdout, "0%o|", dmstat->dt_mode & S_MASK);
-       fprintf(stdout, "%d|",  dmstat->dt_nlink);
-       fprintf(stdout, "%d|",  dmstat->dt_uid);
-       fprintf(stdout, "%d|", dmstat->dt_gid);
-       fprintf(stdout, "0x%llx|", (unsigned long long) dmstat->dt_rdev);
-       fprintf(stdout, "%lld|", (long long) dmstat->dt_size);
-
-       fprintf(stdout, "%s|", date_to_string(dmstat->dt_atime));
-       fprintf(stdout, "%s|", date_to_string(dmstat->dt_mtime));
-       fprintf(stdout, "%s|", date_to_string(dmstat->dt_ctime));
-
-       fprintf(stdout, "%d|", dmstat->dt_blksize);
-       fprintf(stdout, "%lld|", (long long) dmstat->dt_blocks);
-
-       fprintf(stdout, "%d|",  dmstat->dt_xfs_igen);
-       fprintf(stdout, "%s|", xflags_to_string(dmstat->dt_xfs_xflags));
-       fprintf(stdout, "%d|", dmstat->dt_xfs_extsize);
-       fprintf(stdout, "%d|", dmstat->dt_xfs_extents);
-       fprintf(stdout, "%d|", dmstat->dt_xfs_aextents);
-
-       /* Print all other fields. */
-
-       fprintf(stdout, "%s|", emask_to_string(dmstat->dt_emask));
-       fprintf(stdout, "%d|", dmstat->dt_nevents);
-       fprintf(stdout, "%d|", dmstat->dt_pmanreg);
-       fprintf(stdout, "%d|", dmstat->dt_pers);
-       fprintf(stdout, "%s|", date_to_string(dmstat->dt_dtime));
-       fprintf(stdout, "%d", dmstat->dt_change);
-
-       fputc('\n', stdout);
-}
diff --git a/dmapi/src/sample_hsm/Makefile b/dmapi/src/sample_hsm/Makefile
deleted file mode 100644 (file)
index 3c812fd..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-# Copyright (C) 2011 SGI  All Rights Reserved.
-#
-#
-#
-TOPDIR = ../../..
-
-include $(TOPDIR)/include/builddefs
-
-TARGETS = migfind migin migout mls mrmean wbee
-
-CFILES = $(TARGETS:=.c)
-LDIRT = $(TARGETS)
-
-CFLAGS += -I$(TOPDIR)/dmapi/src/common -I/usr/include/xfs
-
-LLDLIBS = $(TOPDIR)/dmapi/src/common/lib/libdmtest.la $(LIBDM)
-
-default: depend $(TARGETS)
-
-depend: .dep
-
-include $(BUILDRULES)
-
-install install-dev: default
-
-$(TARGETS):
-       @echo "    [CC]    $@"
-       $(Q)$(LTLINK) $@.c -o $@ $(CFLAGS) $(LDFLAGS) $(LDLIBS)
-
--include .dep
diff --git a/dmapi/src/sample_hsm/README b/dmapi/src/sample_hsm/README
deleted file mode 100644 (file)
index 0648f81..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-The files in this directory comprise a simple HSM example that uses 
-the DMAPI. These files are distributed in the hope that they will be
-useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  These programs
-have been tested on an SGI platform (as of April 1995) and found
-to be suitably functional; however, there is no guarantee that they
-do, in fact, provide the functationality that is advertised. This
-is a long winded way of saying they probably have bugs; if you 
-find 'em, fix 'em. 
-
-Okay, now that we have the disclaimers out of the way, here are the details.
-
-       migfind
-       =======
-This will find all files of a specified size, and print out the handles.
-It is normally used like this:
-       migfind -s 800k /migfs >& cand_file
-
-This example will find all files greater than 800K in the /migfs filesystem,
-and put the handles (converted to ascii) in the file 'cand_file'. The output
-consists of three fields per line:
-       handle length           filehandle              file size in bytes
-
-       migout
-       ======
-migout reads a list of handles as created by migfind, and migrates
-the files data. The data is stored in files that are located in 
-another directory. The usage is
-       migout /dmapi_fs/stagedir < cand_file
-
-This will all the files specified by handle in 'cand_file', and
-put their data in files located under the directory /dmapi_fs/stagedir'.
-The staging directory must be on a filesystem that supports
-the dmapi; the reason for this is to allow for a simplification
-in the code that stores the location of the data as a DM attribute
-(file handles are easier than path names).
-
-       migin
-       =====
-This daemon waits for DMAPI events and dispatches worker bees
-to actually stage the data in. The usage is:
-       migin -l dmapi_log /migfs
-migin will fork/exec a 'wbee' to either bring the data back from
-the staging directory, or to invalidate the file.
-
-
-Other programs:
-There are a couple of other programs in this directory. 
-
-       mrmean
-       ======
-Simplist cleanup/debugging tool that will print information about
-the active sessions. If desired, it can also respond to outstanding
-events and destroy sessions that may have been left around from
-a process exiting unexpectedly.
-
-       mls
-       ===
-Simple ls type program to display information about a file, such
-as the managed region info, allocation info, event lists, and
-file handle.
-
diff --git a/dmapi/src/sample_hsm/migfind.c b/dmapi/src/sample_hsm/migfind.c
deleted file mode 100644 (file)
index 95b6d6d..0000000
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Simple utility to find all files above a certain size in 
- * a filesystem. The output is to stdout, and is of the form:
- *     filehandle length       filehandle      file size in bytes
- *
- * The list is not sorted in any way.
- *
- * This code was written by Peter Lawthers, and placed in the public
- * domain for use by DMAPI implementors and app writers.
- *
- * Standard disclaimer:
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/stat.h>
-
-#include <lib/hsm.h>
-
-#include <getopt.h>
-
-#define NUMLEN 16              /* arbitrary max len of input size */
-#define MAX_K   (((u_int)LONG_MAX) / 1024)
-#define MAX_M   (((u_int)LONG_MAX) / (1024*1024))
-
-
-
-extern char    *optarg;
-extern int      optind, optopt, opterr;
-char           *Progname;
-
-extern void    print_victim(void *, size_t, dm_off_t);
-extern void    err_msg(char *, ...);
-extern void    errno_msg(char *, ...);
-
-int            setup_dmapi(dm_sessid_t *);
-int            scan_fs(dm_sessid_t, void *, size_t, dm_off_t);
-int            verify_size(char *, dm_off_t *);
-void           usage(char *);
-
-void
-usage(
-       char *prog)
-{
-       fprintf(stderr, "Usage: %s ", prog);
-       fprintf(stderr, " [-s file threshold]");
-       fprintf(stderr, " filesystem\n");
-}
-
-/*
- * Convert an input string on the form 10m or 128K to something reasonable
- */
-int
-verify_size(
-        char           *str,
-        dm_off_t       *sizep)
-{
-        char           *cp;
-        dm_off_t        size;
-
-        if (strlen(str) > NUMLEN) {
-                printf("Size %s is invalid \n", str);
-                return(1);
-        }
-
-        size = strtol(str,0,0); 
-        if (size < 0 || size >= LONG_MAX ) {
-                printf("Size %lld is invalid \n", (long long) size);
-                return(1);
-        }
-
-        cp = str;
-        while (isdigit(*cp))
-                cp++;
-        if (*cp == 'k' || *cp == 'K') {
-                if ( size >= (u_int) MAX_K) {
-                        printf("Size %lld is invalid\n", (long long) size);
-                        return(1);
-                }
-                size *= 1024;
-        } else if (*cp == 'm' || *cp == 'M') {
-                if ( size >= (u_int) MAX_M) {
-                        printf("Size %lld is invalid\n", (long long) size);
-                        return(1);
-                }
-                size *= (1024*1024);
-        }
-        *sizep = size;
-        return(0);
-}
-
-
-
-int
-main(
-       int     argc, 
-       char    *argv[])
-{
-       
-       int              c;
-       int              error;
-       dm_off_t         size;
-       char            *fsname;
-       dm_sessid_t      sid;
-       void            *fs_hanp;
-       size_t           fs_hlen;
-       char            *sizep = "0";
-
-
-       Progname = argv[0];
-       size     = 0;
-
-       while ((c = getopt(argc, argv, "s:")) != EOF) {
-               switch (c) {
-               case 's':
-                       sizep = optarg;
-                       break;
-
-               case '?':
-               default:
-                       usage(Progname);
-                       exit(1);
-               }
-       }
-       if (optind >= argc) {
-               usage(Progname);
-               exit(1);
-       }
-       /*
-        * Verify the input size string is legit
-        */
-       error = verify_size(sizep, &size);
-       if (error) 
-               exit(1);
-
-       fsname = argv[optind];
-
-       /*
-        * Now we have our filesystem name and possibly a size threshold
-        * to look for. Init the dmapi, and get a filesystem handle so
-        * we can scan the filesystem
-        */
-       error = setup_dmapi(&sid);
-       if (error) 
-               exit(1);
-       
-       if (dm_path_to_fshandle(fsname, &fs_hanp, &fs_hlen) == -1) {
-               errno_msg("Can't get filesystem handle");
-               exit(1);
-       }
-
-
-
-       /*
-        * Get the attributes of all files in the filesystem
-        */
-       error = scan_fs(sid, fs_hanp, fs_hlen, size);
-       if (error) 
-               exit(1);
-       
-
-       /*
-        * We're done, so we can shut down our session.
-        */
-       if (dm_destroy_session(sid) == -1) {
-               errno_msg("Can't close session");
-               exit(1);
-       }
-
-       return(0);
-
-}
-
-/*
- * Get the attributes for all the files in a filesystem in bulk,
- * and print out the handles and sizes of any that meet our target
- * criteria.
- *
- * We are not interested in file names; if we were, then we would 
- * have to do a dm_get_dirattrs() on each directroy, then use 
- * dm_handle_to_path() to get the pathname. 
- */
-int
-scan_fs(
-       dm_sessid_t      sid, 
-       void            *fs_hanp, 
-       size_t           fs_hlen, 
-       dm_off_t         target_size)
-{
-       u_int            mask;                  /* attributes to scan for */
-       dm_stat_t       *dm_statbuf, *sbuf;     /* attributes buffer */
-       dm_attrloc_t     locp;                  /* opaque location in fs */
-       size_t           rlenp;                 /* ret length of stat info */
-       size_t           buflen;                /* length of stat buffer */
-       void            *hanp;                  /* file handle */
-       size_t           hlen;                  /* file handle */
-       int              more;                  /* loop terminator */
-       int              error; 
-
-
-       /*
-        * Size the stat buffer to return info on 1K files at a time
-        */
-       buflen     = sizeof(dm_stat_t) * 1024;
-#ifdef VERITAS_21
-       if (buflen > 65536)
-               buflen = 65536;
-#endif
-       dm_statbuf = (dm_stat_t *)calloc(1, buflen);
-       if (dm_statbuf == NULL)  {
-               err_msg("Can't get memory for stat buffer");
-               return(1);
-       }
-
-
-       /*
-        * Initialize the offset opaque offset cookie that
-        * we use in successive calls to dm_get_bulkattr()
-        */
-       error = dm_init_attrloc(sid, fs_hanp, fs_hlen, DM_NO_TOKEN, &locp);
-       if (error == -1) {
-               errno_msg("%s/%d: Can't initialize offset cookie (%d)", __FILE__, __LINE__, errno);
-               free(dm_statbuf);
-               return(1);
-       }
-
-       /*
-        * Set our stat mask so that we'll only get the normal stat(2)
-        * info and the file's handle
-        */
-       mask = DM_AT_HANDLE | DM_AT_STAT;
-       do {
-               more = dm_get_bulkattr(sid, fs_hanp, fs_hlen, DM_NO_TOKEN,
-                                      mask, &locp, buflen, dm_statbuf, &rlenp);
-               if (more == -1) {
-                       errno_msg("%s/%d: Can't get bulkattr for filesystem", __FILE__, __LINE__, errno);
-                       break;
-               }
-
-               /*
-                * Walk through the stat buffer and pull out files 
-                * that are of interest
-                *
-                * The stat buffer is variable length, so we must
-                * use the DM_STEP_TO_NEXT macro to access each individual
-                * dm_stat_t structure in the returned buffer.
-                */
-               sbuf = dm_statbuf;
-               while (sbuf != NULL) {
-                       if (S_ISREG(sbuf->dt_mode) &&
-                           sbuf->dt_size >= target_size) {     
-                               hanp = DM_GET_VALUE(sbuf, dt_handle, void *);
-                               hlen = DM_GET_LEN(sbuf, dt_handle);
-
-                               print_victim(hanp, hlen, sbuf->dt_size);
-                       }
-                       sbuf = DM_STEP_TO_NEXT(sbuf, dm_stat_t *);
-               }
-       } while (more == 1);
-
-       free(dm_statbuf);
-       if (more == -1) 
-               return(1);
-
-       return(0);
-}
-
diff --git a/dmapi/src/sample_hsm/migin.c b/dmapi/src/sample_hsm/migin.c
deleted file mode 100644 (file)
index ff2166c..0000000
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * Master migration daemon
- *
- * The master migration daemon waits for events on a file and
- * spawns a child process to handle the event
- *
- * This code was written by Peter Lawthers, and placed in the public
- * domain for use by DMAPI implementors and app writers.
- *
- * Standard disclaimer:
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <signal.h>
-
-#include <lib/hsm.h>
-
-extern char    *optarg;
-extern int      optind, optopt, opterr;
-extern int      errno;
-char           *Progname;
-int             Verbose;
-dm_sessid_t     sid = DM_NO_SESSION;
-
-extern int      setup_dmapi(dm_sessid_t *);
-extern void     err_msg(char *, ...);
-extern void     errno_msg(char *, ...);
-
-void            event_loop(dm_sessid_t);
-int             set_events(dm_sessid_t, void *, size_t);
-int             mk_daemon(char *);
-void            spawn_kid(dm_sessid_t, dm_token_t, char *);
-void            migin_exit(int);
-void            usage(char *);
-void            setup_signals();
-
-
-void
-usage(
-       char *prog)
-{
-       fprintf(stderr, "Usage: %s ", prog);
-       fprintf(stderr, " <-v verbose> ");
-       fprintf(stderr, " <-l logfile> ");
-       fprintf(stderr, "filesystem \n");
-}
-
-
-int
-main(
-       int     argc, 
-       char    *argv[])
-{
-       
-       int              c;
-       int              error;
-       char            *fsname, *logfile;
-       void            *fs_hanp;
-       size_t           fs_hlen;
-
-
-       Progname  = argv[0];
-       fsname  = NULL;
-       logfile = NULL;
-
-       while ((c = getopt(argc, argv, "vl:")) != EOF) {
-               switch (c) {
-               case 'v':
-                       Verbose = 1;
-                       break;
-               case 'l':
-                       logfile = optarg;
-                       break;
-               case '?':
-               default:
-                       usage(Progname);
-                       exit(1);
-               }
-       }
-       if (optind >= argc) {
-               usage(Progname);
-               exit(1);
-       }
-       fsname = argv[optind];
-       if (fsname == NULL) {
-               usage(Progname);
-               exit(1);
-       }
-       /*
-        * If no logfile name is specified, we'll just send
-        * all output to some file in /tmp
-        */
-       if (logfile == NULL)
-               logfile = LOG_DEFAULT;
-        
-
-       /*
-        * Turn ourselves into a daemon
-        */
-       if (!Verbose){
-               error = mk_daemon(logfile);
-               if (error) 
-                       exit(1);
-       }
-       setup_signals();
-       
-       /*
-        * Now we have our filesystem name and possibly a size threshold
-        * to look for. Init the dmapi, and get a filesystem handle so
-        * we can set up our events
-        */
-       error = setup_dmapi(&sid);
-       if (error) 
-               exit(1);
-       
-       if (dm_path_to_fshandle(fsname, &fs_hanp, &fs_hlen) == -1) {
-               errno_msg("Can't get filesystem handle");
-               exit(1);
-       }
-
-
-       /*
-        * Set the event disposition so that our session will receive 
-        * the managed region events (read, write, and truncate)
-        */
-       error = set_events(sid, fs_hanp, fs_hlen);
-       if (error) 
-               exit(1);
-       
-
-       /*
-        * Now wait forever for messages, spawning kids to
-        * do the actual work
-        */
-       event_loop(sid);
-       return(0);
-}
-
-/*
- * Main event loop processing
- */
-void
-event_loop(
-       dm_sessid_t     sid)
-{
-       void            *msgbuf;
-       size_t           bufsize, rlen;
-       int              error;
-       dm_eventmsg_t   *msg;
-
-       /*
-        * We take a swag at a buffer size. If it's wrong, we can
-        * always resize it
-        */
-       bufsize = sizeof(dm_eventmsg_t) + sizeof(dm_data_event_t) + HANDLE_LEN;
-       bufsize *= 16;
-       msgbuf  = (void *)malloc(bufsize);
-       if (msgbuf == NULL) {
-               err_msg("Can't allocate memory for buffer\n");
-               goto out;
-       }
-
-       for (;;) {      
-               error = dm_get_events(sid, ALL_AVAIL_MSGS, DM_EV_WAIT, bufsize,
-                                       msgbuf, &rlen);
-               if (error == -1) {
-                       if (errno == E2BIG) {
-                               free(msgbuf);
-                               msgbuf = (void *)malloc(rlen);
-                               if (msgbuf == NULL) {
-                                       err_msg("Can't resize msg buffer\n");
-                                       goto out;
-                               }
-                               continue;
-                       }
-                       errno_msg("Error getting events from DMAPI");
-                       goto out;
-               }
-
-               /*
-                * Walk thru the message buffer, pull out each individual
-                * message, and dispatch the messages to child processes
-                * with the sid, token, and data. The children will
-                * respond to the events.
-                */
-               msg = (dm_eventmsg_t *)msgbuf;
-               while (msg != NULL ) {
-                       if (Verbose) {
-                               fprintf(stderr, "Received %s, token %d\n",
-                                   (msg->ev_type == DM_EVENT_READ ? "read" : 
-                                   (msg->ev_type == DM_EVENT_WRITE ? "write" : "trunc")), msg->ev_token);
-                       }
-                       switch (msg->ev_type) {
-
-                       case DM_EVENT_READ:
-                               spawn_kid(sid, msg->ev_token, RESTORE_FILE);
-                               break;
-
-                       case DM_EVENT_WRITE:
-                       case DM_EVENT_TRUNCATE:
-                               spawn_kid(sid, msg->ev_token, INVAL_FILE);
-                               break;
-
-                       default:
-                               err_msg("Invalid msg type %d\n", msg->ev_type);
-                               break;
-                       }
-                       msg = DM_STEP_TO_NEXT(msg, dm_eventmsg_t *);
-               }
-       }
-out:
-       if (msgbuf != NULL)
-               free(msgbuf);
-
-       migin_exit(0);
-}
-
-/*
- * Fork and exec our worker bee to work on  the file. If 
- * there is any error in fork/exec'ing the file, we have to
- * supply the error return to the event. Once the child gets
- * started, they will respond to the event for us.
- */
-void
-spawn_kid(
-       dm_sessid_t      sid,
-       dm_token_t       token,
-       char            *action)
-{
-       pid_t   pid;
-       char    sidbuf[10];
-       char    tokenbuf[10];
-
-       pid = fork();
-       if (pid == 0) {
-               /*
-                * We're in the child. Try and exec the worker bee
-                */
-               sprintf(sidbuf, "%d", sid);
-               sprintf(tokenbuf, "%d", token);
-               if (Verbose) {
-                       fprintf(stderr, "execl(%s, %s, %s, -s, %s, -t, %s, 0)\n",
-                               WORKER_BEE, WORKER_BEE, action, sidbuf,
-                               tokenbuf);
-               }
-               execlp("./"WORKER_BEE, WORKER_BEE, action, "-s", sidbuf, 
-                       "-t", tokenbuf, NULL);
-               errno_msg("execlp of worker bee failed");
-               (void)dm_respond_event(sid, token, DM_RESP_ABORT, 
-                                       errno, 0, 0);
-               exit(1);
-       }
-
-       if (pid < 0) {
-               err_msg("Can't fork worker bee\n");
-               (void)dm_respond_event(sid, token, DM_RESP_ABORT, errno,
-                                       0, 0);
-               return;
-       }
-       return;
-
-}
-
-
-/*
- * Set the event disposition of the managed region events
- */
-int
-set_events(
-       dm_sessid_t      sid,
-       void            *fs_hanp,
-       size_t           fs_hlen)
-{
-       dm_eventset_t   eventlist;
-
-       DMEV_ZERO(eventlist);
-       DMEV_SET(DM_EVENT_READ, eventlist);
-       DMEV_SET(DM_EVENT_WRITE, eventlist);
-       DMEV_SET(DM_EVENT_TRUNCATE, eventlist);
-
-       if (dm_set_disp(sid, fs_hanp, fs_hlen, DM_NO_TOKEN, &eventlist, 
-                       DM_EVENT_MAX) == -1) 
-       {
-               errno_msg("Can't set event disposition");
-               return(1);
-       }
-       return(0);
-}
-
-
-
-
-/*
- * Dissassociate ourselves from our tty, and close all files
- */
-int
-mk_daemon(
-       char    *logfile)
-{
-       int                     fd;
-       int                     i;
-       struct rlimit           lim;
-       pid_t                   pid;
-
-       if ((pid = fork()) == -1)
-               return (-1);
-       if (pid)
-               exit(0);
-
-       (void) setsid();
-
-       (void) chdir("/");
-
-       /*
-        * Determine how many open files we've got and close
-        * then all
-        */
-       if (getrlimit(RLIMIT_NOFILE, &lim) < 0 ) {
-               errno_msg("Can't determine max number of open files");
-               return(1);
-       }
-       for (i=0; i<lim.rlim_cur; i++)
-               (void)close(i);
-
-       /*
-        * For error reporting, we re-direct stdout and stderr to a 
-        * logfile. 
-        */
-       if ((fd = open(logfile, O_WRONLY | O_CREAT | O_TRUNC, 0755)) < 0) {
-               errno_msg("Can't open logfile %s", logfile);
-               return(1);
-       }
-       (void)dup2(fd, STDOUT_FILENO);
-       (void)dup2(fd, STDERR_FILENO);
-       close(fd);
-
-       return(0);
-}
-
-
-void
-setup_signals()
-{
-       struct sigaction        act;
-
-       /*
-        * Set up signals so that we can wait for spawned children 
-        */
-       act.sa_handler = migin_exit;
-       act.sa_flags   = 0;
-       sigemptyset(&act.sa_mask);
-
-       (void)sigaction(SIGHUP, &act, NULL);
-       (void)sigaction(SIGINT, &act, NULL);
-       (void)sigaction(SIGQUIT, &act, NULL);
-       (void)sigaction(SIGTERM, &act, NULL);
-       (void)sigaction(SIGUSR1, &act, NULL);
-       (void)sigaction(SIGUSR1, &act, NULL);
-       (void)sigaction(SIGUSR2, &act, NULL);
-}
-
-void
-migin_exit(int x)
-{
-       int              error;
-
-       /*
-        * We could try and kill off all our kids, but we're not
-        * 'Mr. Mean', so we just wait for them to die.
-        */
-       err_msg("%s: waiting for all children to die...\n", Progname);
-       while (wait3((int *)0, WNOHANG, (struct rusage *)0) > 0)
-               ;
-
-       fprintf(stdout, "\n");
-
-
-       /*
-        * XXXX         FIXME           XXX
-        * 
-        *      Should do a set_disp to 0 and then drain the session
-        *      queue as well. On the SGI, we'll need to make the
-        *      filesystem handle global so that we can get at it
-        */
-
-       error = dm_destroy_session(sid);
-       if (error == -1) {
-               errno_msg("Can't shut down session\n");
-       }
-
-       exit(0);
-}
-
diff --git a/dmapi/src/sample_hsm/migout.c b/dmapi/src/sample_hsm/migout.c
deleted file mode 100644 (file)
index d2e8b78..0000000
+++ /dev/null
@@ -1,577 +0,0 @@
-/*
- * Simple utility to migrate a group of specified files.
- * The unsorted input is from migfind, and is of the form:
- *     filehandle length       filehandle      file size
- *
- * The data for each file will be stored in another file located
- * in a different directory. This 'staging directory' should be on
- * another filesystem. The staging file will be named the same as
- * the file handle. This simple-minded scheme suffices, since we're
- * not interested in showing any media management in this example.
- *
- * ASSUMPTIONS:
- *     Persistent managed regions are supported
- *     Persistent DM attributes are supported
- *
- *
- * This code was written by Peter Lawthers, and placed in the public
- * domain for use by DMAPI implementors and app writers.
- *
- * Standard disclaimer:
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-
-#include <unistd.h>
-#include <ctype.h>
-#include <string.h>
-#include <fcntl.h>
-
-#include <lib/hsm.h>
-
-extern char    *optarg;
-extern int      optind, optopt, opterr;
-char           *Progname;
-int             Verbose;
-
-int    mig_files(dm_sessid_t, char *);
-int    mk_nonrez(dm_sessid_t, void *, size_t, dm_token_t, dm_off_t);
-int    set_mrgns(dm_sessid_t, void *, size_t, dm_token_t, dm_off_t,
-                 dm_off_t *);
-void   clear_mrgns(dm_sessid_t, void *, dm_size_t, dm_token_t);
-int    lock_file(dm_sessid_t, void *, size_t, dm_right_t, dm_token_t *);
-void   unlock_file(dm_sessid_t, dm_token_t);
-int    get_dmchange(dm_sessid_t, void *, size_t, dm_token_t, u_int *);
-int    create_stgfile(char *, void *, size_t, char *, int *);
-int    setup_dmapi(dm_sessid_t *);
-int    save_filedata(dm_sessid_t, void *, size_t, int, dm_size_t);
-int    extract_fields(char *, char *, size_t *, dm_size_t *);
-int    save_dataloc(dm_sessid_t, void *, size_t, dm_token_t, char *);
-
-void   usage(char *);
-
-void
-usage(
-       char *prog)
-{
-       fprintf(stderr, "Usage: %s ", prog);
-       fprintf(stderr, " <-v verbose> ");
-       fprintf(stderr, "<staging directory>\n");
-}
-
-
-int
-main(
-       int     argc,
-       char    *argv[])
-{
-
-       int              c;
-       int              error;
-       char            *stage_dir;
-       dm_sessid_t      sid;
-
-
-       error     = 0;
-       Progname  = argv[0];
-       stage_dir = NULL;
-
-       while ((c = getopt(argc, argv, "v")) != EOF) {
-               switch (c) {
-               case 'v':
-                       Verbose++;
-                       break;
-
-               case '?':
-               default:
-                       usage(Progname);
-                       exit(1);
-               }
-       }
-       if (optind >= argc) {
-               usage(Progname);
-               exit(1);
-       }
-       stage_dir = argv[optind];
-       if (stage_dir == NULL) {
-               usage(Progname);
-               exit(1);
-       }
-
-       /*
-        * Init the dmapi, and get a session.
-        */
-       error = setup_dmapi(&sid);
-       if (error)
-               exit(1);
-
-       /*
-        * Migrate all the files given to us via stdin
-        */
-       error = mig_files(sid, stage_dir);
-
-
-       if (dm_destroy_session(sid))
-               errno_msg("Can't shut down session, line=%d, errno=%d", __LINE__, errno);
-
-       return(error);
-}
-
-/*
- * Migrate all the files given in stdin
- */
-
-int
-mig_files(
-       dm_sessid_t      sid,
-       char            *stage_dir)
-{
-       void            *hanp;
-       size_t           hlen;
-       dm_size_t        fsize;
-       int              error;
-       u_int            change_start, change_end;
-       int              stg_fd;                /* staging file descriptor */
-       dm_off_t         off;                   /* starting offset */
-       dm_token_t       token;                 /* file token */
-       char             ibuf[IBUFSIZE];
-       char             handle_buf[HANDLE_LEN];
-       char             stgpath[MAXPATHLEN];
-
-       /*
-        * Read all the lines in std input and migrate each file.
-        * This simple-minded migout does no batching, sorting, or
-        * anything else that a real HSM might do.
-        */
-       while (fgets(ibuf, IBUFSIZE, stdin) != NULL) {
-               error = extract_fields(ibuf, handle_buf, &hlen, &fsize);
-               if (error) {
-                       err_msg("%s/%d: mangled input line, '%s' ", __FILE__, __LINE__, ibuf);
-                       continue;
-               }
-               hanp = (void *)handle_buf;
-               if (Verbose) {
-                       print_handle(hanp, hlen);
-               }
-
-               /*
-                * Create and open the file in the staging directory.
-                */
-               error = create_stgfile(stage_dir, hanp, hlen, stgpath, &stg_fd);
-               if (error)
-                       continue;
-
-               /*
-                * Get the file's DMAPI change indicator so that we
-                * can tell if it changed (either via a data mod, or
-                * a DM attribute update) while we are staging it out
-                */
-               error = get_dmchange(sid, hanp, hlen, DM_NO_TOKEN,
-                                       &change_start);
-               if (error) {
-                       close(stg_fd);
-                       continue;
-               }
-
-               /*
-                * Write all the file's data to our file in the
-                * staging directory. In a real HSM, the data would
-                * be copied off to tertiary storage somewhere.
-                *
-                * The staging file descriptor will be closed for us
-                * in all cases.
-                */
-               error = save_filedata(sid, hanp, hlen, stg_fd, fsize);
-               if (error)
-                       continue;
-
-
-               /*
-                * Get exclusive access to the file so we can blow
-                * away its data
-                */
-               error = lock_file(sid, hanp, hlen, DM_RIGHT_EXCL, &token);
-               if (error) {
-                       err_msg("Can't get exclusive access to file, ignoring");
-                       continue;
-               }
-
-               /*
-                * Make sure the file did not change
-                */
-               error = get_dmchange(sid, hanp, hlen, token, &change_end);
-               if (error) {
-                       unlock_file(sid, token);
-                       continue;
-               }
-               if (change_start != change_end) {
-                       unlock_file(sid, token);
-                       err_msg("File changed during stageout, ignoring");
-                       continue;
-               }
-
-               /*
-                * Save the location of the data (the staging file)
-                * in a private DM attribute so that we can get the
-                * file back in the future
-                */
-               error = save_dataloc(sid, hanp, hlen, token, stgpath);
-               if (error) {
-                       err_msg("Can't save location of file data");
-                       unlock_file(sid, token);
-                       continue;
-               }
-
-
-               /*
-                * Set up the managed regions on the file so that
-                * a foray past the fencepost will cause an event to
-                * be generated.
-                */
-               error = set_mrgns(sid, hanp, hlen, token, fsize, &off);
-               if (error) {
-                       unlock_file(sid, token);
-                       err_msg("Can't set managed regions");
-                       continue;
-               }
-
-               /*
-                * Now we can safely blow away the data.
-                */
-               error = mk_nonrez(sid, hanp, hlen, token, off);
-               if (error)  {
-                       clear_mrgns(sid, hanp, hlen, token);
-               }
-
-               /*
-                * Unlock the file, which releases the token
-                */
-               unlock_file(sid, token);
-
-       }
-
-       return(0);
-}
-
-
-/*
- * Remove the data for a file
- */
-int
-mk_nonrez(
-       dm_sessid_t      sid,
-       void            *hanp,
-       size_t           hlen,
-       dm_token_t       token,
-       dm_off_t         off)
-{
-       int     error;
-
-       error = dm_punch_hole(sid, hanp, hlen, token, off, 0);
-       if (error == -1) {
-               errno_msg("Can't punch hole in file, line=%d, errno=%d", __LINE__, errno);
-               return(1);
-       }
-       return(0);
-}
-
-
-/*
- * Set up the managed regions on a file. We try to leave some of the
- * file resident; the actual amount left on-disk is dependent
- * on the rounding enforced by the DMAPI implementation.
- */
-int
-set_mrgns(
-       dm_sessid_t      sid,
-       void            *hanp,
-       size_t           hlen,
-       dm_token_t       token,
-       dm_off_t         fsize,
-       dm_off_t        *start_off)
-{
-       dm_off_t        rroff;
-       dm_size_t       rlenp;
-       dm_region_t     rgn;
-       u_int           exact_flag;
-       int             error;
-
-       if (fsize > FENCEPOST_SIZE) {
-               error = dm_probe_hole(sid, hanp, hlen, token, FENCEPOST_SIZE, 0,
-                                       &rroff, &rlenp);
-               if (error == -1) {
-                       errno_msg("Can't probe hole in file, line=%d, errno=%d", __LINE__, errno);
-                       return(1);
-               }
-       } else {
-               rroff = 0;
-       }
-       *start_off = rroff;
-
-       /*
-        * Now we know what the DMAPI and filesystem will support with
-        * respect to rounding of holes. We try to set our managed region
-        * to begin at this offset and continue to the end of the file.
-        * We set the event mask so that we'll trap on all events that
-        * occur in the managed region.
-        *
-        * Note that some implementations may not be able to support
-        * a managed region that starts someplace other than the beginning
-        * of the file. If we really cared, we could check the exact_flag.
-        */
-       rgn.rg_offset = rroff;
-       rgn.rg_size   = 0;
-       rgn.rg_flags  = DM_REGION_READ | DM_REGION_WRITE | DM_REGION_TRUNCATE;
-       error = dm_set_region(sid, hanp, hlen, token, 1, &rgn, &exact_flag);
-       if (error == -1) {
-               errno_msg("Can't set managed region, line=%d, errno=%d", __LINE__, errno);
-               return(1);
-       }
-       return(0);
-}
-
-
-/*
- * Clear a managed region on a file
- */
-void
-clear_mrgns(
-       dm_sessid_t     sid,
-       void            *hanp,
-       dm_size_t       hlen,
-       dm_token_t      token)
-{
-       dm_region_t     rgn;
-       u_int           exact_flag;
-       int             error;
-
-       rgn.rg_offset = 0;
-       rgn.rg_size = 0;
-       rgn.rg_flags = DM_REGION_NOEVENT;
-       error = dm_set_region(sid, hanp, hlen, token, 1, &rgn, &exact_flag);
-       if (error)
-               errno_msg("Can't clear managed regions from file, line=%d, errno=%d", __LINE__, errno);
-
-       return;
-}
-
-
-/*
- * File rights are accessed via a token. The token must be associated
- * with a synchronous event message. So, to obtain either shared or
- * exclusive rights to a file, we first associate a token with a message,
- * and then request our desired right
- */
-int
-lock_file(
-       dm_sessid_t      sid,
-       void            *hanp,
-       size_t           hlen,
-       dm_right_t       right,
-       dm_token_t      *token)
-{
-       int     error;
-
-       error = dm_create_userevent(sid,  (size_t)0, (void *)0, token);
-       if (error == -1) {
-               errno_msg("Can't create user event for token context, line=%d, errno=%d", __LINE__, errno);
-               return(1);
-       }
-       error = dm_request_right(sid, hanp, hlen, *token, DM_RR_WAIT, right);
-       if (error == -1) {
-               errno_msg("Can't get requested right for token, line=%d, errno=%d", __LINE__, errno);
-               return(1);
-       }
-       return(0);
-}
-
-
-/*
- * Release the lock on a file
- */
-void
-unlock_file(
-       dm_sessid_t      sid,
-       dm_token_t       token)
-{
-       int     error;
-
-       error = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0, 0, 0);
-       if (error == -1)
-               errno_msg("Can't respond to event and release token, line=%d, errno=%d", __LINE__, errno);
-
-       return;
-}
-
-
-int
-create_stgfile(
-       char    *stage_dir,
-       void    *hanp,
-       size_t   hlen,
-       char    *path,
-       int     *stg_fd)
-{
-       char    handle_str[HANDLE_STR];
-
-       if (hlen > HANDLE_LEN) {
-               err_msg("Handle length (%d) too long for file", hlen);
-               return(1);
-       }
-
-       strcpy(path, stage_dir);
-       strcat(path, "/");
-       hantoa(hanp, hlen, handle_str);
-
-       /*
-        * Concat the ascii representation of the file handle
-        * (which is two times longer than the binary version)
-        * onto the staging path name
-        */
-       strncat(path, (char *)handle_str, hlen*2);
-
-       if ( (*stg_fd = open(path, O_RDWR | O_CREAT, 0644)) < 0) {
-               errno_msg("Can't open file %s, line=%d, errno=%d\n", path, __LINE__, errno);
-               return(1);
-       }
-
-       return(0);
-}
-
-
-/*
- * Extract the three fields from the input line. THe input is of
- * the form
- *     filehandle length       filehandle      file size
- *
- * The length of the file handle is expected to be less than 64 bytes.
- */
-int
-extract_fields(
-       char            *ibuf,
-       char            *handle_buf,
-       size_t          *hlen,
-       dm_size_t       *fsize)
-{
-       char    *cp, *start;
-       size_t   len;
-       char *hanp;
-       char *hanpp=NULL;
-
-       /*
-        * Skip any leading white space, and check the length
-        * of the file handle
-        */
-       cp = ibuf;
-       while (!isalnum(*cp))
-               cp++;
-
-       start = cp;
-       while (isalnum(*cp))
-               cp++;
-       *cp = '\0';
-
-       len = strtol(start, 0, 0);
-       if (len > HANDLE_LEN) {
-               err_msg("%s/%d: Handle length %d too long in input line", __FILE__, __LINE__, len);
-               return(1);
-       }
-
-       *hlen = len;
-
-       /*
-        * Skip over white space, and extract the file handle
-        */
-       while (!isalnum(*cp))
-               cp++;
-       hanp = cp;
-
-       /*
-        * Skip over the ascii length of the file handle, and
-        * then extract the file's length
-        */
-       cp += len*2;
-       *cp = '\0';
-
-       atohan( hanp, (void**)&hanpp, &len );
-       memcpy( handle_buf, hanpp, len);
-       free( hanpp );
-
-       /* skip over white space */
-       while (!isalnum(*cp))
-               cp++;
-
-       /* read file length */
-       start = cp;
-       while (isalnum(*cp))
-               cp++;
-       *cp = '\0';
-
-       *fsize = strtol(start, 0, 0);
-
-       return(0);
-
-}
-
-
-/*
- * Save the location of the file's data so that we can find
- * it again when we're staging the file back in. Rather than store
- * the full pathname of the staging file, we just store the handle.
- * This means the staging dir must be on a filesystem that supports
- * the DMAPI.
- */
-int
-save_dataloc(
-       dm_sessid_t      sid,
-       void            *hanp,
-       size_t           hlen,
-       dm_token_t       token,
-       char            *stgpath)
-{
-       void            *stg_hanp;
-       size_t           stg_hlen;
-       int              error;
-       dm_attrname_t    hanp_attrname;
-       dm_attrname_t    hlen_attrname;
-
-       if (dm_path_to_handle(stgpath, &stg_hanp, &stg_hlen) == -1) {
-               errno_msg("Can't get handle for path %s, line=%d, errno=%d", stgpath, __LINE__, errno);
-               return(1);
-       }
-
-       /*
-        * Since handles are in two parts, they become two attributes.
-        * This can be useful, since we can extract the length
-        * separately when we stage the file back in
-        */
-       memcpy((void *)&hanp_attrname.an_chars[0], DLOC_HAN, DM_ATTR_NAME_SIZE);
-       error = dm_set_dmattr(sid, hanp, hlen, token, &hanp_attrname,
-                               0, stg_hlen, stg_hanp);
-       if (error == -1) {
-               errno_msg("Can't set DM attr of staging filehandle, line=%d, errno=%d",__LINE__, errno);
-               return(1);
-       }
-
-       memcpy((void *)&hlen_attrname.an_chars[0], DLOC_HANLEN, DM_ATTR_NAME_SIZE);
-       error = dm_set_dmattr(sid, hanp, hlen, token, &hlen_attrname,
-                               0, sizeof(stg_hlen), (void *)&stg_hlen);
-       if (error == -1) {
-               errno_msg("Can't set DM attr of staging filehandle length, line=%d, errno=%d", __LINE__, errno);
-               return(1);
-       }
-       return(0);
-}
diff --git a/dmapi/src/sample_hsm/mls.c b/dmapi/src/sample_hsm/mls.c
deleted file mode 100644 (file)
index 10d8995..0000000
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * Simple util to print out DMAPI info about a file
- *
- * This code was written by Peter Lawthers, and placed in the public
- * domain for use by DMAPI implementors and app writers.
- *
- * Standard disclaimer:
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-
-#include <unistd.h>
-#include <ctype.h>
-#include <string.h>
-#include <fcntl.h>
-
-#include <lib/hsm.h>
-
-#define MAX_RGNS       8       /* Arbitrary for this release */
-#define NUM_EXTENTS    4
-
-extern char    *optarg;
-extern int      optind, optopt, opterr;
-char           *Progname;
-
-void            usage(char *);
-int             mr_info(dm_sessid_t, void *, size_t);
-int             alloc_info(dm_sessid_t, void *, size_t);
-int             event_info(dm_sessid_t, void *, size_t);
-int             handle_info(dm_sessid_t, void *, size_t);
-
-extern int      setup_dmapi(dm_sessid_t *);
-extern void     errno_msg(char *, ...);
-extern void     print_handle(void *, size_t);
-
-
-void
-usage(
-       char *prog)
-{
-       fprintf(stderr, "Usage: %s <options> filename \n ", prog);
-       fprintf(stderr, "\t-m   managed region info\n");
-       fprintf(stderr, "\t-a   allocation info\n");
-       fprintf(stderr, "\t-e   event info\n");
-       fprintf(stderr, "\t-h   handle\n");
-}
-
-
-int
-main(
-       int     argc, 
-       char    *argv[])
-{
-       int              c;
-       int              error;
-       int              mr_flag, alloc_flag, handle_flag, event_flag;
-       void            *hanp;
-       size_t           hlen;
-       char            *filename;
-       dm_sessid_t      sid;
-
-
-       Progname = argv[0];
-       mr_flag  = alloc_flag =  handle_flag = event_flag = 0;
-       
-       while ((c = getopt(argc, argv, "maeh")) != EOF) {
-               switch (c) {
-               case 'm':
-                       mr_flag = 1;
-                       break;
-               case 'a':
-                       alloc_flag = 1;
-                       break;
-               case 'e':
-                       event_flag = 1;
-                       break;
-               case 'h':
-                       handle_flag = 1;
-                       break;
-               case '?':
-               default:
-                       usage(Progname);
-                       exit(1);
-               }
-       }
-       if (optind >= argc) {
-               usage(Progname);
-               exit(1);
-       }
-       filename = argv[optind];
-       if (filename == NULL) {
-               usage(Progname);
-               exit(1);
-       }
-       
-
-       /*
-        * Set up our link to the DMAPI, and get a handle for
-        * the file we want to query
-        */
-       error = setup_dmapi(&sid);
-       if (error)
-               exit(1);
-
-       if (dm_path_to_handle(filename, &hanp, &hlen) == -1) {
-               printf("Can't get handle for path %s", filename);
-               error = 1;
-               goto out;
-       }
-
-       printf("File %s:\n", filename);
-       if (mr_flag) {
-               error = mr_info(sid, hanp, hlen);
-               if (error) {
-                       error = 1;
-                       goto out;
-               }
-       }
-       if (alloc_flag) {
-               error = alloc_info(sid, hanp, hlen);
-               if (error) {
-                       error = 1;
-                       goto out;
-               }
-       }
-       if (event_flag) {
-               error = event_info(sid, hanp, hlen);
-               if (error) {
-                       error = 1;
-                       goto out;
-               }
-       }
-       if (handle_flag) {
-               error = handle_info(sid, hanp, hlen);
-               if (error) {
-                       error = 1;
-                       goto out;
-               }
-       }
-
-out:
-       if (dm_destroy_session(sid)) {
-               errno_msg("Can't shut down session");
-               error = 1;
-       }
-
-       return(error);
-}
-
-/*
- * Get the complete list of all managed regions for a file. For now,
- * we know that most implementations only support a small number of
- * regions, so we don't handle the E2BIG error here.
- */
-int
-mr_info(
-       dm_sessid_t      sid,
-       void            *hanp,
-       size_t           hlen)
-{
-       u_int           i;
-       u_int           ret;
-       dm_region_t     rgn[MAX_RGNS];
-
-       memset((char *)&rgn, 0, (sizeof(dm_region_t) * MAX_RGNS));
-       if (dm_get_region(sid, hanp, hlen, DM_NO_TOKEN, MAX_RGNS, rgn, &ret)) {
-               errno_msg("Can't get list of managed regions");
-               return(1);
-       }
-       printf("\n");
-       for (i=0; i<ret; i++) {
-               printf("\tRegion %d:\n", i);
-               printf("\t\toffset %lld, ", (long long) rgn[i].rg_offset);
-               printf("size %llu, ", (unsigned long long) rgn[i].rg_size);
-               printf("flags 0x%x", rgn[i].rg_flags);
-               printf(" ( ");
-               if (rgn[i].rg_flags & DM_REGION_NOEVENT)
-                       printf("noevent ");
-               if (rgn[i].rg_flags & DM_REGION_READ)
-                       printf("read ");
-               if (rgn[i].rg_flags & DM_REGION_WRITE)
-                       printf("write ");
-               if (rgn[i].rg_flags & DM_REGION_TRUNCATE)
-                       printf("trunc ");
-               printf(" )\n");
-       }
-       return(0);
-}
-
-/*
- * Get the complete list of events for a file.
- */
-int
-event_info(
-       dm_sessid_t      sid,
-       void            *hanp,
-       size_t           hlen)
-{
-       u_int           ret;
-       dm_eventset_t   eventlist;
-
-       DMEV_ZERO(eventlist);
-       if (dm_get_eventlist(sid, hanp, hlen, DM_NO_TOKEN, DM_EVENT_MAX, 
-                               &eventlist, &ret)) {
-               errno_msg("Can't get list of events");
-               return(1);
-       }
-       printf("\n\tEvent list: \n\t\t");
-       if (DMEV_ISSET(DM_EVENT_MOUNT, eventlist)) 
-               printf("mount ");
-       if (DMEV_ISSET(DM_EVENT_PREUNMOUNT, eventlist)) 
-               printf("preunmount ");
-       if (DMEV_ISSET(DM_EVENT_UNMOUNT, eventlist)) 
-               printf("unmount ");
-       if (DMEV_ISSET(DM_EVENT_DEBUT, eventlist)) 
-               printf("debut ");
-       if (DMEV_ISSET(DM_EVENT_CREATE, eventlist)) 
-               printf("create ");
-       if (DMEV_ISSET(DM_EVENT_POSTCREATE, eventlist)) 
-               printf("postcreate ");
-       if (DMEV_ISSET(DM_EVENT_REMOVE, eventlist)) 
-               printf("remove ");
-       if (DMEV_ISSET(DM_EVENT_POSTREMOVE, eventlist)) 
-               printf("postmount ");
-       if (DMEV_ISSET(DM_EVENT_RENAME, eventlist)) 
-               printf("rename ");
-       if (DMEV_ISSET(DM_EVENT_POSTRENAME, eventlist)) 
-               printf("postrename ");
-       if (DMEV_ISSET(DM_EVENT_LINK, eventlist)) 
-               printf("link ");
-       if (DMEV_ISSET(DM_EVENT_POSTLINK, eventlist)) 
-               printf("postlink ");
-       if (DMEV_ISSET(DM_EVENT_SYMLINK, eventlist)) 
-               printf("symlink ");
-       if (DMEV_ISSET(DM_EVENT_POSTSYMLINK, eventlist)) 
-               printf("postsymlink ");
-       if (DMEV_ISSET(DM_EVENT_READ, eventlist)) 
-               printf("read ");
-       if (DMEV_ISSET(DM_EVENT_WRITE, eventlist)) 
-               printf("write ");
-       if (DMEV_ISSET(DM_EVENT_TRUNCATE, eventlist)) 
-               printf("truncate ");
-       if (DMEV_ISSET(DM_EVENT_ATTRIBUTE, eventlist)) 
-               printf("attribute ");
-       if (DMEV_ISSET(DM_EVENT_DESTROY, eventlist)) 
-               printf("destroy ");
-       if (DMEV_ISSET(DM_EVENT_NOSPACE, eventlist)) 
-               printf("nospace ");
-       if (DMEV_ISSET(DM_EVENT_USER, eventlist)) 
-               printf("user ");
-
-       printf("\n");
-       return(0);
-}
-
-/*
- * Print out the handle for a file
- */
-int
-handle_info(
-       dm_sessid_t      sid,
-       void            *hanp,
-       size_t           hlen)
-{
-       printf("\n\tHandle (handle length, value) \n\t\t");
-       print_handle(hanp, hlen);
-       return(0);
-}
-
-/*
- * Get the allocation info for a file. We pick some small number
- * of extents to get the residency info on at one time
- */
-int
-alloc_info(
-       dm_sessid_t      sid,
-       void            *hanp,
-       size_t           hlen)
-{
-       int             i, more;
-       dm_off_t        offset;
-       u_int           nextents, nret;
-       dm_extent_t     ext[NUM_EXTENTS];
-
-
-       nextents = NUM_EXTENTS;
-       offset   = 0;
-       printf("\n\tAllocation info \n");
-       do {
-               more = dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN, &offset, 
-                                       nextents, ext, &nret);
-               if (more == -1) {
-                       errno_msg("Can't get alloc info for file");
-                       return(1);
-               }
-               for (i=0; i<nret; i++) {
-                       printf("\t\tExtent %d ", i);
-                       if (ext[i].ex_type == DM_EXTENT_RES)
-                               printf("(resident): ");
-                       if (ext[i].ex_type == DM_EXTENT_HOLE)
-                               printf("(hole): ");
-                       printf("offset %lld, ", (long long) ext[i].ex_offset);
-                       printf("len %llu\n", (unsigned long long) ext[i].ex_length);
-               }
-       } while (more == 1);
-       return(0);
-}
diff --git a/dmapi/src/sample_hsm/mrmean.c b/dmapi/src/sample_hsm/mrmean.c
deleted file mode 100644 (file)
index 3c2c71c..0000000
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Simple Mr. Mean that can manipulate and torch sessions
- *
- * This code was written by Peter Lawthers, and placed in the public
- * domain for use by DMAPI implementors and app writers.
- *
- * Standard disclaimer:
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/errno.h>
-
-#include <lib/dmport.h>
-
-#include <string.h>
-#include <getopt.h>
-
-extern char    *optarg;
-extern int      optind, opterr, optopt;
-extern int      errno;
-
-int             Verbose;
-char           *Progname;
-
-extern void    err_msg(char *, ...);
-extern void    errno_msg(char *, ...);
-
-int            get_sessions(dm_sessid_t **, u_int *);
-int            get_tokens(dm_sessid_t, dm_token_t **, u_int *);
-void           print_session(dm_sessid_t);
-void           print_tokens(dm_sessid_t);
-void           kill_session(dm_sessid_t);
-
-void
-usage(char *s)
-{
-       fprintf(stderr, "Usage: %s <options>\n", s);
-       fprintf(stderr, "\t-t   list tokens\n");
-       fprintf(stderr, "\t-l   list sessions\n");
-       fprintf(stderr, "\t-k   kill sessions\n");
-       fprintf(stderr, "\t-s   <specific_sid>\n");
-       fprintf(stderr, "\t-v   verbose (for kill)\n");
-}
-
-int
-main(
-       int      argc,
-       char    *argv[])
-{
-       int              c;
-       int              error;
-       u_int            i, nsids;
-       int              list_flag, kill_flag, token_flag, sid_flag;
-       dm_sessid_t     *sidbuf, *sidp, onesid;
-       char            *cp;
-
-
-       Progname = argv[0];
-       list_flag = sid_flag = kill_flag = token_flag = 0;
-
-       while ((c = getopt(argc, argv, "vlkts:")) != EOF) {
-               switch (c) {
-               case 'l':
-                       list_flag = 1;
-                       break;
-               case 'k':
-                       kill_flag = 1;
-                       break;
-               case 't':
-                       token_flag = 1;
-                       break;
-               case 's':
-                       if (sscanf(optarg, "%d", &onesid) <=0 ) {
-                               err_msg("Can't convert sid %s", optarg);
-                               exit(2);
-                       }
-                       sid_flag = 1;
-                       break;
-               case 'v':
-                       Verbose = 1;
-                       break;
-               case '?':
-               default:
-                       usage(Progname);
-                       exit(1);
-               }
-       }
-       if (!list_flag && !sid_flag && !kill_flag && !token_flag) {
-               usage(Progname);
-               exit(1);
-       }
-
-        if (dm_init_service(&cp) == -1)  {
-                err_msg("Can't init dmapi");
-                return(1);
-        }
-        if (strcmp(cp, DM_VER_STR_CONTENTS)) {
-                err_msg("Compiled for a different version");
-                return(1);
-        }
-
-
-       /*
-        * Get the list of all sessions in the system
-        */
-       error = get_sessions(&sidbuf, &nsids);
-       if (error)
-               exit(1);
-
-       /*
-        * Walk through the list of sessions do what is right
-        */
-       sidp = sidbuf;
-       for (i=0; i<nsids; i++, sidp++) {
-               if (sid_flag) {
-                       /*
-                        * If we're only looking for one sid, then
-                        * we can skip this one if there's no match
-                        */
-                       if (onesid != *sidp)
-                               continue;
-               }
-               if (list_flag)
-                       print_session(*sidp);
-               if (token_flag)
-                       print_tokens(*sidp);
-               if (kill_flag)
-                       kill_session(*sidp);
-       }
-       return(0);
-}
-
-/*
- * Print out info about a sessions
- */
-void
-print_session(dm_sessid_t sid)
-{
-       char    buf[DM_SESSION_INFO_LEN];
-       size_t  ret;
-
-       if (dm_query_session(sid,DM_SESSION_INFO_LEN,(void *)buf, &ret) == -1) {
-               errno_msg("Can't get session info");
-               return;
-       }
-
-       printf("Session (%d) name: %s\n", sid, buf);
-       return;
-}
-
-/*
- * Get all the tokens for a session
- */
-void
-print_tokens(dm_sessid_t sid)
-{
-       dm_token_t      *tbuf;
-       int              error;
-       u_int            i, ntokens;
-
-       error = get_tokens(sid, &tbuf, &ntokens);
-       if (error)
-               return;
-
-       printf("\tTokens (%d): ", ntokens);
-       for (i=0; i<ntokens; i++) 
-               printf("%d ", *tbuf++);
-
-       printf("\n");
-
-       free(tbuf);
-       return;
-}
-
-/*
- * Try and kill a session
- */
-void
-kill_session(dm_sessid_t sid)
-{
-       dm_token_t      *tbuf;
-       int              error;
-       u_int            i, ntokens;
-
-       /*
-        * Get all the tokens in the system so we can respond to them
-        */
-       error = get_tokens(sid, &tbuf, &ntokens);
-       if (error)
-               return;
-
-       if (ntokens && Verbose) 
-               printf("\tResponding to events for sid %d, tokens: \n", sid);
-
-       for (i=0; i<ntokens; i++) {
-               if (Verbose)
-                       printf("\t\t%d ", *tbuf);
-
-               if (dm_respond_event(sid, *tbuf, DM_RESP_ABORT, EIO, 0, NULL) == -1) 
-                       errno_msg("Can't respond to event, sid %d token %d", 
-                                  sid, *tbuf);
-               tbuf++;
-       }
-
-       if (Verbose)
-               printf("\tDestroying session %d\n", sid);
-       if (dm_destroy_session(sid) == -1) 
-               errno_msg("Can't shut down session %d", sid);
-       return;
-}
-
-int
-get_sessions(
-       dm_sessid_t **sidpp,
-       u_int        *nsidp)
-{
-       dm_sessid_t     *sidbuf;
-       int              error;
-       u_int            nsids, nret;
-
-       /*
-        * Pick an arbitrary number of sessions to get info for.
-        * If it's not enough, then we can always resize our buffer
-        */
-       error = 0;
-       nsids = 32;
-       sidbuf = malloc(nsids * sizeof(dm_sessid_t));
-       if (sidbuf == NULL) {
-               err_msg("Can't malloc memory");
-               error = 1;
-               goto out;
-       }
-               
-       if (dm_getall_sessions(nsids, sidbuf, &nret) == -1) {
-               if (errno != E2BIG) {
-                       errno_msg("Can't get list of sessions");
-                       error = 1;
-                       goto out;
-               }
-               free(sidbuf);
-               nsids = nret;
-               sidbuf = malloc(nsids * sizeof(dm_sessid_t));
-               if (sidbuf == NULL) {
-                       err_msg("Can't malloc memory");
-                       error = 1;
-                       goto out;
-               }
-               if (dm_getall_sessions(nsids, sidbuf, &nret) == -1) {
-                       if (error == -1) {
-                               errno_msg("Can't get sessions with new buf");
-                               error = 1;
-                               goto out;
-                       }
-               }
-       }
-out:
-       if (error && (sidbuf != NULL) )
-               free(sidbuf);
-       else {
-               *sidpp = sidbuf;
-               *nsidp = nret;
-       }
-       
-       return(error);
-}
-
-
-/*
- * Get all tokens in the session
- */
-int
-get_tokens(
-       dm_sessid_t       sid,
-       dm_token_t      **bufpp,
-       u_int            *nretp)
-{
-       dm_token_t      *tbuf;
-       u_int            ntokens, nret;
-       int              error;
-
-       error   = 0;
-       ntokens = 1024;
-       tbuf = (dm_token_t *)malloc(ntokens * sizeof(dm_token_t));
-       if (tbuf == NULL)  
-               goto out;
-       
-       if (dm_getall_tokens(sid, ntokens, tbuf, &nret) == -1) {
-               if (errno != E2BIG) {
-                       errno_msg("Can't get all tokens");
-                       goto out;
-               }
-               free(tbuf);
-               ntokens = nret;
-               tbuf = (dm_token_t *)malloc(ntokens * sizeof(dm_token_t));
-               if (tbuf == NULL)  
-                       goto out;
-               
-               if (dm_getall_tokens(sid, ntokens, tbuf, &nret) == -1) {
-                       errno_msg("Can't get all tokens");
-                       goto out;
-               }
-       }
-out:
-       if (error && (tbuf != NULL))
-               free(tbuf);
-       else {
-               *bufpp = tbuf;
-               *nretp = nret;
-       }
-
-       return(error);
-}
diff --git a/dmapi/src/sample_hsm/wbee.c b/dmapi/src/sample_hsm/wbee.c
deleted file mode 100644 (file)
index 6701fca..0000000
+++ /dev/null
@@ -1,599 +0,0 @@
-/*
- * Worker bees.
- *
- * The bees perform the grunt work of handling a file event
- *
- * This code was written by Peter Lawthers, and placed in the public
- * domain for use by DMAPI implementors and app writers.
- *
- * Standard disclaimer:
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <string.h>
-
-#include <lib/hsm.h>
-
-extern char    *optarg;
-extern int      optind, optopt, opterr;
-extern int      errno;
-char           *Progname;
-int             Verbose;
-
-extern int      restore_filedata(dm_sessid_t, void *, size_t, dm_token_t, 
-                               void *, size_t, dm_off_t);
-extern int      get_dmchange(dm_sessid_t, void *, size_t, dm_token_t, u_int *);
-extern int      setup_dmapi(dm_sessid_t *);
-extern void     err_msg(char *, ...);
-extern void     errno_msg(char *, ...);
-
-int    stagein_file(dm_sessid_t, dm_token_t, dm_eventmsg_t *);
-int    inval_file(dm_sessid_t, dm_token_t, dm_eventmsg_t *);
-int    check_lockstate(dm_sessid_t, void *, size_t, dm_token_t);
-int    clear_mrgns(dm_sessid_t, void *, size_t, dm_token_t);
-int    find_msg(dm_sessid_t, dm_token_t, dm_eventmsg_t **);
-int    get_stghandle(dm_sessid_t, void *, size_t, dm_token_t, void **, 
-                       size_t *);
-void    usage(char *);
-
-
-
-void
-usage(
-       char *prog)
-{
-       fprintf(stderr, "Usage: %s ", prog);
-       fprintf(stderr, " <-i invalidate file> ");
-       fprintf(stderr, " <-r restore file> ");
-       fprintf(stderr, "[-s sid] [-t token] \n");
-}
-
-
-int
-main(
-       int     argc, 
-       char    *argv[])
-{
-       
-       dm_eventmsg_t   *msgheader;
-       char            *sid_str, *token_str;
-       dm_sessid_t      sid;
-       dm_token_t       token;
-       int              c;
-       int              error;
-       int              restore_flag, inval_flag;
-       char            *cp;
-
-       Progname  = argv[0];
-       sid_str   = NULL;
-       token_str = NULL;
-       restore_flag = 0;
-       inval_flag   = 0;
-
-       while ((c = getopt(argc, argv, "s:t:ri")) != EOF) {
-               switch (c) {
-               case 'r':
-                       restore_flag++;
-                       break;
-
-               case 'i':
-                       inval_flag++;
-                       break;
-
-               case 's':
-                       sid_str = optarg;
-                       break;
-
-               case 't':
-                       token_str = optarg;
-                       break;
-
-               case '?':
-               default:
-                       usage(Progname);
-                       exit(1);
-               }
-       }
-       if (optind < argc) {
-               usage(Progname);
-               exit(1);
-       }
-       if (sid_str == NULL || token_str == NULL) {
-               usage(Progname);
-               exit(1);
-       }
-       if ((restore_flag > 0) && (inval_flag > 0)) {
-               usage(Progname);
-               exit(1);
-       }
-
-       if (sscanf(sid_str, "%d", &sid) <= 0) {
-               err_msg("Can't convert sid");
-               exit(1);
-       }
-       if (sscanf(token_str, "%d", &token) <= 0) {
-               err_msg("Can't convert token");
-               exit(1);
-       }
-
-       /*
-        * Now we have our session and token. We just need to
-        * let the DMAPI know we exist so we can use the interface.
-        * We don't need to create a session since we'll be using
-        * the session of our parent.
-        */
-       error = dm_init_service(&cp);
-       if (error == -1) {
-               errno_msg("Can't init DMAPI");
-               exit(1);
-       }
-       if (strcmp(cp, DM_VER_STR_CONTENTS)) {
-               err_msg("Compiled for a different version");
-               exit(1);
-       }
-       
-       /*
-        * Find the message our caller wants us to handle
-        */
-       error = find_msg(sid, token, &msgheader);
-       if (error) 
-               exit(1);
-
-       /*
-        * Now service the particular event type
-        */
-       if (restore_flag) 
-               error = stagein_file(sid, token, msgheader);
-       else
-               error = inval_file(sid, token, msgheader);
-
-       return(error);
-}
-
-
-/*
- * Find the data event message that correponds to the token.
- *
- * RETURNS:
- *     A pointer to malloc'd memory that contains the message
- *     we're supposed to handle in the 'msgheader' param.
- */
-int
-find_msg(
-       dm_sessid_t       sid,
-       dm_token_t        token,
-       dm_eventmsg_t   **msgheader)
-{
-       void    *buf;
-       size_t   buflen, rlen;
-       int      error;
-
-       /*
-        * Malloc a buffer that we think is large enough for
-        * the common message header and the event specific part. 
-        * If it's not large enough, we can always resize it.
-        */
-       buflen = sizeof(dm_eventmsg_t) + sizeof(dm_data_event_t) + HANDLE_LEN;
-       buf = (void *)malloc(buflen);
-       if (buf == NULL) {
-               err_msg("Can't alloc memory for event buffer");
-               return(1);
-       }
-
-       error = dm_find_eventmsg(sid, token, buflen, buf, &rlen);
-       if (error == -1) {
-               if (errno != E2BIG) {
-                       free(buf);
-                       errno_msg("Can't obtain message from token");
-                       return(1);
-               }
-               free(buf);
-               buflen = rlen;
-               buf = (void *)malloc(buflen);
-               if (buf == NULL) {
-                       err_msg("Can't resize event buffer");
-                       return(1);
-               }
-               error = dm_find_eventmsg(sid, token, buflen, buf, &rlen);
-               if (error == -1) {
-                       errno_msg("Can't get message with resized buffer");
-                       return(1);
-               }
-       }
-       
-       *msgheader = (dm_eventmsg_t *)buf;
-       return(0);
-}
-
-
-/*
- * Check the lock state associated with the file. If the token
- * does not reference exclusive access, try to upgrade our lock.
- * If we can't upgrade, drop the lock and start over
- */
-int
-check_lockstate(
-       dm_sessid_t      sid, 
-       void            *hanp, 
-       size_t           hlen, 
-       dm_token_t       token)
-{
-       int             error;
-       dm_right_t      right;
-       u_int           change_start, change_end;
-
-       error = dm_query_right(sid, hanp, hlen, token, &right);
-       if (error == -1) {
-               errno_msg("Can't query file access rights");
-               return(1);
-       }
-#if defined(linux)
-       /*
-        * There are no access rights on the SGI. 1 means it's
-        * there.
-        */
-       if (right == DM_RIGHT_SHARED)
-               return 0;
-#endif
-
-       if (right != DM_RIGHT_EXCL) {
-               error = dm_request_right(sid, hanp, hlen, token, 0,
-                                        DM_RIGHT_EXCL);
-               if (error == -1) {
-                       if (errno != EAGAIN) {
-                               errno_msg("Can't upgrade lock");
-                               return(1);
-                       }
-                       error = get_dmchange(sid, hanp, hlen, token, 
-                                               &change_start);
-                       if (error) 
-                               return(1);
-                               
-                       
-                       error = dm_release_right(sid, hanp, hlen, token);
-                       if (error == -1) {
-                               errno_msg("Can't release file access rights");
-                               return(1);
-                       }
-                       error = dm_request_right(sid, hanp, hlen, token, 
-                                               DM_RR_WAIT, DM_RIGHT_EXCL);
-                       if (error == -1)  {
-                               errno_msg("Can't get exclusive right to file");
-                               return(1);
-                       }
-
-                       /*
-                        * If the file changed while we slept, then someone
-                        * must have modified the file
-                        */
-                       error = get_dmchange(sid, hanp, hlen, token, 
-                                               &change_end);
-                       if (error == -1) 
-                               return(1);
-                       
-                       if (change_start != change_end) {
-                               err_msg("File changed while waiting for lock");
-                               return(1);
-                       }
-               }
-       }
-       return(0);
-}
-
-
-/*
- * Stage in the data for a file
- */
-int
-stagein_file(
-       dm_sessid_t      sid, 
-       dm_token_t       token,
-       dm_eventmsg_t   *msgheader)
-{
-
-       void            *stg_hanp, *hanp;
-       size_t           stg_hlen, hlen;
-       int              error, ret_errno;
-       dm_response_t    reply;
-       dm_data_event_t *msg;
-
-       /*
-        * Extract the event-specific info from the message header,
-        * then get the file handle.
-        */
-       msg  = DM_GET_VALUE(msgheader, ev_data, dm_data_event_t *);
-       hanp = DM_GET_VALUE(msg, de_handle, void *);
-       hlen = DM_GET_LEN(msg, de_handle);
-
-       /*
-        * Check our permissions. We need exclusive access to the 
-        * file to stage it back in.
-        */
-       error = check_lockstate(sid, hanp, hlen, token);
-       if (error) 
-               goto out;
-
-       /*
-        * get the staging file handle from it's DM attributes
-        */
-       stg_hanp = NULL;
-       error = get_stghandle(sid, hanp, hlen, token, &stg_hanp, &stg_hlen);
-       if (error) 
-               goto out;
-
-       /*
-        * We keep the exclusive lock held for the *entire* duration
-        * of the stagein. This is not required, but just quick and
-        * [sl]easy. For a large file, it is typically better to release
-        * the lock, and have a sliding window of managed regions to allow
-        * people to consume the data as it is being read in.
-        */
-       error = restore_filedata(sid, hanp, hlen, token, stg_hanp, stg_hlen,
-                          msg->de_offset);
-       if (error) 
-               goto out;
-
-       /*
-        * Now that the data is restored, and while we still have exclusive
-        * access to the file, clear the managed regions.
-        */
-       error = clear_mrgns(sid, hanp, hlen, token);
-       if (error) 
-               goto out;
-
-out:
-       if (stg_hanp)
-               free((char *)stg_hanp);
-
-       /*
-        * Figure out what our response to the event will be. Once
-        * we've responded to the event, the token is no longer valid.
-        * On error, we pick the (less than helpful) errno EIO to signal
-        * to the user that something went wrong.
-        */
-       if (error) {
-               reply = DM_RESP_ABORT;
-               ret_errno = EIO;
-       } else {
-               reply = DM_RESP_CONTINUE;
-               ret_errno = 0;
-       }
-       (void)dm_respond_event(sid, token, reply, ret_errno, 0, 0);
-
-       return(ret_errno);
-
-}
-
-/*
- * Turn off event monitoring for a file. In a real HSM, we would
- * probably want to either invalidate the file's data on 
- * tertiary storage, or start some aging process so that it will
- * eventually go away.
- *
- * The assumption is that for write and truncate events, the file
- * data is about to be invalidated.
- */
-int
-inval_file(
-       dm_sessid_t      sid, 
-       dm_token_t       token,
-       dm_eventmsg_t   *msgheader)
-{
-       dm_data_event_t *msg;
-       void            *hanp;
-       size_t           hlen;
-       int              error, ret_errno;
-       dm_response_t    reply;
-
-       /*
-        * Extract the event-specific info from the message header,
-        * then get the file handle.
-        */
-       msg  = DM_GET_VALUE(msgheader, ev_data, dm_data_event_t *);
-       hanp = DM_GET_VALUE(msg, de_handle, void *);
-       hlen = DM_GET_LEN(msg, de_handle);
-
-       /*
-        * Check our permissions. We need exclusive access to the 
-        * file to clear our managed regions.
-        */
-       error = check_lockstate(sid, hanp, hlen, token);
-       if (error) 
-               goto out;
-
-       /*
-        * Clear all the managed regions for the file.
-        */
-       error = clear_mrgns(sid, hanp, hlen, token);
-
-out:
-       /*
-        * Figure out what our response to the event will be. Once
-        * we've responded to the event, the token is no longer valid.
-        * On error, we pick the (less than helpful) errno EIO to signal
-        * to the user that something went wrong.
-        */
-       if (error) {
-               reply = DM_RESP_ABORT;
-               ret_errno = EIO;
-       } else {
-               reply = DM_RESP_CONTINUE;
-               ret_errno = 0;
-       }
-       (void)dm_respond_event(sid, token, reply, ret_errno, 0, 0);
-       
-       return(ret_errno);
-}
-
-/*
- * Clear all of the managed regions for a file. 
- */
-int
-clear_mrgns(
-       dm_sessid_t      sid, 
-       void            *hanp, 
-       size_t           hlen, 
-       dm_token_t       token)
-{
-       dm_region_t     *rgn, *sv_rgn;
-       u_int            nregions, nret;
-       u_int            exact_flag;
-       int              i;
-       int              error, retval;
-
-       /*
-        * We take a guess first and assume there is only one managed
-        * region per file. There should'nt be more than this, but
-        * it never hurts to check, since we want to make sure that
-        * all regions are turned off.
-        *
-        * The main purpose of this is to demonstrate the use of the 
-        * E2BIG paradigm.
-        */
-       retval = 1;
-       nregions = 1;
-       rgn = (dm_region_t *)malloc(nregions * sizeof(dm_region_t));
-       if (rgn == NULL) {
-               err_msg("Can't allocate memory for region buffers");
-               goto out;
-       }
-
-       error = dm_get_region(sid, hanp, hlen, token, nregions, rgn, &nret);
-       if (error == -1) {
-               if (errno != E2BIG) {
-                       errno_msg("Can't get list of managed regions for file");
-                       goto out;
-               }
-
-               /*
-                * Now we know how many managed regions there are, so we can
-                * resize our buffer
-                */
-               nregions = nret;
-               free(rgn);
-               rgn = (dm_region_t *)malloc(nregions * sizeof(dm_region_t));
-               if (rgn == NULL) {
-                       err_msg("Can't resize region buffers");
-                       goto out;
-               }
-               error = dm_get_region(sid, hanp, hlen, token, nregions, rgn, 
-                                       &nret);
-               if (error == -1) {
-                       errno_msg("Can't get list of managed regions for file");
-                       goto out;
-               }
-       }
-
-       sv_rgn = rgn;
-
-       /*
-        * Clear all the managed regions
-        */
-       for (i=0; i<nregions; i++) {
-               rgn->rg_offset = 0;
-               rgn->rg_size   = 0;
-               rgn->rg_flags  = DM_REGION_NOEVENT;
-               rgn++;
-       }
-       rgn = sv_rgn;
-
-       error = dm_set_region(sid, hanp, hlen, token, nregions, rgn, 
-                               &exact_flag);
-       if (error == -1) {
-               errno_msg("Can't clear list of managed regions for file");
-       }
-       retval = 0;
-
-out:
-       if (rgn != NULL) 
-               free(rgn);
-
-       return(retval);
-}
-
-
-/*
- * Extract the staging file handle from a file's DM attributes
- */
-int
-get_stghandle(
-       dm_sessid_t       sid, 
-       void             *hanp, 
-       size_t            hlen, 
-       dm_token_t        token,
-       void            **stg_hanp,
-       size_t           *stg_hlen)
-{
-       void            *han_buf;
-       size_t           han_len;
-       int              error;
-       size_t           rlen;
-       dm_attrname_t    hanp_attrname;
-       dm_attrname_t    hlen_attrname;
-
-       /*
-        * First get the length of the file handle, so we
-        * can size our buffer correctly
-        */
-       memcpy((void *)&hlen_attrname.an_chars[0], DLOC_HANLEN, DM_ATTR_NAME_SIZE);
-       error = dm_get_dmattr(sid, hanp, hlen, token, &hlen_attrname,
-                               sizeof(size_t), &han_len, &rlen);
-       if (error == -1) {
-               /*
-                * On any error, even E2BIG, we bail since the size of
-                * the file handle should be a constant
-                */
-               errno_msg("Can't get size of staging file handle");
-               return(1);
-       }
-       if (rlen != sizeof(size_t)) {
-               err_msg("File handle length component incorrect");
-               return(1);
-       }
-
-       /*
-        * Malloc space for our staging file handle, and 
-        * extract it from our DM attributes
-        */
-       han_buf = (void *)malloc(han_len);
-       if (han_buf == NULL) {
-               err_msg("Can't alloc memory for file handle");
-               return(1);
-       }
-
-       memcpy((void *)&hanp_attrname.an_chars[0], DLOC_HAN, DM_ATTR_NAME_SIZE);
-       error = dm_get_dmattr(sid, hanp, hlen, token, &hanp_attrname, 
-                               han_len, han_buf, &rlen);
-       if (error == -1) {
-               errno_msg("Can't get staging file handle");
-               free(han_buf);
-               return(1);
-       }
-       if (rlen != han_len) {
-               err_msg("File handle is incorrect length");
-               free(han_buf);
-               return(1);
-       }
-       *stg_hanp = han_buf;
-       *stg_hlen = han_len;
-       return(0);
-}
-
diff --git a/dmapi/src/simple/Makefile b/dmapi/src/simple/Makefile
deleted file mode 100644 (file)
index 7c41832..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-# Copyright (C) 2011 SGI  All Rights Reserved.
-#
-#
-#
-TOPDIR = ../../..
-
-include $(TOPDIR)/include/builddefs
-
-TARGETS = dm_create_session dm_destroy_session dm_find_eventmsg \
-               dm_getall_sessions dm_getall_tokens dm_query_session
-
-CFILES = $(TARGETS:=.c)
-LDIRT = $(TARGETS)
-
-CFLAGS += -I$(TOPDIR)/dmapi/src/common -I/usr/include/xfs
-
-LLDLIBS = $(LIBDM)
-
-default: depend $(TARGETS)
-
-depend: .dep
-
-include $(BUILDRULES)
-
-install install-dev: default
-
-$(TARGETS):
-       @echo "    [CC]    $@"
-       $(Q)$(LTLINK) $@.c -o $@ $(CFLAGS) $(LDFLAGS) $(LDLIBS)
-
--include .dep
diff --git a/dmapi/src/simple/dm_create_session.c b/dmapi/src/simple/dm_create_session.c
deleted file mode 100644 (file)
index ec76888..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/errno.h>
-#include <getopt.h>
-#ifdef linux
-#include <dmapi.h>
-#endif
-
-int
-main( int argc, char **argv )
-{
-       extern char *optarg;
-       int c;
-       int ret;
-       dm_sessid_t oldsid = DM_NO_SESSION;
-       dm_sessid_t newsid = 0;
-       char *sessinfo = "test1";
-       char *versionstr;
-
-       while( (c = getopt(argc, argv, "hs:i:")) != -1 ) {
-               switch(c){
-               case 's':
-                       oldsid = atoi( optarg );
-                       break;
-               case 'i':
-                       sessinfo = optarg;
-                       break;
-               case 'h':
-                       fprintf(stderr, "Usage: %s [-s oldsid] [-i sessinfo_txt]\n", argv[0]);
-                       exit(2);
-               }
-       }
-
-       if( dm_init_service( &versionstr ) < 0 )
-               exit(1);
-
-       ret = dm_create_session( oldsid, sessinfo, &newsid);
-       printf( "ret=%d\n", ret );
-       printf( "newsid=%d\n", newsid );
-       exit(0);
-}
-
diff --git a/dmapi/src/simple/dm_destroy_session.c b/dmapi/src/simple/dm_destroy_session.c
deleted file mode 100644 (file)
index 1a6da4b..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/errno.h>
-#include <getopt.h>
-#ifdef linux
-#include <dmapi.h>
-#endif
-
-int
-main( int argc, char **argv )
-{
-       extern char *optarg;
-       int c;
-       int ret;
-       dm_sessid_t sid = 0;
-       char *versionstr;
-
-       while( (c = getopt(argc, argv, "hs:")) != -1 ) {
-               switch(c){
-               case 's':
-                       sid = atoi( optarg );
-                       break;
-               case 'h':
-                       fprintf(stderr, "Usage: %s <-s sid>\n", argv[0] );
-                       exit(2);
-               }
-       }
-
-       if( sid == 0 ){
-               fprintf(stderr, "%s: must specify -s\n", argv[0] );
-               exit(1);
-       }
-
-       if( dm_init_service( &versionstr ) < 0 )
-               exit(1);
-
-       ret = dm_destroy_session( sid );
-       printf( "ret=%d\n", ret );
-       exit(0);
-}
diff --git a/dmapi/src/simple/dm_find_eventmsg.c b/dmapi/src/simple/dm_find_eventmsg.c
deleted file mode 100644 (file)
index 0765eb0..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/errno.h>
-#include <getopt.h>
-#ifdef linux
-#include <dmapi.h>
-#endif
-
-int
-main( int argc, char **argv )
-{
-       extern char *optarg;
-       int c;
-       int ret;
-       dm_sessid_t sid = 0;
-       dm_token_t token = 0;
-       dm_eventmsg_t msg;
-       size_t rlen;
-       int buflen = sizeof(dm_eventmsg_t) + 100;
-       char *versionstr;
-
-       while( (c = getopt(argc, argv, "hs:t:l:q")) != -1 ) {
-               switch(c){
-               case 's':
-                       sid = atoi( optarg );
-                       break;
-               case 't':
-                       token = atoi( optarg );
-                       break;
-               case 'l':
-                       buflen = atoi( optarg );
-                       break;
-               case 'q':
-                       printf("dm_eventmsg_t=%zd\n", sizeof(dm_eventmsg_t) );
-                       exit(0);
-               case 'h':
-                       fprintf(stderr, "Usage: %s <-s sid> <-t token> [-l buflen]\n", argv[0]);
-                       fprintf(stderr, "       %s -q\n", argv[0]);
-                       exit(2);
-               }
-       }
-
-       if( sid == 0 ){
-               fprintf(stderr, "%s: must specify -s\n", argv[0] );
-               exit(1);
-       }
-
-       if( token == 0 ){
-               fprintf(stderr, "%s: must specify -t\n", argv[0] );
-               exit(1);
-       }
-
-       if( dm_init_service( &versionstr ) < 0 )
-               exit(1);
-
-       ret = dm_find_eventmsg( sid, token, buflen, &msg, &rlen );
-       printf( "ret=%d\n", ret );
-       printf( "rlen=%zd\n", rlen );
-       exit(0);
-}
diff --git a/dmapi/src/simple/dm_getall_sessions.c b/dmapi/src/simple/dm_getall_sessions.c
deleted file mode 100644 (file)
index d762f75..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/errno.h>
-#include <string.h>
-#include <malloc.h>
-#include <getopt.h>
-#ifdef linux
-#include <dmapi.h>
-#endif
-
-int
-main( int argc, char **argv )
-{
-       extern char *optarg;
-       int c;
-       int ret;
-       dm_sessid_t *sidbuf;
-       u_int nelem = 100;
-       u_int rnelem = 0;
-       int i;
-       char *versionstr;
-       int anyway = 0; /* attempt to show this many elements anyway,
-                        * even if it looks like nothing was returned.
-                        */
-
-       while( (c = getopt(argc, argv, "hn:x:")) != -1 ) {
-               switch(c){
-               case 'n':
-                       nelem = atoi( optarg );
-                       break;
-               case 'x':
-                       anyway = atoi( optarg );
-                       break;
-               case 'h':
-                       fprintf(stderr, "Usage: %s [-n nelem]\n", argv[0]);
-                       exit(2);
-               }
-       }
-       
-       if( (sidbuf = malloc( sizeof(*sidbuf) * nelem )) == NULL ){
-               fprintf(stderr, "%s: malloc failed\n", argv[0] );
-               exit(1);
-       }
-
-       memset( sidbuf, 0, sizeof(*sidbuf) * nelem );
-
-       if( dm_init_service( &versionstr ) < 0 )
-               exit(1);
-
-       ret = dm_getall_sessions( nelem, sidbuf, &rnelem );
-       printf( "ret=%d\n", ret );
-       printf( "rnelem=%d\n", rnelem );
-
-       /* user wants us to try to show a specific number of elements */
-       if( anyway > 0 )
-               rnelem = anyway;
-
-       printf("sids=\"");
-       for( i = 0; i < rnelem; i++ ){
-               printf("%d ", sidbuf[i]);
-       }
-       printf("\"\n");
-       exit(0);
-}
-
diff --git a/dmapi/src/simple/dm_getall_tokens.c b/dmapi/src/simple/dm_getall_tokens.c
deleted file mode 100644 (file)
index de813c7..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/errno.h>
-#include <malloc.h>
-#include <getopt.h>
-#ifdef linux
-#include <dmapi.h>
-#endif
-
-int
-main( int argc, char **argv )
-{
-       extern char *optarg;
-       int c;
-       int ret;
-       dm_token_t *tokenbuf;
-       u_int nelem = 100;
-       u_int rnelem = 0;
-       dm_sessid_t sid = 0;
-       int i;
-       char *versionstr;
-
-       while( (c = getopt(argc, argv, "hs:n:")) != -1 ) {
-               switch(c){
-               case 's':
-                       sid = atoi( optarg );
-                       break;
-               case 'n':
-                       nelem = atoi( optarg );
-                       break;
-               case 'h':
-                       fprintf(stderr, "Usage: %s <-s sid> [-n nelem]\n", argv[0]);
-                       exit(2);
-               }
-       }
-
-       if( sid == 0 ){
-               fprintf(stderr, "%s: must specify -s\n", argv[0] );
-               exit(1);
-       }
-
-       if( (tokenbuf = malloc( sizeof(dm_token_t) * nelem )) == NULL ){
-               fprintf(stderr, "%s: malloc failed\n", argv[0] );
-               exit(1);
-       }
-
-       if( dm_init_service( &versionstr ) < 0 )
-               exit(1);
-
-       ret = dm_getall_tokens( sid, nelem, tokenbuf, &rnelem );
-       printf( "ret=%d\n", ret );
-       printf( "rnelem=%d\n", rnelem );
-
-       printf("tokens=\"");
-       for( i = 0; i < rnelem; i++ ){
-               printf("%d ", (int)*(tokenbuf+i));
-       }
-       printf("\"\n");
-       exit(0);
-}
diff --git a/dmapi/src/simple/dm_query_session.c b/dmapi/src/simple/dm_query_session.c
deleted file mode 100644 (file)
index 795418f..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/errno.h>
-#include <getopt.h>
-#ifdef linux
-#include <dmapi.h>
-#endif
-
-int
-main( int argc, char **argv )
-{
-       extern char *optarg;
-       int c;
-       int ret;
-       char *sessinfo;
-       size_t rlen = 0;
-       dm_sessid_t sid = 0;
-       int buflen = 100;
-       char *versionstr;
-
-       while( (c = getopt(argc, argv, "hs:l:")) != -1 ) {
-               switch(c){
-               case 's':
-                       sid = atoi( optarg );
-                       break;
-               case 'l':
-                       buflen = atoi( optarg );
-                       break;
-               case 'h':
-                       fprintf(stderr, "Usage: %s <-s sid> [-l buflen]\n", argv[0]);
-                       exit(2);
-               }
-       }
-
-       if( sid == 0 ){
-               fprintf(stderr, "%s: must specify -s\n", argv[0] );
-               exit(1);
-       }
-
-       if( (sessinfo = malloc( sizeof(char*) * buflen )) == NULL ){
-               fprintf(stderr, "%s: malloc failed\n", argv[0] );
-               exit(1);
-       }
-
-       if( dm_init_service( &versionstr ) < 0 )
-               exit(1);
-
-       ret = dm_query_session( sid, buflen, sessinfo, &rlen );
-       printf( "ret=%d\n", ret );
-       printf( "rlen=%zd\n", rlen );
-       if( ret != -1 )
-               printf( "sessinfo=%s\n", sessinfo );
-       exit(0);
-}
diff --git a/dmapi/src/suite1/Makefile b/dmapi/src/suite1/Makefile
deleted file mode 100644 (file)
index 3bfaf7a..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-# Copyright (C) 2011 SGI  All Rights Reserved.
-#
-#
-#
-TOPDIR = ../../..
-
-include $(TOPDIR)/include/builddefs
-
-SUBDIRS = cmd
-
-default: $(SUBDIRS)
-
-include $(BUILDRULES)
-
-install: default
-
-install-dev:
diff --git a/dmapi/src/suite1/cmd/Makefile b/dmapi/src/suite1/cmd/Makefile
deleted file mode 100644 (file)
index f185a7a..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-# Copyright (C) 2011 SGI  All Rights Reserved.
-#
-#
-#
-TOPDIR = ../../../..
-
-include $(TOPDIR)/include/builddefs
-
-# things needing -ldm -lhandle -ldmtest
-DM_TARGS = test_assumption get_eventlist set_eventlist set_disp \
-               get_region get_dmattr set_dmattr remove_dmattr \
-               probe_hole probe_punch_xfsctl_hole punch_hole \
-               get_fileattr sync_by_handle getall_dmattr \
-               set_fileattr path_to_handle path_to_fshandle \
-               get_mountinfo getall_disp get_events dm_handle \
-               handle_to_fshandle get_config_events get_allocinfo \
-               create_userevent request_right release_right \
-               upgrade_right query_right downgrade_right \
-               obj_ref_hold obj_ref_rele obj_ref_query print_event \
-               get_dirattrs
-
-# things needing -ldm -lhandle
-NT_TARGS = fd_to_handle handle_to_path init_service pending \
-               print_fshandle respond_event
-
-# things needing -ldm -ldmtest
-NTDM_TARGS = make_sparse randomize_file rwt struct_test
-
-# things left out for some reason...
-UNUSED_TARGS = make_rt_sparse security_hole2 security_hole
-
-TARGETS = $(DM_TARGS) $(NT_TARGS) $(NTDM_TARGS) link_test
-
-CFILES = $(TARGETS:=.c)
-LDIRT = $(TARGETS)
-
-CFLAGS += -I$(TOPDIR)/dmapi/src/common -I/usr/include/xfs
-
-LLDLIBS = $(TOPDIR)/dmapi/src/common/lib/libdmtest.la $(LIBDM)
-
-default: depend $(TARGETS)
-
-depend: .dep
-
-include $(BUILDRULES)
-
-install install-dev: default
-
-$(TARGETS):
-       @echo "    [CC]    $@"
-       $(Q)$(LTLINK) $@.c -o $@ $(CFLAGS) $(LDFLAGS) $(LDLIBS)
-
--include .dep
diff --git a/dmapi/src/suite1/cmd/create_userevent.c b/dmapi/src/suite1/cmd/create_userevent.c
deleted file mode 100644 (file)
index 23faf89..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-
-#include <lib/hsm.h>
-
-#include <string.h>
-#include <getopt.h>
-
-/*---------------------------------------------------------------------------
-
-Test program used to test the DMAPI function create_userevent().  The
-command line is:
-
-       create_userevent [-s sid] string
-
-where string is the msgdata to be stored in the event.
-sid is the session ID to use for the event.
-
-----------------------------------------------------------------------------*/
-
-#ifndef linux
-extern char    *sys_errlist[];
-#endif
-extern  int     optind;
-extern  char    *optarg;
-
-
-char   *Progname;
-
-static void
-usage(void)
-{
-       fprintf(stderr, "usage:\t%s [-s sid] string\n", Progname);
-       exit(1);
-}
-
-
-int
-main(
-       int     argc, 
-       char    **argv)
-{
-       dm_sessid_t     sid = DM_NO_SESSION;
-       char            *string;
-       dm_token_t      token;
-       char            *name;
-       int             opt;
-
-       Progname = strrchr(argv[0], '/');
-       if (Progname) {
-               Progname++;
-       } else {
-               Progname = argv[0];
-       }
-
-       /* Crack and validate the command line options. */
-
-       while ((opt = getopt(argc, argv, "s:")) != EOF) {
-               switch (opt) {
-               case 's':
-                       sid = atol(optarg);
-                       break;
-               case '?':
-                       usage();
-               }
-       }
-       if (optind + 1 != argc)
-               usage();
-       string = argv[optind++];
-
-       if (dm_init_service(&name) == -1)  {
-               fprintf(stderr, "Can't initialize the DMAPI\n");
-               exit(1);
-       }
-       if (sid == DM_NO_SESSION)
-               find_test_session(&sid);
-
-       if (dm_create_userevent(sid, strlen(string)+ 1, string, &token)) {
-               fprintf(stderr, "dm_create_userevent failed, %s\n",
-                       strerror(errno));
-               exit(1);
-       }
-
-       fprintf(stdout, "New token %d\n", token);
-       exit(0);
-}
diff --git a/dmapi/src/suite1/cmd/dm_handle.c b/dmapi/src/suite1/cmd/dm_handle.c
deleted file mode 100644 (file)
index 2ba7239..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <fcntl.h>
-#include <unistd.h>
-
-#include <lib/hsm.h>
-
-#include <string.h>
-
-/*---------------------------------------------------------------------------
-
-Test program used to test all the DMAPI functions in dm_handle.c.  The
-command line is:
-
-        dm_handle pathname
-
-where pathname is the name of a file.  If any function fails, an error message
-containing the work ERROR will be written to stderr.
-
-Tested DMAPI functions are:
-       dm_fd_to_handle
-       dm_handle_cmp
-       dm_handle_free
-       dm_handle_hash
-       dm_handle_is_valid
-       dm_handle_to_fshandle
-       dm_handle_to_fsid
-       dm_handle_to_ino
-       dm_handle_to_igen
-       dm_make_handle
-       dm_make_fshandle
-       dm_path_to_handle
-       dm_path_to_fshandle
-
-----------------------------------------------------------------------------*/
-
-
-char   *Progname;
-
-
-
-int
-main(
-       int             argc,
-       char            **argv)
-{
-       char            *pathname;
-       char            *name;
-       void            *hanp1, *hanp2, *hanp3, *fshanp1, *fshanp2, *fshanp3;
-       size_t          hlen1, hlen2, hlen3, fshlen1, fshlen2, fshlen3;
-       u_int           hash1, hash2, hash3, fshash1, fshash2, fshash3;
-       dm_fsid_t       fsid;
-       dm_ino_t        ino;
-       dm_igen_t       igen;
-       char            buffer[100];
-       char            buffer1[100];
-       char            fsbuffer1[100];
-       char            buffer2[100];
-       char            fsbuffer2[100];
-       char            buffer3[100];
-       char            fsbuffer3[100];
-       int             fd;
-
-       Progname = strrchr(argv[0], '/');
-       if (Progname) {
-               Progname++;
-       } else {
-               Progname = argv[0];
-       }
-
-       if (argc != 2) {
-               fprintf(stderr, "usage: %s path\n", argv[0]);
-               exit(1);
-       }
-       pathname = argv[1];
-
-       (void)dm_init_service(&name);
-
-       if (dm_path_to_handle(pathname, &hanp1, &hlen1) != 0) {
-               fprintf(stderr, "dm_path_to_handle failed, %s\n",
-                       strerror(errno));
-               exit(1);
-       }
-       hash1 = dm_handle_hash(hanp1, hlen1);
-       hantoa(hanp1, hlen1, buffer1);
-       fprintf(stdout, "  han1:  hash %u  value %s  (dm_path_to_handle)\n",
-               hash1, buffer1);
-       if (dm_handle_is_valid(hanp1, hlen1) == DM_FALSE) {
-               fprintf(stderr, "ERROR: han1 is not valid\n");
-       }
-
-       if (dm_path_to_fshandle(pathname, &fshanp1, &fshlen1) != 0) {
-               fprintf(stderr, "dm_path_to_fshandle failed, %s\n",
-                       strerror(errno));
-               exit(1);
-       }
-       fshash1 = dm_handle_hash(fshanp1, fshlen1);
-       hantoa(fshanp1, fshlen1, fsbuffer1);
-       fprintf(stdout, "fshan1:  hash %u  value %s  (dm_path_to_fshandle\n",
-               fshash1, fsbuffer1);
-       if (dm_handle_is_valid(fshanp1, fshlen1) == DM_FALSE) {
-               fprintf(stderr, "ERROR: fshan1 is not valid\n");
-       }
-
-       if ((fd = open(pathname, O_RDONLY)) < 0) {
-               fprintf(stderr, "open of %s failed, %s\n", pathname,
-                       strerror(errno));
-               exit(1);
-       }
-       if (dm_fd_to_handle(fd, &hanp2, &hlen2) != 0) {
-               fprintf(stderr, "dm_fd_to_handle failed, %s\n",
-                       strerror(errno));
-               exit(1);
-       }
-       (void)close(fd);
-       hash2 = dm_handle_hash(hanp2, hlen2);
-       hantoa(hanp2, hlen2, buffer2);
-       fprintf(stdout, "  han2:  hash %u  value %s  (dm_fd_to_handle)\n",
-               hash2, buffer2);
-       if (dm_handle_is_valid(hanp2, hlen2) == DM_FALSE) {
-               fprintf(stderr, "ERROR: han2 is not valid\n");
-       }
-
-       if (dm_handle_to_fshandle(hanp2, hlen2, &fshanp2, &fshlen2) != 0) {
-               fprintf(stderr, "dm_handle_to_fshandle failed, %s\n",
-                       strerror(errno));
-               exit(1);
-       }
-       fshash2 = dm_handle_hash(fshanp2, fshlen2);
-       hantoa(fshanp2, fshlen2, fsbuffer2);
-       fprintf(stdout, "fshan2:  hash %u  value %s  (dm_handle_to_fshandle)\n",
-               fshash2, fsbuffer2);
-       if (dm_handle_is_valid(fshanp2, fshlen2) == DM_FALSE) {
-               fprintf(stderr, "ERROR: fshan2 is not valid\n");
-       }
-
-       if (dm_handle_cmp(hanp1, hlen1, hanp2, hlen2)) {
-               fprintf(stderr, "ERROR: han1 and han2 differ in dm_handle_cmp\n");
-       }
-       if (strcmp(buffer1, buffer2)) {
-               fprintf(stderr, "ERROR: han1 and han2 differ in strcmp\n");
-       }
-       if (hash1 != hash2) {
-               fprintf(stderr, "ERROR: hash1 and hash2 differ\n");
-       }
-
-       if (dm_handle_cmp(fshanp1, fshlen1, fshanp2, fshlen2)) {
-               fprintf(stderr, "ERROR: fshan1 and fshan2 differ in dm_handle_cmp\n");
-       }
-       if (strcmp(fsbuffer1, fsbuffer2)) {
-               fprintf(stderr, "ERROR: fshan1 and fshan2 differ in strcmp\n");
-       }
-       if (fshash1 != fshash2) {
-               fprintf(stderr, "ERROR: fshash1 and fshash2 differ\n");
-       }
-
-       /* Break the handle into its component parts and display them.  Use
-          hantoa() instead of printing the parts directly because some are
-          32 bits on Veritas and 64 bits on SGI.
-       */
-
-       if (dm_handle_to_fsid(hanp1, hlen1, &fsid) != 0) {
-               fprintf(stderr, "dm_handle_to_fsid failed, %s\n",
-                       strerror(errno));
-               exit(1);
-       }
-       hantoa(&fsid, sizeof(fsid), buffer);
-       fprintf(stdout, "fsid  %s       (dm_handle_to_fsid)\n", buffer);
-
-       if (dm_handle_to_ino(hanp1, hlen1, &ino) != 0) {
-               fprintf(stderr, "dm_handle_to_ino failed, %s\n",
-                       strerror(errno));
-               exit(1);
-       }
-       hantoa(&ino, sizeof(ino), buffer);
-       fprintf(stdout, "ino   %s       (dm_handle_to_ino)\n", buffer);
-
-       if (dm_handle_to_igen(hanp1, hlen1, &igen) != 0) {
-               fprintf(stderr, "dm_handle_to_igen failed, %s\n",
-                       strerror(errno));
-               exit(1);
-       }
-       hantoa(&igen, sizeof(igen), buffer);
-       fprintf(stdout, "igen  %s       (dm_handle_to_igen)\n", buffer);
-
-       /* Now use the parts to remake the handle and verify we get the same
-          answer.
-       */
-
-       if (dm_make_handle(&fsid, &ino, &igen, &hanp3, &hlen3) != 0) {
-               fprintf(stderr, "dm_make_handle failed, %s\n",
-                       strerror(errno));
-               exit(1);
-       }
-       hash3 = dm_handle_hash(hanp3, hlen3);
-       hantoa(hanp3, hlen3, buffer3);
-       fprintf(stdout, "  han3:  hash %u  value %s  (dm_make_handle)\n",
-               hash3, buffer3);
-       if (dm_handle_is_valid(hanp3, hlen3) == DM_FALSE) {
-               fprintf(stderr, "ERROR: han3 is not valid\n");
-       }
-
-       if (dm_handle_cmp(hanp1, hlen1, hanp3, hlen3)) {
-               fprintf(stderr, "ERROR: hanp1 and hanp3 differ in dm_handle_cmp\n");
-       }
-       if (strcmp(buffer1, buffer3)) {
-               fprintf(stderr, "ERROR: hanp1 and hanp3 differ in strcmp\n");
-       }
-       if (hash1 != hash3) {
-               fprintf(stderr, "ERROR: hash1 and hash3 differ\n");
-       }
-
-       if (dm_make_fshandle(&fsid, &fshanp3, &fshlen3) != 0) {
-               fprintf(stderr, "dm_make_fshandle failed, %s\n",
-                       strerror(errno));
-               exit(1);
-       }
-       fshash3 = dm_handle_hash(fshanp3, fshlen3);
-       hantoa(fshanp3, fshlen3, fsbuffer3);
-       fprintf(stdout, "fshan3:  hash %u  value %s  (dm_make_fshandle)\n",
-               fshash3, fsbuffer3);
-       if (dm_handle_is_valid(fshanp3, fshlen3) == DM_FALSE) {
-               fprintf(stderr, "ERROR: fshan3 is not valid\n");
-       }
-
-       if (dm_handle_cmp(fshanp1, fshlen1, fshanp3, fshlen3)) {
-               fprintf(stderr, "ERROR: fshan1 and fshan3 differ in dm_handle_cmp\n");
-       }
-       if (strcmp(fsbuffer1, fsbuffer3)) {
-               fprintf(stderr, "ERROR: fshan1 and fshan3 differ in strcmp\n");
-       }
-       if (fshash1 != fshash3) {
-               fprintf(stderr, "ERROR: fshash1 and fshash3 differ\n");
-       }
-
-       dm_handle_free(hanp1, hlen1);
-       dm_handle_free(hanp2, hlen2);
-       dm_handle_free(hanp3, hlen3);
-       dm_handle_free(fshanp1, fshlen1);
-       dm_handle_free(fshanp2, fshlen2);
-       dm_handle_free(fshanp3, fshlen3);
-       exit(0);
-}
diff --git a/dmapi/src/suite1/cmd/downgrade_right.c b/dmapi/src/suite1/cmd/downgrade_right.c
deleted file mode 100644 (file)
index d8ddfbb..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-
-#include <lib/hsm.h>
-
-#include <string.h>
-#include <getopt.h>
-
-/*---------------------------------------------------------------------------
-
-Test program used to test the DMAPI function dm_downgrade_right().  The
-command line is:
-
-       downgrade_right {-F} [-s sid] token {pathname|handle}
-
-where:
--F
-       when a pathname is specified, -F indicates that its filesystem handle
-       should be used rather than its file object handle.
-sid
-       is the dm_sessid_t to use rather than the default test session.
-token
-       is the dm_token_t to use.
-{pathname|handle}
-       is either a handle, or is the pathname of a file whose handle is
-       to be used.
-
-----------------------------------------------------------------------------*/
-
-#ifndef linux
-extern char    *sys_errlist[];
-#endif
-extern  int     optind;
-extern  char    *optarg;
-
-
-char   *Progname;
-
-
-static void
-usage(void)
-{
-       fprintf(stderr, "usage:\t%s [-F] [-s sid] token {pathname|handle}\n",
-               Progname);
-       exit(1);
-}
-
-
-int
-main(
-       int     argc,
-       char    **argv)
-{
-       dm_sessid_t     sid = DM_NO_SESSION;
-       dm_token_t      token;
-       char            *object;
-       void            *hanp;
-       size_t          hlen;
-       int             Fflag = 0;
-       char            *name;
-       int             opt;
-
-       Progname = strrchr(argv[0], '/');
-       if (Progname) {
-               Progname++;
-       } else {
-               Progname = argv[0];
-       }
-
-       /* Crack and validate the command line options. */
-
-       while ((opt = getopt(argc, argv, "Fs:")) != EOF) {
-               switch (opt) {
-               case 'F':
-                       Fflag++;
-                       break;
-               case 's':
-                       sid = atol(optarg);
-                       break;
-               case '?':
-                       usage();
-               }
-       }
-       if (optind + 2 != argc)
-               usage();
-       token = atol(argv[optind++]);
-       object = argv[optind];
-
-       if (dm_init_service(&name) == -1)  {
-               fprintf(stderr, "Can't initialize the DMAPI\n");
-               exit(1);
-       }
-       if (sid == DM_NO_SESSION)
-               find_test_session(&sid);
-
-       /* Get the file or filesystem's handle. */
-
-       if (opaque_to_handle(object, &hanp, &hlen)) {
-               fprintf(stderr, "can't get handle from %s\n", object);
-               exit(1);
-       }
-       if (Fflag) {
-               void    *fshanp;
-               size_t  fshlen;
-
-               if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
-                       fprintf(stderr, "can't get filesystem handle from %s\n",
-                               object);
-                       exit(1);
-               }
-    &nb