let the user specify a token
authorDean Roehrich <roehrich@sgi.com>
Mon, 15 Apr 2002 20:07:13 +0000 (20:07 +0000)
committerDean Roehrich <roehrich@sgi.com>
Mon, 15 Apr 2002 20:07:13 +0000 (20:07 +0000)
dmapi/src/common/cmd/set_return_on_destroy.c
dmapi/src/suite1/cmd/print_event.c
dmapi/src/suite1/cmd/set_eventlist.c

index 1f9730e48434c49e71927a2461285bd07ef88922..c63ccc53057bab0cb450926fa3dc37c1fc54a076 100644 (file)
@@ -40,7 +40,7 @@
 Test program used to test the DMAPI function dm_set_return_on_destroy().  The
 command line is:
 
-       set_return_on_destroy [-F] [-s sid] {pathname|fshandle} [attr]
+       set_return_on_destroy [-F] [-s sid] [-t token] {pathname|fshandle} [attr]
 
 where pathname is the name of a file which resides in the filesystem of
 interest.  attr is the name of the DMAPI attribute; if none is specified,
@@ -63,7 +63,7 @@ char  *Progname;
 static void
 usage(void)
 {
-       fprintf(stderr, "usage:\t%s [-F] [-s sid] {pathname|fshandle} [attr]\n", Progname);
+       fprintf(stderr, "usage:\t%s [-F] [-s sid] [-t token] {pathname|fshandle} [attr]\n", Progname);
        exit(1);
 }
 
@@ -74,6 +74,7 @@ main(
        char    **argv)
 {
        dm_sessid_t     sid = DM_NO_SESSION;
+       dm_token_t      token = DM_NO_TOKEN;
        char            *pathname;
        dm_attrname_t   *attrnamep = NULL;
        dm_boolean_t    enable = DM_FALSE;
@@ -91,11 +92,14 @@ main(
 
        /* Crack and validate the command line options. */
 
-       while ((opt = getopt(argc, argv, "Fs:")) != EOF) {
+       while ((opt = getopt(argc, argv, "Fs:t:")) != EOF) {
                switch (opt) {
                case 's':
                        sid = atol(optarg);
                        break;
+               case 't':
+                       token = atol(optarg);
+                       break;
                case 'F':
                        Fflag++;
                        break;
@@ -139,7 +143,7 @@ main(
                hlen = fshlen;
        }
 
-       if (dm_set_return_on_destroy(sid, hanp, hlen, DM_NO_TOKEN,
+       if (dm_set_return_on_destroy(sid, hanp, hlen, token,
            attrnamep, enable)) {
                fprintf(stderr, "dm_set_return_on_destroy failed, %s\n",
                        strerror(errno));
index 16ec97058da32c287b7e3e85233845dd6a1c23e0..66e5970ce3ccce1d184a0f7dcf4455bf41be4081 100644 (file)
@@ -50,6 +50,7 @@ int            handle_message (dm_sessid_t, dm_eventmsg_t *);
 static int     format_mode(mode_t mode, char **ptr);
 static int     get_fs_handle   (char *, void **, size_t *);
 static int     set_disposition(dm_sessid_t, void *, size_t);
+static int     set_disp_global(dm_sessid_t);
 static int     set_events      (dm_sessid_t, void *, size_t);
 static int     clear_events    (dm_sessid_t, void *, size_t);
 int             finish_responding(dm_sessid_t);
@@ -67,14 +68,14 @@ int          Verbose;
 dm_sessid_t     sid = 0;
 dm_sessid_t     oldsid = 0;
 char            *fsname;
-
+int             register_new_mnts = 0;
 
 void
 usage(
       char *prog)
 {
   fprintf(stderr, "Usage: %s ", prog);
-  fprintf(stderr, " <-S oldsid> <-v verbose> ");
+  fprintf(stderr, " <-S oldsid> <-v> <-s sleep> <-R> ");
   fprintf(stderr, "filesystem \n");
 }
 
@@ -94,11 +95,14 @@ main(
 /*  Progname  = argv[0];*/ Progname = "print_event";
   fsname  = NULL;
 
-  while ((c = getopt(argc, argv, "vs:S:")) != EOF) {
+  while ((c = getopt(argc, argv, "vs:S:R")) != EOF) {
     switch (c) {
     case 's':
       Sleep = atoi(optarg);
       break;
+    case 'R':
+      register_new_mnts = 1;
+      break;
     case 'S':
       oldsid = atoi(optarg);
       break;
@@ -149,6 +153,9 @@ main(
    * Set the event disposition so that our session will receive
    * all the events for the given file system
    */
+  error = set_disp_global(sid);
+  if (error)
+    goto cleanup;
   error = set_disposition(sid, fs_hanp, fs_hlen);
   if (error)
     goto cleanup;
@@ -517,12 +524,22 @@ handle_message(
                printf(HDR, "mount", msg->ev_token, msg->ev_sequence);
 #if    !VERITAS_21
                msg_me = DM_GET_VALUE(msg, ev_data, dm_mount_event_t *);
+               hanp1 = DM_GET_VALUE(msg_me, me_handle1, void *);
+               hlen1 = DM_GET_LEN(msg_me, me_handle1);
+               
                print_one_mount_event(msg_me);
+
+               if (register_new_mnts) {
+                       if (set_disposition(sid, hanp1, hlen1) == 0)
+                               set_events(sid, hanp1, hlen1);
+               }
+
 #else  /* VERITAS_21 */
                msg_ne = DM_GET_VALUE(msg, ev_data, dm_namesp_event_t *);
                print_one_mount_event(msg_ne);
 #endif /* VERITAS_21 */
-  }
+
+       }
 
   /***** NAMESPACE EVENTS *****/
 
@@ -829,16 +846,14 @@ get_fs_handle(
 */
 
 static int
-set_disposition(
-       dm_sessid_t      sid,
-       void            *fs_hanp,
-       size_t           fs_hlen)
+set_disp_global(
+       dm_sessid_t     sid)
 {
        dm_eventset_t   eventlist;
 
        if (Verbose) {
                err_msg("Setting event disposition to send all "
-                       "events to this session\n");
+                       "mount events to this session\n");
        }
 
        /* DM_EVENT_MOUNT must be sent in a separate request using the global
@@ -856,6 +871,23 @@ set_disposition(
                return(1);
        }
 
+       return(0);
+}
+
+
+static int
+set_disposition(
+       dm_sessid_t      sid,
+       void            *fs_hanp,
+       size_t           fs_hlen)
+{
+       dm_eventset_t   eventlist;
+
+       if (Verbose) {
+               err_msg("Setting event disposition to send all "
+                       "events to this session\n");
+       }
+
        DMEV_ZERO(eventlist);
 
        /* File system administration events. */
index 02572aca5d61ec47a01549db3dbce3a6438e5b06..d9e6abd4688f7c3a5c4cec8b17dbf048fe0b185f 100644 (file)
@@ -72,7 +72,7 @@ usage(void)
 {
        int     i;
 
-       fprintf(stderr, "usage:\t%s [-F] [-m max] [-s sid] "
+       fprintf(stderr, "usage:\t%s [-F] [-m max] [-s sid] [-t token] "
                "{pathname|handle} event [...]\n", Progname);
        fprintf(stderr, "possible events are:\n");
        for (i = 0; i < ev_namecnt; i++) {