~n-muench/ubuntu/precise/open-vm-tools/open-vm-tools.march-merge

« back to all changes in this revision

Viewing changes to lib/hgfsServer/hgfsServer.c

  • Committer: Nate Muench
  • Date: 2012-03-22 17:50:13 UTC
  • mfrom: (1.4.7)
  • Revision ID: nowiwilldestroyabydos@gmail.com-20120322175013-0jh30wfk7ut20rdj
Tags: 2012.03.13-651368-0ubuntu1
* Merge latest upstream git tag.
* debian/rules: Removed glib2.0 compatibility CFLAG.
  - Packaging can now build without it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2966
2966
 
2967
2967
      ASSERT_DEVEL(reply && (replySize <= replyPacketSize));
2968
2968
      if (reply && (sizeof *reply <= replyPacketSize)) {
2969
 
         reply->id = input->id;
2970
 
         reply->status = HgfsConvertFromInternalStatus(status);
 
2969
         HgfsPackLegacyReplyHeader(status, input->id, reply);
2971
2970
      }
2972
2971
   }
2973
2972
   if (!HgfsPacketSend(input->packet, packetOut, replySize,
8375
8374
 *    to a event.
8376
8375
 *
8377
8376
 *    The function builds directory notification packet and queues it to be sent
8378
 
 *    to the client. It processes one notification at a time. It relies on transport
8379
 
 *    to perform coalescing.
 
8377
 *    to the client. It processes one notification at a time. Any consolidation of
 
8378
 *    packets is expected to occur at the transport layer.
8380
8379
 *
8381
8380
 * Results:
8382
8381
 *    None.
8394
8393
                          uint32 mask,                         // IN: event type
8395
8394
                          struct HgfsSessionInfo *session)     // IN: session info
8396
8395
{
8397
 
   HgfsPacket *packet;
 
8396
   HgfsPacket *packet = NULL;
 
8397
   HgfsHeader *packetHeader = NULL;
 
8398
   char *shareName = NULL;
 
8399
   size_t shareNameLen;
8398
8400
   size_t sizeNeeded;
8399
 
   char *shareName;
8400
 
   size_t shareNameLen;
8401
 
   HgfsHeader *packetHeader;
8402
8401
   uint32 flags;
8403
8402
 
8404
 
   if (HgfsServerGetShareName(sharedFolder, &shareNameLen, &shareName)) {
8405
 
 
8406
 
      sizeNeeded = HgfsPackCalculateNotificationSize(shareName, fileName);
8407
 
 
8408
 
      packetHeader = Util_SafeCalloc(1, sizeNeeded);
8409
 
      packet = Util_SafeCalloc(1, sizeof *packet);
8410
 
      packet->guestInitiated = FALSE;
8411
 
      packet->metaPacketSize = sizeNeeded;
8412
 
      packet->metaPacket = packetHeader;
8413
 
      packet->dataPacketIsAllocated = TRUE;
8414
 
      flags = 0;
8415
 
      if (mask & HGFS_NOTIFY_EVENTS_DROPPED) {
8416
 
         flags |= HGFS_NOTIFY_FLAG_OVERFLOW;
8417
 
      }
8418
 
 
8419
 
      HgfsPackChangeNotificationRequest(packetHeader, subscriber, shareName, fileName, mask,
8420
 
                                        flags, session, &sizeNeeded);
8421
 
      if (!HgfsPacketSend(packet, (char *)packetHeader,  sizeNeeded, session->transportSession, 0)) {
8422
 
         LOG(4, ("%s: failed to send notification to the host\n", __FUNCTION__));
8423
 
      }
8424
 
 
8425
 
      LOG(4, ("%s: notification for folder: %d index: %d file name %s "
8426
 
              " mask %x\n", __FUNCTION__, sharedFolder,
8427
 
              (int)subscriber, fileName, mask));
8428
 
      free(shareName);
8429
 
   } else {
 
8403
   if (!HgfsServerGetShareName(sharedFolder, &shareNameLen, &shareName)) {
8430
8404
      LOG(4, ("%s: failed to find shared folder for a handle %x\n",
8431
8405
              __FUNCTION__, sharedFolder));
 
8406
      goto exit;
 
8407
   }
 
8408
 
 
8409
   sizeNeeded = HgfsPackCalculateNotificationSize(shareName, fileName);
 
8410
 
 
8411
   packetHeader = Util_SafeCalloc(1, sizeNeeded);
 
8412
   packet = Util_SafeCalloc(1, sizeof *packet);
 
8413
   packet->guestInitiated = FALSE;
 
8414
   packet->metaPacketSize = sizeNeeded;
 
8415
   packet->metaPacket = packetHeader;
 
8416
   packet->dataPacketIsAllocated = TRUE;
 
8417
   flags = 0;
 
8418
   if (mask & HGFS_NOTIFY_EVENTS_DROPPED) {
 
8419
      flags |= HGFS_NOTIFY_FLAG_OVERFLOW;
 
8420
   }
 
8421
 
 
8422
   if (!HgfsPackChangeNotificationRequest(packetHeader, subscriber, shareName, fileName, mask,
 
8423
                                          flags, session, &sizeNeeded)) {
 
8424
      LOG(4, ("%s: failed to pack notification request\n", __FUNCTION__));
 
8425
      goto exit;
 
8426
   }
 
8427
 
 
8428
   if (!HgfsPacketSend(packet, (char *)packetHeader,  sizeNeeded, session->transportSession, 0)) {
 
8429
      LOG(4, ("%s: failed to send notification to the host\n", __FUNCTION__));
 
8430
      goto exit;
 
8431
   }
 
8432
 
 
8433
   /* The transport will call the server send complete callback to release the packets. */
 
8434
   packet = NULL;
 
8435
   packetHeader = NULL;
 
8436
 
 
8437
   LOG(4, ("%s: notification for folder: %d index: %"FMT64"u file name %s mask %x\n",
 
8438
           __FUNCTION__, sharedFolder, subscriber, fileName, mask));
 
8439
 
 
8440
exit:
 
8441
   if (shareName) {
 
8442
      free(shareName);
 
8443
   }
 
8444
   if (packet) {
 
8445
      free(packet);
 
8446
   }
 
8447
   if (packetHeader) {
 
8448
      free(packetHeader);
8432
8449
   }
8433
8450
}
8434
8451