summaryrefslogtreecommitdiff
path: root/source3/locking
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-06-01 15:50:39 +0200
committerStefan Metzmacher <metze@samba.org>2012-06-03 17:23:28 +0200
commit103b89fb071966eb5ca135039249e5def5eb0250 (patch)
treec17d8a0099f3500b21465065c2f7fd2b25e4524e /source3/locking
parent8541829a9ab20c7fa8c892490284c31593eb2fb8 (diff)
downloadsamba-103b89fb071966eb5ca135039249e5def5eb0250.tar.gz
samba-103b89fb071966eb5ca135039249e5def5eb0250.tar.bz2
samba-103b89fb071966eb5ca135039249e5def5eb0250.zip
s3: Simplify get_delete_on_close_token slightly
Introduce find_delete_on_close_token. Thus is_delete_on_close_set does not have to call get_delete_on_close_token anymore. Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3/locking')
-rw-r--r--source3/locking/locking.c51
1 files changed, 32 insertions, 19 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 76c2bc7a48..0003f94d18 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -1045,6 +1045,26 @@ bool set_delete_on_close(files_struct *fsp, bool delete_on_close,
return True;
}
+static struct delete_token *find_delete_on_close_token(
+ struct share_mode_data *d, uint32_t name_hash)
+{
+ uint32_t i;
+
+ DEBUG(10, ("find_delete_on_close_token: name_hash = 0x%x\n",
+ (unsigned int)name_hash));
+
+ for (i=0; i<d->num_delete_tokens; i++) {
+ struct delete_token *dt = &d->delete_tokens[i];
+
+ DEBUG(10, ("find__delete_on_close_token: dt->name_hash = 0x%x\n",
+ (unsigned int)dt->name_hash ));
+ if (dt->name_hash == name_hash) {
+ return dt;
+ }
+ }
+ return NULL;
+}
+
/****************************************************************************
Return the NT token and UNIX token if there's a match. Return true if
found, false if not.
@@ -1055,31 +1075,24 @@ bool get_delete_on_close_token(struct share_mode_lock *lck,
const struct security_token **pp_nt_tok,
const struct security_unix_token **pp_tok)
{
- int i;
-
- DEBUG(10,("get_delete_on_close_token: name_hash = 0x%x\n",
- (unsigned int)name_hash ));
+ struct delete_token *dt;
- for (i=0; i<lck->data->num_delete_tokens; i++) {
- struct delete_token *dt = &lck->data->delete_tokens[i];
- DEBUG(10,("get_delete_on_close_token: dtl->name_hash = 0x%x\n",
- (unsigned int)dt->name_hash ));
- if (dt->name_hash == name_hash) {
- if (pp_nt_tok) {
- *pp_nt_tok = dt->delete_nt_token;
- }
- if (pp_tok) {
- *pp_tok = dt->delete_token;
- }
- return true;
- }
+ dt = find_delete_on_close_token(lck->data, name_hash);
+ if (dt == NULL) {
+ return false;
+ }
+ if (pp_nt_tok) {
+ *pp_nt_tok = dt->delete_nt_token;
}
- return false;
+ if (pp_tok) {
+ *pp_tok = dt->delete_token;
+ }
+ return true;
}
bool is_delete_on_close_set(struct share_mode_lock *lck, uint32_t name_hash)
{
- return get_delete_on_close_token(lck, name_hash, NULL, NULL);
+ return find_delete_on_close_token(lck->data, name_hash) != NULL;
}
bool set_sticky_write_time(struct file_id fileid, struct timespec write_time)