|
/* |
|
* Samba VFS module to map Windows share modes to AIX open(2) flags |
|
* |
|
* Copyright (C) SATOH Fumiyasu @ OSS Technology, Inc., Japan, 2011 |
|
* |
|
* This program is free software; you can redistribute it and/or modify |
|
* it under the terms of the GNU General Public License as published by |
|
* the Free Software Foundation; either version 3 of the License, or |
|
* (at your option) any later version. |
|
* |
|
* This program is distributed in the hope that it will be useful, |
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
* GNU General Public License for more details. |
|
* |
|
* You should have received a copy of the GNU General Public License |
|
* along with this program; if not, see <http://www.gnu.org/licenses/>. |
|
*/ |
|
|
|
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING */ |
|
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING */ |
|
/* WARNING * This VFS module is still work in progress. * WARNING */ |
|
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING */ |
|
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING */ |
|
|
|
#include "includes.h" |
|
|
|
#if SMB_VFS_INTERFACE_VERSION >= 28 /* Samba 3.6.0 and later */ |
|
# include "smbd/smbd.h" |
|
# include "system/filesys.h" |
|
#endif |
|
|
|
static int vfs_sharemodes_aix_debug_level = DBGC_VFS; |
|
|
|
#undef DBGC_CLASS |
|
#define DBGC_CLASS vfs_sharemodes_aix_debug_level |
|
|
|
static int smb_sharemodes_aix_open(vfs_handle_struct *handle, |
|
struct smb_filename *smb_fname, |
|
files_struct *fsp, int flags, mode_t mode) |
|
{ |
|
int result; |
|
|
|
if (fsp->share_access & FILE_SHARE_WRITE) { |
|
DEBUG(5, ("Map FILE_SHARE_WRITE to O_NSHARE\n")); |
|
flags |= O_NSHARE; |
|
} else if (fsp->share_access & FILE_SHARE_READ) { |
|
DEBUG(5, ("Map FILE_SHARE_WRITE to O_RSHARE\n")); |
|
flags |= O_RSHARE; |
|
} |
|
|
|
result = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode); |
|
|
|
return result; |
|
} |
|
|
|
static struct vfs_fn_pointers vfs_sharemodes_aix_fns = { |
|
#if SMB_VFS_INTERFACE_VERSION >= 28 /* Samba 3.6.0 and later */ |
|
.open_fn = smb_sharemodes_aix_open, |
|
#else |
|
.open = smb_sharemodes_aix_open, |
|
#endif |
|
}; |
|
|
|
NTSTATUS vfs_sharemodes_aix_init(void) |
|
{ |
|
NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION, |
|
"sharemodes_aix", &vfs_sharemodes_aix_fns); |
|
|
|
if (!NT_STATUS_IS_OK(ret)) |
|
return ret; |
|
|
|
vfs_sharemodes_aix_debug_level = debug_add_class("sharemodes_aix"); |
|
if (vfs_sharemodes_aix_debug_level == -1) { |
|
vfs_sharemodes_aix_debug_level = DBGC_VFS; |
|
DEBUG(0, ("vfs_sharemodes_aix: Couldn't register custom debugging " |
|
"class!\n")); |
|
} else { |
|
DEBUG(10, ("vfs_sharemodes_aix: Debug class number of " |
|
"'sharemodes_aix': %d\n", vfs_sharemodes_aix_debug_level)); |
|
} |
|
|
|
return ret; |
|
} |