summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-02-04 06:31:04 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:06:25 -0500
commit40d3c7ebb22bae6f486e8c60c3bb0494d2d397d9 (patch)
tree34e4eec0c679809d469bf853459d5c27b3c1c090 /source3/libsmb
parentfeb50dae419380f200bc127632be88637788dc8f (diff)
downloadsamba-40d3c7ebb22bae6f486e8c60c3bb0494d2d397d9.tar.gz
samba-40d3c7ebb22bae6f486e8c60c3bb0494d2d397d9.tar.bz2
samba-40d3c7ebb22bae6f486e8c60c3bb0494d2d397d9.zip
r13329: Fix libsmbsharemodes.so to work with the stored delete token.
Less trouble than I thought plus it didn't need an interface change (thank goodness !). Jeremy. (This used to be commit dbe2572d1c713f46b0d1d0c405f88456c9336297)
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/smb_share_modes.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/source3/libsmb/smb_share_modes.c b/source3/libsmb/smb_share_modes.c
index 86071ee2e9..f7e7baf445 100644
--- a/source3/libsmb/smb_share_modes.c
+++ b/source3/libsmb/smb_share_modes.c
@@ -2,7 +2,7 @@
Samba share mode database library external interface library.
Used by non-Samba products needing access to the Samba share mode db.
- Copyright (C) Jeremy Allison 2005.
+ Copyright (C) Jeremy Allison 2005 - 2006
sharemodes_procid functions (C) Copyright (C) Volker Lendecke 2005
@@ -25,6 +25,11 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+/*
+ * Version 2 - interface changed to handle the token added for correct
+ * delete on close semantics.
+ */
+
#include "includes.h"
#include "smb_share_modes.h"
@@ -115,9 +120,7 @@ int smb_unlock_share_mode_entry(struct smbdb_ctx *db_ctx,
return tdb_chainunlock(db_ctx->smb_tdb, get_locking_key(dev, ino));
}
-/* Internal structure of Samba share mode db. */
-/* FIXME ! This should be moved into a Samba include file. */
-
+#if 0
struct locking_data {
union {
struct {
@@ -132,12 +135,14 @@ struct locking_data {
char file_name[];
*/
};
+#endif
/*
* Check if an external smb_share_mode_entry and an internal share_mode entry match.
*/
-static int share_mode_entry_equal(const struct smb_share_mode_entry *e_entry, const struct share_mode_entry *entry)
+static int share_mode_entry_equal(const struct smb_share_mode_entry *e_entry,
+ const struct share_mode_entry *entry)
{
return (sharemodes_procid_equal(&e_entry->pid, &entry->pid) &&
e_entry->file_id == (uint32_t)entry->share_file_id &&
@@ -153,7 +158,8 @@ static int share_mode_entry_equal(const struct smb_share_mode_entry *e_entry, co
* Create an internal Samba share_mode entry from an external smb_share_mode_entry.
*/
-static void create_share_mode_entry(struct share_mode_entry *out, const struct smb_share_mode_entry *in)
+static void create_share_mode_entry(struct share_mode_entry *out,
+ const struct smb_share_mode_entry *in)
{
memset(out, '\0', sizeof(struct share_mode_entry));
@@ -281,9 +287,11 @@ int smb_create_share_mode_entry_ex(struct smbdb_ctx *db_ctx,
return -1;
}
ld = (struct locking_data *)db_data.dptr;
+ memset(ld, '\0', sizeof(struct locking_data));
ld->u.s.num_share_mode_entries = 1;
ld->u.s.delete_on_close = 0;
ld->u.s.initial_delete_on_close = 0;
+ ld->u.s.delete_token_size = 0;
shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct share_mode_entry));
create_share_mode_entry(shares, new_entry);
@@ -328,7 +336,7 @@ int smb_create_share_mode_entry_ex(struct smbdb_ctx *db_ctx,
ld = (struct locking_data *)new_data_p;
ld->u.s.num_share_mode_entries++;
- /* Append the original filename */
+ /* Append the original delete_token and filenames. */
memcpy(new_data_p + ((ld->u.s.num_share_mode_entries+1)*sizeof(struct share_mode_entry)),
db_data.dptr + ((orig_num_share_modes+1)*sizeof(struct share_mode_entry)),
db_data.dsize - ((orig_num_share_modes+1) * sizeof(struct share_mode_entry)));
@@ -378,9 +386,9 @@ int smb_delete_share_mode_entry(struct smbdb_ctx *db_ctx,
struct locking_data *ld = NULL; /* internal samba db state. */
struct share_mode_entry *shares = NULL;
char *new_data_p = NULL;
- size_t filename_size = 0;
+ size_t remaining_size = 0;
size_t i, num_share_modes;
- const char *fname_ptr = NULL;
+ const char *remaining_ptr = NULL;
db_data = tdb_fetch(db_ctx->smb_tdb, locking_key);
if (!db_data.dptr) {
@@ -440,13 +448,13 @@ int smb_delete_share_mode_entry(struct smbdb_ctx *db_ctx,
return tdb_delete(db_ctx->smb_tdb, locking_key);
}
- /* Copy the terminating filename. */
- fname_ptr = db_data.dptr + ((orig_num_share_modes+1) * sizeof(struct share_mode_entry));
- filename_size = db_data.dsize - (fname_ptr - db_data.dptr);
+ /* Copy any delete token plus the terminating filenames. */
+ remaining_ptr = db_data.dptr + ((orig_num_share_modes+1) * sizeof(struct share_mode_entry));
+ remaining_size = db_data.dsize - (remaining_ptr - db_data.dptr);
memcpy(new_data_p + ((num_share_modes+1)*sizeof(struct share_mode_entry)),
- fname_ptr,
- filename_size);
+ remaining_ptr,
+ remaining_size);
free(db_data.dptr);
@@ -456,7 +464,7 @@ int smb_delete_share_mode_entry(struct smbdb_ctx *db_ctx,
ld = (struct locking_data *)db_data.dptr;
ld->u.s.num_share_mode_entries = num_share_modes;
- db_data.dsize = ((num_share_modes+1)*sizeof(struct share_mode_entry)) + filename_size;
+ db_data.dsize = ((num_share_modes+1)*sizeof(struct share_mode_entry)) + remaining_size;
if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_REPLACE) == -1) {
free(db_data.dptr);