1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001 Silicon Graphics, Inc.
13 /*---------------------------------------------------------------------------
15 Test program used to test the DMAPI function dm_query_right(). The
18 query_right [-F] [-s sid] token {pathname|handle}
22 when a pathname is specified, -F indicates that its filesystem handle
23 should be used rather than its file object handle.
25 is the dm_sessid_t to use rather than the default test session.
27 is the dm_token_t to use.
29 is either a handle, or is the pathname of a file whose handle is
32 ----------------------------------------------------------------------------*/
35 extern char *sys_errlist[];
47 fprintf(stderr, "usage:\t%s [-F] [-s sid] token "
48 "{pathname|handle}\n", Progname);
58 dm_sessid_t sid = DM_NO_SESSION;
68 Progname = strrchr(argv[0], '/');
75 /* Crack and validate the command line options. */
77 while ((opt = getopt(argc, argv, "Fs:")) != EOF) {
89 if (optind + 2 != argc)
91 token = atol(argv[optind++]);
92 object = argv[optind++];
94 if (dm_init_service(&name) == -1) {
95 fprintf(stderr, "Can't initialize the DMAPI\n");
98 if (sid == DM_NO_SESSION)
99 find_test_session(&sid);
101 /* Get the file or filesystem's handle. */
103 if (opaque_to_handle(object, &hanp, &hlen)) {
104 fprintf(stderr, "can't get handle from %s\n", object);
111 if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
112 fprintf(stderr, "can't get filesystem handle from %s\n",
116 dm_handle_free(hanp, hlen);
121 if (dm_query_right(sid, hanp, hlen, token, &right)) {
122 fprintf(stderr, "dm_query_right failed, %s\n",
127 fprintf(stderr, "right is %s\n", rt_value_to_name(right));
129 dm_handle_free(hanp, hlen);