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 if (Progname = strrchr(argv[0], '/')) {
94 /* Crack and validate the command line options. */
96 while ((opt = getopt(argc, argv, "Fm:s:t:")) != EOF) {
102 maxevent = atol(optarg);
108 token = atol(optarg);
114 if (optind + 1 > argc)
116 object = argv[optind++];
118 if (dm_init_service(&name) == -1) {
119 fprintf(stderr, "Can't initialize the DMAPI\n");
122 if (sid == DM_NO_SESSION)
123 find_test_session(&sid);
127 /* Get the file's handle or convert the external handle. */
129 if (opaque_to_handle(object, &hanp, &hlen)) {
130 fprintf(stderr, "can't get handle for %s\n", object);
138 if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
139 fprintf(stderr, "can't get filesystem handle from %s\n",
143 dm_handle_free(hanp, hlen);
148 for (; optind < argc; optind++) {
149 dm_eventtype_t event;
151 event = ev_name_to_value(argv[optind]);
152 if (event == DM_EVENT_INVALID) {
153 fprintf(stderr, "invalid event %s\n", argv[optind]);
156 if ((event == DM_EVENT_READ) || (event == DM_EVENT_WRITE) ||
157 (event == DM_EVENT_TRUNCATE)) {
158 fprintf(stderr, "Use set_region to twiddle read/write/trunc events\n");
162 DMEV_SET(event, eventset);
165 if (dm_set_eventlist(sid, hanp, hlen, token, &eventset, maxevent)) {
166 fprintf(stderr, "dm_set_eventlist failed, %s\n",
171 dm_handle_free(hanp, hlen);