smb_fem.c revision 54207fd2e1e7ed01d0416da8cf296dbef920fbfc
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
* Copyright 2015 Joyent, Inc.
*/
#include <smbsrv/smb_kproto.h>
#include <smbsrv/smb_fsops.h>
#include <sys/vfs_opreg.h>
extern caller_context_t smb_ct;
/*
* Declarations for FCN (file change notification) FEM monitors
*/
caller_context_t *, int);
cred_t *, caller_context_t *, int);
caller_context_t *, int);
caller_context_t *, int);
char *, cred_t *, caller_context_t *, int);
static const fs_operation_def_t smb_fcn_tmpl[] = {
};
/*
* Declarations for oplock FEM monitors
*/
struct caller_context *);
struct caller_context *);
struct caller_context *);
caller_context_t *);
caller_context_t *);
static const fs_operation_def_t smb_oplock_tmpl[] = {
};
/*
* smb_fem_init
*
* This function is not multi-thread safe. The caller must make sure only one
* thread makes the call.
*/
int
smb_fem_init(void)
{
int rc = 0;
if (smb_fem_initialized)
return (0);
if (rc)
return (rc);
if (rc) {
smb_fcn_ops = NULL;
return (rc);
}
return (0);
}
/*
* smb_fem_fini
*
* This function is not multi-thread safe. The caller must make sure only one
* thread makes the call.
*/
void
smb_fem_fini(void)
{
if (!smb_fem_initialized)
return;
if (smb_fcn_ops != NULL) {
smb_fcn_ops = NULL;
}
if (smb_oplock_ops != NULL) {
}
}
int
{
int rc;
if (smb_fcn_ops == NULL)
return (ENOSYS);
return (rc);
}
void
{
if (smb_fcn_ops == NULL)
return;
}
int
{
int rc;
if (smb_oplock_ops == NULL)
return (ENOSYS);
return (rc);
}
void
{
if (smb_oplock_ops == NULL)
return;
}
/*
* FEM FCN monitors
*
* The FCN monitors intercept the respective VOP_* call regardless
* of whether the call originates from CIFS, NFS, or a local process.
*/
/*
* smb_fem_fcn_create()
*
* This monitor will catch only changes to VREG files and not to extended
* attribute files. This is fine because, for CIFS files, stream creates
* should not trigger any file change notification on the VDIR directory
* being monitored. Creates of any other kind of extended attribute in
* the directory will also not trigger any file change notification on the
* VDIR directory being monitored.
*/
static int
char *name,
int mode,
int flag,
{
int error;
return (error);
}
/*
* smb_fem_fcn_remove()
*
* This monitor will catch only changes to VREG files and to not extended
* attribute files. This is fine because, for CIFS files, stream deletes
* should not trigger any file change notification on the VDIR directory
* being monitored. Deletes of any other kind of extended attribute in
* the directory will also not trigger any file change notification on the
* VDIR directory being monitored.
*/
static int
char *name,
int flags)
{
int error;
return (error);
}
static int
char *snm,
char *tnm,
int flags)
{
int error;
/*
* Note that renames in the same directory are normally
* delivered in {old,new} pairs, and clients expect them
* in that order, if both events are delivered.
*/
}
return (error);
}
static int
char *name,
int flags,
{
int error;
return (error);
}
static int
char *name,
int flags)
{
int error;
return (error);
}
static int
char *tnm,
int flags)
{
int error;
return (error);
}
static int
char *linkname,
char *target,
int flags)
{
int error;
return (error);
}
/*
* FEM oplock monitors
*
* The monitors below are not intended to intercept CIFS calls.
* CIFS higher-level routines will break oplocks as needed prior
* to getting to the VFS layer.
*/
static int
int mode,
{
int rc = 0;
else
}
if (rc == 0)
return (rc);
}
/*
*/
static int
int ioflag,
{
int rc = 0;
}
if (rc == 0)
return (rc);
}
/*
*/
static int
int ioflag,
{
int rc = 0;
if (rc == 0)
return (rc);
}
static int
int flags,
{
int rc = 0;
if (rc == 0)
return (rc);
}
static int
int write_lock,
{
int rc = 0;
if (write_lock)
else
}
if (rc == 0)
return (rc);
}
static int
int cmd,
int flag,
{
int rc = 0;
if (rc == 0)
return (rc);
}
/*
* smb_fem_oplock_vnevent()
*
* To intercept NFS and local renames and removes in order to break any
* existing oplock prior to the operation.
*
* Note: Currently, this monitor is traversed only when an FS is mounted
* non-nbmand. (When the FS is mounted nbmand, share reservation checking
* will detect a share violation and return an error prior to the VOP layer
* being reached.) Thus, for nbmand NFS and local renames and removes,
* an existing oplock is never broken prior to share checking (contrary to
* how it is with intra-CIFS remove and rename requests).
*/
static int
char *name,
{
int rc = 0;
switch (vnevent) {
case VE_REMOVE:
case VE_PRE_RENAME_DEST:
case VE_RENAME_DEST:
break;
case VE_PRE_RENAME_SRC:
case VE_RENAME_SRC:
break;
default:
rc = 0;
break;
}
}
if (rc == 0)
return (rc);
}
static int
{
int rc;
} else {
}
return (rc);
}