diff options
author | Ralph Boehme <slow@samba.org> | 2018-05-27 13:03:25 +0200 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2018-07-12 13:10:26 +0200 |
commit | dd78d9a602e2a088b3a3b7ce0f0a9520ce926268 (patch) | |
tree | b087f11388a37c8db0352daabf91015f5b75ba35 | |
parent | 85571d08b2683ee2c9bf8f2abc76af8bc6055a86 (diff) | |
download | samba-dd78d9a602e2a088b3a3b7ce0f0a9520ce926268.tar.gz |
s3:locking: add file_has_open_streams()
This can be used to check if a file opened by fsp also has stream opens.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13451
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit dd8cf54c79fe8536e34cde15801d60931cd47b8b)
-rw-r--r-- | source3/locking/locking.c | 31 | ||||
-rw-r--r-- | source3/locking/proto.h | 1 |
2 files changed, 32 insertions, 0 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 4e9f1bbc681..f71cd176029 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -1318,3 +1318,34 @@ struct timespec get_share_mode_write_time(struct share_mode_lock *lck) } return d->old_write_time; } + +bool file_has_open_streams(files_struct *fsp) +{ + struct share_mode_lock *lock = NULL; + struct share_mode_data *d = NULL; + uint32_t i; + + lock = get_existing_share_mode_lock(talloc_tos(), fsp->file_id); + if (lock == NULL) { + return false; + } + d = lock->data; + + for (i = 0; i < d->num_share_modes; i++) { + struct share_mode_entry *e = &d->share_modes[i]; + + if (share_mode_stale_pid(d, i)) { + continue; + } + + if (e->private_options & + NTCREATEX_OPTIONS_PRIVATE_STREAM_BASEOPEN) + { + TALLOC_FREE(lock); + return true; + } + } + + TALLOC_FREE(lock); + return false; +} diff --git a/source3/locking/proto.h b/source3/locking/proto.h index 33184e0fa0a..4cd38091f3c 100644 --- a/source3/locking/proto.h +++ b/source3/locking/proto.h @@ -205,6 +205,7 @@ bool is_delete_on_close_set(struct share_mode_lock *lck, uint32_t name_hash); bool set_sticky_write_time(struct file_id fileid, struct timespec write_time); bool set_write_time(struct file_id fileid, struct timespec write_time); struct timespec get_share_mode_write_time(struct share_mode_lock *lck); +bool file_has_open_streams(files_struct *fsp); int share_mode_forall(int (*fn)(struct file_id fid, const struct share_mode_data *data, void *private_data), |