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
25 /*---------------------------------------------------------------------------
27 Test program used to test the DMAPI function dm_set_eventlist(). The
30 set_disp [-m max] [-s sid] [-t token] {pathname|handle} [event...]
31 set_disp [-m max] [-s sid] -G [DM_EVENT_MOUNT]
35 is the name of a file or handle whose filesystem is of interest.
37 if the global handle should be used
39 is the value to use for the maxevent parameter of dm_set_disp(),
41 is the dm_sessid_t to use rather than the default test session.
43 is the dm_token_t to use in place of DM_NO_TOKEN.
45 is zero or more events to set.
47 ----------------------------------------------------------------------------*/
50 extern char *sys_errlist[];
64 fprintf(stderr, "usage:\t%s [-m max] [-s sid] [-t token] "
65 "{pathname|handle} [event...]\n", Progname);
66 fprintf(stderr, "usage:\t%s [-m max] [-s sid] -G [DM_EVENT_MOUNT]\n",
68 fprintf(stderr, "possible events are:\n");
69 for (i = 0; i < ev_namecnt; i++) {
70 fprintf(stderr, "%s (%d)\n", ev_names[i].name,
82 dm_sessid_t sid = DM_NO_SESSION;
83 dm_token_t token = DM_NO_TOKEN;
84 u_int maxevent = DM_EVENT_MAX;
85 dm_eventset_t eventset;
92 Progname = strrchr(argv[0], '/');
99 /* Crack and validate the command line options. */
101 while ((opt = getopt(argc, argv, "Gm:s:t:")) != EOF) {
107 maxevent = atol(optarg);
113 token = atol(optarg);
119 if (Gflag && token != DM_NO_TOKEN)
121 if (optind + (Gflag ? 0 : 1) > argc)
124 if (dm_init_service(&name) == -1) {
125 fprintf(stderr, "Can't initialize the DMAPI\n");
128 if (sid == DM_NO_SESSION)
129 find_test_session(&sid);
133 /* Get the file or filesystem's handle. */
136 fshanp = DM_GLOBAL_HANP;
137 fshlen = DM_GLOBAL_HLEN;
143 object = argv[optind++];
145 if (opaque_to_handle(object, &hanp, &hlen)) {
146 fprintf(stderr, "can't get handle from %s\n", object);
149 if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
150 fprintf(stderr, "can't get filesystem handle from %s\n",
154 dm_handle_free(hanp, hlen);
157 for (; optind < argc; optind++) {
158 dm_eventtype_t event;
160 event = ev_name_to_value(argv[optind]);
161 if (event == DM_EVENT_INVALID) {
162 fprintf(stderr, "invalid event %s\n", argv[optind]);
165 DMEV_SET(event, eventset);
168 if (dm_set_disp(sid, fshanp, fshlen, token, &eventset, maxevent)) {
169 fprintf(stderr, "dm_set_disp failed, %s\n",
175 dm_handle_free(fshanp, fshlen);