summaryrefslogtreecommitdiff
path: root/source3/smbd/fileio.c
AgeCommit message (Collapse)AuthorFilesLines
2010-09-22Fix bug #7693 - smbd changing mode of files on renameJeremy Allison1-6/+7
When using "map archive", don't change the archive bit on renames or writes with UNIX extensions turned on. Jeremy.
2010-07-29s3: Do the ftruncate write cache optimization in one placeVolker Lendecke1-0/+31
Instead of hand-tuning all the cases that are below this piece of code, this is a general case that we can catch upfront.
2010-07-29Revert "s3: Avoid pwrite calls for the 1-byte writes with zero content"Volker Lendecke1-50/+4
This reverts commit 6763730304627a58139450fd3e03a0ce48e31bb9.
2010-07-27s3-smbd: Migrated to new spoolss functions for printing.Simo Sorce1-11/+7
Signed-off-by: Jim McDonough <jmcd@samba.org>
2010-07-19s3: Avoid pwrite calls for the 1-byte writes with zero contentVolker Lendecke1-4/+50
When a write cache is empty and we write one 0, there is no point in actually writing into the write cache, which would trigger a potentially superfluous write cache flush. We can rely on posix semantics to give us 0's when subsequent read calls want to read from file areas not written yet. Jeremy, please check!
2010-07-09s3: Optimize the write cache for sequential writesVolker Lendecke1-0/+20
In case of the one-byte allocating writes we don't work work optimally because we start the write cache at the current offset. This patch tries to avoid this case.
2010-04-30smbd: move printfile_offset() within write_file()Simo Sorce1-0/+3
2010-04-23s3-smbd: group print relate data in own structureSimo Sorce1-3/+4
2009-11-16Don't overwrite a dynamic pointer with the address of a stackJeremy Allison1-8/+6
variable. Jeremy.
2009-11-05Got the logic simplification worked out so we still passJeremy Allison1-4/+4
BASE-DELAYWRITE and also RAW-CLOSE. Jeremy.
2009-11-05Get closer to an accurate model of Windows timestamp changes.Jeremy Allison1-8/+30
"Normal" non truncate writes always cause the timestamp to be set on close. Once a close is done on a handle this can reset the sticky write time to current time also. Updated smbtorture4 confirms this. Jeremy.
2009-07-20s3: Change fsp->fsp_name to be an smb_filename struct!Tim Prouty1-29/+28
2009-07-10Remove reply_unixerror() - no longer needed. Should make Metze's refactoring ↵Jeremy Allison1-0/+1
a lot easier. Jeremy.
2009-07-08s3: Plumb smb_filename through dos_mode() and related funtionsTim Prouty1-18/+16
2009-07-06s3: Plumb smb_filename around SMB_VFS_CHFLAGSTim Prouty1-4/+16
SMB_VFS_CHFLAGS isn't actually getting the smb_filename struct for now since it only operates on the basefile. This is the strategy for all path-based operations that will never actually operate on a stream. By clarifying the meaning of path based operations that don't take an smb_filename struct, modules that implement streams such as vfs_onefs no longer need to implement SMB_VFS_CHFLAGS to ensure it's only called on the base_name.
2009-07-01Ensure we don't use delayed writes on POSIX opened files.Jeremy Allison1-0/+10
Don't remove pending writetime changes if no time changes are sent in UNIX_BASIC infolevel. Jeremy
2009-06-24s3: Plumb smb_filename through SMB_VFS_STAT and SMB_VFS_LSTATTim Prouty1-1/+1
This patch introduces two new temporary helper functions vfs_stat_smb_fname and vfs_lstat_smb_fname. They basically allowed me to call the new smb_filename version of stat, while avoiding plumbing it through callers that are still too inconvenient. As the conversion moves along, I will be able to remove callers of this, with the goal being to remove all callers. There was also a bug in create_synthetic_smb_fname_split (also a temporary utility function) that caused it to incorrectly handle filenames with ':'s in them when in posix mode. This is now fixed.
2009-05-26Introduce "struct stat_ex" as a replacement for SMB_STRUCT_STATVolker Lendecke1-1/+1
This patch introduces struct stat_ex { dev_t st_ex_dev; ino_t st_ex_ino; mode_t st_ex_mode; nlink_t st_ex_nlink; uid_t st_ex_uid; gid_t st_ex_gid; dev_t st_ex_rdev; off_t st_ex_size; struct timespec st_ex_atime; struct timespec st_ex_mtime; struct timespec st_ex_ctime; struct timespec st_ex_btime; /* birthtime */ blksize_t st_ex_blksize; blkcnt_t st_ex_blocks; }; typedef struct stat_ex SMB_STRUCT_STAT; It is really large because due to the friendly libc headers playing macro tricks with fields like st_ino, so I renamed them to st_ex_xxx. Why this change? To support birthtime, we already have quite a few #ifdef's at places where it does not really belong. With a stat struct that we control, we can consolidate the nanosecond timestamps and the birthtime deep in the VFS stat calls. At this moment it is triggered by a request to support the birthtime field for GPFS. GPFS does not extend the system level struct stat, but instead has a separate call that gets us the additional information beyond posix. Without being able to do that within the VFS stat calls, that support would have to be scattered around the main smbd code. It will very likely break all the onefs modules, but I think the changes will be reasonably easy to do.
2009-03-01Only copy sharename up from rap_to_pjobidVolker Lendecke1-2/+1
Why?? :-) Another one of the little micro-optimizations that I just came across: If you allocate a variable in a sub-block like the "fstring sharename" in write_file(), gcc even with -O3 will allocate this variable unconditionally on the stack at the beginning of the routine. So with eliminating this fstring we cut 256 bytes of stack in a very hot code path writing to a file. It might make us a bit more cache-friendly. This would probably not be worth a second look if it involved larger code changes, but this one was just too simple to let it pass :-)
2009-02-09s3 oplocks: Make the level2 oplock contention API more granularTim Prouty1-1/+3
This replaces release_level2_oplocks_on_change with contend_level2_oplock_begin/end in order to contend level2 oplocks throughout an operation rather than just at the begining. This is necessary for some kernel oplock implementations, and also lays the groundwork for better correctness in Samba's standard level2 oplock handling. The next step for non-kernel oplocks is to add additional state to the share mode lock struct that prevents any new opens from granting oplocks while a contending operation is in progress. All operations that contend level 2 oplocks are now correctly spanned except for aio and synchronous writes. The two write paths both have non-trivial error paths that need extra care to get right. RAW-OPLOCK and the rest of 'make test' are still passing with this change.
2009-01-08s3:smbd: move all globals and static variables in globals.[ch]Stefan Metzmacher1-3/+1
The goal is to move all this variables into a big context structure. metze
2009-01-05s3:events: change event_add_timed() prototype to match samba4Stefan Metzmacher1-2/+1
metze
2008-12-23Fix more asprintf warnings and some error path errors.Jeremy Allison1-3/+6
Jeremy.
2008-09-12Modify a comment to make things clearer.Jeremy Allison1-1/+3
Jeremy. (This used to be commit 9d55ca85ffc73e3fa5fb9895fbcb1ee22f4e320d)
2008-09-08smbd: some write time fixesStefan Metzmacher1-8/+7
- only the first non truncating write causes the write time update with 2 seconds delay. It's not enough to check for an existing update event as it will be NULL after the event was triggered. - SMBwrite truncates always update the write time unless the sticky write time is set. - SMBwrite truncates don't trigger a write time update on close. metze (This used to be commit 3d17089b6dc773303c8c553f3f6140e60e348fb7)
2008-09-05Write times code update.Jeremy Allison1-8/+39
Ok, here's the fix for the write times breakage with the new tests in S4 smbtorture. The key is keeping in the share mode struct the "old_file_time" as the real write time, set by all the write and allocation calls, and the "changed_write_time" as the "sticky" write time - set by the SET_FILE_TIME calls. We can set them independently (although I kept the optimization of not setting the "old_file_time" is a "changed_write_time" was already set, as we'll never see it. This allows us to update the write time immediately on the SMBwrite truncate case, SET_END_OF_FILE and SET_ALLOCATION_SIZE calls, whilst still have the 2 second delay on the "normal" SMBwrite, SMBwriteX calls. I think in a subsequent patch I'd like to change the name of these from "old_file_time" to "write_time" and "changed_write_time" to "sticky_write_time" to make this clearer. I think I also fixed a bug in Metze's original code in that once a write timestamp had been set from a "normal" SMBwriteX call the fsp->update_write_time_triggered variable was set and then never reset - thus meaning the write timestamp would never get updated again on subsequent SMBwriteX's. The new code checks the update_write_time_event event instead, and doesn't update is there's an event already scheduled. Metze especially, please check this over for your understanding. Jeremy. (This used to be commit 6f20585419046c4aca1f7d6c863cf79eb6ae53b0)
2008-04-07smbd: make it possible to change the write time delay for testingStefan Metzmacher1-1/+7
metze (This used to be commit df8c100c2b53575a0d425a2daf52e2d59904746a)
2008-04-07smbd: implement the strange write time update logicStefan Metzmacher1-22/+38
We now never call file_ntimes() directly, every update is done via smb_set_file_time(). This let samba3 pass the BASE-DELAYWRITE test. The write time is only updated 2 seconds after the first write() on any open handle to the current time (not the time of the first write). Each handle which had write requests updates the write time to the current time on close(). If the write time is set explicit via setfileinfo or setpathinfo the write time is visible directly and a following close on the same handle doesn't update the write time. metze (This used to be commit 2eab212ea2e1bfd8fa716c2c89b2c042f7ba12ea)
2008-01-07Remove redundant parameter fd from SMB_VFS_FTRUNCATE().Michael Adam1-1/+1
Michael (This used to be commit 2ad66050a0452b8e7e08b1e7a01efa00c72fd451)
2008-01-07Remove redundant parameter fd from SMB_VFS_FSTAT().Michael Adam1-2/+2
Michael (This used to be commit 0b86c420be94d295f6917a220b5d699f65b46711)
2008-01-07Remove redundant parameter fd from SMB_VFS_FSYNC().Michael Adam1-1/+1
Michael (This used to be commit 8f83c9a7b245dbfef28195f9a7f33047a8ba95a0)
2008-01-07Remove unneeded parameter fd from SMB_VFS_PREAD().Michael Adam1-2/+2
Michael (This used to be commit 73e28806ce87d829ea7c38ed3440020845bb13bf)
2007-10-31Note when we're setting change time, not write time, and sendJeremy Allison1-1/+2
message accordingly. Apart from not supporting create time we now pass the S4 RAW-NOTIFY torture. Jeremy. (This used to be commit 8a77f520fa03afa60eac2aaeab4babe7dd8db4f0)
2007-10-31Fix some cases where file_set_dosmode was being passedJeremy Allison1-2/+7
False instead of NULL. Fix more of the notifications to be correct for Samba4 RAW-NOTIFY torture (we had missed one when calling set_ea_dos_attribute(). Jeremy. (This used to be commit 39d265375cf55eedddef2c4faa65398df73d5ed2)
2007-10-30Add new parameter, "min receivefile size" (by default setJeremy Allison1-12/+29
to zero). If non-zero, writeX calls greater than this value will be left in the socket buffer for later handling with recvfile (or userspace equivalent). Definition of recvfile for your system is left as an exercise for the reader (I'm working on getting splice working :-). Jeremy. (This used to be commit 11c03b75ddbcb6e36b231bb40a1773d1c550621c)
2007-10-18RIP BOOL. Convert BOOL -> bool. I found a few interestingJeremy Allison1-5/+5
bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f)
2007-10-10r24164: Fix for write cache corruption bug reported by Jean-Francois ↵Jeremy Allison1-10/+20
Panisset <panisset@A52.com>. Awaiting confirmation from reporter. Jeremy. (This used to be commit 7bd65060bd965bd17a5d79639cf561b8b578cb36)
2007-10-10r23784: use the GPLv3 boilerplate as recommended by the FSF and the license textAndrew Tridgell1-2/+1
(This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07)
2007-10-10r23779: Change from v2 or later to v3 or later.Jeremy Allison1-1/+1
Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3)
2007-10-10r23773: One pstring a day...Volker Lendecke1-3/+5
(This used to be commit 0c3016d32b5277b901788b13aa7d3f4b647728f2)
2007-10-10r23508: Fix sync_file() to return NTSTATUS and return thisJeremy Allison1-4/+11
on failure in the write path. Jeremy. (This used to be commit cd3f7dbee809fb40194af0e7509142166e02b252)
2007-10-10r21714: Change the VFS interface to use struct timespecJeremy Allison1-2/+2
for utimes - change the call to ntimes. This preserves nsec timestamps we get from stat (if the system supports it) and only maps back down to usec or sec resolution on time set. Looks bigger than it is as I had to move lots of internal code from using time_t and struct utimebuf to struct timespec. Jeremy. (This used to be commit 8f3d530c5a748ea90f42ed8fbe68ae92178d4875)
2007-10-10r17220: If we're going to fail a write with an errno, makeJeremy Allison1-1/+1
sure we return -1. Jeremy. (This used to be commit 89b83237b03066785ca4bf3b9d120519bddeffad)
2007-10-10r9985: Move the all the strict sync logic into file_sync().James Peach1-3/+6
(This used to be commit cc680bbe22b8bfc5a1900f11c2cbaeca3a9f9922)
2007-10-10r8219: Merge the new open code from HEAD to 3.0. Haven't yet run the tortureJeremy Allison1-21/+21
tests on this as it's very late NY time (just wanted to get this work into the tree). I'll test this over the weekend.... Jerry - in looking at the difference between the two trees there seem to be some printing/ntprinting.c and registry changes we might want to examine to try keep in sync. Jeremy. (This used to be commit c7fe18761e2c753afbffd3a78abff46472a9b8eb)
2007-10-10r7882: Looks like a large patch - but what it actually does is make SambaJeremy Allison1-1/+1
safe for using our headers and linking with C++ modules. Stops us from using C++ reserved keywords in our code. Jeremy (This used to be commit 9506b8e145982b1160a2f0aee5c9b7a54980940a)
2007-10-10r6949: Back-port Volker's cache fix, plus my change.Jeremy Allison1-0/+38
Jeremy. (This used to be commit 27d43f6d36b3f6abc368ec6a00ef9803cb27c324)
2007-10-10r6890: Refactor printing interface to take offset into job. Fixes bugJeremy Allison1-3/+3
where large print jobs can have out-of-order offsets. Bug found by Arcady Chernyak <Arcady.Chernyak@efi.com> Jeremy. (This used to be commit 482f7e0e3706098b71aa0b31a134994acb1e9fcf)
2007-10-10r6841: Attempt to fix buf #2681. With "strict allocate = yes" we now zeroJeremy Allison1-0/+5
fill when a file is extended. Should catch disk full errors on write from MS-Office. Jeremy. (This used to be commit 858824f37be443320487a8e28ec8fa172cdf5a18)
2007-10-10r6673: Fix the write cache based on some VERY good detective workJeremy Allison1-59/+80
from Ingo Kilian <ikilian@web.de>. You must do a make clean after updating this. Jeremy. (This used to be commit 3b2cd19fcb8ce38578b122fd6ae722b73081dcda)