Ejemplo n.º 1
0
static int
HgfsBdChannelSend(HgfsTransportChannel *channel, // IN: Channel
                  HgfsReq *req)                  // IN: request to send
{
   char const *replyPacket = NULL;
   size_t payloadSize;
   int ret;

   ASSERT(req);
   ASSERT(req->state == HGFS_REQ_STATE_UNSENT);
   ASSERT(req->payloadSize <= req->bufferSize);

   LOG(8, ("VMware hgfs: %s: backdoor sending.\n", __func__));
   payloadSize = req->payloadSize;
   ret = HgfsBd_Dispatch(channel->priv, HGFS_REQ_PAYLOAD(req), &payloadSize,
                         &replyPacket);
   if (ret == 0) {
      LOG(8, ("VMware hgfs: %s: Backdoor reply received.\n", __func__));
      /* Request sent successfully. Copy the reply and wake the client. */
      ASSERT(replyPacket);
      ASSERT(payloadSize <= req->bufferSize);
      memcpy(HGFS_REQ_PAYLOAD(req), replyPacket, payloadSize);
      req->payloadSize = payloadSize;
      HgfsCompleteReq(req);
   }

   return ret;
}
Ejemplo n.º 2
0
void
HgfsVmciChannelCompleteRequest(uint64 id) // IN: Request ID
{
   HgfsVmciTransportStatus *transportStatus;
   HgfsReq *req;

   spin_lock_bh(&vmciRequestProcessLock);

   /* Reference is taken here */
   req = HgfsTransportGetPendingRequest(id);
   if (!req) {
      LOG(0, (KERN_WARNING "No request with id %"FMT64"u \n", id));
      goto exit;
   }

   transportStatus = (HgfsVmciTransportStatus *)req->buffer;
   if (transportStatus->status != HGFS_TS_IO_COMPLETE) {
      LOG(0, (KERN_WARNING "Request not completed with id %"FMT64"u \n", id));
      goto exit;
   }

   /* Request is completed (yay!), let's remove it from the list */
   HgfsTransportRemovePendingRequest(req);

   req->payloadSize = transportStatus->size;
   HgfsCompleteReq(req);

exit:
   if (req) {
      /* Drop the reference taken in *GetPendingRequest */
      HgfsRequestPutRef(req);
   }
   spin_unlock_bh(&vmciRequestProcessLock);
}
Ejemplo n.º 3
0
void HgfsFailReq(HgfsReq *req,   // IN: erequest to be marked failed
                 int error)     // IN: error code
{
   HgfsReply *reply = req->payload;

   reply->id = req->id;
   reply->status = error;

   req->payloadSize = sizeof *reply;
   HgfsCompleteReq(req);
}
Ejemplo n.º 4
0
static int
HgfsBdChannelSend(HgfsTransportChannel *channel, // IN: Channel
                  HgfsReq *req)                  // IN: request to send
{
   char const *replyPacket = NULL;
   size_t payloadSize;
   int ret;

   ASSERT(req);
   ASSERT(req->state == HGFS_REQ_STATE_UNSENT);
   ASSERT(req->payloadSize <= HGFS_LARGE_PACKET_MAX);

   pthread_mutex_lock(&channel->connLock);

   if (channel->status != HGFS_CHANNEL_CONNECTED) {
      LOG(6, ("Backdoor not opened.\n"));
      pthread_mutex_unlock(&channel->connLock);
      return -ENOTCONN;
   }

   payloadSize = req->payloadSize;
   LOG(8, ("Backdoor sending.\n"));
   ret = HgfsBd_Dispatch(channel->priv, HGFS_REQ_PAYLOAD(req), &payloadSize,
                         &replyPacket);
   if (ret == 0) {
      LOG(8, ("Backdoor reply received.\n"));
      /* Request sent successfully. Copy the reply and wake the client. */
      ASSERT(replyPacket);
      HgfsCompleteReq(req, replyPacket, payloadSize);
   } else {
      /* Map rpc failure to EIO. */
      ret = -EIO;
   }

   pthread_mutex_unlock(&channel->connLock);

   return ret;
}