~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201210021442

« back to all changes in this revision

Viewing changes to lib/hgfsServer/hgfsServerPacketUtil.c

  • Committer: Package Import Robot
  • Author(s): Nate Muench
  • Date: 2012-01-23 16:09:45 UTC
  • mfrom: (1.4.6) (2.4.26 sid)
  • Revision ID: package-import@ubuntu.com-20120123160945-b6s0r1vkcovucpf3
Tags: 2011.12.20-562307-0ubuntu1
* Merge latest upstream git tag. Fixes building on Precise
  (LP: #898289, LP: #905612)

* Items merged from Debian unstable:
  - debian/control:
    + open-vm-tools recommends open-vm-dkms. (LP: #598933)
    + open-vm-tools now suggests open-vm-toolbox. (LP: #604998)
  (From 2011.08.21-471295-1 release)
  - Updating maintainer and uploaders fields.
  - Removing vcs fields.
  - Removing references to Daniel's old email address.
  - Updating years in copyright file.
  - Updating to standards version 3.9.2.
  - Updating to debhelper version 8.
  - Switching to source format 3.0 (quilt).
  - Removing manual chrpath setting.
  - Removing exclusion from plugins from debhelper shlibs.
  - Rediffing kvers.patch.
  (From 2011.09.23-491607-1 release)
  - Marking binary architecture-dependend packages as linux and kfreebsd
  only.
  - Removing liburiparser-dev from build-depends as upstream dropped
  unity support.
  - Building with libproc-dev on amd64 again.
  - Dropping disabling of dnet support.
  (From 2011.09.23-491607-2 release)
  - Adding doxygen to build-depends for api documentation.
  - Adding libcunit1-dev to build-depends for test suites.
  - Minimizing rules file.
  - Adding open-vm-tools-dev package, containing only the api
    documentation for now.
  (From 2011.09.23-491607-3 release)
  - Sorting overrides in rules alphabetically.
  - Compacting copyright file.
  - Adding udev rule to set timeout for vmware scsi devices
  (From 2011.12.20-562307-1 release)
  - Adding patch to correct typo in upstreams dkms configuration

* Remaining Changes:
  - Remove Stable part of version numbering.
  - debian folder:
    + Re-added open-vm-dkms.postinst & open-vm-dkms.prerm.
      * Allows dkms modules to compile upon installation.
  - debian/control:
    + Re-add open-vm-source and make into a transitional package
      for open-vm-toolbox.
    + Return dependancies that were moved to open-vm-tools back to
      open-vm-toolbox.
  - debian/rules and debian/open-vm-toolbox.lintian-overrides:
    + Make vmware-user-suid-wrapper suid-root
  - debian/rules:
    + Added CFLAGS field with -Wno-deprecated-declarations
      * Will suppress issues with glib 2.31 or later.
    + Add line to copy vmware-xdg-detect-de into place.
    + Install vmware-user.desktop through toolbox package.
  - debian/open-vm-tools.init:
    + Re-add 'modprobe [-r] vmblock'.
    + Add 'modprobe [-r] vmxnet'.
      * Incase it's not loaded during boot.
    + Remove and re-add pcnet32 module
      * Will be done before (remove) and after (readd) vmxnet module
        is added.
      * If vmxnet doesn't exist (aka modules fail to build), pcnet32 can be
        still used for network connectivity.
      * Workaround until a better fix can be done.
  - Re-add gnome-session to debian/local/xautostart.conf
  - Manpages removed (from debian/manpages):
    + vmmemctl.9
    + vmxnet3.9
    + Remove references to manpages that have been removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
void *
54
54
HSPU_GetReplyPacket(HgfsPacket *packet,        // IN/OUT: Hgfs Packet
55
55
                    size_t *replyPacketSize,   // IN/OUT: Size of reply Packet
56
 
                    HgfsSessionInfo *session)  // IN: Session Info
 
56
                    HgfsTransportSessionInfo *transportSession)  // IN: Session Info
57
57
{
58
 
   ASSERT(session);
 
58
   ASSERT(transportSession);
59
59
   if (packet->replyPacket) {
60
60
      /*
61
61
       * When we are transferring packets over backdoor, reply packet
64
64
      LOG(4, ("Exising reply packet %s %Zu %Zu\n", __FUNCTION__,
65
65
              *replyPacketSize, packet->replyPacketSize));
66
66
      ASSERT_DEVEL(*replyPacketSize <= packet->replyPacketSize);
67
 
   } else if (session->channelCbTable && session->channelCbTable->getWriteVa) {
 
67
   } else if (transportSession->channelCbTable && transportSession->channelCbTable->getWriteVa) {
68
68
     /* Can we write directly into guest memory ? */
69
69
      ASSERT_DEVEL(packet->metaPacket);
70
70
      if (packet->metaPacket) {
79
79
                                           packet->metaPacketSize,
80
80
                                           &packet->metaPacketIsAllocated,
81
81
                                           BUF_WRITEABLE,
82
 
                                           session);
 
82
                                           transportSession);
83
83
         /*
84
84
          * Really this can never happen, we would have caught bad physical address
85
85
          * during getMetaPacket.
117
117
 
118
118
void
119
119
HSPU_PutReplyPacket(HgfsPacket *packet,        // IN/OUT: Hgfs Packet
120
 
                    HgfsSessionInfo *session)  // IN: Session Info
 
120
                    HgfsTransportSessionInfo *transportSession)  // IN: Session Info
121
121
{
122
122
   if (packet->replyPacketIsAllocated) {
123
123
      LOG(10, ("%s Freeing reply packet", __FUNCTION__));
148
148
void *
149
149
HSPU_GetMetaPacket(HgfsPacket *packet,        // IN/OUT: Hgfs Packet
150
150
                   size_t *metaPacketSize,    // OUT: Size of metaPacket
151
 
                   HgfsSessionInfo *session)  // IN: Session Info
 
151
                   HgfsTransportSessionInfo *transportSession)  // IN: Session Info
152
152
{
153
153
   *metaPacketSize = packet->metaPacketSize;
154
154
   return HSPU_GetBuf(packet, 0, &packet->metaPacket,
155
155
                      packet->metaPacketSize,
156
156
                      &packet->metaPacketIsAllocated,
157
 
                      BUF_READWRITEABLE, session);
 
157
                      BUF_READWRITEABLE, transportSession);
158
158
}
159
159
 
160
160
 
176
176
 
177
177
void *
178
178
HSPU_GetDataPacketIov(HgfsPacket *packet,       // IN/OUT: Hgfs Packet
179
 
                      HgfsSessionInfo *session, // IN: Session Info
 
179
                      HgfsTransportSessionInfo *transportSession, // IN: Session Info
180
180
                      HgfsVaIov iov)            // OUT: I/O vector
181
181
{
182
182
   NOT_IMPLEMENTED();
204
204
void *
205
205
HSPU_GetDataPacketBuf(HgfsPacket *packet,       // IN/OUT: Hgfs Packet
206
206
                      MappingType mappingType,  // IN: Writeable/Readable
207
 
                      HgfsSessionInfo *session) // IN: Session Info
 
207
                      HgfsTransportSessionInfo *transportSession) // IN: Session Info
208
208
{
209
209
   packet->dataMappingType = mappingType;
210
210
   return HSPU_GetBuf(packet, packet->dataPacketIovIndex,
211
211
                      &packet->dataPacket, packet->dataPacketSize,
212
 
                      &packet->dataPacketIsAllocated, mappingType, session);
 
212
                      &packet->dataPacketIsAllocated, mappingType, transportSession);
213
213
}
214
214
 
215
215
 
236
236
            size_t  bufSize,              // IN: Size of buffer
237
237
            Bool *isAllocated,            // OUT: Was buffer allocated ?
238
238
            MappingType mappingType,      // IN: Readable/Writeable ?
239
 
            HgfsSessionInfo *session)     // IN: Session Info
 
239
            HgfsTransportSessionInfo *transportSession)     // IN: Session Info
240
240
{
241
241
   uint32 iovCount;
242
242
   uint32 iovMapped = 0;
251
251
      return NULL;
252
252
   }
253
253
 
254
 
   if (!session->channelCbTable) {
 
254
   if (!transportSession->channelCbTable) {
255
255
      return NULL;
256
256
   }
257
257
 
258
258
   if (mappingType == BUF_WRITEABLE ||
259
259
       mappingType == BUF_READWRITEABLE) {
260
 
      func = session->channelCbTable->getWriteVa;
 
260
      func = transportSession->channelCbTable->getWriteVa;
261
261
   } else {
262
262
      ASSERT(mappingType == BUF_READABLE);
263
 
      func = session->channelCbTable->getReadVa;
 
263
      func = transportSession->channelCbTable->getReadVa;
264
264
   }
265
265
 
266
266
   /* Looks like we are in the middle of poweroff. */
329
329
 
330
330
freeMem:
331
331
   for (i = startIndex; i < iovCount; i++) {
332
 
      session->channelCbTable->putVa(&packet->iov[i].token);
 
332
      transportSession->channelCbTable->putVa(&packet->iov[i].token);
333
333
      packet->iov[i].va = NULL;
334
334
   }
335
335
 
355
355
 
356
356
void
357
357
HSPU_PutMetaPacket(HgfsPacket *packet,       // IN/OUT: Hgfs Packet
358
 
                   HgfsSessionInfo *session) // IN: Session Info
 
358
                   HgfsTransportSessionInfo *transportSession) // IN: Session Info
359
359
{
360
360
   LOG(4, ("%s Hgfs Putting Meta packet\n", __FUNCTION__));
361
361
   HSPU_PutBuf(packet, 0, &packet->metaPacket,
362
362
               &packet->metaPacketSize,
363
363
               &packet->metaPacketIsAllocated,
364
 
               BUF_WRITEABLE, session);
 
364
               BUF_WRITEABLE, transportSession);
365
365
}
366
366
 
367
367
 
405
405
 
406
406
void
407
407
HSPU_PutDataPacketBuf(HgfsPacket *packet,        // IN/OUT: Hgfs Packet
408
 
                      HgfsSessionInfo *session)  // IN: Session Info
 
408
                      HgfsTransportSessionInfo *transportSession)  // IN: Session Info
