Example #1
0
CoreResult setHiddenFlag(CryptedVolume * pVolume,
   CryptedFileID idDir, CryptedFileID idFile, bool fHidden)
{
   CoreResult cr;
   CryptedDirEntry * pEntries, * pCur;
   bool fFound = false;
   
   cr = coreQueryDirEntries(pVolume, idDir, &pEntries);
   if (cr) {
      coreFreeDirEntries(pEntries);
      return cr;
   }

   for (pCur = pEntries; pCur; pCur = pCur->pNext)
      if (pCur->idFile == idFile) {
         fFound = true;
         if (fHidden)
            pCur->flFlags |= CDF_HIDDEN;
         else
            pCur->flFlags &= ~CDF_HIDDEN;
      }

   if (!fFound) {
      coreFreeDirEntries(pEntries);
      return CORERC_FILE_NOT_FOUND;
   }

   cr = coreSetDirEntries(pVolume, idDir, pEntries);
   coreFreeDirEntries(pEntries);
   return cr;
}
Example #2
0
APIRET fsRmDir(ServerData * pServerData, struct rmdir * prmdir)
{
   CoreResult cr;
   VolData * pVolData;
   CryptedVolume * pVolume;
   CHAR szName[CCHMAXPATH];
   CryptedFileID idDir;
   CryptedFileID idFile;
   CryptedDirEntry * pFirstEntry;
   
   if (VERIFYFIXED(prmdir->szName) ||
       verifyPathName(prmdir->szName))
      return ERROR_INVALID_PARAMETER;
   
   GET_VOLUME(prmdir);
   pVolume = pVolData->pVolume;
   
   logMsg(L_DBG, "FS_RMDIR, szName=%s", prmdir->szName);

   cr = findFromCurDir(pVolData, prmdir->szName, &prmdir->cdfsi,
       &prmdir->cdfsd, prmdir->iCurDirEnd, &idDir, &idFile, 0,
       szName);
   if (cr) return coreResultToOS2(cr);

   /* Yes.  Read the directory contents.  (This implicitly makes sure
      that pFile is a directory. */
   cr = coreQueryDirEntries(pVolume, idFile, &pFirstEntry);
   if (cr || pFirstEntry) {
      coreFreeDirEntries(pFirstEntry);
      return cr ? coreResultToOS2(cr) : ERROR_CURRENT_DIRECTORY;
   }

   /* The directory is empty, so we can proceed with the deletion. */

   /* Remove the directory from its parent directory. */
   cr = coreMoveDirEntry(pVolume, szName, idDir, 0, 0);
   if (cr) return coreResultToOS2(cr);

   /* Delete the directory. */
   cr = coreDeleteFile(pVolume, idFile);
   if (cr) return coreResultToOS2(cr);
   
   return NO_ERROR;
}
Example #3
0
APIRET fsPathInfo(ServerData * pServerData,
   struct pathinfo * ppathinfo)
{
   CoreResult cr;
   VolData * pVolData;
   CryptedVolume * pVolume;
   CHAR szName[CCHMAXPATH];
   CryptedFileID idDir;
   CryptedFileID idFile;
   CryptedDirEntry * pDirEntry;
   bool fHidden;
   
   if (VERIFYFIXED(ppathinfo->szName) ||
       verifyPathName(ppathinfo->szName))
      return ERROR_INVALID_PARAMETER;
   
   GET_VOLUME(ppathinfo);
   pVolume = pVolData->pVolume;
   
   logMsg(L_DBG,
      "FS_PATHINFO, szName=%s, usLevel=%hd, "
      "cbData=%hd, fsFlag=%04hx",
      ppathinfo->szName, ppathinfo->usLevel,
      ppathinfo->cbData, ppathinfo->fsFlag);
   
   cr = findFromCurDir(pVolData, ppathinfo->szName, &ppathinfo->cdfsi,
       &ppathinfo->cdfsd, ppathinfo->iCurDirEnd, &idDir, &idFile,
       &pDirEntry, szName);
   if (cr) return coreResultToOS2(cr);

   fHidden = pDirEntry->flFlags & CDF_HIDDEN;
   coreFreeDirEntries(pDirEntry);

   return doFileInfo(
      0,
      ppathinfo->fsFlag,
      ppathinfo->usLevel,
      pVolData,
      idFile,
      idDir,
      fHidden,
      ppathinfo->cbData,
      (char *) pServerData->pData);
}
Example #4
0
APIRET fsFileAttribute(ServerData * pServerData,
   struct fileattribute * pfileattribute)
{
   CoreResult cr;
   VolData * pVolData;
   CryptedVolume * pVolume;
   CHAR szName[CCHMAXPATH];
   CryptedFileID idDir;
   CryptedFileID idFile;
   CryptedFileInfo info, info2;
   CryptedDirEntry * pDirEntry;
   bool fHidden;
   
   if (VERIFYFIXED(pfileattribute->szName) ||
       verifyPathName(pfileattribute->szName))
      return ERROR_INVALID_PARAMETER;
   
   GET_VOLUME(pfileattribute);
   pVolume = pVolData->pVolume;
   
   logMsg(L_DBG,
      "FS_FILEATTRIBUTE, szName=%s, fsFlag=%hd, fsAttr=%hd",
      pfileattribute->szName, pfileattribute->fsFlag,
      pfileattribute->fsAttr);
   
   cr = findFromCurDir(pVolData, pfileattribute->szName,
       &pfileattribute->cdfsi, &pfileattribute->cdfsd,
       pfileattribute->iCurDirEnd, &idDir, &idFile, &pDirEntry,
       szName);
   if (cr) return coreResultToOS2(cr);

   fHidden = pDirEntry->flFlags & CDF_HIDDEN;
   coreFreeDirEntries(pDirEntry);
   
   /* Access the file and get file info. */
   cr = coreQueryFileInfo(pVolume, idFile, &info);
   if (cr) return coreResultToOS2(cr);

   if (pfileattribute->fsFlag & FA_SET) {
      
      /* Set the file attributes. */
      
      /* Update the hidden flag in the directory, if necessary. */
      if (!beq(fHidden, pfileattribute->fsAttr & FILE_HIDDEN)) {
         cr = setHiddenFlag(pVolume, idDir, idFile,
            pfileattribute->fsAttr & FILE_HIDDEN);
         if (cr) return coreResultToOS2(cr);
      }

      /* Update the flags in the info sector, if necessary. */
      info2 = info;
      extractDOSAttr(pfileattribute->fsAttr, &info2);

      if (info2.flFlags != info.flFlags) {
         cr = coreSetFileInfo(pVolume, idFile, &info2);
         if (cr) return coreResultToOS2(cr);
      }

      return NO_ERROR;
      
   } else {
      /* Query the file attributes. */
      pfileattribute->fsAttr = makeDOSAttr(fHidden, &info);
      return NO_ERROR;
   }
}