void QFSEventsFileSystemWatcherEngine::updateList(PathInfoList &list, bool directory, bool emitSignals)
{
    PathInfoList::iterator End = list.end();
    PathInfoList::iterator it = list.begin();
    while (it != End) {
        struct ::stat64 newInfo;
        if (::stat64(it->absolutePath, &newInfo) == 0) {
            if (emitSignals) {
                if (newInfo != it->savedInfo) {
                    it->savedInfo = newInfo;
                    if (directory)
                        emit directoryChanged(it->originalPath, false);
                    else
                        emit fileChanged(it->originalPath, false);
                }
            } else {
                it->savedInfo = newInfo;
            }
        } else {
            if (errno == ENOENT) {
                if (emitSignals) {
                    if (directory)
                        emit directoryChanged(it->originalPath, true);
                    else
                        emit fileChanged(it->originalPath, true);
                }
                it = list.erase(it);
                continue;
            } else {
                qWarning("%s:%d:QFSEventsFileSystemWatcherEngine: stat error on %s:%s",
                         __FILE__, __LINE__, qPrintable(it->originalPath), strerror(errno));

            }
        }
        ++it;
    }
}
示例#2
0
void MsgHelperRepair::fixChunkPermissions(Node* node, FsckChunkList& chunkList,
   PathInfoList& pathInfoList, FsckChunkList& failedChunks)
{
   const char* logContext = "MsgHelperRepair (fixChunkPermissions)";

   if ( chunkList.size() != pathInfoList.size() )
   {
      LogContext(logContext).logErr(
         "Failed to set uid/gid for chunks. Size of lists does not match.");
      return;
   }

   FsckChunkListIter chunksIter = chunkList.begin();
   PathInfoListIter pathInfoIter = pathInfoList.begin();
   for ( ; chunksIter != chunkList.end(); chunksIter++, pathInfoIter++ )
   {
      bool commRes;
      char *respBuf = NULL;
      NetMessage *respMsg = NULL;

      std::string chunkID = chunksIter->getID();
      uint16_t targetID = chunksIter->getTargetID();
      int validAttribs = SETATTR_CHANGE_USERID | SETATTR_CHANGE_GROUPID; // only interested in these
      SettableFileAttribs attribs;
      attribs.userID = chunksIter->getUserID();
      attribs.groupID = chunksIter->getGroupID();

      bool enableCreation = false;

      PathInfo pathInfo = *pathInfoIter;
      SetLocalAttrMsg setLocalAttrMsg(chunkID, targetID, &pathInfo, validAttribs, &attribs,
         enableCreation);
      setLocalAttrMsg.addMsgHeaderFeatureFlag(SETLOCALATTRMSG_FLAG_USE_QUOTA);

      commRes = MessagingTk::requestResponse(node, &setLocalAttrMsg, NETMSGTYPE_SetLocalAttrResp,
         &respBuf, &respMsg);

      if ( commRes )
      {
         SetLocalAttrRespMsg* setLocalAttrRespMsg = (SetLocalAttrRespMsg*) respMsg;

         if ( setLocalAttrRespMsg->getResult() != FhgfsOpsErr_SUCCESS )
         {
            LogContext(logContext).logErr(
               "Failed to set uid/gid for chunk. chunkID: " + chunkID + "; targetID: "
                  + StringTk::uintToStr(targetID));

            failedChunks.push_back(*chunksIter);
         }
      }
      else
      {
         LogContext(logContext).logErr("Communication error occured with node: " + node->getID());

         failedChunks.push_back(*chunksIter);
      }

      SAFE_FREE(respBuf);
      SAFE_DELETE(respMsg);
   }
}