Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/locking/posix.c

    r740 r988  
    2525#include "system/filesys.h"
    2626#include "locking/proto.h"
    27 #include "dbwrap.h"
     27#include "dbwrap/dbwrap.h"
     28#include "dbwrap/dbwrap_rbt.h"
    2829#include "util_tdb.h"
    2930
     
    8384****************************************************************************/
    8485
    85 static bool posix_lock_in_range(SMB_OFF_T *offset_out, SMB_OFF_T *count_out,
     86static bool posix_lock_in_range(off_t *offset_out, off_t *count_out,
    8687                                uint64_t u_offset, uint64_t u_count)
    8788{
    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;
    9091
    9192        /*
    9293         * 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.
    9495         */
    9596
    9697#if defined(MAX_POSITIVE_LOCK_OFFSET) /* Some systems have arbitrary limits. */
    9798
    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,
    104103         * and the underlying system can handle 64 bit signed locks.
    105104         */
    106105
    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
    123111        /*
    124112         * POSIX locks of length zero mean lock to end-of-file.
     
    127115         */
    128116
    129         if (count == (SMB_OFF_T)0) {
     117        if (count == 0) {
    130118                DEBUG(10,("posix_lock_in_range: count = 0, ignoring.\n"));
    131119                return False;
     
    138126
    139127        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));
    142132                return False;
    143133        }
     
    164154
    165155        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));
    168160                return False;
    169161        }
     
    173165         */
    174166
    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));
    177170
    178171        *offset_out = offset;
     
    183176
    184177bool smb_vfs_call_lock(struct vfs_handle_struct *handle,
    185                        struct files_struct *fsp, int op, SMB_OFF_T offset,
    186                        SMB_OFF_T count, int type)
     178                       struct files_struct *fsp, int op, off_t offset,
     179                       off_t count, int type)
    187180{
    188181        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);
    190183}
    191184
     
    195188****************************************************************************/
    196189
    197 static bool posix_fcntl_lock(files_struct *fsp, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
     190static bool posix_fcntl_lock(files_struct *fsp, int op, off_t offset, off_t count, int type)
    198191{
    199192        bool ret;
    200193
    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));
    202196
    203197        ret = SMB_VFS_LOCK(fsp, op, offset, count, type);
     
    205199        if (!ret && ((errno == EFBIG) || (errno == ENOLCK) || (errno ==  EINVAL))) {
    206200
    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"));
    211207
    212208                /*
     
    215211                 */
    216212
    217                 if (offset & ~((SMB_OFF_T)0x7fffffff)) {
     213                if (offset & ~((off_t)0x7fffffff)) {
    218214                        DEBUG(0,("Offset greater than 31 bits. Returning success.\n"));
    219215                        return True;
    220216                }
    221217
    222                 if (count & ~((SMB_OFF_T)0x7fffffff)) {
     218                if (count & ~((off_t)0x7fffffff)) {
    223219                        /* 32 bit NFS file system, retry with smaller offset */
    224220                        DEBUG(0,("Count greater than 31 bits - retrying with 31 bit truncated length.\n"));
     
    234230
    235231bool 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)
    238234{
    239235        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);
    241238}
    242239
     
    246243****************************************************************************/
    247244
    248 static bool posix_fcntl_getlock(files_struct *fsp, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype)
     245static bool posix_fcntl_getlock(files_struct *fsp, off_t *poffset, off_t *pcount, int *ptype)
    249246{
    250247        pid_t pid;
    251248        bool ret;
    252249
    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));
    255253
    256254        ret = SMB_VFS_GETLOCK(fsp, poffset, pcount, ptype, &pid);
     
    258256        if (!ret && ((errno == EFBIG) || (errno == ENOLCK) || (errno ==  EINVAL))) {
    259257
    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"));
    264264
    265265                /*
     
    268268                 */
    269269
    270                 if (*poffset & ~((SMB_OFF_T)0x7fffffff)) {
     270                if (*poffset & ~((off_t)0x7fffffff)) {
    271271                        DEBUG(0,("Offset greater than 31 bits. Returning success.\n"));
    272272                        return True;
    273273                }
    274274
    275                 if (*pcount & ~((SMB_OFF_T)0x7fffffff)) {
     275                if (*pcount & ~((off_t)0x7fffffff)) {
    276276                        /* 32 bit NFS file system, retry with smaller offset */
    277277                        DEBUG(0,("Count greater than 31 bits - retrying with 31 bit truncated length.\n"));
     
    297297                        enum brl_flavour lock_flav)
    298298{
    299         SMB_OFF_T offset;
    300         SMB_OFF_T count;
     299        off_t offset;
     300        off_t count;
    301301        int posix_lock_type = map_posix_lock_type(fsp,*plock_type);
    302302
    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)));
    306306
    307307        /*
     
    362362static TDB_DATA fd_array_key_fsp(files_struct *fsp)
    363363{
    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));
    365365}
    366366
     
    404404
    405405/****************************************************************************
    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.
    412410****************************************************************************/
    413411
     
    420418{
    421419        struct lock_ref_count_key tmp;
    422         struct db_record *rec;
    423         int lock_ref_count = 0;
     420        int32_t lock_ref_count = 0;
    424421        NTSTATUS status;
    425422
    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);
    442426
    443427        SMB_ASSERT(NT_STATUS_IS_OK(status));
    444 
    445         TALLOC_FREE(rec);
     428        SMB_ASSERT(lock_ref_count < INT32_MAX);
    446429
    447430        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));
    449432}
    450433
     
    453436****************************************************************************/
    454437
    455 void reduce_windows_lock_ref_count(files_struct *fsp, unsigned int dcount)
     438static void decrement_windows_lock_ref_count(files_struct *fsp)
    456439{
    457440        struct lock_ref_count_key tmp;
    458         struct db_record *rec;
    459         int lock_ref_count = 0;
     441        int32_t lock_ref_count = 0;
    460442        NTSTATUS status;
    461443
    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);
    478447
    479448        SMB_ASSERT(NT_STATUS_IS_OK(status));
    480 
    481         TALLOC_FREE(rec);
     449        SMB_ASSERT(lock_ref_count >= 0);
    482450
    483451        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));
    490453}
    491454
     
    494457****************************************************************************/
    495458
    496 static int get_windows_lock_ref_count(files_struct *fsp)
     459static int32_t get_windows_lock_ref_count(files_struct *fsp)
    497460{
    498461        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        }
    518475        return lock_ref_count;
    519476}
     
    526483{
    527484        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);
    535485
    536486        /* Not a bug if it doesn't exist - no locks were ever granted. */
    537487
    538         rec->delete_rec(rec);
    539         TALLOC_FREE(rec);
     488        dbwrap_delete(posix_pending_close_db,
     489                      locking_ref_count_key_fsp(fsp, &tmp));
    540490
    541491        DEBUG(10,("delete_windows_lock_ref_count for file %s\n",
     
    550500{
    551501        struct db_record *rec;
    552         uint8_t *new_data;
     502        int *fds;
     503        size_t num_fds;
    553504        NTSTATUS status;
    554 
    555         rec = posix_pending_close_db->fetch_locked(
     505        TDB_DATA value;
     506
     507        rec = dbwrap_fetch_locked(
    556508                posix_pending_close_db, talloc_tos(),
    557509                fd_array_key_fsp(fsp));
     
    559511        SMB_ASSERT(rec != NULL);
    560512
    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);
    573526
    574527        SMB_ASSERT(NT_STATUS_IS_OK(status));
     
    588541        struct db_record *rec;
    589542
    590         rec = posix_pending_close_db->fetch_locked(
     543        rec = dbwrap_fetch_locked(
    591544                posix_pending_close_db, talloc_tos(),
    592545                fd_array_key_fsp(fsp));
    593546
    594547        SMB_ASSERT(rec != NULL);
    595         rec->delete_rec(rec);
     548        dbwrap_record_delete(rec);
    596549        TALLOC_FREE(rec);
    597550}
     
    606559{
    607560        TDB_DATA dbuf;
    608         int res;
    609 
    610         res = posix_pending_close_db->fetch(
     561        NTSTATUS status;
     562
     563        status = dbwrap_fetch(
    611564                posix_pending_close_db, mem_ctx, fd_array_key_fsp(fsp),
    612565                &dbuf);
    613566
    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));
    615573
    616574        if (dbuf.dsize == 0) {
     
    716674        struct lock_list *next;
    717675        struct lock_list *prev;
    718         SMB_OFF_T start;
    719         SMB_OFF_T size;
     676        off_t start;
     677        off_t size;
    720678};
    721679
     
    729687                                                struct lock_list *lhead,
    730688                                                const struct lock_context *lock_ctx, /* Lock context lhead belongs to. */
    731                                                 files_struct *fsp,
    732689                                                const struct lock_struct *plocks,
    733690                                                int num_locks)
     
    740697         */
    741698
    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 ));
    744701
    745702        for (i=0; i<num_locks && lhead; i++) {
     
    753710
    754711                /* 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)) {
    756713                        continue;
    757714                }
     
    765722                for (l_curr = lhead; l_curr;) {
    766723
    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) ));
    769730
    770731                        if ( (l_curr->start >= (lock->start + lock->size)) ||
     
    840801                                l_curr->start = lock->start + lock->size;
    841802
    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 ));
    844807
    845808                                l_curr = l_curr->next;
     
    868831                                l_curr->size = lock->start - l_curr->start;
    869832
    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 ));
    872837
    873838                                l_curr = l_curr->next;
     
    893858        +-------+         +---------+
    894859**********************************************/
    895                                 struct lock_list *l_new = TALLOC_P(ctx, struct lock_list);
     860                                struct lock_list *l_new = talloc(ctx, struct lock_list);
    896861
    897862                                if(l_new == NULL) {
     
    907872                                l_curr->size = lock->start - l_curr->start;
    908873
    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 ));
    912881
    913882                                /*
     
    927896                                char *msg = NULL;
    928897
    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) {
    931906                                        smb_panic(msg);
    932907                                } else {
     
    954929                        int *errno_ret)
    955930{
    956         SMB_OFF_T offset;
    957         SMB_OFF_T count;
     931        off_t offset;
     932        off_t count;
    958933        int posix_lock_type = map_posix_lock_type(fsp,lock_type);
    959934        bool ret = True;
     
    963938        struct lock_list *ll = NULL;
    964939
    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)));
    969944
    970945        /*
     
    1001976        }
    1002977
    1003         if ((ll = TALLOC_P(l_ctx, struct lock_list)) == NULL) {
     978        if ((ll = talloc(l_ctx, struct lock_list)) == NULL) {
    1004979                DEBUG(0,("set_posix_lock_windows_flavour: unable to talloc unlock list.\n"));
    1005980                talloc_destroy(l_ctx);
     
    10291004                                llist,
    10301005                                lock_ctx, /* Lock context llist belongs to. */
    1031                                 fsp,
    10321006                                plocks,
    10331007                                num_locks);
     
    10431017                count = ll->size;
    10441018
    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)) {
    10491025                        *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) ));
    10521032                        ret = False;
    10531033                        break;
     
    10651045                        count = ll->size;
    10661046
    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);
    10711054                }
    10721055        } else {
     
    10921075                                int num_locks)
    10931076{
    1094         SMB_OFF_T offset;
    1095         SMB_OFF_T count;
     1077        off_t offset;
     1078        off_t count;
    10961079        bool ret = True;
    10971080        TALLOC_CTX *ul_ctx = NULL;
     
    10991082        struct lock_list *ul = NULL;
    11001083
    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));
    11041087
    11051088        /* Remember the number of Windows locks we have on this dev/ino pair. */
     
    11201103        }
    11211104
    1122         if ((ul = TALLOC_P(ul_ctx, struct lock_list)) == NULL) {
     1105        if ((ul = talloc(ul_ctx, struct lock_list)) == NULL) {
    11231106                DEBUG(0,("release_posix_lock_windows_flavour: unable to talloc unlock list.\n"));
    11241107                talloc_destroy(ul_ctx);
     
    11491132                                ulist,
    11501133                                lock_ctx, /* Lock context ulist belongs to. */
    1151                                 fsp,
    11521134                                plocks,
    11531135                                num_locks);
     
    11641146                        (!ulist || ulist->next != NULL || ulist->start != offset || ulist->size != count)) {
    11651147
    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)) {
    11701153                        DEBUG(0,("release_posix_lock_windows_flavour: downgrade of lock failed with error %s !\n", strerror(errno) ));
    11711154                        talloc_destroy(ul_ctx);
     
    11821165                count = ulist->size;
    11831166
    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)) {
    11881172                        ret = False;
    11891173                }
     
    12141198                        int *errno_ret)
    12151199{
    1216         SMB_OFF_T offset;
    1217         SMB_OFF_T count;
     1200        off_t offset;
     1201        off_t count;
    12181202        int posix_lock_type = map_posix_lock_type(fsp,lock_type);
    12191203
    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,
    12231207                 posix_lock_type_name(lock_type)));
    12241208
     
    12321216        }
    12331217
    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)) {
    12351219                *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) ));
    12381222                return False;
    12391223        }
     
    12581242{
    12591243        bool ret = True;
    1260         SMB_OFF_T offset;
    1261         SMB_OFF_T count;
     1244        off_t offset;
     1245        off_t count;
    12621246        TALLOC_CTX *ul_ctx = NULL;
    12631247        struct lock_list *ulist = NULL;
    12641248        struct lock_list *ul = NULL;
    12651249
    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));
    12691253
    12701254        /*
     
    12821266        }
    12831267
    1284         if ((ul = TALLOC_P(ul_ctx, struct lock_list)) == NULL) {
     1268        if ((ul = talloc(ul_ctx, struct lock_list)) == NULL) {
    12851269                DEBUG(0,("release_posix_lock_windows_flavour: unable to talloc unlock list.\n"));
    12861270                talloc_destroy(ul_ctx);
     
    13071291                                ulist,
    13081292                                lock_ctx, /* Lock context ulist belongs to. */
    1309                                 fsp,
    13101293                                plocks,
    13111294                                num_locks);
     
    13191302                count = ulist->size;
    13201303
    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)) {
    13251309                        ret = False;
    13261310                }
Note: See TracChangeset for help on using the changeset viewer.