. Fix confusion about buffer ownership in the HGFS server.
. Do not delete files after DnD if all files are copied.
. Invalidate HgfsNodeInfo->hostFileId associated with the inode in the open()
code path.
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
void *clientData) // IN: session info
{
HgfsSessionInfo *session = (HgfsSessionInfo *)clientData;
- HSPU_PutMetaPacket(packet, session);
- HSPU_PutReplyPacket(packet, session);
- HSPU_PutDataPacketBuf(packet, session);
+
+ if (packet->guestInitiated) {
+ HSPU_PutMetaPacket(packet, session);
+ HSPU_PutReplyPacket(packet, session);
+ HSPU_PutDataPacketBuf(packet, session);
+ } else {
+ free(packet->metaPacket);
+ free(packet);
+ }
}
switch (result) {
case 0:
iinfo->createdAndUnopened = FALSE;
+ LOG(10, (KERN_DEBUG "VMware hgfs: HgfsOpen: old hostFileId = "
+ "%"FMT64"u\n", iinfo->hostFileId));
+ /*
+ * Invalidate the hostFileId as we need to retrieve it from
+ * the server.
+ */
+ iinfo->hostFileId = 0;
result = HgfsUnpackOpenReply(req, opUsed, &replyFile, &replyLock);
if (result != 0) {
break;
int error = 0;
HgfsSuperInfo *si;
unsigned long age;
+ HgfsInodeInfo *iinfo;
ASSERT(dentry);
si = HGFS_SB_TO_COMMON(dentry->d_sb);
"inum %lu\n", dentry->d_name.name, dentry->d_inode->i_ino));
age = jiffies - dentry->d_time;
- if (age > si->ttl) {
+ iinfo = INODE_GET_II_P(dentry->d_inode);
+
+ if (age > si->ttl || iinfo->hostFileId == 0) {
HgfsAttrInfo attr;
LOG(6, (KERN_DEBUG "VMware hgfs: HgfsRevalidate: dentry is too old, "
"getting new attributes\n"));
* the same file name has been used for other file during the period.
*/
if (attr.mask & HGFS_ATTR_VALID_FILEID) {
- HgfsInodeInfo *iinfo = INODE_GET_II_P(dentry->d_inode);
if (iinfo->hostFileId == 0) {
- /* It should not happen, just in case. */
+ /* hostFileId was invalidated, so update it here */
iinfo->hostFileId = attr.hostFileId;
} else if (iinfo->hostFileId != attr.hostFileId) {
LOG(4, ("VMware hgfs: %s: host file id mismatch. Expected "
mHGGetFileStatus(DND_FILE_TRANSFER_NOT_STARTED),
mBlockAdded(false),
mBlockCtrl(0),
- mInited(false)
+ mInited(false),
+ mTotalFileSize(0)
{
GuestDnDCPMgr *p = GuestDnDCPMgr::GetInstance();
ASSERT(p);
/* Any files from last unfinished file transfer should be deleted. */
if (DND_FILE_TRANSFER_IN_PROGRESS == mHGGetFileStatus &&
!mHGStagingDir.empty()) {
- g_debug("%s: deleting dir %s\n", __FUNCTION__, mHGStagingDir.c_str());
- DnD_DeleteStagingFiles(mHGStagingDir.c_str(), FALSE);
+ uint64 totalSize = File_GetSizeEx(mHGStagingDir.c_str());
+ if (mTotalFileSize != totalSize) {
+ g_debug("%s: deleting %s, expecting %"FMT64"d, finished %"FMT64"d\n",
+ __FUNCTION__, mHGStagingDir.c_str(),
+ mTotalFileSize, totalSize);
+ DnD_DeleteStagingFiles(mHGStagingDir.c_str(), FALSE);
+ } else {
+ g_debug("%s: file size match %s\n",
+ __FUNCTION__, mHGStagingDir.c_str());
+ }
}
if (mBlockAdded) {
g_debug("%s: removing block for %s\n", __FUNCTION__, mHGStagingDir.c_str());
g_debug("%s: File data.\n", __FUNCTION__);
DnDFileList flist;
flist.FromCPClipboard(buf, sz);
+ mTotalFileSize = flist.GetFileSize();
mHGFCPData = flist.GetRelPathsStr();
refClipboard->set(mListTargets,
bool mBlockAdded;
DnDBlockControl *mBlockCtrl;
bool mInited;
+ uint64 mTotalFileSize;
};
#endif // __COPYPASTE_UI_X11_H__
m_mousePosY(0),
m_dc(NULL),
m_numPendingRequest(0),
- m_destDropTime(0)
+ m_destDropTime(0),
+ mTotalFileSize(0)
{
g_debug("%s: enter\n", __FUNCTION__);
}
/* Any files from last unfinished file transfer should be deleted. */
if (DND_FILE_TRANSFER_IN_PROGRESS == m_HGGetFileStatus &&
!m_HGStagingDir.empty()) {
- g_debug("%s: deleting dir %s\n", __FUNCTION__, m_HGStagingDir.c_str());
- DnD_DeleteStagingFiles(m_HGStagingDir.c_str(), FALSE);
+ uint64 totalSize = File_GetSizeEx(m_HGStagingDir.c_str());
+ if (mTotalFileSize != totalSize) {
+ g_debug("%s: deleting %s, expecting %"FMT64"d, finished %"FMT64"d\n",
+ __FUNCTION__, m_HGStagingDir.c_str(),
+ mTotalFileSize, totalSize);
+ DnD_DeleteStagingFiles(m_HGStagingDir.c_str(), FALSE);
+ } else {
+ g_debug("%s: file size match %s\n",
+ __FUNCTION__, m_HGStagingDir.c_str());
+ }
}
CommonResetCB();
}
return;
}
+ mTotalFileSize = fList.GetFileSize();
+
/* Provide URIs for each path in the guest's file list. */
if (FCP_TARGET_INFO_GNOME_COPIED_FILES == info) {
pre = FCP_GNOME_LIST_PRE;
GdkDragContext *m_dc;
int m_numPendingRequest;
unsigned long m_destDropTime;
+ uint64 mTotalFileSize;
};
#endif // __DND_UI_X11_H__