Removed version number from file header.
[ira/wip.git] / source3 / smbd / notify_kernel.c
index c5172540483327212cc7bf38587b459c2eff1845..19ea41e19568b750c321bf91716cf9ed5cdbc02c 100644 (file)
@@ -1,7 +1,5 @@
-#define OLD_NTDOMAIN 1
 /*
-   Unix SMB/Netbios implementation.
-   Version 3.0
+   Unix SMB/CIFS implementation.
    change notify handling - linux kernel based implementation
    Copyright (C) Andrew Tridgell 2000
 
 
 #if HAVE_KERNEL_CHANGE_NOTIFY
 
-extern int DEBUGLEVEL;
-static VOLATILE SIG_ATOMIC_T fd_pending;
-static VOLATILE SIG_ATOMIC_T signals_received;
-static VOLATILE SIG_ATOMIC_T signals_processed;
+static VOLATILE sig_atomic_t fd_pending;
+static VOLATILE sig_atomic_t signals_received;
+static VOLATILE sig_atomic_t signals_processed;
 
 #ifndef DN_ACCESS
 #define DN_ACCESS       0x00000001      /* File accessed in directory */
@@ -63,10 +60,10 @@ struct change_data {
 /****************************************************************************
 the signal handler for change notify
 *****************************************************************************/
-static void signal_handler(int signal, siginfo_t *info, void *unused)
+static void signal_handler(int sig, siginfo_t *info, void *unused)
 {
-       BlockSignals(True, signal);
-       fd_pending = (SIG_ATOMIC_T)info->si_fd;
+       BlockSignals(True, sig);
+       fd_pending = (sig_atomic_t)info->si_fd;
        signals_received++;
        sys_select_signal();
 }
@@ -74,18 +71,23 @@ static void signal_handler(int signal, siginfo_t *info, void *unused)
 
 
 /****************************************************************************
-check if a change notify should be issued 
+ Check if a change notify should be issued.
+ time non-zero means timeout check (used for hash). Ignore this (async method
+ where time is zero will be used instead).
 *****************************************************************************/
 static BOOL kernel_check_notify(connection_struct *conn, uint16 vuid, char *path, uint32 flags, void *datap, time_t t)
 {
        struct change_data *data = (struct change_data *)datap;
 
+       if (t)
+               return False;
+
        if (data->directory_handle != (int)fd_pending) return False;
 
        DEBUG(3,("kernel change notify on %s fd=%d\n", path, (int)fd_pending));
 
        close((int)fd_pending);
-       fd_pending = (SIG_ATOMIC_T)-1;
+       fd_pending = (sig_atomic_t)-1;
        data->directory_handle = -1;
        signals_processed++;
        BlockSignals(False, RT_SIGNAL_NOTIFY);
@@ -101,13 +103,13 @@ static void kernel_remove_notify(void *datap)
        int fd = data->directory_handle;
        if (fd != -1) {
                if (fd == (int)fd_pending) {
-                       fd_pending = (SIG_ATOMIC_T)-1;
+                       fd_pending = (sig_atomic_t)-1;
                        signals_processed++;
                        BlockSignals(False, RT_SIGNAL_NOTIFY);
                }
                close(fd);
        }
-       free(data);
+       SAFE_FREE(data);
        DEBUG(3,("removed kernel change notify fd=%d\n", fd));
 }
 
@@ -121,7 +123,7 @@ static void *kernel_register_notify(connection_struct *conn, char *path, uint32
        int fd;
        unsigned long kernel_flags;
        
-       fd = dos_open(path, O_RDONLY, 0);
+       fd = conn->vfs_ops.open(conn, path, O_RDONLY, 0);
 
        if (fd == -1) {
                DEBUG(3,("Failed to open directory %s for change notify\n", path));
@@ -202,5 +204,3 @@ struct cnotify_fns *kernel_notify_init(void)
 #else
  void notify_kernel_dummy(void) {}
 #endif /* HAVE_KERNEL_CHANGE_NOTIFY */
-
-#undef OLD_NTDOMAIN