s4-torture: verify #8373 and add ndr nbt tests for LOGON_PRIMARY_QUERY nbt_netlogon_r...
[Samba/wip.git] / source3 / modules / vfs_gpfs_hsm_notify.c
blobd53363c4604183178a2c2715ff95cc2c8e5ed80a
1 /*
2 Unix SMB/CIFS implementation.
3 Make sure offline->online changes are propagated by notifies
5 This module must come before aio_fork in the chain, because
6 aio_fork (correcly!) does not propagate the aio calls further
8 Copyright (C) Volker Lendecke 2011
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "includes.h"
25 #include "smbd/smbd.h"
26 #include "librpc/gen_ndr/ndr_xattr.h"
27 #include "include/smbprofile.h"
29 #undef DBGC_CLASS
30 #define DBGC_CLASS DBGC_VFS
32 #include <gpfs_gpl.h>
33 #include "nfs4_acls.h"
34 #include "vfs_gpfs.h"
36 static ssize_t vfs_gpfs_hsm_notify_pread(vfs_handle_struct *handle, files_struct *fsp,
37 void *data, size_t n, off_t offset)
39 ssize_t ret;
41 ret = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
43 DEBUG(10, ("vfs_private = %x\n",
44 (unsigned int)fsp->fsp_name->st.vfs_private));
46 if ((ret != -1) &&
47 ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0)) {
48 fsp->fsp_name->st.vfs_private &= ~GPFS_WINATTR_OFFLINE;
49 notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED,
50 FILE_NOTIFY_CHANGE_ATTRIBUTES,
51 fsp->fsp_name->base_name);
54 return ret;
57 static ssize_t vfs_gpfs_hsm_notify_pwrite(struct vfs_handle_struct *handle,
58 struct files_struct *fsp,
59 const void *data, size_t n, off_t offset)
61 ssize_t ret;
63 ret = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
65 if ((ret != -1) &&
66 ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0)) {
67 fsp->fsp_name->st.vfs_private &= ~GPFS_WINATTR_OFFLINE;
68 notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED,
69 FILE_NOTIFY_CHANGE_ATTRIBUTES,
70 fsp->fsp_name->base_name);
73 return ret;
76 static ssize_t vfs_gpfs_hsm_notify_aio_return(struct vfs_handle_struct *handle,
77 struct files_struct *fsp,
78 SMB_STRUCT_AIOCB *aiocb)
80 ssize_t ret;
82 ret = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
84 DEBUG(10, ("vfs_gpfs_hsm_notify_aio_return: vfs_private = %x\n",
85 (unsigned int)fsp->fsp_name->st.vfs_private));
87 if ((ret != -1) &&
88 ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0)) {
89 fsp->fsp_name->st.vfs_private &= ~GPFS_WINATTR_OFFLINE;
90 DEBUG(10, ("sending notify\n"));
91 notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED,
92 FILE_NOTIFY_CHANGE_ATTRIBUTES,
93 fsp->fsp_name->base_name);
96 return ret;
99 static struct vfs_fn_pointers vfs_gpfs_hsm_notify_fns = {
100 .pread_fn = vfs_gpfs_hsm_notify_pread,
101 .pwrite_fn = vfs_gpfs_hsm_notify_pwrite,
102 .aio_return_fn = vfs_gpfs_hsm_notify_aio_return
105 NTSTATUS vfs_gpfs_hsm_notify_init(void);
106 NTSTATUS vfs_gpfs_hsm_notify_init(void)
108 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "gpfs_hsm_notify",
109 &vfs_gpfs_hsm_notify_fns);