2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
39 /*---------------------------------------------------------------------------
41 Test program used to test the DMAPI function dm_set_eventlist(). The
44 set_disp [-m max] [-s sid] [-t token] {pathname|handle} [event...]
45 set_disp [-m max] [-s sid] -G [DM_EVENT_MOUNT]
49 is the name of a file or handle whose filesystem is of interest.
51 if the global handle should be used
53 is the value to use for the maxevent parameter of dm_set_disp(),
55 is the dm_sessid_t to use rather than the default test session.
57 is the dm_token_t to use in place of DM_NO_TOKEN.
59 is zero or more events to set.
61 ----------------------------------------------------------------------------*/
64 extern char *sys_errlist[];
78 fprintf(stderr, "usage:\t%s [-m max] [-s sid] [-t token] "
79 "{pathname|handle} [event...]\n", Progname);
80 fprintf(stderr, "usage:\t%s [-m max] [-s sid] -G [DM_EVENT_MOUNT]\n",
82 fprintf(stderr, "possible events are:\n");
83 for (i = 0; i < ev_namecnt; i++) {
84 fprintf(stderr, "%s (%d)\n", ev_names[i].name,
96 dm_sessid_t sid = DM_NO_SESSION;
97 dm_token_t token = DM_NO_TOKEN;
98 u_int maxevent = DM_EVENT_MAX;
99 dm_eventset_t eventset;
106 if (Progname = strrchr(argv[0], '/')) {
112 /* Crack and validate the command line options. */
114 while ((opt = getopt(argc, argv, "Gm:s:t:")) != EOF) {
120 maxevent = atol(optarg);
126 token = atol(optarg);
132 if (Gflag && token != DM_NO_TOKEN)
134 if (optind + (Gflag ? 0 : 1) > argc)
137 if (dm_init_service(&name) == -1) {
138 fprintf(stderr, "Can't initialize the DMAPI\n");
141 if (sid == DM_NO_SESSION)
142 find_test_session(&sid);
146 /* Get the file or filesystem's handle. */
149 fshanp = DM_GLOBAL_HANP;
150 fshlen = DM_GLOBAL_HLEN;
156 object = argv[optind++];
158 if (opaque_to_handle(object, &hanp, &hlen)) {
159 fprintf(stderr, "can't get handle from %s\n", object);
162 if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
163 fprintf(stderr, "can't get filesystem handle from %s\n",
167 dm_handle_free(hanp, hlen);
170 for (; optind < argc; optind++) {
171 dm_eventtype_t event;
173 event = ev_name_to_value(argv[optind]);
174 if (event == DM_EVENT_INVALID) {
175 fprintf(stderr, "invalid event %s\n", argv[optind]);
178 DMEV_SET(event, eventset);
181 if (dm_set_disp(sid, fshanp, fshlen, token, &eventset, maxevent)) {
182 fprintf(stderr, "dm_set_disp failed, %s\n",
188 dm_handle_free(fshanp, fshlen);