409
409
{
410
410
 
411
411
   LOG(4, ("%s Hgfs Putting Data packet\n", __FUNCTION__));
412
412
   HSPU_PutBuf(packet, packet->dataPacketIovIndex,
413
413
               &packet->dataPacket, &packet->dataPacketSize,
414
414
               &packet->dataPacketIsAllocated,
415
 
               packet->dataMappingType, session);
 
415
               packet->dataMappingType, transportSession);
416
416
}
417
417
 
418
418
 
438
438
            size_t *bufSize,           // IN: Size of the buffer
439
439
            Bool *isAllocated,         // IN: Was buffer allocated ?
440
440
            MappingType mappingType,   // IN: Readable / Writeable ?
441
 
            HgfsSessionInfo *session)  // IN: Session info
 
441
            HgfsTransportSessionInfo *transportSession)  // IN: Session info
442
442
{
443
443
   uint32 iovCount = 0;
444
444
   int size = *bufSize;
445
445
   ASSERT(buf);
446
446
 
447
 
   if (!session->channelCbTable) {
 
447
   if (!transportSession->channelCbTable) {
448
448
      return;
449
449
   }
450
450
 
451
 
   if (!session->channelCbTable->putVa || *buf == NULL) {
 
451
   if (!transportSession->channelCbTable->putVa || *buf == NULL) {
452
452
      return;
453
453
   }
454
454
 
455
455
   if (*isAllocated) {
456
456
      if (mappingType == BUF_WRITEABLE) {
457
 
         HSPU_CopyBufToIovec(packet, startIndex, *buf, *bufSize, session);
 
457
         HSPU_CopyBufToIovec(packet, startIndex, *buf, *bufSize, transportSession);
458
458
      }
459
459
      LOG(10, ("%s: Hgfs Freeing buffer \n", __FUNCTION__));
460
460
      free(*buf);
464
464
           iovCount < packet->iovCount && size > 0;
465
465
           iovCount++) {
466
466
         ASSERT_DEVEL(packet->iov[iovCount].token);
467
 
         session->channelCbTable->putVa(&packet->iov[iovCount].token);
 
467
         transportSession->channelCbTable->putVa(&packet->iov[iovCount].token);
468
468
         size -= packet->iov[iovCount].len;
469
469
      }
470
470
      LOG(10, ("%s: Hgfs bufSize = %d \n", __FUNCTION__, size));
493
493
HSPU_CopyBufToMetaIovec(HgfsPacket *packet,      // IN/OUT: Hgfs packet
494
494
                        void *buf,               // IN: Buffer to copy from
495
495
                        size_t bufSize,          // IN: Size of buffer
496
 
                        HgfsSessionInfo *session)// IN: Session Info
 
496
                        HgfsTransportSessionInfo *transportSession)// IN: Session Info
497
497
{
498
 
   HSPU_CopyBufToIovec(packet, 0, buf, bufSize, session);
 
498
   HSPU_CopyBufToIovec(packet, 0, buf, bufSize, transportSession);
499
499
}
500
500
 
501
501
 
518
518
HSPU_CopyBufToDataIovec(HgfsPacket *packet,   // IN: Hgfs packet
519
519
                        void *buf,            // IN: Buffer to copy from
520
520
                        uint32 bufSize,       // IN: Size of buffer
521
 
                        HgfsSessionInfo *session)
 
521
                        HgfsTransportSessionInfo *transportSession)
522
522
{
523
523
   HSPU_CopyBufToIovec(packet, packet->dataPacketIovIndex, buf, bufSize,
524
 
                       session);
 
524
                       transportSession);
525
525
}
526
526
 
