diff options
author | Jim McDonough <jmcd@samba.org> | 2007-02-14 02:37:14 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:17:56 -0500 |
commit | 9463211bf3b46ee408b88dfbf42d498e3839d4cc (patch) | |
tree | c476b1c1375aad177847114739c6edc6fe88e6f5 /source/smbd/oplock_linux.c | |
parent | bc77622134e606b8a643454493ba316f84312d52 (diff) | |
download | samba-9463211bf3b46ee408b88dfbf42d498e3839d4cc.tar.gz samba-9463211bf3b46ee408b88dfbf42d498e3839d4cc.tar.xz samba-9463211bf3b46ee408b88dfbf42d498e3839d4cc.zip |
r21324: Add linux setlease to the vfs layer. Next round, as Volker points out,
it should be abstracted a little higher up so other os'es can have an
entry, but it will take a bit more work. Thanks to Chetan Shringarpure
and Mathias Dietz.
I didn't increment the vfs number again because the kernel change notify
stuff hasn't been released yet anyway.
Diffstat (limited to 'source/smbd/oplock_linux.c')
-rw-r--r-- | source/smbd/oplock_linux.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/source/smbd/oplock_linux.c b/source/smbd/oplock_linux.c index 518283c587e..14db98cde6c 100644 --- a/source/smbd/oplock_linux.c +++ b/source/smbd/oplock_linux.c @@ -102,20 +102,29 @@ static void set_capability(unsigned capability) } } +/* + Call to set the kernel lease signal handler +*/ +int linux_set_lease_sighandler(int fd) +{ + if (fcntl(fd, F_SETSIG, RT_SIGNAL_LEASE) == -1) { + DEBUG(3,("Failed to set signal handler for kernel lease\n")); + return -1; + } + + return 0; +} + /**************************************************************************** Call SETLEASE. If we get EACCES then we try setting up the right capability and - try again + try again. + Use the SMB_VFS_LINUX_SETLEASE instead of this call directly. ****************************************************************************/ -static int linux_setlease(int fd, int leasetype) +int linux_setlease(int fd, int leasetype) { int ret; - if (fcntl(fd, F_SETSIG, RT_SIGNAL_LEASE) == -1) { - DEBUG(3,("Failed to set signal handler for kernel lease\n")); - return -1; - } - ret = fcntl(fd, F_SETLEASE, leasetype); if (ret == -1 && errno == EACCES) { set_capability(CAP_LEASE); @@ -156,7 +165,7 @@ static files_struct *linux_oplock_receive_message(fd_set *fds) static BOOL linux_set_kernel_oplock(files_struct *fsp, int oplock_type) { - if (linux_setlease(fsp->fh->fd, F_WRLCK) == -1) { + if ( SMB_VFS_LINUX_SETLEASE(fsp,fsp->fh->fd, F_WRLCK) == -1) { DEBUG(3,("linux_set_kernel_oplock: Refused oplock on file %s, " "fd = %d, dev = %x, inode = %.0f. (%s)\n", fsp->fsp_name, fsp->fh->fd, @@ -194,7 +203,7 @@ static void linux_release_kernel_oplock(files_struct *fsp) /* * Remove the kernel oplock on this file. */ - if (linux_setlease(fsp->fh->fd, F_UNLCK) == -1) { + if ( SMB_VFS_LINUX_SETLEASE(fsp,fsp->fh->fd, F_UNLCK) == -1) { if (DEBUGLVL(0)) { dbgtext("linux_release_kernel_oplock: Error when " "removing kernel oplock on file " ); |