~n-muench/ubuntu/precise/open-vm-tools/open-vm-tools-precise.sid-merge1

« back to all changes in this revision

Viewing changes to modules/freebsd/vmhgfs/request.c

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2011-03-31 14:20:05 UTC
  • mfrom: (1.4.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110331142005-3n9red91p7ogkweo
Tags: 2011.03.28-387002-0ubuntu1
* Merge latest upstream git tag.  This has the unlocked_ioctl change
  needed to fix dkms build failures (LP: #727342)
* Changes in debian/rules:
  - work around a bug in toolbox/Makefile, where install-exec-hook is
    not happening.  This needs to get fixed the right way.
  - don't install 'vmware-user' which seems to no longer exist
  - move /etc/xdg into open-vm-toolbox (which should be done using .install)
* debian/open-vm-tools.init: add 'modprobe [-r] vmblock'. (LP: #332323)
* debian/rules and debian/open-vm-toolbox.lintian-overrides:
  - Make vmware-user-suid-wrapper suid-root (LP: #332323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
#include "hgfs_kernel.h"
32
32
#include "requestInt.h"
 
33
#include "channel.h"
33
34
 
34
35
/*
35
36
 * Macros
62
63
 * Local functions (prototypes)
63
64
 */
64
65
 
65
 
   static int   HgfsKReqZCtor(void *mem, int size, void *arg, int flags);
66
 
   static void  HgfsKReqZDtor(void *mem, int size, void *arg);
67
 
   static int   HgfsKReqZInit(void *mem, int size, int flags);
68
 
   static void  HgfsKReqZFini(void *mem, int size);
 
66
static int   HgfsKReqZCtor(void *mem, int size, void *arg, int flags);
 
67
static void  HgfsKReqZDtor(void *mem, int size, void *arg);
 
68
static int   HgfsKReqZInit(void *mem, int size, int flags);
 
69
static void  HgfsKReqZFini(void *mem, int size);
69
70
 
70
71
/*
71
72
 * Global functions (definitions)
370
371
 *      interrupted by a signal.
371
372
 *
372
373
 * Results:
373
 
 *      Pointer to fresh HgfsKReqObject or NULL on failure.
 
374
 *      Pointer to fresh HgfsKReqHandle or NULL on failure.
374
375
 *
375
376
 * Side effects:
376
377
 *      Request inserted into caller's requests container.  This routine may
379
380
 *----------------------------------------------------------------------------
380
381
 */
381
382
 
382
 
HgfsKReqObject *
383
 
HgfsKReq_AllocateRequest(HgfsKReqContainerHandle container)        // IN
 
383
HgfsKReqHandle
 
384
HgfsKReq_AllocateRequest(HgfsKReqContainerHandle container,  // IN:
 
385
                         int *errorRet)                      // OUT:
384
386
{
385
387
   HgfsKReqObject *req;
386
388
 
 
389
   ASSERT(errorRet);
387
390
   ASSERT(container);
388
391
 
 
392
   *errorRet = 0;
 
393
 
 
394
   if (!gHgfsChannel) {
 
395
      *errorRet = EIO;
 
396
      return NULL;
 
397
   }
 
398
 
 
399
   /*
 
400
    * In case we don't have any channel currently, set up a new channel.
 
401
    * Note that we remember the channel from which request was allocated
 
402
    * and sent, thereby making sure that we free it via correct channel.
 
403
    */
 
404
   if (gHgfsChannel->status != HGFS_CHANNEL_CONNECTED) {
 
405
      if (!HgfsSetupNewChannel()) {
 
406
         *errorRet = EIO;
 
407
         return NULL;
 
408
      }
 
409
   }
 
410
 
389
411
   req = os_zone_alloc(hgfsKReqZone, M_WAITOK);
390
412
   if (!req) {
 
413
      *errorRet = ENOMEM;
391
414
      return NULL;
392
415
   }
393
416
 
716
739
              int size,      // IN: Size of item being initialized [ignored]
717
740
              int flags)     // IN: malloc(9) style flags
718
741
{
 
742
   static unsigned int id = 0;
719
743
   HgfsKReqObject *req = (HgfsKReqObject *)mem;
720
744
   ASSERT(size == sizeof *req);
721
745
 
722
 
   /*
723
 
    * Zero out the object.  (Do NOT pass UMA_ZEROINIT to uma_zcreate, as
724
 
    * that will override this routine and zero everything -after- us.)
725
 
    */
726
 
   bzero(req, sizeof *req);
727
 
 
728
 
   /*
729
 
    * Request IDs are a 32-bit unsigned integer.  Conveniently enough for us,
730
 
    * our memory addresses provide (at least) 32 bits.
731
 
    *
732
 
    * Assumption:  Kernel memory will never straddle a 2**32 byte boundary.
733
 
    */
734
 
   req->id = (uint32_t)((unsigned long)req & 0xffffffff);
 
746
   os_add_atomic(&id, 1);
 
747
   req->id = id;
735
748
   req->state = HGFS_REQ_UNUSED;
736
749
   req->stateLock = os_mutex_alloc_init("hgfs_req_mtx");
737
750
   if (!req->stateLock) {
743
756
   /* Reset list pointers. */
744
757
   DblLnkLst_Init(&req->fsNode);
745
758
   DblLnkLst_Init(&req->pendingNode);
 
759
   DblLnkLst_Init(&req->sentNode);
746
760
 
747
761
   /* Clear packet of request before allocating to clients. */
748
762
   bzero(&req->__rpc_packet, sizeof req->__rpc_packet);
749
 
   bcopy(HGFS_SYNC_REQREP_CLIENT_CMD, req->__rpc_packet._command,
750
 
         HGFS_SYNC_REQREP_CLIENT_CMD_LEN);
751
763
 
752
764
   return 0;
753
765
}
817
829
   /* Initialize state & reference count. */
818
830
   req->state = HGFS_REQ_ALLOCATED;
819
831
   req->refcnt = 1;
820
 
 
821
 
   ASSERT(!strncmp(req->__rpc_packet._command, HGFS_SYNC_REQREP_CLIENT_CMD, HGFS_SYNC_REQREP_CLIENT_CMD_LEN));
822
 
 
823
832
   return 0;
824
833
}
825
834