diff options
author | Jeremy Allison <jra@samba.org> | 1998-09-25 23:40:49 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1998-09-25 23:40:49 +0000 |
commit | 5f7ee360567a6b4e1a6f43ff01da057d2998fef8 (patch) | |
tree | b8528e7d3bc30fc7b2ab191bc9235be604daf98e /source3/smbd/open.c | |
parent | 14f9495e4c5ff98cd15bf18d7fbc63c1b491cfea (diff) | |
download | samba-5f7ee360567a6b4e1a6f43ff01da057d2998fef8.tar.gz samba-5f7ee360567a6b4e1a6f43ff01da057d2998fef8.tar.bz2 samba-5f7ee360567a6b4e1a6f43ff01da057d2998fef8.zip |
Makefile.in: Fixed bug with continuation line causing proto to fail.
Added $(PROGS) $(SPROGS) as targets for make clean.
acconfig.h: Added HAVE_IRIX_SPECIFIC_CAPABILITIES.
configure.in: Added sys/capability.h header check.
Added function checks for srandom random srand rand.
Added HAVE_IRIX_SPECIFIC_CAPABILITIES test.
includes.h: Added #include <sys/capability.h>.
ntdomain.h: Moved struct acct_info into here from smb.h
smb.h: Added KERNEL_OPLOCK_CAPABILITY define.
Moved enum action_type into rpcclient.h
Moved struct cli_state into client.h
Moved struct nt_client_info, struct tar_client_info, struct client_info
into rpcclient.h
lib/genrand.c: Changed to use sys_random() & friends.
lib/smbrun.c: Lose capabilities after fork.
lib/system.c: Added set_process_capability(), set_inherited_process_capability()
sys_random(), sys_srandom().
lib/util.c: Added Ander's EFBIG lock check to fcntl_lock for 64 bit access to an
32 bit mounted NFS filesystem.
nmbd/nmbd.c: Changed to use sys_random() & friends.
nmbd/nmbd_browsesync.c: Changed to use sys_random() & friends.
passdb/ldap.c: Missed one pdb_encode_acct_ctrl call.
passdb/passdb.c: Changed to Ander's code for ' ' characters.
passdb/smbpass.c: Added Ander's code to reset ACB_PWNOTREQ.
script/mkproto.awk: Added 'long' to prototypes.
smbd/chgpasswd.c: Lose capabilities after fork.
smbd/open.c: Do the mmap *after* the kernel oplock.
smbd/oplock.c: Removed stub code from kernel oplock path.
Added set_process_capability(), set_inherited_process_capability() calls.
smbd/reply.c: Initialize count = 0, offset = 0.
smbd/server.c: Added set_process_capability(), set_inherited_process_capability() calls.
tests/summary.c: Ensure we have RANDOM or RAND.
utils/smbpasswd.c: Added Ander's code to reset ACB_PWNOTREQ.
utils/torture.c: Changed to use sys_random() & friends.
Jeremy.
(This used to be commit e8be306f23963ac00b1a383ebe0cc1421529fb02)
Diffstat (limited to 'source3/smbd/open.c')
-rw-r--r-- | source3/smbd/open.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 64f28ddfe2..2b2f0f0524 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -535,18 +535,30 @@ static void open_file(files_struct *fsp,connection_struct *conn, conn->num_files_open)); } +} +/**************************************************************************** + If it's a read-only file, and we were compiled with mmap enabled, + try and mmap the file. This is split out from open_file() above + as mmap'ing the file can cause the kernel reference count to + be incremented, which can cause kernel oplocks to be refused. + Splitting this call off allows the kernel oplock to be granted, then + the file mmap'ed. +****************************************************************************/ + +static void mmap_open_file(files_struct *fsp) +{ #if WITH_MMAP /* mmap it if read-only */ if (!fsp->can_write) { - fsp->mmap_size = file_size(fname); + fsp->mmap_size = file_size(fsp->fsp_name); if (fsp->mmap_size < MAX_MMAP_SIZE) { fsp->mmap_ptr = (char *)mmap(NULL,fsp->mmap_size, PROT_READ,MAP_SHARED,fsp->fd_ptr->fd,0); if (fsp->mmap_ptr == (char *)-1 || !fsp->mmap_ptr) { DEBUG(3,("Failed to mmap() %s - %s\n", - fname,strerror(errno))); + fsp->fsp_name,strerror(errno))); fsp->mmap_ptr = NULL; } } @@ -554,7 +566,6 @@ static void open_file(files_struct *fsp,connection_struct *conn, #endif } - /**************************************************************************** C. Hoch 11/22/95 Helper for open_file_shared. @@ -938,6 +949,13 @@ dev = %x, inode = %.0f\n", old_shares[i].op_type, fname, (unsigned int)dev, (dou if ((flags2&O_TRUNC) && file_existed) truncate_unless_locked(fsp,conn,token,&share_locked); + + /* + * Attempt to mmap a read only file. + * Moved until after a kernel oplock may + * be granted due to reference count issues. JRA. + */ + mmap_open_file(fsp); } if (share_locked && lp_share_modes(SNUM(conn))) |