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_downgrade_right(). The
17 downgrade_right {-F} [-s sid] token {pathname|handle}
21 when a pathname is specified, -F indicates that its filesystem handle
22 should be used rather than its file object handle.
24 is the dm_sessid_t to use rather than the default test session.
26 is the dm_token_t to use.
28 is either a handle, or is the pathname of a file whose handle is
31 ----------------------------------------------------------------------------*/
34 extern char *sys_errlist[];
46 fprintf(stderr, "usage:\t%s [-F] [-s sid] token {pathname|handle}\n",
57 dm_sessid_t sid = DM_NO_SESSION;
66 Progname = strrchr(argv[0], '/');
73 /* Crack and validate the command line options. */
75 while ((opt = getopt(argc, argv, "Fs:")) != EOF) {
87 if (optind + 2 != argc)
89 token = atol(argv[optind++]);
90 object = argv[optind];
92 if (dm_init_service(&name) == -1) {
93 fprintf(stderr, "Can't initialize the DMAPI\n");
96 if (sid == DM_NO_SESSION)
97 find_test_session(&sid);
99 /* Get the file or filesystem's handle. */
101 if (opaque_to_handle(object, &hanp, &hlen)) {
102 fprintf(stderr, "can't get handle from %s\n", object);
109 if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
110 fprintf(stderr, "can't get filesystem handle from %s\n",
114 dm_handle_free(hanp, hlen);
119 if (dm_downgrade_right(sid, hanp, hlen, token)) {
120 fprintf(stderr, "dm_downgrade_right failed, %s\n",
125 dm_handle_free(hanp, hlen);