| 1 | /*
|
|---|
| 2 | Unix SMB/CIFS implementation.
|
|---|
| 3 | Make sure offline->online changes are propagated by notifies
|
|---|
| 4 |
|
|---|
| 5 | This module must come before aio_fork in the chain, because
|
|---|
| 6 | aio_fork (correcly!) does not propagate the aio calls further
|
|---|
| 7 |
|
|---|
| 8 | Copyright (C) Volker Lendecke 2011
|
|---|
| 9 |
|
|---|
| 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.
|
|---|
| 14 |
|
|---|
| 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.
|
|---|
| 19 |
|
|---|
| 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/>.
|
|---|
| 22 | */
|
|---|
| 23 |
|
|---|
| 24 | #include "includes.h"
|
|---|
| 25 | #include "smbd/smbd.h"
|
|---|
| 26 | #include "librpc/gen_ndr/ndr_xattr.h"
|
|---|
| 27 | #include "include/smbprofile.h"
|
|---|
| 28 |
|
|---|
| 29 | #undef DBGC_CLASS
|
|---|
| 30 | #define DBGC_CLASS DBGC_VFS
|
|---|
| 31 |
|
|---|
| 32 | #include <gpfs_gpl.h>
|
|---|
| 33 | #include "nfs4_acls.h"
|
|---|
| 34 | #include "vfs_gpfs.h"
|
|---|
| 35 |
|
|---|
| 36 | static ssize_t vfs_gpfs_hsm_notify_pread(vfs_handle_struct *handle, files_struct *fsp,
|
|---|
| 37 | void *data, size_t n, SMB_OFF_T offset)
|
|---|
| 38 | {
|
|---|
| 39 | ssize_t ret;
|
|---|
| 40 |
|
|---|
| 41 | ret = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
|
|---|
| 42 |
|
|---|
| 43 | DEBUG(10, ("vfs_private = %x\n",
|
|---|
| 44 | (unsigned int)fsp->fsp_name->st.vfs_private));
|
|---|
| 45 |
|
|---|
| 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);
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | return ret;
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 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, SMB_OFF_T offset)
|
|---|
| 60 | {
|
|---|
| 61 | ssize_t ret;
|
|---|
| 62 |
|
|---|
| 63 | ret = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
|
|---|
| 64 |
|
|---|
| 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);
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | return ret;
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 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)
|
|---|
| 79 | {
|
|---|
| 80 | ssize_t ret;
|
|---|
| 81 |
|
|---|
| 82 | ret = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
|
|---|
| 83 |
|
|---|
| 84 | DEBUG(10, ("vfs_gpfs_hsm_notify_aio_return: vfs_private = %x\n",
|
|---|
| 85 | (unsigned int)fsp->fsp_name->st.vfs_private));
|
|---|
| 86 |
|
|---|
| 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);
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | return ret;
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 | static struct vfs_fn_pointers vfs_gpfs_hsm_notify_fns = {
|
|---|
| 100 | .pread = vfs_gpfs_hsm_notify_pread,
|
|---|
| 101 | .pwrite = vfs_gpfs_hsm_notify_pwrite,
|
|---|
| 102 | .aio_return_fn = vfs_gpfs_hsm_notify_aio_return
|
|---|
| 103 | };
|
|---|
| 104 |
|
|---|
| 105 | NTSTATUS vfs_gpfs_hsm_notify_init(void);
|
|---|
| 106 | NTSTATUS vfs_gpfs_hsm_notify_init(void)
|
|---|
| 107 | {
|
|---|
| 108 | return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "gpfs_hsm_notify",
|
|---|
| 109 | &vfs_gpfs_hsm_notify_fns);
|
|---|
| 110 | }
|
|---|