/* move/rename a host file/directory */ int VMShfMoveFile( const shf_t *shf, const char *srcname, const char *dstname, uint32_t *status) { uint32_t srclen, dstlen, datalen; int ret; if (vmshf_debug) { fprintf(stderr, "VMSHF_MOVE_FILE src:'%s', dst:'%s' -> ", srcname, dstname); fflush(stderr); } *status = (uint32_t)-1; memcpy(shf->buf, shf_header, sizeof(shf_header)); *(uint32_t *)&shf->buf[6] = VMSHF_MOVE_FILE; srclen = LocalToUtf8((char *)&shf->buf[14], srcname); *(uint32_t *)&shf->buf[10] = srclen; ReplaceDelim((char *)&shf->buf[14], srclen, '\0'); datalen = 15 + srclen; dstlen = LocalToUtf8((char *)&shf->buf[datalen + 4], dstname); *(uint32_t *)&shf->buf[datalen] = dstlen; ReplaceDelim((char *)&shf->buf[datalen + 4], dstlen, '\0'); datalen = datalen + 5 + dstlen; ret = ExecuteRpc(shf, &datalen); if (ret != VMTOOL_SUCCESS) { return ret; } *status = *(uint32_t *)&shf->buf[6]; if (vmshf_debug) { fprintf(stderr, "status:%lu\n", *status); } return VMTOOL_SUCCESS; }
bool CommitAction::Perform() { svn::Client client(GetContext()); std::string messageUtf8(LocalToUtf8(m_message)); svn::Pool pool; svn_revnum_t revision = client.commit(m_files, messageUtf8.c_str(), m_recursive, m_keepLocks); wxString str; str = wxString::Format(wxT("%s %") wxT(SVN_REVNUM_T_FMT) wxT("."), _("Committed revision"), revision); Trace(str); const std::string &postCommitErr = client.commitInfo().postCommitErr; if (postCommitErr.length() > 0) throw svn::ClientException(postCommitErr.c_str()); return true; }
/* set file attributes */ int VMShfSetAttr( const shf_t *shf, uint32_t attrmask, const uint8_t unknown, const fileattr_t *fileattr, const char *filename, uint32_t *status) { uint32_t namelen, datalen; int ret; if (vmshf_debug) { fprintf(stderr, "VMSHF_SET_INFO name:'%s'\n", filename); fprintf(stderr, "mask:0x%04x ( %s%s%s%s%s%s)\n", attrmask, (attrmask & VMSHF_ATTRMASK_FSIZE) ? "fsize " : "", (attrmask & VMSHF_ATTRMASK_CTIME) ? "ctime " : "", (attrmask & VMSHF_ATTRMASK_ATIME) ? "atime " : "", (attrmask & VMSHF_ATTRMASK_UTIME) ? "utime " : "", (attrmask & VMSHF_ATTRMASK_XTIME) ? "?time " : "", (attrmask & VMSHF_ATTRMASK_FMODE) ? "fmode " : ""); PrintFileAttr(attrmask, fileattr ? fileattr : SETA_BUF(shf)); } *status = (uint32_t)-1; memcpy(shf->buf, shf_header, sizeof(shf_header)); *(uint32_t *)&shf->buf[ 6] = VMSHF_SET_ATTR; *(uint32_t *)&shf->buf[10] = attrmask; *&shf->buf[14] = unknown; if (fileattr) { memcpy(SETA_BUF(shf), fileattr, sizeof(fileattr_t)); } namelen = LocalToUtf8((char *)&shf->buf[60], filename); *(uint32_t *)&shf->buf[56] = namelen; ReplaceDelim((char *)&shf->buf[60], namelen, '\0'); datalen = 61 + namelen; ret = ExecuteRpc(shf, &datalen); if (ret != VMTOOL_SUCCESS) { return ret; } *status = *(uint32_t *)&shf->buf[6]; if (vmshf_debug) { fprintf(stderr, "-> status:%lu\n", *status); } return VMTOOL_SUCCESS; }
bool LockAction::Perform() { svn::Client client(GetContext()); std::string messageUtf8(LocalToUtf8(m_message)); client.lock(GetTargets(), m_stealLock, messageUtf8.c_str()); return true; }
/* get host drive free space */ int VMShfGetDirSize( const shf_t *shf, const char *dirname, uint32_t *status, uint64_t *avail, uint64_t *total) { uint32_t namelen, datalen; int ret; if (vmshf_debug) { fprintf(stderr, "VMSHF_GET_FREESPACE name:'%s' -> ", dirname); fflush(stderr); } *status = (uint32_t)-1; memcpy(shf->buf, shf_header, sizeof(shf_header)); *(uint32_t *)&shf->buf[6] = VMSHF_GET_DIRSIZE; namelen = LocalToUtf8((char *)&shf->buf[14], dirname); *(uint32_t *)&shf->buf[10] = namelen; ReplaceDelim((char *)&shf->buf[14], namelen, '\0'); datalen = 15 + namelen; ret = ExecuteRpc(shf, &datalen); if (ret != VMTOOL_SUCCESS) { return ret; } *status = *(uint32_t *)&shf->buf[6]; if (datalen >= 26) { *avail = *(uint64_t *)&shf->buf[10]; *total = *(uint64_t *)&shf->buf[18]; } else { U64INIT(*avail, 0, 0); U64INIT(*total, 0, 0); } if (vmshf_debug) { fprintf(stderr, "status: %lu, free: %" I64D_FMT "u, total: %" I64D_FMT "u\n", *status, *avail, *total); } return VMTOOL_SUCCESS; }
/* get file attributes */ int VMShfGetAttr( const shf_t *shf, const char *filename, uint32_t *status, uint32_t *dirflag, fileattr_t **fileattr) { uint32_t namelen, datalen; int ret; if (vmshf_debug) { fprintf(stderr, "VMSHF_GET_INFO name:'%s' -> ", filename); fflush(stderr); } *status = (uint32_t)-1; memcpy(shf->buf, shf_header, sizeof(shf_header)); *(uint32_t *)&shf->buf[6] = VMSHF_GET_ATTR; namelen = LocalToUtf8((char *)&shf->buf[14], filename); *(uint32_t *)&shf->buf[10] = namelen; ReplaceDelim((char *)&shf->buf[14], namelen, '\0'); datalen = 15 + namelen; ret = ExecuteRpc(shf, &datalen); if (ret != VMTOOL_SUCCESS) { return ret; } *status = *(uint32_t *)&shf->buf[6]; if (vmshf_debug) { fprintf(stderr, "status:%lu\n", *status); } if (datalen >= 55) { *dirflag = *(uint32_t *)&shf->buf[10]; *fileattr = GETA_BUF(shf); if (vmshf_debug) { fprintf(stderr, "dflag: %d\n", *dirflag); PrintFileAttr(0xff, GETA_BUF(shf)); } } return VMTOOL_SUCCESS; }
/* open directory */ int VMShfOpenDir( const shf_t *shf, const char *dirname, uint32_t *status, uint32_t *handle) { uint32_t namelen, datalen; int ret; if (vmshf_debug) { fprintf(stderr, "VMSHF_OPEN_DIR name:'%s' -> ", dirname); fflush(stderr); } *status = (uint32_t)-1; memcpy(shf->buf, shf_header, sizeof(shf_header)); *(uint32_t *)&shf->buf[6] = VMSHF_OPEN_DIR; namelen = LocalToUtf8((char *)&shf->buf[14], dirname); ReplaceDelim((char *)&shf->buf[14], namelen, '\0'); *(uint32_t *)&shf->buf[10] = namelen; datalen = 15 + namelen; ret = ExecuteRpc(shf, &datalen); if (ret != VMTOOL_SUCCESS) { if (vmshf_debug) { fprintf(stderr, "rpc failed\n"); } return ret; } *status = *(uint32_t *)&shf->buf[6]; if (datalen >= 14) { *handle = *(uint32_t *)&shf->buf[10]; } else { *handle = (uint32_t)-1; } if (vmshf_debug) { fprintf(stderr, "status:%lu, handle:%lu\n", *status, *handle); } return VMTOOL_SUCCESS; }
/* create a host directory */ int VMShfCreateDir( const shf_t *shf, uint8_t dirmode, const char *dirname, uint32_t *status) { uint32_t namelen, datalen; int ret; if (vmshf_debug) { fprintf(stderr, "VMSHF_CREATE_DIR name:'%s', mode:%c%c%c (0x%02x) -> ", dirname, (dirmode & VMSHF_FILEMODE_READ) ? 'r' : '-', (dirmode & VMSHF_FILEMODE_WRITE) ? 'w' : '-', (dirmode & VMSHF_FILEMODE_EXEC) ? 'x' : '-', dirmode); fflush(stderr); } *status = (uint32_t)-1; memcpy(shf->buf, shf_header, sizeof(shf_header)); *(uint32_t *)&shf->buf[6] = VMSHF_CREATE_DIR; shf->buf[10] = dirmode; namelen = LocalToUtf8((char *)&shf->buf[15], dirname); *(uint32_t *)&shf->buf[11] = namelen; ReplaceDelim((char *)&shf->buf[15], namelen, '\0'); datalen = 16 + namelen; ret = ExecuteRpc(shf, &datalen); if (ret != VMTOOL_SUCCESS) { return ret; } *status = *(uint32_t *)&shf->buf[6]; if (vmshf_debug) { fprintf(stderr, "status:%lu\n", *status); } return VMTOOL_SUCCESS; }
/* delete a host directory */ int VMShfDeleteDir( const shf_t *shf, const char *dirname, uint32_t *status) { uint32_t namelen, datalen; int ret; if (vmshf_debug) { fprintf(stderr, "VMSHF_DELETE_DIR name:%s -> ", dirname); fflush(stderr); } *status = (uint32_t)-1; memcpy(shf->buf, shf_header, sizeof(shf_header)); *(uint32_t *)&shf->buf[6] = VMSHF_DELETE_DIR; namelen = LocalToUtf8((char *)&shf->buf[14], dirname); *(uint32_t *)&shf->buf[10] = namelen; ReplaceDelim((char *)&shf->buf[14], namelen, '\0'); datalen = 15 + namelen; ret = ExecuteRpc(shf, &datalen); if (ret != VMTOOL_SUCCESS) { return ret; } *status = *(uint32_t *)&shf->buf[6]; if (vmshf_debug) { fprintf(stderr, "status:%lu\n", *status); } return VMTOOL_SUCCESS; }
/* open a host file */ int VMShfOpenFile( const shf_t *shf, uint32_t access, /* 10: one of VMSHF_ACCESS_* values */ uint32_t openmode, /* 14: one of VMSHF_OPENMODE_* values */ uint8_t filemode, /* 18: VMSHF_FILEMODE_* mask values */ const char *filename, /* 23: variable length file name */ uint32_t *status, /* 10: status */ uint32_t *handle) /* 14: file handle */ { uint32_t namelen, datalen; int ret; if (vmshf_debug) { const static char *access_name[] = { "ro", "??", "rw" }; const static char *openmode_name[] = { "o_exist", "?", "o_always", "c_new", "c_always" }; fprintf(stderr, "VMSHF_OPEN_FILE name:'%s'\n" "access:%lu (%s), openmode:%lu (%s), " "filemode:%c%c%c (0x%02x) -> ", filename, access, access_name[access < 3 ? access : 1], openmode, openmode_name[openmode < 5 ? openmode : 1], (filemode & VMSHF_FILEMODE_READ) ? 'r' : '-', (filemode & VMSHF_FILEMODE_WRITE) ? 'w' : '-', (filemode & VMSHF_FILEMODE_EXEC) ? 'x' : '-', filemode); fflush(stderr); } *status = (uint32_t)-1; *handle = (uint32_t)-1; memcpy(shf->buf, shf_header, sizeof(shf_header)); *(uint32_t *)&shf->buf[ 6] = VMSHF_OPEN_FILE; *(uint32_t *)&shf->buf[10] = access; *(uint32_t *)&shf->buf[14] = openmode; shf->buf[18] = filemode; namelen = LocalToUtf8((char *)&shf->buf[23], filename); *(uint32_t *)&shf->buf[19] = namelen; ReplaceDelim((char *)&shf->buf[23], namelen, '\0'); datalen = 24 + namelen; ret = ExecuteRpc(shf, &datalen); if (ret != VMTOOL_SUCCESS) { return ret; } *status = *(uint32_t *)&shf->buf[6]; if (datalen >= 14) { *handle = *(uint32_t *)&shf->buf[10]; } if (vmshf_debug) { fprintf(stderr, "status:%lu, handle:%ld\n", *status, *handle); } return VMTOOL_SUCCESS; }