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_set_dmattr(). The
18 set_dmattr [-b buflen] [-s sid] [-u] {pathname|handle} attr value
20 where pathname is the name of a file, buflen is the size of the buffer to use
21 in the call, attr is the name of the DMAPI attribute, -u is selected if
22 setdtime should be updated, and sid is the session ID whose attributes you
25 ----------------------------------------------------------------------------*/
28 extern char *sys_errlist[];
39 fprintf(stderr, "usage:\t%s [-b buflen] [-s sid] [-u] "
40 "{pathname|handle} attr value\n", Progname);
50 dm_sessid_t sid = DM_NO_SESSION;
52 dm_attrname_t *attrnamep;
62 Progname = strrchr(argv[0], '/');
69 /* Crack and validate the command line options. */
71 while ((opt = getopt(argc, argv, "b:s:u")) != EOF) {
75 buflen = atol(optarg);
87 if (optind + 3 != argc)
89 object = argv[optind++];
90 attrnamep = (dm_attrname_t *)argv[optind++];
93 buflen = strlen(bufp) + 1;
95 if (dm_init_service(&name) == -1) {
96 fprintf(stderr, "Can't initialize the DMAPI\n");
99 if (sid == DM_NO_SESSION)
100 find_test_session(&sid);
102 /* Get the file's handle. */
104 if (opaque_to_handle(object, &hanp, &hlen)) {
105 fprintf(stderr, "can't get handle for %s\n", object);
109 if (dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, attrnamep, setdtime,
111 fprintf(stderr, "dm_set_dmattr failed, %s\n",
116 dm_handle_free(hanp, hlen);