2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
33 #include <sys/types.h>
36 #include <lib/errtest.h>
42 /*---------------------------------------------------------------------------
44 Manual test for the DMAPI functions dm_set_region() and dm_get_region().
48 region_test [-Rv] [-s sid] [-l len] [-o offset] ls_path directory
52 reuse the existing test file
56 is the path to a specific copy of ls, important only for its size
58 is the session ID whose events you you are interested in.
59 ----------------------------------------------------------------------------*/
64 extern char *sys_errlist[];
78 fprintf(stderr, "usage:\t%s [-Rv] [-s sid] [-l len] [-o offset] ls_path pathname\n", Progname);
88 dm_sessid_t sid = DM_NO_SESSION;
89 char *dir_name = NULL;
95 dm_region_t region = { 0, 0, 0 };
100 dm_boolean_t exactflag;
102 if (Progname = strrchr(argv[0], '/')) {
108 /* Crack and validate the command line options. */
110 while ((opt = getopt(argc, argv, "vo:l:s:R")) != EOF) {
119 region.rg_offset = atol(optarg);
122 region.rg_size = atol(optarg);
131 if (optind + 2 > argc)
133 ls_path = argv[optind];
134 dir_name = argv[optind+1];
136 if (dm_init_service(&name) == -1) {
137 fprintf(stderr, "Can't inititalize the DMAPI\n");
140 if (sid == DM_NO_SESSION)
141 find_test_session(&sid);
143 sprintf(test_file, "%s/DMAPI_test_file", dir_name);
145 sprintf(command, "cp %s %s\n", ls_path, test_file);
149 if (dm_path_to_handle(test_file, &hanp, &hlen)) {
150 fprintf(stderr, "can't get handle for file %s\n", test_file);
154 region.rg_flags = DM_REGION_READ | DM_REGION_WRITE | DM_REGION_TRUNCATE;
155 if( dm_set_region( sid, hanp, hlen, DM_NO_TOKEN, NELEM,
156 ®ion, &exactflag ) ){
157 fprintf(stderr, "dm_set_region failed, err=%d\n", errno);
158 dm_handle_free(hanp,hlen);
161 if( exactflag == DM_FALSE )
162 fprintf(stderr, "exact flag was false\n");
164 dm_handle_free(hanp, hlen);