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
25 /*---------------------------------------------------------------------------
27 Test program used to test the DMAPI function dm_query_right(). The
30 query_right [-F] [-s sid] token {pathname|handle}
34 when a pathname is specified, -F indicates that its filesystem handle
35 should be used rather than its file object handle.
37 is the dm_sessid_t to use rather than the default test session.
39 is the dm_token_t to use.
41 is either a handle, or is the pathname of a file whose handle is
44 ----------------------------------------------------------------------------*/
47 extern char *sys_errlist[];
59 fprintf(stderr, "usage:\t%s [-F] [-s sid] token "
60 "{pathname|handle}\n", Progname);
70 dm_sessid_t sid = DM_NO_SESSION;
80 Progname = strrchr(argv[0], '/');
87 /* Crack and validate the command line options. */
89 while ((opt = getopt(argc, argv, "Fs:")) != EOF) {
101 if (optind + 2 != argc)
103 token = atol(argv[optind++]);
104 object = argv[optind++];
106 if (dm_init_service(&name) == -1) {
107 fprintf(stderr, "Can't initialize the DMAPI\n");
110 if (sid == DM_NO_SESSION)
111 find_test_session(&sid);
113 /* Get the file or filesystem's handle. */
115 if (opaque_to_handle(object, &hanp, &hlen)) {
116 fprintf(stderr, "can't get handle from %s\n", object);
123 if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
124 fprintf(stderr, "can't get filesystem handle from %s\n",
128 dm_handle_free(hanp, hlen);
133 if (dm_query_right(sid, hanp, hlen, token, &right)) {
134 fprintf(stderr, "dm_query_right failed, %s\n",
139 fprintf(stderr, "right is %s\n", rt_value_to_name(right));
141 dm_handle_free(hanp, hlen);