Changeset 988 for vendor/current/source3/locking/posix.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/locking/posix.c
r740 r988 25 25 #include "system/filesys.h" 26 26 #include "locking/proto.h" 27 #include "dbwrap.h" 27 #include "dbwrap/dbwrap.h" 28 #include "dbwrap/dbwrap_rbt.h" 28 29 #include "util_tdb.h" 29 30 … … 83 84 ****************************************************************************/ 84 85 85 static bool posix_lock_in_range( SMB_OFF_T *offset_out, SMB_OFF_T*count_out,86 static bool posix_lock_in_range(off_t *offset_out, off_t *count_out, 86 87 uint64_t u_offset, uint64_t u_count) 87 88 { 88 SMB_OFF_T offset = (SMB_OFF_T)u_offset;89 SMB_OFF_T count = (SMB_OFF_T)u_count;89 off_t offset = (off_t)u_offset; 90 off_t count = (off_t)u_count; 90 91 91 92 /* 92 93 * For the type of system we are, attempt to 93 * find the maximum positive lock offset as an SMB_OFF_T.94 * find the maximum positive lock offset as an off_t. 94 95 */ 95 96 96 97 #if defined(MAX_POSITIVE_LOCK_OFFSET) /* Some systems have arbitrary limits. */ 97 98 98 SMB_OFF_T max_positive_lock_offset = (MAX_POSITIVE_LOCK_OFFSET); 99 100 #elif defined(LARGE_SMB_OFF_T) && !defined(HAVE_BROKEN_FCNTL64_LOCKS) 101 102 /* 103 * In this case SMB_OFF_T is 64 bits, 99 off_t max_positive_lock_offset = (MAX_POSITIVE_LOCK_OFFSET); 100 #else 101 /* 102 * In this case off_t is 64 bits, 104 103 * and the underlying system can handle 64 bit signed locks. 105 104 */ 106 105 107 SMB_OFF_T mask2 = ((SMB_OFF_T)0x4) << (SMB_OFF_T_BITS-4); 108 SMB_OFF_T mask = (mask2<<1); 109 SMB_OFF_T max_positive_lock_offset = ~mask; 110 111 #else /* !LARGE_SMB_OFF_T || HAVE_BROKEN_FCNTL64_LOCKS */ 112 113 /* 114 * In this case either SMB_OFF_T is 32 bits, 115 * or the underlying system cannot handle 64 bit signed locks. 116 * All offsets & counts must be 2^31 or less. 117 */ 118 119 SMB_OFF_T max_positive_lock_offset = 0x7FFFFFFF; 120 121 #endif /* !LARGE_SMB_OFF_T || HAVE_BROKEN_FCNTL64_LOCKS */ 122 106 off_t mask2 = ((off_t)0x4) << (SMB_OFF_T_BITS-4); 107 off_t mask = (mask2<<1); 108 off_t max_positive_lock_offset = ~mask; 109 110 #endif 123 111 /* 124 112 * POSIX locks of length zero mean lock to end-of-file. … … 127 115 */ 128 116 129 if (count == (SMB_OFF_T)0) {117 if (count == 0) { 130 118 DEBUG(10,("posix_lock_in_range: count = 0, ignoring.\n")); 131 119 return False; … … 138 126 139 127 if (u_offset & ~((uint64_t)max_positive_lock_offset)) { 140 DEBUG(10,("posix_lock_in_range: (offset = %.0f) offset > %.0f and we cannot handle this. Ignoring lock.\n", 141 (double)u_offset, (double)((uint64_t)max_positive_lock_offset) )); 128 DEBUG(10, ("posix_lock_in_range: (offset = %ju) offset > %ju " 129 "and we cannot handle this. Ignoring lock.\n", 130 (uintmax_t)u_offset, 131 (uintmax_t)max_positive_lock_offset)); 142 132 return False; 143 133 } … … 164 154 165 155 if (count == 0) { 166 DEBUG(10,("posix_lock_in_range: Count = 0. Ignoring lock u_offset = %.0f, u_count = %.0f\n", 167 (double)u_offset, (double)u_count )); 156 DEBUG(10, ("posix_lock_in_range: Count = 0. Ignoring lock " 157 "u_offset = %ju, u_count = %ju\n", 158 (uintmax_t)u_offset, 159 (uintmax_t)u_count)); 168 160 return False; 169 161 } … … 173 165 */ 174 166 175 DEBUG(10,("posix_lock_in_range: offset_out = %.0f, count_out = %.0f\n", 176 (double)offset, (double)count )); 167 DEBUG(10, ("posix_lock_in_range: offset_out = %ju, " 168 "count_out = %ju\n", 169 (uintmax_t)offset, (uintmax_t)count)); 177 170 178 171 *offset_out = offset; … … 183 176 184 177 bool smb_vfs_call_lock(struct vfs_handle_struct *handle, 185 struct files_struct *fsp, int op, SMB_OFF_Toffset,186 SMB_OFF_Tcount, int type)178 struct files_struct *fsp, int op, off_t offset, 179 off_t count, int type) 187 180 { 188 181 VFS_FIND(lock); 189 return handle->fns->lock (handle, fsp, op, offset, count, type);182 return handle->fns->lock_fn(handle, fsp, op, offset, count, type); 190 183 } 191 184 … … 195 188 ****************************************************************************/ 196 189 197 static bool posix_fcntl_lock(files_struct *fsp, int op, SMB_OFF_T offset, SMB_OFF_Tcount, int type)190 static bool posix_fcntl_lock(files_struct *fsp, int op, off_t offset, off_t count, int type) 198 191 { 199 192 bool ret; 200 193 201 DEBUG(8,("posix_fcntl_lock %d %d %.0f %.0f %d\n",fsp->fh->fd,op,(double)offset,(double)count,type)); 194 DEBUG(8,("posix_fcntl_lock %d %d %jd %jd %d\n", 195 fsp->fh->fd,op,(intmax_t)offset,(intmax_t)count,type)); 202 196 203 197 ret = SMB_VFS_LOCK(fsp, op, offset, count, type); … … 205 199 if (!ret && ((errno == EFBIG) || (errno == ENOLCK) || (errno == EINVAL))) { 206 200 207 DEBUG(0,("posix_fcntl_lock: WARNING: lock request at offset %.0f, length %.0f returned\n", 208 (double)offset,(double)count)); 209 DEBUGADD(0,("an %s error. This can happen when using 64 bit lock offsets\n", strerror(errno))); 210 DEBUGADD(0,("on 32 bit NFS mounted file systems.\n")); 201 DEBUG(0, ("posix_fcntl_lock: WARNING: lock request at offset " 202 "%ju, length %ju returned\n", 203 (uintmax_t)offset, (uintmax_t)count)); 204 DEBUGADD(0, ("an %s error. This can happen when using 64 bit " 205 "lock offsets\n", strerror(errno))); 206 DEBUGADD(0, ("on 32 bit NFS mounted file systems.\n")); 211 207 212 208 /* … … 215 211 */ 216 212 217 if (offset & ~(( SMB_OFF_T)0x7fffffff)) {213 if (offset & ~((off_t)0x7fffffff)) { 218 214 DEBUG(0,("Offset greater than 31 bits. Returning success.\n")); 219 215 return True; 220 216 } 221 217 222 if (count & ~(( SMB_OFF_T)0x7fffffff)) {218 if (count & ~((off_t)0x7fffffff)) { 223 219 /* 32 bit NFS file system, retry with smaller offset */ 224 220 DEBUG(0,("Count greater than 31 bits - retrying with 31 bit truncated length.\n")); … … 234 230 235 231 bool smb_vfs_call_getlock(struct vfs_handle_struct *handle, 236 struct files_struct *fsp, SMB_OFF_T*poffset,237 SMB_OFF_T*pcount, int *ptype, pid_t *ppid)232 struct files_struct *fsp, off_t *poffset, 233 off_t *pcount, int *ptype, pid_t *ppid) 238 234 { 239 235 VFS_FIND(getlock); 240 return handle->fns->getlock(handle, fsp, poffset, pcount, ptype, ppid); 236 return handle->fns->getlock_fn(handle, fsp, poffset, pcount, ptype, 237 ppid); 241 238 } 242 239 … … 246 243 ****************************************************************************/ 247 244 248 static bool posix_fcntl_getlock(files_struct *fsp, SMB_OFF_T *poffset, SMB_OFF_T*pcount, int *ptype)245 static bool posix_fcntl_getlock(files_struct *fsp, off_t *poffset, off_t *pcount, int *ptype) 249 246 { 250 247 pid_t pid; 251 248 bool ret; 252 249 253 DEBUG(8,("posix_fcntl_getlock %d %.0f %.0f %d\n", 254 fsp->fh->fd,(double)*poffset,(double)*pcount,*ptype)); 250 DEBUG(8, ("posix_fcntl_getlock %d %ju %ju %d\n", 251 fsp->fh->fd, (uintmax_t)*poffset, (uintmax_t)*pcount, 252 *ptype)); 255 253 256 254 ret = SMB_VFS_GETLOCK(fsp, poffset, pcount, ptype, &pid); … … 258 256 if (!ret && ((errno == EFBIG) || (errno == ENOLCK) || (errno == EINVAL))) { 259 257 260 DEBUG(0,("posix_fcntl_getlock: WARNING: lock request at offset %.0f, length %.0f returned\n", 261 (double)*poffset,(double)*pcount)); 262 DEBUGADD(0,("an %s error. This can happen when using 64 bit lock offsets\n", strerror(errno))); 263 DEBUGADD(0,("on 32 bit NFS mounted file systems.\n")); 258 DEBUG(0, ("posix_fcntl_getlock: WARNING: lock request at " 259 "offset %ju, length %ju returned\n", 260 (uintmax_t)*poffset, (uintmax_t)*pcount)); 261 DEBUGADD(0, ("an %s error. This can happen when using 64 bit " 262 "lock offsets\n", strerror(errno))); 263 DEBUGADD(0, ("on 32 bit NFS mounted file systems.\n")); 264 264 265 265 /* … … 268 268 */ 269 269 270 if (*poffset & ~(( SMB_OFF_T)0x7fffffff)) {270 if (*poffset & ~((off_t)0x7fffffff)) { 271 271 DEBUG(0,("Offset greater than 31 bits. Returning success.\n")); 272 272 return True; 273 273 } 274 274 275 if (*pcount & ~(( SMB_OFF_T)0x7fffffff)) {275 if (*pcount & ~((off_t)0x7fffffff)) { 276 276 /* 32 bit NFS file system, retry with smaller offset */ 277 277 DEBUG(0,("Count greater than 31 bits - retrying with 31 bit truncated length.\n")); … … 297 297 enum brl_flavour lock_flav) 298 298 { 299 SMB_OFF_Toffset;300 SMB_OFF_Tcount;299 off_t offset; 300 off_t count; 301 301 int posix_lock_type = map_posix_lock_type(fsp,*plock_type); 302 302 303 DEBUG(10, ("is_posix_locked: File %s, offset = %.0f, count = %.0f, "304 "type = %s\n", fsp_str_dbg(fsp), (double)*pu_offset,305 (double)*pu_count, posix_lock_type_name(*plock_type)));303 DEBUG(10, ("is_posix_locked: File %s, offset = %ju, count = %ju, " 304 "type = %s\n", fsp_str_dbg(fsp), (uintmax_t)*pu_offset, 305 (uintmax_t)*pu_count, posix_lock_type_name(*plock_type))); 306 306 307 307 /* … … 362 362 static TDB_DATA fd_array_key_fsp(files_struct *fsp) 363 363 { 364 return make_tdb_data((uint8 *)&fsp->file_id, sizeof(fsp->file_id));364 return make_tdb_data((uint8_t *)&fsp->file_id, sizeof(fsp->file_id)); 365 365 } 366 366 … … 404 404 405 405 /**************************************************************************** 406 The records in posix_pending_close_tdb are composed of an array of ints 407 keyed by dev/ino pair. 408 The first int is a reference count of the number of outstanding locks on 409 all open fd's on this dev/ino pair. Any subsequent ints are the fd's that 410 were open on this dev/ino pair that should have been closed, but can't as 411 the lock ref count is non zero. 406 The records in posix_pending_close_db are composed of an array of 407 ints keyed by dev/ino pair. Those ints are the fd's that were open on 408 this dev/ino pair that should have been closed, but can't as the lock 409 ref count is non zero. 412 410 ****************************************************************************/ 413 411 … … 420 418 { 421 419 struct lock_ref_count_key tmp; 422 struct db_record *rec; 423 int lock_ref_count = 0; 420 int32_t lock_ref_count = 0; 424 421 NTSTATUS status; 425 422 426 rec = posix_pending_close_db->fetch_locked( 427 posix_pending_close_db, talloc_tos(), 428 locking_ref_count_key_fsp(fsp, &tmp)); 429 430 SMB_ASSERT(rec != NULL); 431 432 if (rec->value.dptr != NULL) { 433 SMB_ASSERT(rec->value.dsize == sizeof(lock_ref_count)); 434 memcpy(&lock_ref_count, rec->value.dptr, 435 sizeof(lock_ref_count)); 436 } 437 438 lock_ref_count++; 439 440 status = rec->store(rec, make_tdb_data((uint8 *)&lock_ref_count, 441 sizeof(lock_ref_count)), 0); 423 status = dbwrap_change_int32_atomic( 424 posix_pending_close_db, locking_ref_count_key_fsp(fsp, &tmp), 425 &lock_ref_count, 1); 442 426 443 427 SMB_ASSERT(NT_STATUS_IS_OK(status)); 444 445 TALLOC_FREE(rec); 428 SMB_ASSERT(lock_ref_count < INT32_MAX); 446 429 447 430 DEBUG(10,("increment_windows_lock_ref_count for file now %s = %d\n", 448 fsp_str_dbg(fsp), lock_ref_count));431 fsp_str_dbg(fsp), (int)lock_ref_count)); 449 432 } 450 433 … … 453 436 ****************************************************************************/ 454 437 455 void reduce_windows_lock_ref_count(files_struct *fsp, unsigned int dcount)438 static void decrement_windows_lock_ref_count(files_struct *fsp) 456 439 { 457 440 struct lock_ref_count_key tmp; 458 struct db_record *rec; 459 int lock_ref_count = 0; 441 int32_t lock_ref_count = 0; 460 442 NTSTATUS status; 461 443 462 rec = posix_pending_close_db->fetch_locked( 463 posix_pending_close_db, talloc_tos(), 464 locking_ref_count_key_fsp(fsp, &tmp)); 465 466 SMB_ASSERT((rec != NULL) 467 && (rec->value.dptr != NULL) 468 && (rec->value.dsize == sizeof(lock_ref_count))); 469 470 memcpy(&lock_ref_count, rec->value.dptr, sizeof(lock_ref_count)); 471 472 SMB_ASSERT(lock_ref_count > 0); 473 474 lock_ref_count -= dcount; 475 476 status = rec->store(rec, make_tdb_data((uint8 *)&lock_ref_count, 477 sizeof(lock_ref_count)), 0); 444 status = dbwrap_change_int32_atomic( 445 posix_pending_close_db, locking_ref_count_key_fsp(fsp, &tmp), 446 &lock_ref_count, -1); 478 447 479 448 SMB_ASSERT(NT_STATUS_IS_OK(status)); 480 481 TALLOC_FREE(rec); 449 SMB_ASSERT(lock_ref_count >= 0); 482 450 483 451 DEBUG(10,("reduce_windows_lock_ref_count for file now %s = %d\n", 484 fsp_str_dbg(fsp), lock_ref_count)); 485 } 486 487 static void decrement_windows_lock_ref_count(files_struct *fsp) 488 { 489 reduce_windows_lock_ref_count(fsp, 1); 452 fsp_str_dbg(fsp), (int)lock_ref_count)); 490 453 } 491 454 … … 494 457 ****************************************************************************/ 495 458 496 static int get_windows_lock_ref_count(files_struct *fsp)459 static int32_t get_windows_lock_ref_count(files_struct *fsp) 497 460 { 498 461 struct lock_ref_count_key tmp; 499 TDB_DATA dbuf; 500 int res; 501 int lock_ref_count = 0; 502 503 res = posix_pending_close_db->fetch( 504 posix_pending_close_db, talloc_tos(), 505 locking_ref_count_key_fsp(fsp, &tmp), &dbuf); 506 507 SMB_ASSERT(res == 0); 508 509 if (dbuf.dsize != 0) { 510 SMB_ASSERT(dbuf.dsize == sizeof(lock_ref_count)); 511 memcpy(&lock_ref_count, dbuf.dptr, sizeof(lock_ref_count)); 512 TALLOC_FREE(dbuf.dptr); 513 } 514 515 DEBUG(10,("get_windows_lock_count for file %s = %d\n", 516 fsp_str_dbg(fsp), lock_ref_count)); 517 462 NTSTATUS status; 463 int32_t lock_ref_count = 0; 464 465 status = dbwrap_fetch_int32( 466 posix_pending_close_db, locking_ref_count_key_fsp(fsp, &tmp), 467 &lock_ref_count); 468 469 if (!NT_STATUS_IS_OK(status) && 470 !NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) { 471 DEBUG(0, ("get_windows_lock_ref_count: Error fetching " 472 "lock ref count for file %s: %s\n", 473 fsp_str_dbg(fsp), nt_errstr(status))); 474 } 518 475 return lock_ref_count; 519 476 } … … 526 483 { 527 484 struct lock_ref_count_key tmp; 528 struct db_record *rec;529 530 rec = posix_pending_close_db->fetch_locked(531 posix_pending_close_db, talloc_tos(),532 locking_ref_count_key_fsp(fsp, &tmp));533 534 SMB_ASSERT(rec != NULL);535 485 536 486 /* Not a bug if it doesn't exist - no locks were ever granted. */ 537 487 538 rec->delete_rec(rec);539 TALLOC_FREE(rec);488 dbwrap_delete(posix_pending_close_db, 489 locking_ref_count_key_fsp(fsp, &tmp)); 540 490 541 491 DEBUG(10,("delete_windows_lock_ref_count for file %s\n", … … 550 500 { 551 501 struct db_record *rec; 552 uint8_t *new_data; 502 int *fds; 503 size_t num_fds; 553 504 NTSTATUS status; 554 555 rec = posix_pending_close_db->fetch_locked( 505 TDB_DATA value; 506 507 rec = dbwrap_fetch_locked( 556 508 posix_pending_close_db, talloc_tos(), 557 509 fd_array_key_fsp(fsp)); … … 559 511 SMB_ASSERT(rec != NULL); 560 512 561 new_data = TALLOC_ARRAY( 562 rec, uint8_t, rec->value.dsize + sizeof(fsp->fh->fd)); 563 564 SMB_ASSERT(new_data != NULL); 565 566 memcpy(new_data, rec->value.dptr, rec->value.dsize); 567 memcpy(new_data + rec->value.dsize, 568 &fsp->fh->fd, sizeof(fsp->fh->fd)); 569 570 status = rec->store( 571 rec, make_tdb_data(new_data, 572 rec->value.dsize + sizeof(fsp->fh->fd)), 0); 513 value = dbwrap_record_get_value(rec); 514 SMB_ASSERT((value.dsize % sizeof(int)) == 0); 515 516 num_fds = value.dsize / sizeof(int); 517 fds = talloc_array(rec, int, num_fds+1); 518 519 SMB_ASSERT(fds != NULL); 520 521 memcpy(fds, value.dptr, value.dsize); 522 fds[num_fds] = fsp->fh->fd; 523 524 status = dbwrap_record_store( 525 rec, make_tdb_data((uint8_t *)fds, talloc_get_size(fds)), 0); 573 526 574 527 SMB_ASSERT(NT_STATUS_IS_OK(status)); … … 588 541 struct db_record *rec; 589 542 590 rec = posix_pending_close_db->fetch_locked(543 rec = dbwrap_fetch_locked( 591 544 posix_pending_close_db, talloc_tos(), 592 545 fd_array_key_fsp(fsp)); 593 546 594 547 SMB_ASSERT(rec != NULL); 595 rec->delete_rec(rec);548 dbwrap_record_delete(rec); 596 549 TALLOC_FREE(rec); 597 550 } … … 606 559 { 607 560 TDB_DATA dbuf; 608 int res;609 610 res = posix_pending_close_db->fetch(561 NTSTATUS status; 562 563 status = dbwrap_fetch( 611 564 posix_pending_close_db, mem_ctx, fd_array_key_fsp(fsp), 612 565 &dbuf); 613 566 614 SMB_ASSERT(res == 0); 567 if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) { 568 *entries = NULL; 569 return 0; 570 } 571 572 SMB_ASSERT(NT_STATUS_IS_OK(status)); 615 573 616 574 if (dbuf.dsize == 0) { … … 716 674 struct lock_list *next; 717 675 struct lock_list *prev; 718 SMB_OFF_Tstart;719 SMB_OFF_Tsize;676 off_t start; 677 off_t size; 720 678 }; 721 679 … … 729 687 struct lock_list *lhead, 730 688 const struct lock_context *lock_ctx, /* Lock context lhead belongs to. */ 731 files_struct *fsp,732 689 const struct lock_struct *plocks, 733 690 int num_locks) … … 740 697 */ 741 698 742 DEBUG(10, ("posix_lock_list: curr: start=%.0f,size=%.0f\n",743 (double)lhead->start, (double)lhead->size ));699 DEBUG(10, ("posix_lock_list: curr: start=%ju,size=%ju\n", 700 (uintmax_t)lhead->start, (uintmax_t)lhead->size )); 744 701 745 702 for (i=0; i<num_locks && lhead; i++) { … … 753 710 754 711 /* Ignore locks not owned by this process. */ 755 if (! procid_equal(&lock->context.pid, &lock_ctx->pid)) {712 if (!serverid_equal(&lock->context.pid, &lock_ctx->pid)) { 756 713 continue; 757 714 } … … 765 722 for (l_curr = lhead; l_curr;) { 766 723 767 DEBUG(10,("posix_lock_list: lock: fnum=%d: start=%.0f,size=%.0f:type=%s", lock->fnum, 768 (double)lock->start, (double)lock->size, posix_lock_type_name(lock->lock_type) )); 724 DEBUG(10, ("posix_lock_list: lock: fnum=%ju: " 725 "start=%ju,size=%ju:type=%s", 726 (uintmax_t)lock->fnum, 727 (uintmax_t)lock->start, 728 (uintmax_t)lock->size, 729 posix_lock_type_name(lock->lock_type) )); 769 730 770 731 if ( (l_curr->start >= (lock->start + lock->size)) || … … 840 801 l_curr->start = lock->start + lock->size; 841 802 842 DEBUG(10,(" truncate high case: start=%.0f,size=%.0f\n", 843 (double)l_curr->start, (double)l_curr->size )); 803 DEBUG(10, (" truncate high case: start=%ju," 804 "size=%ju\n", 805 (uintmax_t)l_curr->start, 806 (uintmax_t)l_curr->size )); 844 807 845 808 l_curr = l_curr->next; … … 868 831 l_curr->size = lock->start - l_curr->start; 869 832 870 DEBUG(10,(" truncate low case: start=%.0f,size=%.0f\n", 871 (double)l_curr->start, (double)l_curr->size )); 833 DEBUG(10, (" truncate low case: start=%ju," 834 "size=%ju\n", 835 (uintmax_t)l_curr->start, 836 (uintmax_t)l_curr->size )); 872 837 873 838 l_curr = l_curr->next; … … 893 858 +-------+ +---------+ 894 859 **********************************************/ 895 struct lock_list *l_new = TALLOC_P(ctx, struct lock_list);860 struct lock_list *l_new = talloc(ctx, struct lock_list); 896 861 897 862 if(l_new == NULL) { … … 907 872 l_curr->size = lock->start - l_curr->start; 908 873 909 DEBUG(10,(" split case: curr: start=%.0f,size=%.0f \ 910 new: start=%.0f,size=%.0f\n", (double)l_curr->start, (double)l_curr->size, 911 (double)l_new->start, (double)l_new->size )); 874 DEBUG(10, (" split case: curr: start=%ju," 875 "size=%ju new: start=%ju," 876 "size=%ju\n", 877 (uintmax_t)l_curr->start, 878 (uintmax_t)l_curr->size, 879 (uintmax_t)l_new->start, 880 (uintmax_t)l_new->size )); 912 881 913 882 /* … … 927 896 char *msg = NULL; 928 897 929 if (asprintf(&msg, "logic flaw in cases: l_curr: start = %.0f, size = %.0f : \ 930 lock: start = %.0f, size = %.0f", (double)l_curr->start, (double)l_curr->size, (double)lock->start, (double)lock->size ) != -1) { 898 if (asprintf(&msg, "logic flaw in cases: " 899 "l_curr: start = %ju, " 900 "size = %ju : lock: " 901 "start = %ju, size = %ju", 902 (uintmax_t)l_curr->start, 903 (uintmax_t)l_curr->size, 904 (uintmax_t)lock->start, 905 (uintmax_t)lock->size ) != -1) { 931 906 smb_panic(msg); 932 907 } else { … … 954 929 int *errno_ret) 955 930 { 956 SMB_OFF_Toffset;957 SMB_OFF_Tcount;931 off_t offset; 932 off_t count; 958 933 int posix_lock_type = map_posix_lock_type(fsp,lock_type); 959 934 bool ret = True; … … 963 938 struct lock_list *ll = NULL; 964 939 965 DEBUG(5, ("set_posix_lock_windows_flavour: File %s, offset = %.0f, "966 "count = %.0f, type = %s\n", fsp_str_dbg(fsp),967 (double)u_offset, (double)u_count,968 posix_lock_type_name(lock_type)));940 DEBUG(5, ("set_posix_lock_windows_flavour: File %s, offset = %ju, " 941 "count = %ju, type = %s\n", fsp_str_dbg(fsp), 942 (uintmax_t)u_offset, (uintmax_t)u_count, 943 posix_lock_type_name(lock_type))); 969 944 970 945 /* … … 1001 976 } 1002 977 1003 if ((ll = TALLOC_P(l_ctx, struct lock_list)) == NULL) {978 if ((ll = talloc(l_ctx, struct lock_list)) == NULL) { 1004 979 DEBUG(0,("set_posix_lock_windows_flavour: unable to talloc unlock list.\n")); 1005 980 talloc_destroy(l_ctx); … … 1029 1004 llist, 1030 1005 lock_ctx, /* Lock context llist belongs to. */ 1031 fsp,1032 1006 plocks, 1033 1007 num_locks); … … 1043 1017 count = ll->size; 1044 1018 1045 DEBUG(5,("set_posix_lock_windows_flavour: Real lock: Type = %s: offset = %.0f, count = %.0f\n", 1046 posix_lock_type_name(posix_lock_type), (double)offset, (double)count )); 1047 1048 if (!posix_fcntl_lock(fsp,SMB_F_SETLK,offset,count,posix_lock_type)) { 1019 DEBUG(5, ("set_posix_lock_windows_flavour: Real lock: " 1020 "Type = %s: offset = %ju, count = %ju\n", 1021 posix_lock_type_name(posix_lock_type), 1022 (uintmax_t)offset, (uintmax_t)count )); 1023 1024 if (!posix_fcntl_lock(fsp,F_SETLK,offset,count,posix_lock_type)) { 1049 1025 *errno_ret = errno; 1050 DEBUG(5,("set_posix_lock_windows_flavour: Lock fail !: Type = %s: offset = %.0f, count = %.0f. Errno = %s\n", 1051 posix_lock_type_name(posix_lock_type), (double)offset, (double)count, strerror(errno) )); 1026 DEBUG(5, ("set_posix_lock_windows_flavour: Lock " 1027 "fail !: Type = %s: offset = %ju, " 1028 "count = %ju. Errno = %s\n", 1029 posix_lock_type_name(posix_lock_type), 1030 (uintmax_t)offset, (uintmax_t)count, 1031 strerror(errno) )); 1052 1032 ret = False; 1053 1033 break; … … 1065 1045 count = ll->size; 1066 1046 1067 DEBUG(5,("set_posix_lock_windows_flavour: Backing out locks: Type = %s: offset = %.0f, count = %.0f\n", 1068 posix_lock_type_name(posix_lock_type), (double)offset, (double)count )); 1069 1070 posix_fcntl_lock(fsp,SMB_F_SETLK,offset,count,F_UNLCK); 1047 DEBUG(5, ("set_posix_lock_windows_flavour: Backing " 1048 "out locks: Type = %s: offset = %ju, " 1049 "count = %ju\n", 1050 posix_lock_type_name(posix_lock_type), 1051 (uintmax_t)offset, (uintmax_t)count )); 1052 1053 posix_fcntl_lock(fsp,F_SETLK,offset,count,F_UNLCK); 1071 1054 } 1072 1055 } else { … … 1092 1075 int num_locks) 1093 1076 { 1094 SMB_OFF_Toffset;1095 SMB_OFF_Tcount;1077 off_t offset; 1078 off_t count; 1096 1079 bool ret = True; 1097 1080 TALLOC_CTX *ul_ctx = NULL; … … 1099 1082 struct lock_list *ul = NULL; 1100 1083 1101 DEBUG(5, ("release_posix_lock_windows_flavour: File %s, offset = %.0f, "1102 "count = %.0f\n", fsp_str_dbg(fsp),1103 (double)u_offset, (double)u_count));1084 DEBUG(5, ("release_posix_lock_windows_flavour: File %s, offset = %ju, " 1085 "count = %ju\n", fsp_str_dbg(fsp), 1086 (uintmax_t)u_offset, (uintmax_t)u_count)); 1104 1087 1105 1088 /* Remember the number of Windows locks we have on this dev/ino pair. */ … … 1120 1103 } 1121 1104 1122 if ((ul = TALLOC_P(ul_ctx, struct lock_list)) == NULL) {1105 if ((ul = talloc(ul_ctx, struct lock_list)) == NULL) { 1123 1106 DEBUG(0,("release_posix_lock_windows_flavour: unable to talloc unlock list.\n")); 1124 1107 talloc_destroy(ul_ctx); … … 1149 1132 ulist, 1150 1133 lock_ctx, /* Lock context ulist belongs to. */ 1151 fsp,1152 1134 plocks, 1153 1135 num_locks); … … 1164 1146 (!ulist || ulist->next != NULL || ulist->start != offset || ulist->size != count)) { 1165 1147 1166 DEBUG(5,("release_posix_lock_windows_flavour: downgrading lock to READ: offset = %.0f, count = %.0f\n", 1167 (double)offset, (double)count )); 1168 1169 if (!posix_fcntl_lock(fsp,SMB_F_SETLK,offset,count,F_RDLCK)) { 1148 DEBUG(5, ("release_posix_lock_windows_flavour: downgrading " 1149 "lock to READ: offset = %ju, count = %ju\n", 1150 (uintmax_t)offset, (uintmax_t)count )); 1151 1152 if (!posix_fcntl_lock(fsp,F_SETLK,offset,count,F_RDLCK)) { 1170 1153 DEBUG(0,("release_posix_lock_windows_flavour: downgrade of lock failed with error %s !\n", strerror(errno) )); 1171 1154 talloc_destroy(ul_ctx); … … 1182 1165 count = ulist->size; 1183 1166 1184 DEBUG(5,("release_posix_lock_windows_flavour: Real unlock: offset = %.0f, count = %.0f\n", 1185 (double)offset, (double)count )); 1186 1187 if (!posix_fcntl_lock(fsp,SMB_F_SETLK,offset,count,F_UNLCK)) { 1167 DEBUG(5, ("release_posix_lock_windows_flavour: Real unlock: " 1168 "offset = %ju, count = %ju\n", 1169 (uintmax_t)offset, (uintmax_t)count )); 1170 1171 if (!posix_fcntl_lock(fsp,F_SETLK,offset,count,F_UNLCK)) { 1188 1172 ret = False; 1189 1173 } … … 1214 1198 int *errno_ret) 1215 1199 { 1216 SMB_OFF_Toffset;1217 SMB_OFF_Tcount;1200 off_t offset; 1201 off_t count; 1218 1202 int posix_lock_type = map_posix_lock_type(fsp,lock_type); 1219 1203 1220 DEBUG(5,("set_posix_lock_posix_flavour: File %s, offset = % .0f, count "1221 "= % .0f, type = %s\n", fsp_str_dbg(fsp),1222 ( double)u_offset, (double)u_count,1204 DEBUG(5,("set_posix_lock_posix_flavour: File %s, offset = %ju, count " 1205 "= %ju, type = %s\n", fsp_str_dbg(fsp), 1206 (uintmax_t)u_offset, (uintmax_t)u_count, 1223 1207 posix_lock_type_name(lock_type))); 1224 1208 … … 1232 1216 } 1233 1217 1234 if (!posix_fcntl_lock(fsp, SMB_F_SETLK,offset,count,posix_lock_type)) {1218 if (!posix_fcntl_lock(fsp,F_SETLK,offset,count,posix_lock_type)) { 1235 1219 *errno_ret = errno; 1236 DEBUG(5,("set_posix_lock_posix_flavour: Lock fail !: Type = %s: offset = % .0f, count = %.0f. Errno = %s\n",1237 posix_lock_type_name(posix_lock_type), ( double)offset, (double)count, strerror(errno) ));1220 DEBUG(5,("set_posix_lock_posix_flavour: Lock fail !: Type = %s: offset = %ju, count = %ju. Errno = %s\n", 1221 posix_lock_type_name(posix_lock_type), (intmax_t)offset, (intmax_t)count, strerror(errno) )); 1238 1222 return False; 1239 1223 } … … 1258 1242 { 1259 1243 bool ret = True; 1260 SMB_OFF_Toffset;1261 SMB_OFF_Tcount;1244 off_t offset; 1245 off_t count; 1262 1246 TALLOC_CTX *ul_ctx = NULL; 1263 1247 struct lock_list *ulist = NULL; 1264 1248 struct lock_list *ul = NULL; 1265 1249 1266 DEBUG(5, ("release_posix_lock_posix_flavour: File %s, offset = %.0f, "1267 "count = %.0f\n", fsp_str_dbg(fsp),1268 (double)u_offset, (double)u_count));1250 DEBUG(5, ("release_posix_lock_posix_flavour: File %s, offset = %ju, " 1251 "count = %ju\n", fsp_str_dbg(fsp), 1252 (uintmax_t)u_offset, (uintmax_t)u_count)); 1269 1253 1270 1254 /* … … 1282 1266 } 1283 1267 1284 if ((ul = TALLOC_P(ul_ctx, struct lock_list)) == NULL) {1268 if ((ul = talloc(ul_ctx, struct lock_list)) == NULL) { 1285 1269 DEBUG(0,("release_posix_lock_windows_flavour: unable to talloc unlock list.\n")); 1286 1270 talloc_destroy(ul_ctx); … … 1307 1291 ulist, 1308 1292 lock_ctx, /* Lock context ulist belongs to. */ 1309 fsp,1310 1293 plocks, 1311 1294 num_locks); … … 1319 1302 count = ulist->size; 1320 1303 1321 DEBUG(5,("release_posix_lock_posix_flavour: Real unlock: offset = %.0f, count = %.0f\n", 1322 (double)offset, (double)count )); 1323 1324 if (!posix_fcntl_lock(fsp,SMB_F_SETLK,offset,count,F_UNLCK)) { 1304 DEBUG(5, ("release_posix_lock_posix_flavour: Real unlock: " 1305 "offset = %ju, count = %ju\n", 1306 (uintmax_t)offset, (uintmax_t)count )); 1307 1308 if (!posix_fcntl_lock(fsp,F_SETLK,offset,count,F_UNLCK)) { 1325 1309 ret = False; 1326 1310 }
Note:
See TracChangeset
for help on using the changeset viewer.