summaryrefslogtreecommitdiff
path: root/source3/smbd/close.c
AgeCommit message (Collapse)AuthorFilesLines
2009-06-12Fix bug 6440Volker Lendecke1-11/+19
Don't ignore the close error of the output file in check_magic()
2009-06-12Simplify close_normal_file()Volker Lendecke1-22/+21
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-02-25Fix more POSIX path lstat calls. Fix bug where close can returnJeremy Allison1-5/+17
failure if we have a pending modtime and the containing directory of the file has been renamed (there is no POSIX "update time by fd" call). This can't happen on Windows as the rename will fail if there are open files beneath it. Will add a torture test for this. Jeremy.
2009-02-09s3 oplocks: Remove oplocks before handling delete on close semanticsTim Prouty1-4/+5
Unlinking a file while still holding an oplock can cause problems with kernel oplocks. This simply releases the oplock before actually unlinking the file.
2009-02-09s3 oplocks: Add capabilites flags field to the kernel_oplocks structTim Prouty1-0/+4
Here is a short description for each of the new capability flags: KOPLOCKS_LEVEL2_SUPPORTED: Level 2 oplocks are supported natively in the kernel. KOPLOCKS_DEFERRED_OPEN_NOTIFICATION: The kernel notifies deferred openers when they can retry the open. KOPLOCKS_TIMEOUT_NOTIFICATION: The kernel notifies smbds when an oplock break times out. KOPLOCKS_OPLOCK_BROKEN_NOTIFICATION: The kernel notifies smbds when an oplock is broken.
2009-01-23Extend NTIMES to allow setting create_timetodd stecher1-4/+4
1) Add in smb_file_time struct to clarify code and make room for createtime. 2) Get and set create time from SMB messages. 3) Fixup existing VFS modules + examples Some OS'es allow for the setting of the birthtime through kernel interfaces. This value is generically used for Windows createtime, but is not settable in the code today.
2009-01-09s3: Add delete_all_streams to proto.hTim Prouty1-1/+1
2009-01-06Fix bug #6017, - magic script does not work. based on a patch from ↵Jeremy Allison1-3/+13
monyo@samba.gr.jp. Jeremy.
2008-12-09s3: Call fd_close from close_directoryTim Prouty1-0/+7
Some implementations of SMB_VFS_CREATE_FILE implementations actually keep an fd open for directories just as files. In this case it is necessary to call fd_close when closing directories. This is safe because fd_close is a no-op when fd == -1, which is true for directory opens originating from open.c (the default SMB_VFS_CREATE_FILE implementation).
2008-11-21First part of fix for bug #5903 - vfs_streams_xattr breaks contents of the file.Jeremy Allison1-5/+3
Restructures parts of open code so that fsp must be allocated before calling open_file_ntcreate(_internal). Also fix up file ref-counting inside files.c. Jeremy.
2008-10-13Pass struct smb_request to file_freeVolker Lendecke1-11/+14
on the way to get rid of chain_fsp
2008-05-27Allow server manager to close open files selected by id.Jeremy Allison1-0/+34
Jeremy. (This used to be commit 7eeed8bb41059ec2bddedb6a71deddeec7f33af2)
2008-05-10Remove "user" from connection_structVolker Lendecke1-1/+1
(This used to be commit 368454a27cb53a408ec416cbf37235b304592fb5)
2008-05-02Remove the "stat_open()" function, flag, and all associated code. It was onlyJeremy Allison1-16/+0
being (correctly) used in the can_read/can_write checks for hide unreadable/unwritable and this is more properly done using the functions in smbd/file_access.c. Preparing to do NT access checks on all file access. Jeremy. (This used to be commit 6bfb06ad95963ae2acb67c4694a98282d3b29faa)
2008-04-07smbd: implement the strange write time update logicStefan Metzmacher1-5/+73
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-04-07locking: store the write time in the locking.tdbStefan Metzmacher1-2/+4
This is needed to implement the strange write time update logic later. We need to store 2 time timestamps to distinguish between the time the file system had before the first client opened the file and a forced timestamp update. metze (This used to be commit 6aaa2ce0eeb46f6735ec984a2e7aadde7a7f456d)
2008-04-01smbd: always close the base_fsp even if the real close returned an errorStefan Metzmacher1-4/+0
Otherwise we may end up with share mode entry without an open file. Volker, Jeremy: please check... metze (This used to be commit 547eacf6058d2bc5b41b266b70f8f4747aca4eae)
2008-01-19Add streams supportVolker Lendecke1-4/+111
This is the core of the streams support. The main change is that in files_struct there is now a base_fsp pointer that holds the main file open while a stream is open. This is necessary to get the rather strange delete semantics right: You can't delete the main file while a stream is open without FILE_SHARE_DELETE, and while a stream is open a successful unlink of the main file leads to DELETE_PENDING for all further access on the main file or any stream. (This used to be commit 6022873cc155bdbbd3fb620689715f07a24d6ed1)
2008-01-11Fix a build warning.Günther Deschner1-0/+1
Guenther (This used to be commit 88874a501d0c086f796e4838af8c9399d3cccc1f)
2008-01-10Don't switch user contexts unless you have to. SavesJeremy Allison1-14/+25
a bunch of syscalls on close. Noticed by Volker. Jeremy. (This used to be commit 3caeeaea162e2083a087c242b850c107a3be1bf9)
2008-01-10use talloc_tos in a few more placesVolker Lendecke1-2/+2
(This used to be commit 65dd869bea351010c67f02046ae4134bdada1a4c)
2007-12-22Remove redundant connection_struct from check_magic() parameter list.Michael Adam1-2/+3
Michael (This used to be commit cebaa483e62910ac3f87cd135b2aff18dc880416)
2007-12-22Remove redundant connection_struct from fd_close() parameter list.Michael Adam1-1/+1
Michael (This used to be commit 3611cc8561cf837adea83fc7c16ca7535f188466)
2007-11-23smbd: close_stat() should be staticStefan Metzmacher1-1/+1
metze (This used to be commit e186b60afacfb609968b581a6d32757e1885a319)
2007-10-18RIP BOOL. Convert BOOL -> bool. I found a few interestingJeremy Allison1-4/+4
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-10[GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch.Gerald (Jerry) Carter1-3/+17
(This used to be commit 5c6c8e1fe93f340005110a7833946191659d88ab)
2007-10-10r25118: More pstring elimination.Jeremy Allison1-45/+58
Jeremy. (This used to be commit 7632f8fb4003657591778d2b55f546d1737859d1)
2007-10-10r25117: The mega-patch Jerry was waiting for. Remove all pstrings fromJeremy Allison1-1/+2
the main server code paths. We should now be able to cope with paths up to PATH_MAX length now. Final job will be to add the TALLOC_CTX * parameter to unix_convert to make it explicit (for Volker). Jeremy. (This used to be commit 7f0db75fb0f24873577dcb758a2ecee74fdc4297)
2007-10-10r25055: Add file_id_string_tosVolker Lendecke1-2/+2
This removes file_id_string_static and file_id_string_static2 (This used to be commit 638c848c9afe374feb30e34c494f89b2a6c64f7b)
2007-10-10r24464: Now Volker removed the readbmpx we don't need cached errors any more.Jeremy Allison1-1/+0
Jeremy. (This used to be commit 9256ec0a20f532c7dd7ddc2d3534336a47e6c2d2)
2007-10-10r24120: add a file_id_create() hook into the VFS layerStefan Metzmacher1-1/+1
it's needed for some cluster filesystems to overload this function. metze (This used to be commit cdaa24e8047399002e4b287a31a8340a665e580f)
2007-10-10r23906: Fix POSIX unlink bug found by Steve. If weJeremy Allison1-2/+9
used lstat during the open (which we always do for POSIX) then use lstat for the unlink. Jeremy. (This used to be commit 4aad77c27cc277e3d937f674ee620729411e3eaf)
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-10r23183: Check in a change made by Tridge:Volker Lendecke1-7/+10
This replaces the internal explicit dev/ino file id representation by a "struct file_id". This is necessary as cluster file systems and NFS don't necessarily assign the same device number to the shared file system. With this structure in place we can now easily add different schemes to map a file to a unique 64-bit device node. Jeremy, you might note that I did not change the external interface of smb_share_modes.c. Volker (This used to be commit 9b10dbbd5de8813fc15ebbb6be9b18010ffe8139)
2007-10-10r22868: Replace some message_send_pid calls with messaging_send_pid calls. MoreVolker Lendecke1-2/+4
tomorrow. (This used to be commit 74fa57ca5d7fa8eace72bbe948a08a0bca3cc4ca)
2007-10-10r22846: Chunk one to replace message_send_pid with messaging_send: Deep insideVolker Lendecke1-1/+1
locking/locking.c we have to send retry messages to timed lock holders. The majority of this patch passes a "struct messaging_context" down there. No functional change, survives make test. (This used to be commit bbb508414683eeddd2ee0d2d36fe620118180bbb)
2007-10-10r22784: fixed change notify for delete on closeAndrew Tridgell1-0/+4
(This used to be commit 6f52435a72427a8264096ac14bad54020c9d852b)
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-10r21409: saved_status1 is not used anymore after aio write behind was removedVolker Lendecke1-5/+2
(This used to be commit 29a1892c131ed41a06d3dcfdb5d21371e60c1ba6)
2007-10-10r21280: Fix an uninitialized variable warning. Jeremy, please check.Volker Lendecke1-3/+3
Volker (This used to be commit 4faa37a515fb6c6fa0f9364271755f954429beec)
2007-10-10r21279: Get rid of 'aio write behind', this is broken.Volker Lendecke1-12/+1
It should probably better be integrated with our write cache. Volker (This used to be commit 58bfd168b046a97a895aaa3384fd7af8d077a1d5)
2007-10-10r21274: As we now have POSIX opens which can unlinkJeremy Allison1-0/+9
with other open files we may have taken the delete code path with more than one share mode entry - ensure we only delete once by resetting the delete on close flag. Jeremy. (This used to be commit 429dff31663e71556b5193b25d5b8e7e09fa5b9c)
2007-10-10r21191: Add in the POSIX open/mkdir/unlink calls.Jeremy Allison1-55/+56
Move more error code returns to NTSTATUS. Client test code to follow... See if this passes the build-farm before I add it into 3.0.25. Jeremy. (This used to be commit 83dbbdff345fa9e427c9579183f4380004bf3dd7)
2007-10-10r20931: This changes the notify infrastructure from a polling-based to an ↵Volker Lendecke1-5/+0
event-driven based approach. The only remaining hook into the backend is now void *(*notify_add)(TALLOC_CTX *mem_ctx, struct event_context *event_ctx, files_struct *fsp, uint32 *filter); (Should we put this through the VFS, so that others can more easily plug in?) The trick here is that the backend can pick filter bits that the main smbd should not handle anymore. Thanks to tridge for this idea. The backend can notify the main smbd process via void notify_fsp(files_struct *fsp, uint32 action, char *name); The core patch is not big, what makes this more than 1800 lines are the individual backends that are considerably changed but can be reviewed one by one. Based on this I'll continue with inotify now. Volker (This used to be commit 9cd6a8a82792b7b6967141565d043b6337836a5d)
2007-10-10r20916: Add in the delete on close final fix - but only enabledJeremy Allison1-0/+1
with -DDEVELOPER. Jeremy. (This used to be commit 7f817067a70930ee3502ea3373173e0c23733253)
2007-10-10r20883: W00t! I now understand how "delete on close" reallyJeremy Allison1-2/+37
works - even with the strange "initial delete on close" semantics. The "initial delete on close" flag isn't committed to the share mode db until the handle is closed, and is discarded if any real "delete on close" was set. This allows me to remove the "initial_delete_on_close" flag from the share db, and move it into a BOOL in files_struct. Warning ! You must do a make clean after this. Cope with the wrinkle in directory delete on close which is done differently from files. We now pass all Samba4 smbtortute BASE-DELETE tests except for the one checking that files can't be created in a directory which has the delete on close set (possibly expensive to fix). Jeremy. (This used to be commit f2df77a1497958c1ea791f1d2f4446b5fc3389b3)
2007-10-10r20542: Make close_remove_share_mode retun NTSTATUS. Not that anybody cares ↵Volker Lendecke1-4/+16
yet... (This used to be commit c8995771531caa4ec9bcaef2c29b11ee7d8e49e6)
2007-10-10r20525: Closing a dir with del-on-close set requires the same as files: ↵Volker Lendecke1-0/+12
Don't actually unlink/rmdir if another process still has it open. Jeremy, this is a potential merger to 3.0.24. Volker (This used to be commit 8e1e896b02da99b5a48883c5f37fe146ad0fb5ce)