コード例 #1
0
ファイル: storage.c プロジェクト: OS2World/UTIL-ENCRYPT-AEFS
/* Remove the CryptedFile from memory.  All dirty sectors are flushed
   to disk and removed from the cache. */
static CoreResult dropFile(CryptedFile * pFile)
{
   CoreResult cr;

   cr = coreFlushFile(pFile->pVolume, pFile->id);
   if (cr) return cr; /* !!! */
   
   /* Delete all sectors from the cache. */
   deleteHighSectors(pFile, 0);

   /* Close the storage file, if we have one. */
   cr = closeStorageFile(pFile);
   if (cr) return cr; /* !!! */
   
   /* Remove the file from the volume's MRU list. */
   removeFileFromMRUList(pFile);
   
   /* Remove the CryptedFile from the volume's file hash table. */
   if (pFile->pPrevInHash)
      pFile->pPrevInHash->pNextInHash = pFile->pNextInHash;
   else
      pFile->pVolume->FileHashTable[fileHashTableHash(pFile->id)] =
         pFile->pNextInHash;
   if (pFile->pNextInHash)
      pFile->pNextInHash->pPrevInHash = pFile->pPrevInHash;

   /* Free the CryptedFile. */
   sysFreeSecureMem(pFile);

   return CORERC_OK;
}
コード例 #2
0
ファイル: fileinfo.c プロジェクト: edolstra/aefs
/* Update file time stamps if required.  Flush none, some or all of
   the file to disk. */
APIRET stampFileAndFlush(VolData * pVolData, CryptedFileID idFile,
   struct sffsi * psffsi, int flush)
{
   CoreResult cr;
   CryptedVolume * pVolume = pVolData->pVolume;
   CryptedFileInfo info;

   /* If any of the ST_Sxxx stamp bits is set, copy the sffsi times
      into the info sector. */
   if (!pVolData->fReadOnly &&
       ((psffsi->sfi_tstamp & (ST_SCREAT | ST_SWRITE)) ||
        ((psffsi->sfi_tstamp & ST_SREAD) &&
         !pVolData->pServerData->fLazyLastAccess)))
   {
      cr = coreQueryFileInfo(pVolume, idFile, &info);
      if (cr) return coreResultToOS2(cr);

      /* Copy the time stamps from the sffsi. */
      os2TimeToCore(
         * (FDATE *) &psffsi->sfi_cdate,
         * (FTIME *) &psffsi->sfi_ctime,
         &info.timeCreation);
      os2TimeToCore(
         * (FDATE *) &psffsi->sfi_adate,
         * (FTIME *) &psffsi->sfi_atime,
         &info.timeAccess);
      os2TimeToCore(
         * (FDATE *) &psffsi->sfi_mdate,
         * (FTIME *) &psffsi->sfi_mtime,
         &info.timeWrite);

      if (psffsi->sfi_tstamp & ST_SWRITE)
         info.flFlags |= CFF_OS2A;

      /* Write the info sector. */
      cr = coreSetFileInfo(pVolume, idFile, &info);
      if (cr) return coreResultToOS2(cr);
   }

   psffsi->sfi_tstamp = 0;

   switch (flush) {

      case SFAF_NOFLUSH:
         break;

      case SFAF_FLUSHINFO:
         /* Flush the info sector if it's in the cache and dirty. */
         cr = coreFlushSector(pVolume, INFOSECTORFILE_ID,
            coreQueryInfoSectorNumber(pVolume, idFile));
         if (cr) return coreResultToOS2(cr);
         break;
         
      case SFAF_FLUSHALL:
         if (cr = coreFlushFile(pVolume, idFile))
            return coreResultToOS2(cr);
         break;

      default:
         abort();
   }

   return NO_ERROR;
}