2 * Copyright (c) 2000-2001 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #include <sys/types.h>
22 #include <lib/errtest.h>
28 /*---------------------------------------------------------------------------
30 Manual test for the DMAPI functions dm_set_region() and dm_get_region().
34 region_test [-Rv] [-s sid] [-l len] [-o offset] ls_path directory
38 reuse the existing test file
42 is the path to a specific copy of ls, important only for its size
44 is the session ID whose events you you are interested in.
45 ----------------------------------------------------------------------------*/
50 extern char *sys_errlist[];
62 fprintf(stderr, "usage:\t%s [-Rv] [-s sid] [-l len] [-o offset] ls_path pathname\n", Progname);
72 dm_sessid_t sid = DM_NO_SESSION;
73 char *dir_name = NULL;
79 dm_region_t region = { 0, 0, 0 };
84 dm_boolean_t exactflag;
86 if (Progname = strrchr(argv[0], '/')) {
92 /* Crack and validate the command line options. */
94 while ((opt = getopt(argc, argv, "vo:l:s:R")) != EOF) {
103 region.rg_offset = atol(optarg);
106 region.rg_size = atol(optarg);
115 if (optind + 2 > argc)
117 ls_path = argv[optind];
118 dir_name = argv[optind+1];
120 if (dm_init_service(&name) == -1) {
121 fprintf(stderr, "Can't initialize the DMAPI\n");
124 if (sid == DM_NO_SESSION)
125 find_test_session(&sid);
127 sprintf(test_file, "%s/DMAPI_test_file", dir_name);
129 sprintf(command, "cp %s %s\n", ls_path, test_file);
133 if (dm_path_to_handle(test_file, &hanp, &hlen)) {
134 fprintf(stderr, "can't get handle for file %s\n", test_file);
138 region.rg_flags = DM_REGION_READ | DM_REGION_WRITE | DM_REGION_TRUNCATE;
139 if( dm_set_region( sid, hanp, hlen, DM_NO_TOKEN, NELEM,
140 ®ion, &exactflag ) ){
141 fprintf(stderr, "dm_set_region failed, err=%d\n", errno);
142 dm_handle_free(hanp,hlen);
145 if( exactflag == DM_FALSE )
146 fprintf(stderr, "exact flag was false\n");
148 dm_handle_free(hanp, hlen);