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
26 /*---------------------------------------------------------------------------
28 Test program used to test the DMAPI function dm_request_right(). The
31 request_right [-F] [-w] [-s sid] token {pathname|handle} right
35 when a pathname is specified, -F indicates that its filesystem handle
36 should be used rather than its file object handle.
38 if specified, the DM_RR_WAIT flag will be used.
40 is the dm_sessid_t to use rather than the default test session.
42 is the dm_token_t to use.
44 is either a handle, or is the pathname of a file whose handle is
47 is the dm_right_t to use.
49 ----------------------------------------------------------------------------*/
52 extern char *sys_errlist[];
66 fprintf(stderr, "usage:\t%s [-F] [-w] [-s sid] token "
67 "{pathname|handle} right\n", Progname);
68 fprintf(stderr, "possible rights are:\n");
69 for (i = 0; i < rt_namecnt; i++) {
70 fprintf(stderr, "%s (%d)\n", rt_names[i].name,
82 dm_sessid_t sid = DM_NO_SESSION;
94 Progname = strrchr(argv[0], '/');
101 /* Crack and validate the command line options. */
103 while ((opt = getopt(argc, argv, "Fws:")) != EOF) {
118 if (optind + 3 != argc)
120 token = atol(argv[optind++]);
121 object = argv[optind++];
122 rightstr = argv[optind];
124 if (dm_init_service(&name) == -1) {
125 fprintf(stderr, "Can't initialize the DMAPI\n");
128 if (sid == DM_NO_SESSION)
129 find_test_session(&sid);
131 /* Get the file or filesystem's handle. */
133 if (opaque_to_handle(object, &hanp, &hlen)) {
134 fprintf(stderr, "can't get handle from %s\n", object);
141 if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
142 fprintf(stderr, "can't get filesystem handle from %s\n",
146 dm_handle_free(hanp, hlen);
151 if (rt_name_to_value(rightstr, &right)) {
152 fprintf(stderr, "invalid right %s\n", rightstr);
156 if (dm_request_right(sid, hanp, hlen, token,
157 (wflag ? DM_RR_WAIT : 0), right)) {
158 fprintf(stderr, "dm_request_right failed, %s\n",
163 dm_handle_free(hanp, hlen);