1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001 Silicon Graphics, Inc.
10 #include <lib/errtest.h>
16 /*---------------------------------------------------------------------------
18 Manual test for the DMAPI functions dm_set_region() and dm_get_region().
22 region_test [-Rv] [-s sid] [-l len] [-o offset] ls_path directory
26 reuse the existing test file
30 is the path to a specific copy of ls, important only for its size
32 is the session ID whose events you you are interested in.
33 ----------------------------------------------------------------------------*/
38 extern char *sys_errlist[];
50 fprintf(stderr, "usage:\t%s [-Rv] [-s sid] [-l len] [-o offset] ls_path pathname\n", Progname);
60 dm_sessid_t sid = DM_NO_SESSION;
61 char *dir_name = NULL;
67 dm_region_t region = { 0, 0, 0 };
72 dm_boolean_t exactflag;
74 Progname = strrchr(argv[0], '/');
81 /* Crack and validate the command line options. */
83 while ((opt = getopt(argc, argv, "vo:l:s:R")) != EOF) {
92 region.rg_offset = atol(optarg);
95 region.rg_size = atol(optarg);
104 if (optind + 2 > argc)
106 ls_path = argv[optind];
107 dir_name = argv[optind+1];
109 if (dm_init_service(&name) == -1) {
110 fprintf(stderr, "Can't initialize the DMAPI\n");
113 if (sid == DM_NO_SESSION)
114 find_test_session(&sid);
116 sprintf(test_file, "%s/DMAPI_test_file", dir_name);
118 sprintf(command, "cp %s %s\n", ls_path, test_file);
122 if (dm_path_to_handle(test_file, &hanp, &hlen)) {
123 fprintf(stderr, "can't get handle for file %s\n", test_file);
127 region.rg_flags = DM_REGION_READ | DM_REGION_WRITE | DM_REGION_TRUNCATE;
128 if( dm_set_region( sid, hanp, hlen, DM_NO_TOKEN, NELEM,
129 ®ion, &exactflag ) ){
130 fprintf(stderr, "dm_set_region failed, err=%d\n", errno);
131 dm_handle_free(hanp,hlen);
134 if( exactflag == DM_FALSE )
135 fprintf(stderr, "exact flag was false\n");
137 dm_handle_free(hanp, hlen);