527
527
 
545
545
                    uint32 startIndex,        // IN: start index into iov
546
546
                    void *buf,                // IN: Contigous Buffer
547
547
                    size_t bufSize,           // IN: Size of buffer
548
 
                    HgfsSessionInfo *session) // IN: Session Info
 
548
                    HgfsTransportSessionInfo *transportSession) // IN: Session Info
549
549
{
550
550
   uint32 iovCount;
551
551
   size_t remainingSize = bufSize;
555
555
   ASSERT(packet);
556
556
   ASSERT(buf);
557
557
 
558
 
   if (!session->channelCbTable) {
 
558
   if (!transportSession->channelCbTable) {
559
559
      return;
560
560
   }
561
561
 
562
 
   ASSERT_DEVEL(session->channelCbTable->getWriteVa);
563
 
   if (!session->channelCbTable->getWriteVa) {
 
562
   ASSERT_DEVEL(transportSession->channelCbTable->getWriteVa);
 
563
   if (!transportSession->channelCbTable->getWriteVa) {
564
564
      return;
565
565
   }
566
566
 
575
575
      ASSERT_DEVEL(packet->iov[iovCount].len <=
576
576
                  (PAGE_SIZE - PAGE_OFFSET(packet->iov[iovCount].pa)));
577
577
 
578
 
      packet->iov[iovCount].va = session->channelCbTable->getWriteVa(packet->iov[iovCount].pa,
 
578
      packet->iov[iovCount].va = transportSession->channelCbTable->getWriteVa(packet->iov[iovCount].pa,
579
579
                                                     packet->iov[iovCount].len,
580
580
                                                     &packet->iov[iovCount].token);
581
581
      ASSERT_DEVEL(packet->iov[iovCount].va);
582
582
      if (packet->iov[iovCount].va != NULL) {
583
583
         memcpy(packet->iov[iovCount].va, (char *)buf + copiedAmount, copyAmount);
584
 
         session->channelCbTable->putVa(&packet->iov[iovCount].token);
 
584
         transportSession->channelCbTable->putVa(&packet->iov[iovCount].token);
585
585
         remainingSize -= copyAmount;
586
586
         copiedAmount += copyAmount;
587
587
      } else {