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
24 /*---------------------------------------------------------------------------
26 Test program used to test the DMAPI function dm_downgrade_right(). The
29 downgrade_right {-F} [-s sid] token {pathname|handle}
33 when a pathname is specified, -F indicates that its filesystem handle
34 should be used rather than its file object handle.
36 is the dm_sessid_t to use rather than the default test session.
38 is the dm_token_t to use.
40 is either a handle, or is the pathname of a file whose handle is
43 ----------------------------------------------------------------------------*/
46 extern char *sys_errlist[];
58 fprintf(stderr, "usage:\t%s [-F] [-s sid] token {pathname|handle}\n",
69 dm_sessid_t sid = DM_NO_SESSION;
78 Progname = strrchr(argv[0], '/');
85 /* Crack and validate the command line options. */
87 while ((opt = getopt(argc, argv, "Fs:")) != EOF) {
99 if (optind + 2 != argc)
101 token = atol(argv[optind++]);
102 object = argv[optind];
104 if (dm_init_service(&name) == -1) {
105 fprintf(stderr, "Can't initialize the DMAPI\n");
108 if (sid == DM_NO_SESSION)
109 find_test_session(&sid);
111 /* Get the file or filesystem's handle. */
113 if (opaque_to_handle(object, &hanp, &hlen)) {
114 fprintf(stderr, "can't get handle from %s\n", object);
121 if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
122 fprintf(stderr, "can't get filesystem handle from %s\n",
126 dm_handle_free(hanp, hlen);
131 if (dm_downgrade_right(sid, hanp, hlen, token)) {
132 fprintf(stderr, "dm_downgrade_right failed, %s\n",
137 dm_handle_free(hanp, hlen);