s3: Add smbstatus -N to output the notify db
authorVolker Lendecke <vl@samba.org>
Wed, 4 Apr 2012 12:51:09 +0000 (14:51 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 17 Apr 2012 09:54:35 +0000 (11:54 +0200)
Autobuild-User: Volker Lendecke <vl@samba.org>
Autobuild-Date: Tue Apr 17 11:54:35 CEST 2012 on sn-devel-104

source3/Makefile.in
source3/utils/status.c
source3/wscript_build

index aef9750cbd465c8bf2e2ae9414b94c20aa3bffed..d48ce3706412d5769c351125735099dc0c514136 100644 (file)
@@ -1038,6 +1038,7 @@ SWAT_OBJ = $(SWAT_OBJ1) $(PARAM_OBJ) $(PRINTING_OBJ) $(PRINTBASE_OBJ) $(LIBSMB_O
 
 STATUS_OBJ = utils/status.o utils/status_profile.o \
             $(LOCKING_OBJ) $(PARAM_OBJ) \
+            smbd/notify_internal.o librpc/gen_ndr/ndr_notify.o \
              $(PROFILE_OBJ) $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) \
             $(LIBSMB_ERR_OBJ) $(FNAME_UTIL_OBJ)
 
index 0755f9fdf27e5e3ca3f39678ed136d80c1d60a1c..95b279ea3b2595d0afcabf746ff99fd51863180d 100644 (file)
@@ -40,6 +40,8 @@
 #include "locking/proto.h"
 #include "messages.h"
 #include "librpc/gen_ndr/open_files.h"
+#include "smbd/proto.h"
+#include "librpc/gen_ndr/notify.h"
 
 #define SMB_MAXPIDS            2048
 static uid_t           Ucrit_uid = 0;               /* added by OH */
@@ -287,13 +289,36 @@ static int traverse_sessionid(const char *key, struct sessionid *session,
 }
 
 
+static void print_notify_recs(const char *path,
+                             struct notify_db_entry *entries,
+                             size_t num_entries,
+                             time_t deleted_time, void *private_data)
+{
+       size_t i;
+       d_printf("%s\n", path);
+
+       if (num_entries == 0) {
+               d_printf("deleted %s\n", time_to_asc(deleted_time));
+       }
 
+       for (i=0; i<num_entries; i++) {
+               struct notify_db_entry *e = &entries[i];
+               char *str;
+
+               str = server_id_str(talloc_tos(), &e->server);
+               printf("%s %x %x\n", str, (unsigned)e->filter,
+                      (unsigned)e->subdir_filter);
+               TALLOC_FREE(str);
+       }
+       printf("\n");
+}
 
  int main(int argc, char *argv[])
 {
        int c;
        int profile_only = 0;
        bool show_processes, show_locks, show_shares;
+       bool show_notify = false;
        poptContext pc;
        struct poptOption long_options[] = {
                POPT_AUTOHELP
@@ -301,6 +326,7 @@ static int traverse_sessionid(const char *key, struct sessionid *session,
                {"verbose",     'v', POPT_ARG_NONE,     NULL, 'v', "Be verbose" },
                {"locks",       'L', POPT_ARG_NONE,     NULL, 'L', "Show locks only" },
                {"shares",      'S', POPT_ARG_NONE,     NULL, 'S', "Show shares only" },
+               {"notify",      'N', POPT_ARG_NONE,     NULL, 'N', "Show notifies" },
                {"user",        'u', POPT_ARG_STRING,   &username, 'u', "Switch to user" },
                {"brief",       'b', POPT_ARG_NONE,     NULL, 'b', "Be brief" },
                {"profile",     'P', POPT_ARG_NONE, NULL, 'P', "Do profiling" },
@@ -342,6 +368,9 @@ static int traverse_sessionid(const char *key, struct sessionid *session,
                case 'S':
                        shares_only = true;
                        break;
+               case 'N':
+                       show_notify = true;
+                       break;
                case 'b':
                        brief = true;
                        break;
@@ -487,6 +516,17 @@ static int traverse_sessionid(const char *key, struct sessionid *session,
                locking_end();
        }
 
+       if (show_notify) {
+               struct notify_context *n;
+
+               n = notify_init(talloc_tos(), NULL, NULL);
+               if (n == NULL) {
+                       goto done;
+               }
+               notify_walk(n, print_notify_recs, NULL);
+               TALLOC_FREE(n);
+       }
+
 done:
        TALLOC_FREE(frame);
        return ret;
index 652743c86fb586955976bc1025c31544de47c34c..d68dd5cdb20fd07c2121e592551c5d7f4c500069 100755 (executable)
@@ -427,7 +427,7 @@ SWAT_SRC1 = '''web/cgi.c web/diagnose.c web/startstop.c web/statuspage.c
 
 SWAT_SRC = '''${SWAT_SRC1}'''
 
-STATUS_SRC = '''utils/status.c utils/status_profile.c'''
+STATUS_SRC = '''utils/status.c utils/status_profile.c smbd/notify_internal.c'''
 
 SMBCONTROL_SRC = '''utils/smbcontrol.c'''