2 * Copyright (c) 2000-2002 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_eventlist [-F] [-m max] [-s sid] [-t token] {pathname|handle} event [...]
34 is either the pathname of a file or a handle.
36 is the value to use for the maxevent parameter of dm_set_eventlist().
38 is the dm_sessid_t value to use.
40 is the dm_token_t value to use (DM_NO_TOKEN is the default).
42 is one or more events to set.
44 ----------------------------------------------------------------------------*/
47 extern char *sys_errlist[];
61 fprintf(stderr, "usage:\t%s [-F] [-m max] [-s sid] [-t token] "
62 "{pathname|handle} event [...]\n", Progname);
63 fprintf(stderr, "possible events are:\n");
64 for (i = 0; i < ev_namecnt; i++) {
65 fprintf(stderr, "%s (%d)\n", ev_names[i].name,
77 dm_sessid_t sid = DM_NO_SESSION;
78 dm_token_t token = DM_NO_TOKEN;
80 dm_eventset_t eventset;
84 u_int maxevent = DM_EVENT_MAX;
88 Progname = strrchr(argv[0], '/');
95 /* Crack and validate the command line options. */
97 while ((opt = getopt(argc, argv, "Fm:s:t:")) != EOF) {
103 maxevent = atol(optarg);
109 token = atol(optarg);
115 if (optind + 1 > argc)
117 object = argv[optind++];
119 if (dm_init_service(&name) == -1) {
120 fprintf(stderr, "Can't initialize the DMAPI\n");
123 if (sid == DM_NO_SESSION)
124 find_test_session(&sid);
128 /* Get the file's handle or convert the external handle. */
130 if (opaque_to_handle(object, &hanp, &hlen)) {
131 fprintf(stderr, "can't get handle for %s\n", object);
139 if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
140 fprintf(stderr, "can't get filesystem handle from %s\n",
144 dm_handle_free(hanp, hlen);
149 for (; optind < argc; optind++) {
150 dm_eventtype_t event;
152 event = ev_name_to_value(argv[optind]);
153 if (event == DM_EVENT_INVALID) {
154 fprintf(stderr, "invalid event %s\n", argv[optind]);
157 if ((event == DM_EVENT_READ) || (event == DM_EVENT_WRITE) ||
158 (event == DM_EVENT_TRUNCATE)) {
159 fprintf(stderr, "Use set_region to twiddle read/write/trunc events\n");
163 DMEV_SET(event, eventset);
166 if (dm_set_eventlist(sid, hanp, hlen, token, &eventset, maxevent)) {
167 fprintf(stderr, "dm_set_eventlist failed, %s\n",
172 dm_handle_free(hanp, hlen);