APIRET fsMkDir(ServerData * pServerData, struct mkdir * pmkdir) { CoreResult cr; APIRET rc; VolData * pVolData; CryptedVolume * pVolume; CHAR szName[CCHMAXPATH]; CryptedFileID idDir, idFile, idNewDir; CryptedFileInfo info; pmkdir->oError = 0; if (VERIFYFIXED(pmkdir->szName) || verifyPathName(pmkdir->szName)) return ERROR_INVALID_PARAMETER; GET_VOLUME(pmkdir); pVolume = pVolData->pVolume; logMsg(L_DBG, "FS_MKDIR, szName=%s, fsFlags=%d", pmkdir->szName, pmkdir->fsFlags); cr = findFromCurDir(pVolData, pmkdir->szName, &pmkdir->cdfsi, &pmkdir->cdfsd, pmkdir->iCurDirEnd, &idDir, &idFile, 0, szName); if (!idDir) return coreResultToOS2(cr); if (cr == CORERC_OK) return ERROR_ACCESS_DENIED; if (cr != CORERC_FILE_NOT_FOUND) return coreResultToOS2(cr); /* No. Create a new directory. */ memset(&info, 0, sizeof(info)); info.flFlags = CFF_IFDIR | 0700; /* rwx for user */ info.cRefs = 1; info.cbFileSize = 0; info.timeWrite = info.timeAccess = info.timeCreation = curTime(); info.idParent = idDir; /* uid and gid are set to 0 */ cr = coreCreateBaseFile(pVolume, &info, &idNewDir); if (cr) return coreResultToOS2(cr); /* Set the extended attributes. */ if (pmkdir->fHasEAs) { rc = addEAs(pVolume, idNewDir, (PFEALIST) pServerData->pData); if (rc) { coreDeleteFile(pVolume, idNewDir); return rc; } } /* Add the directory to the parent directory. */ cr = coreAddEntryToDir(pVolume, idDir, szName, idNewDir, 0); if (cr) { coreDeleteFile(pVolume, idNewDir); return coreResultToOS2(cr); } return NO_ERROR; }
APIRET doFileInfo(struct sffsi * psffsi, ULONG flFlag, ULONG ulLevel, VolData * pVolData, CryptedFileID idFile, CryptedFileID idDir, bool fHidden, ULONG cbData, char * pData) { CoreResult cr; APIRET rc; CryptedVolume * pVolume = pVolData->pVolume; CryptedFileInfo info; PGEALIST pgeas; /* Access the file and get file info. */ cr = coreQueryFileInfo(pVolume, idFile, &info); if (cr) return coreResultToOS2(cr); if (flFlag & FI_SET) { /* Set file info. */ switch (ulLevel) { case FIL_STANDARD: /* Set file info. */ if (cbData < sizeof(FILESTATUS)) return ERROR_INVALID_PARAMETER; return setLevel1Info(pVolume, psffsi, idFile, idDir, fHidden, (PFILESTATUS) pData); case FIL_QUERYEASIZE: /* Set EAs. */ rc = addEAs(pVolume, idFile, (PFEALIST) pData); if (rc) return rc; return easChanged(pVolume, idFile, fHidden, psffsi); default: logMsg(L_EVIL, "unknown set-FS_[FILE|PATH]INFO info level: %d", ulLevel); return ERROR_NOT_SUPPORTED; } } else { /* Query file info. */ switch (ulLevel) { case FIL_STANDARD: case FIL_QUERYEASIZE: /* Query level 1 or 2 file info. */ memset(pData, 0, cbData); return storeFileInfo(0, 0, 0, 0, fHidden, &info, &pData, &cbData, ulLevel, 0, 0); case FIL_QUERYEASFROMLIST: /* Query level 3 (EA) file info. */ /* The GEAs are stored in the exchange buffer which is about to be overwritten; so make a copy. */ pgeas = alloca(((PGEALIST) pData)->cbList); memcpy(pgeas, pData, ((PGEALIST) pData)->cbList); return storeEAsInFEAList(pVolume, idFile, &info, pgeas, 65536, pData); case 4: /* Store the entire EA set. */ return storeEAsInFEAList(pVolume, idFile, &info, 0, 65536, pData); default: logMsg(L_EVIL, "unknown query-FS_[FILE|PATH]INFO info level: %d", ulLevel); return ERROR_NOT_SUPPORTED; } } }