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_upgrade_right(). The
18 upgrade_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 {pathname|handle}\n",
58 dm_sessid_t sid = DM_NO_SESSION;
67 Progname = strrchr(argv[0], '/');
74 /* Crack and validate the command line options. */
76 while ((opt = getopt(argc, argv, "Fs:")) != EOF) {
88 if (optind + 2 != argc)
90 token = atol(argv[optind++]);
91 object = argv[optind];
93 if (dm_init_service(&name) == -1) {
94 fprintf(stderr, "Can't initialize the DMAPI\n");
97 if (sid == DM_NO_SESSION)
98 find_test_session(&sid);
100 /* Get the file or filesystem's handle. */
102 if (opaque_to_handle(object, &hanp, &hlen)) {
103 fprintf(stderr, "can't get handle from %s\n", object);
110 if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
111 fprintf(stderr, "can't get filesystem handle from %s\n",
115 dm_handle_free(hanp, hlen);
120 if (dm_upgrade_right(sid, hanp, hlen, token)) {
121 fprintf(stderr, "dm_upgrade_right failed, %s\n",
126 dm_handle_free(hanp, hlen);