1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001 Silicon Graphics, Inc.
12 /*---------------------------------------------------------------------------
14 Test program used to test the DMAPI function dm_set_region(). The
17 get_region [-n nelem] [-s sid] {pathname|handle}
19 where pathname is the name of a file, nelem is the number of regions to pass
20 in the call, and sid is the session ID whose events you you are interested in.
22 ----------------------------------------------------------------------------*/
25 extern char *sys_errlist[];
37 fprintf(stderr, "usage:\t%s [-n nelem] [-s sid] {pathname|handle}\n", Progname);
47 dm_sessid_t sid = DM_NO_SESSION;
48 dm_region_t *regbufp = NULL;
58 Progname = strrchr(argv[0], '/');
65 /* Crack and validate the command line options. */
67 while ((opt = getopt(argc, argv, "n:s:")) != EOF) {
79 if (optind + 1 != argc)
81 object = argv[optind++];
83 if (dm_init_service(&name) == -1) {
84 fprintf(stderr, "Can't initialize the DMAPI\n");
87 if (sid == DM_NO_SESSION)
88 find_test_session(&sid);
90 /* Get the file's handle. */
92 if (opaque_to_handle(object, &hanp, &hlen)) {
93 fprintf(stderr, "can't get handle for %s\n", object);
98 if ((regbufp = calloc(nelem, sizeof(*regbufp))) == NULL) {
99 fprintf(stderr, "calloc failed, %s\n", strerror(errno));
104 if (dm_get_region(sid, hanp, hlen, DM_NO_TOKEN, nelem, regbufp,
106 fprintf(stderr, "dm_get_region failed, %s\n",
110 fprintf(stdout, "%d regions\n", nelemp);
112 for (i = 0; i < nelemp; i++) {
113 fprintf(stdout, "offset %lld, size %llu, flags 0x%x\n",
114 (long long) regbufp[i].rg_offset,
115 (unsigned long long) regbufp[i].rg_size,
116 regbufp[i].rg_flags);
119 dm_handle_free(hanp, hlen);