svn commit: samba r22012 - in branches: SAMBA_3_0/source/libsmb
SAMBA_3_0_25/source/libsmb
jra at samba.org
jra at samba.org
Thu Mar 29 22:12:28 GMT 2007
Author: jra
Date: 2007-03-29 22:12:28 +0000 (Thu, 29 Mar 2007)
New Revision: 22012
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=22012
Log:
Ensure we use the same technique to pull the share mode
data out that locking/locking.c does.
Jeremy.
Modified:
branches/SAMBA_3_0/source/libsmb/smb_share_modes.c
branches/SAMBA_3_0_25/source/libsmb/smb_share_modes.c
Changeset:
Modified: branches/SAMBA_3_0/source/libsmb/smb_share_modes.c
===================================================================
--- branches/SAMBA_3_0/source/libsmb/smb_share_modes.c 2007-03-29 19:46:34 UTC (rev 22011)
+++ branches/SAMBA_3_0/source/libsmb/smb_share_modes.c 2007-03-29 22:12:28 UTC (rev 22012)
@@ -200,7 +200,7 @@
memset(list, '\0', num_share_modes * sizeof(struct smb_share_mode_entry));
- shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct share_mode_entry));
+ shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct locking_data));
list_num = 0;
for (i = 0; i < num_share_modes; i++) {
@@ -265,7 +265,8 @@
if (!db_data.dptr) {
/* We must create the entry. */
db_data.dptr = (uint8 *)malloc(
- (2*sizeof(struct share_mode_entry)) +
+ sizeof(struct locking_data) +
+ sizeof(struct share_mode_entry) +
strlen(sharepath) + 1 +
strlen(filename) + 1);
if (!db_data.dptr) {
@@ -276,18 +277,18 @@
ld->u.s.num_share_mode_entries = 1;
ld->u.s.delete_on_close = 0;
ld->u.s.delete_token_size = 0;
- shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct share_mode_entry));
+ shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct locking_data));
create_share_mode_entry(shares, new_entry);
- memcpy(db_data.dptr + 2*sizeof(struct share_mode_entry),
+ memcpy(db_data.dptr + sizeof(struct locking_data) + sizeof(struct share_mode_entry),
sharepath,
strlen(sharepath) + 1);
- memcpy(db_data.dptr + 2*sizeof(struct share_mode_entry) +
+ memcpy(db_data.dptr + sizeof(struct locking_data) + sizeof(struct share_mode_entry) +
strlen(sharepath) + 1,
filename,
strlen(filename) + 1);
- db_data.dsize = 2*sizeof(struct share_mode_entry) +
+ db_data.dsize = sizeof(struct locking_data) + sizeof(struct share_mode_entry) +
strlen(sharepath) + 1 +
strlen(filename) + 1;
if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_INSERT) == -1) {
@@ -310,11 +311,11 @@
orig_num_share_modes = ld->u.s.num_share_mode_entries;
/* Copy the original data. */
- memcpy(new_data_p, db_data.dptr, (orig_num_share_modes+1)*sizeof(struct share_mode_entry));
+ memcpy(new_data_p, db_data.dptr, sizeof(struct locking_data) + (orig_num_share_modes * sizeof(struct share_mode_entry)));
/* Add in the new share mode */
- shares = (struct share_mode_entry *)(new_data_p +
- ((orig_num_share_modes+1)*sizeof(struct share_mode_entry)));
+ shares = (struct share_mode_entry *)(new_data_p + sizeof(struct locking_data) +
+ (orig_num_share_modes * sizeof(struct share_mode_entry)));
create_share_mode_entry(shares, new_entry);
@@ -322,9 +323,9 @@
ld->u.s.num_share_mode_entries++;
/* 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)));
+ memcpy(new_data_p + sizeof(struct locking_data) + (ld->u.s.num_share_mode_entries * sizeof(struct share_mode_entry)),
+ db_data.dptr + sizeof(struct locking_data) + (orig_num_share_modes * sizeof(struct share_mode_entry)),
+ db_data.dsize - sizeof(struct locking_data) - (orig_num_share_modes * sizeof(struct share_mode_entry)));
new_data_size = db_data.dsize + sizeof(struct share_mode_entry);
@@ -382,7 +383,7 @@
ld = (struct locking_data *)db_data.dptr;
orig_num_share_modes = ld->u.s.num_share_mode_entries;
- shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct share_mode_entry));
+ shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct locking_data));
if (orig_num_share_modes == 1) {
/* Only one entry - better be ours... */
@@ -405,7 +406,7 @@
}
/* Copy the header. */
- memcpy(new_data_p, db_data.dptr, sizeof(struct share_mode_entry));
+ memcpy(new_data_p, db_data.dptr, sizeof(struct locking_data));
num_share_modes = 0;
for (i = 0; i < orig_num_share_modes; i++) {
@@ -421,7 +422,8 @@
continue; /* This is our delete taget. */
}
- memcpy(new_data_p + ((num_share_modes+1)*sizeof(struct share_mode_entry)),
+ memcpy(new_data_p + sizeof(struct locking_data) +
+ (num_share_modes * sizeof(struct share_mode_entry)),
share, sizeof(struct share_mode_entry) );
num_share_modes++;
@@ -435,10 +437,10 @@
}
/* Copy any delete token plus the terminating filenames. */
- remaining_ptr = db_data.dptr + ((orig_num_share_modes+1) * sizeof(struct share_mode_entry));
+ remaining_ptr = db_data.dptr + sizeof(struct locking_data) + (orig_num_share_modes * 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)),
+ memcpy(new_data_p + sizeof(struct locking_data) + (num_share_modes * sizeof(struct share_mode_entry)),
remaining_ptr,
remaining_size);
@@ -450,7 +452,7 @@
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)) + remaining_size;
+ db_data.dsize = sizeof(struct locking_data) + (num_share_modes * 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);
@@ -481,7 +483,7 @@
ld = (struct locking_data *)db_data.dptr;
num_share_modes = ld->u.s.num_share_mode_entries;
- shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct share_mode_entry));
+ shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct locking_data));
for (i = 0; i < num_share_modes; i++) {
struct share_mode_entry *share = &shares[i];
Modified: branches/SAMBA_3_0_25/source/libsmb/smb_share_modes.c
===================================================================
--- branches/SAMBA_3_0_25/source/libsmb/smb_share_modes.c 2007-03-29 19:46:34 UTC (rev 22011)
+++ branches/SAMBA_3_0_25/source/libsmb/smb_share_modes.c 2007-03-29 22:12:28 UTC (rev 22012)
@@ -200,7 +200,7 @@
memset(list, '\0', num_share_modes * sizeof(struct smb_share_mode_entry));
- shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct share_mode_entry));
+ shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct locking_data));
list_num = 0;
for (i = 0; i < num_share_modes; i++) {
@@ -265,7 +265,8 @@
if (!db_data.dptr) {
/* We must create the entry. */
db_data.dptr = (char *)malloc(
- (2*sizeof(struct share_mode_entry)) +
+ sizeof(struct locking_data) +
+ sizeof(struct share_mode_entry) +
strlen(sharepath) + 1 +
strlen(filename) + 1);
if (!db_data.dptr) {
@@ -276,18 +277,18 @@
ld->u.s.num_share_mode_entries = 1;
ld->u.s.delete_on_close = 0;
ld->u.s.delete_token_size = 0;
- shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct share_mode_entry));
+ shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct locking_data));
create_share_mode_entry(shares, new_entry);
- memcpy(db_data.dptr + 2*sizeof(struct share_mode_entry),
+ memcpy(db_data.dptr + sizeof(struct locking_data) + sizeof(struct share_mode_entry),
sharepath,
strlen(sharepath) + 1);
- memcpy(db_data.dptr + 2*sizeof(struct share_mode_entry) +
+ memcpy(db_data.dptr + sizeof(struct locking_data) + sizeof(struct share_mode_entry) +
strlen(sharepath) + 1,
filename,
strlen(filename) + 1);
- db_data.dsize = 2*sizeof(struct share_mode_entry) +
+ db_data.dsize = sizeof(struct locking_data) + sizeof(struct share_mode_entry) +
strlen(sharepath) + 1 +
strlen(filename) + 1;
if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_INSERT) == -1) {
@@ -310,11 +311,11 @@
orig_num_share_modes = ld->u.s.num_share_mode_entries;
/* Copy the original data. */
- memcpy(new_data_p, db_data.dptr, (orig_num_share_modes+1)*sizeof(struct share_mode_entry));
+ memcpy(new_data_p, db_data.dptr, sizeof(struct locking_data) + (orig_num_share_modes * sizeof(struct share_mode_entry)));
/* Add in the new share mode */
- shares = (struct share_mode_entry *)(new_data_p +
- ((orig_num_share_modes+1)*sizeof(struct share_mode_entry)));
+ shares = (struct share_mode_entry *)(new_data_p + sizeof(struct locking_data) +
+ (orig_num_share_modes * sizeof(struct share_mode_entry)));
create_share_mode_entry(shares, new_entry);
@@ -322,9 +323,9 @@
ld->u.s.num_share_mode_entries++;
/* 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)));
+ memcpy(new_data_p + sizeof(struct locking_data) + (ld->u.s.num_share_mode_entries * sizeof(struct share_mode_entry)),
+ db_data.dptr + sizeof(struct locking_data) + (orig_num_share_modes * sizeof(struct share_mode_entry)),
+ db_data.dsize - sizeof(struct locking_data) - (orig_num_share_modes * sizeof(struct share_mode_entry)));
new_data_size = db_data.dsize + sizeof(struct share_mode_entry);
@@ -382,7 +383,7 @@
ld = (struct locking_data *)db_data.dptr;
orig_num_share_modes = ld->u.s.num_share_mode_entries;
- shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct share_mode_entry));
+ shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct locking_data));
if (orig_num_share_modes == 1) {
/* Only one entry - better be ours... */
@@ -405,7 +406,7 @@
}
/* Copy the header. */
- memcpy(new_data_p, db_data.dptr, sizeof(struct share_mode_entry));
+ memcpy(new_data_p, db_data.dptr, sizeof(struct locking_data));
num_share_modes = 0;
for (i = 0; i < orig_num_share_modes; i++) {
@@ -421,7 +422,8 @@
continue; /* This is our delete taget. */
}
- memcpy(new_data_p + ((num_share_modes+1)*sizeof(struct share_mode_entry)),
+ memcpy(new_data_p + sizeof(struct locking_data) +
+ (num_share_modes * sizeof(struct share_mode_entry)),
share, sizeof(struct share_mode_entry) );
num_share_modes++;
@@ -435,10 +437,10 @@
}
/* Copy any delete token plus the terminating filenames. */
- remaining_ptr = db_data.dptr + ((orig_num_share_modes+1) * sizeof(struct share_mode_entry));
+ remaining_ptr = db_data.dptr + sizeof(struct locking_data) + (orig_num_share_modes * 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)),
+ memcpy(new_data_p + sizeof(struct locking_data) + (num_share_modes * sizeof(struct share_mode_entry)),
remaining_ptr,
remaining_size);
@@ -450,7 +452,7 @@
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)) + remaining_size;
+ db_data.dsize = sizeof(struct locking_data) + (num_share_modes * 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);
@@ -481,7 +483,7 @@
ld = (struct locking_data *)db_data.dptr;
num_share_modes = ld->u.s.num_share_mode_entries;
- shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct share_mode_entry));
+ shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct locking_data));
for (i = 0; i < num_share_modes; i++) {
struct share_mode_entry *share = &shares[i];
More information about the samba-cvs
mailing list