Changeset 69832 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Nov 24, 2017 8:04:37 PM (7 years ago)
- Location:
- trunk/src/VBox/Runtime/common/fs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/fs/fatvfs.cpp
r69831 r69832 4180 4180 4181 4181 4182 #if 04183 /**4184 * @interface_method_impl{RTVFSDIROPS,pfnOpenFile}4185 */4186 static DECLCALLBACK(int) rtFsFatDir_OpenFile(void *pvThis, const char *pszFilename, uint64_t fOpen, PRTVFSFILE phVfsFile)4187 {4188 PRTFSFATDIR pThis = (PRTFSFATDIR)pvThis;4189 PRTFSFATDIRSHRD pShared = pThis->pShared;4190 4191 /*4192 * Try open existing file.4193 */4194 uint32_t offEntryInDir;4195 bool fLong;4196 FATDIRENTRY DirEntry;4197 int rc = rtFsFatDirShrd_FindEntry(pShared, pszFilename, &offEntryInDir, &fLong, &DirEntry);4198 if (RT_SUCCESS(rc))4199 {4200 switch (DirEntry.fAttrib & (FAT_ATTR_DIRECTORY | FAT_ATTR_VOLUME))4201 {4202 case 0:4203 if ( !(DirEntry.fAttrib & FAT_ATTR_READONLY)4204 || !(fOpen & RTFILE_O_WRITE))4205 {4206 if ( (fOpen & RTFILE_O_ACTION_MASK) == RTFILE_O_OPEN4207 || (fOpen & RTFILE_O_ACTION_MASK) == RTFILE_O_OPEN_CREATE4208 || (fOpen & RTFILE_O_ACTION_MASK) == RTFILE_O_CREATE_REPLACE)4209 rc = rtFsFatFile_New(pShared->Core.pVol, pShared, &DirEntry, offEntryInDir, fOpen, phVfsFile);4210 else4211 rc = VERR_ALREADY_EXISTS;4212 }4213 else4214 rc = VERR_ACCESS_DENIED;4215 break;4216 4217 case FAT_ATTR_DIRECTORY:4218 rc = VERR_NOT_A_FILE;4219 break;4220 default:4221 rc = VERR_PATH_NOT_FOUND;4222 break;4223 }4224 }4225 /*4226 * Create the file?4227 */4228 else if ( rc == VERR_FILE_NOT_FOUND4229 && ( (fOpen & RTFILE_O_ACTION_MASK) == RTFILE_O_CREATE4230 || (fOpen & RTFILE_O_ACTION_MASK) == RTFILE_O_OPEN_CREATE4231 || (fOpen & RTFILE_O_ACTION_MASK) == RTFILE_O_CREATE_REPLACE) )4232 {4233 rc = rtFsFatDirShrd_CreateEntry(pShared, pszFilename, FAT_ATTR_ARCHIVE, 0 /*cbInitial*/, &offEntryInDir, &DirEntry);4234 if (RT_SUCCESS(rc))4235 rc = rtFsFatFile_New(pShared->Core.pVol, pShared, &DirEntry, offEntryInDir, fOpen, phVfsFile);4236 }4237 return rc;4238 }4239 #endif4240 4241 4242 #if 04243 /**4244 * @interface_method_impl{RTVFSDIROPS,pfnCreateDir}4245 */4246 static DECLCALLBACK(int) rtFsFatDir_CreateDir(void *pvThis, const char *pszSubDir, RTFMODE fMode, PRTVFSDIR phVfsDir)4247 {4248 PRTFSFATDIR pThis = (PRTFSFATDIR)pvThis;4249 PRTFSFATDIRSHRD pShared = pThis->pShared;4250 RT_NOREF(fMode);4251 4252 /*4253 * Check if it already exists in any form.4254 */4255 uint32_t offEntryInDir;4256 bool fLong;4257 FATDIRENTRY DirEntry;4258 int rc = rtFsFatDirShrd_FindEntry(pShared, pszSubDir, &offEntryInDir, &fLong, &DirEntry);4259 if (rc != VERR_FILE_NOT_FOUND)4260 return RT_SUCCESS(rc) ? VERR_ALREADY_EXISTS : rc;4261 4262 if ( strcmp(pszSubDir, ".") == 04263 || strcmp(pszSubDir, "..") == 0)4264 return VERR_ALREADY_EXISTS;4265 4266 /*4267 * Okay, create it.4268 */4269 rc = rtFsFatDirShrd_CreateEntry(pShared, pszSubDir, FAT_ATTR_ARCHIVE | FAT_ATTR_DIRECTORY,4270 pShared->Core.pVol->cbCluster, &offEntryInDir, &DirEntry);4271 if (RT_SUCCESS(rc))4272 rc = rtFsFatDir_New(pShared->Core.pVol, pShared, &DirEntry, offEntryInDir,4273 RTFSFAT_GET_CLUSTER(&DirEntry, pShared->Core.pVol), UINT64_MAX /*offDisk*/,4274 DirEntry.cbFile, phVfsDir);4275 return rc;4276 }4277 #endif4278 4279 4280 4182 /** 4281 4183 * @interface_method_impl{RTVFSDIROPS,pfnOpenSymlink} … … 4297 4199 return VERR_NOT_SUPPORTED; 4298 4200 } 4299 4300 4301 #if 04302 /**4303 * @interface_method_impl{RTVFSDIROPS,pfnQueryEntryInfo}4304 */4305 static DECLCALLBACK(int) rtFsFatDir_QueryEntryInfo(void *pvThis, const char *pszEntry,4306 PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr)4307 {4308 /*4309 * Try locate the entry.4310 */4311 PRTFSFATDIR pThis = (PRTFSFATDIR)pvThis;4312 PRTFSFATDIRSHRD pShared = pThis->pShared;4313 uint32_t offEntryInDir;4314 bool fLong;4315 FATDIRENTRY DirEntry;4316 int rc = rtFsFatDirShrd_FindEntry(pShared, pszEntry, &offEntryInDir, &fLong, &DirEntry);4317 Log2(("rtFsFatDir_QueryEntryInfo: FindEntry(,%s,) -> %Rrc\n", pszEntry, rc));4318 if (RT_SUCCESS(rc))4319 {4320 /*4321 * To avoid duplicating code in rtFsFatObj_InitFromDirRec and4322 * rtFsFatObj_QueryInfo, we create a dummy RTFSFATOBJ on the stack.4323 */4324 RTFSFATOBJ TmpObj;4325 RT_ZERO(TmpObj);4326 rtFsFatObj_InitFromDirEntry(&TmpObj, &DirEntry, offEntryInDir, pShared->Core.pVol);4327 rc = rtFsFatObj_QueryInfo(&TmpObj, pObjInfo, enmAddAttr);4328 }4329 return rc;4330 }4331 #endif4332 4201 4333 4202 -
trunk/src/VBox/Runtime/common/fs/isovfs.cpp
r69831 r69832 3068 3068 3069 3069 3070 #if 03071 /**3072 * @interface_method_impl{RTVFSDIROPS,pfnOpenFile}3073 */3074 static DECLCALLBACK(int) rtFsIsoDir_OpenFile(void *pvThis, const char *pszFilename, uint64_t fOpen, PRTVFSFILE phVfsFile)3075 {3076 PRTFSISODIROBJ pThis = (PRTFSISODIROBJ)pvThis;3077 PRTFSISODIRSHRD pShared = pThis->pShared;3078 3079 /*3080 * We cannot create or replace anything, just open stuff.3081 */3082 if ( (fOpen & RTFILE_O_ACTION_MASK) == RTFILE_O_CREATE3083 || (fOpen & RTFILE_O_ACTION_MASK) == RTFILE_O_CREATE_REPLACE)3084 return VERR_WRITE_PROTECT;3085 3086 /*3087 * Try open file.3088 */3089 int rc;3090 if (pShared->Core.pVol->enmType != RTFSISOVOLTYPE_UDF)3091 {3092 /*3093 * ISO 96603094 */3095 PCISO9660DIRREC pDirRec;3096 uint64_t offDirRec;3097 uint32_t cDirRecs;3098 RTFMODE fMode;3099 uint32_t uVersion;3100 rc = rtFsIsoDir_FindEntry9660(pShared, pszFilename, &offDirRec, &pDirRec, &cDirRecs, &fMode, &uVersion);3101 Log2(("rtFsIsoDir_OpenFile: FindEntry9660(,%s,) -> %Rrc\n", pszFilename, rc));3102 if (RT_SUCCESS(rc))3103 {3104 switch (fMode & RTFS_TYPE_MASK)3105 {3106 case RTFS_TYPE_FILE:3107 rc = rtFsIsoFile_New9660(pShared->Core.pVol, pShared, pDirRec, cDirRecs, offDirRec, fOpen, uVersion, phVfsFile);3108 break;3109 3110 case RTFS_TYPE_SYMLINK:3111 case RTFS_TYPE_DEV_BLOCK:3112 case RTFS_TYPE_DEV_CHAR:3113 case RTFS_TYPE_FIFO:3114 case RTFS_TYPE_SOCKET:3115 case RTFS_TYPE_WHITEOUT:3116 rc = VERR_NOT_IMPLEMENTED;3117 break;3118 3119 case RTFS_TYPE_DIRECTORY:3120 rc = VERR_NOT_A_FILE;3121 break;3122 3123 default:3124 rc = VERR_PATH_NOT_FOUND;3125 break;3126 }3127 }3128 }3129 else3130 {3131 /*3132 * UDF3133 */3134 PCUDFFILEIDDESC pFid;3135 rc = rtFsIsoDir_FindEntryUdf(pShared, pszFilename, &pFid);3136 Log2(("rtFsIsoDir_OpenFile: FindEntryUdf(,%s,) -> %Rrc\n", pszFilename, rc));3137 if (RT_SUCCESS(rc))3138 {3139 if (!(pFid->fFlags & UDF_FILE_FLAGS_DELETED))3140 {3141 if (!(pFid->fFlags & UDF_FILE_FLAGS_DIRECTORY))3142 rc = rtFsIsoFile_NewUdf(pShared->Core.pVol, pShared, pFid, fOpen, phVfsFile);3143 else3144 rc = VERR_NOT_A_FILE;3145 }3146 /* We treat UDF_FILE_FLAGS_DELETED like RTFS_TYPE_WHITEOUT for now. */3147 else3148 rc = VERR_PATH_NOT_FOUND;3149 }3150 }3151 return rc;3152 }3153 #endif3154 3155 3156 #if 03157 /**3158 * @interface_method_impl{RTVFSDIROPS,pfnOpenDir}3159 */3160 static DECLCALLBACK(int) rtFsIsoDir_OpenDir(void *pvThis, const char *pszSubDir, uint32_t fFlags, PRTVFSDIR phVfsDir)3161 {3162 PRTFSISODIROBJ pThis = (PRTFSISODIROBJ)pvThis;3163 PRTFSISODIRSHRD pShared = pThis->pShared;3164 AssertReturn(!fFlags, VERR_INVALID_FLAGS);3165 3166 /*3167 * Try open file.3168 */3169 int rc;3170 if (pShared->Core.pVol->enmType != RTFSISOVOLTYPE_UDF)3171 {3172 /*3173 * ISO 96603174 */3175 PCISO9660DIRREC pDirRec;3176 uint64_t offDirRec;3177 uint32_t cDirRecs;3178 RTFMODE fMode;3179 uint32_t uVersion;3180 rc = rtFsIsoDir_FindEntry9660(pShared, pszSubDir, &offDirRec, &pDirRec, &cDirRecs, &fMode, &uVersion);3181 Log2(("rtFsIsoDir_OpenDir: FindEntry9660(,%s,) -> %Rrc\n", pszSubDir, rc));3182 if (RT_SUCCESS(rc))3183 {3184 switch (fMode & RTFS_TYPE_MASK)3185 {3186 case RTFS_TYPE_DIRECTORY:3187 rc = rtFsIsoDir_New9660(pShared->Core.pVol, pShared, pDirRec, cDirRecs, offDirRec, phVfsDir);3188 break;3189 3190 case RTFS_TYPE_FILE:3191 case RTFS_TYPE_SYMLINK:3192 case RTFS_TYPE_DEV_BLOCK:3193 case RTFS_TYPE_DEV_CHAR:3194 case RTFS_TYPE_FIFO:3195 case RTFS_TYPE_SOCKET:3196 case RTFS_TYPE_WHITEOUT:3197 rc = VERR_NOT_A_DIRECTORY;3198 break;3199 3200 default:3201 rc = VERR_PATH_NOT_FOUND;3202 break;3203 }3204 }3205 }3206 else3207 {3208 /*3209 * UDF3210 */3211 PCUDFFILEIDDESC pFid;3212 rc = rtFsIsoDir_FindEntryUdf(pShared, pszSubDir, &pFid);3213 Log2(("rtFsIsoDir_OpenDir: FindEntryUdf(,%s,) -> %Rrc\n", pszSubDir, rc));3214 if (RT_SUCCESS(rc))3215 {3216 if (!(pFid->fFlags & UDF_FILE_FLAGS_DELETED))3217 {3218 if (pFid->fFlags & UDF_FILE_FLAGS_DIRECTORY)3219 rc = rtFsIsoDir_NewUdf(pShared->Core.pVol, pShared, pFid, phVfsDir);3220 else3221 rc = VERR_NOT_A_DIRECTORY;3222 }3223 /* We treat UDF_FILE_FLAGS_DELETED like RTFS_TYPE_WHITEOUT for now. */3224 else3225 rc = VERR_PATH_NOT_FOUND;3226 }3227 }3228 return rc;3229 }3230 #endif3231 3232 3233 3070 /** 3234 3071 * @interface_method_impl{RTVFSDIROPS,pfnCreateDir} … … 3260 3097 return VERR_WRITE_PROTECT; 3261 3098 } 3262 3263 3264 #if 03265 /**3266 * @interface_method_impl{RTVFSDIROPS,pfnQueryEntryInfo}3267 */3268 static DECLCALLBACK(int) rtFsIsoDir_QueryEntryInfo(void *pvThis, const char *pszEntry,3269 PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr)3270 {3271 PRTFSISODIROBJ pThis = (PRTFSISODIROBJ)pvThis;3272 PRTFSISODIRSHRD pShared = pThis->pShared;3273 RTFSISOCORE TmpObj;3274 int rc;3275 if (pShared->Core.pVol->enmType != RTFSISOVOLTYPE_UDF)3276 {3277 /*3278 * Try locate the entry.3279 */3280 PCISO9660DIRREC pDirRec;3281 uint64_t offDirRec;3282 uint32_t cDirRecs;3283 RTFMODE fMode;3284 uint32_t uVersion;3285 rc = rtFsIsoDir_FindEntry9660(pShared, pszEntry, &offDirRec, &pDirRec, &cDirRecs, &fMode, &uVersion);3286 Log2(("rtFsIsoDir_QueryEntryInfo: FindEntry9660(,%s,) -> %Rrc\n", pszEntry, rc));3287 if (RT_SUCCESS(rc))3288 {3289 /*3290 * To avoid duplicating code in rtFsIsoCore_InitFrom9660DirRec and3291 * rtFsIsoCore_QueryInfo, we create a dummy RTFSISOCORE on the stack.3292 */3293 RT_ZERO(TmpObj);3294 rc = rtFsIsoCore_InitFrom9660DirRec(&TmpObj, pDirRec, cDirRecs, offDirRec, uVersion, pShared->Core.pVol);3295 if (RT_SUCCESS(rc))3296 {3297 rc = rtFsIsoCore_QueryInfo(&TmpObj, pObjInfo, enmAddAttr);3298 rtFsIsoCore_Destroy(&TmpObj);3299 }3300 }3301 }3302 else3303 {3304 /*3305 * Try locate the entry.3306 */3307 PCUDFFILEIDDESC pFid;3308 rc = rtFsIsoDir_FindEntryUdf(pShared, pszEntry, &pFid);3309 Log2(("rtFsIsoDir_QueryEntryInfo: FindEntryUdf(,%s,) -> %Rrc\n", pszEntry, rc));3310 if (RT_SUCCESS(rc))3311 {3312 /*3313 * To avoid duplicating code in rtFsIsoCore_InitFromUdfIcbAndFileIdDesc and3314 * rtFsIsoCore_QueryInfo, we create a dummy RTFSISOCORE on the stack.3315 */3316 RT_ZERO(TmpObj);3317 uintptr_t offInDir = (uintptr_t)pFid - (uintptr_t)pShared->pbDir;3318 rc = rtFsIsoCore_InitFromUdfIcbAndFileIdDesc(&TmpObj, &pFid->Icb, pFid, offInDir, pShared->Core.pVol);3319 if (RT_SUCCESS(rc))3320 {3321 rc = rtFsIsoCore_QueryInfo(&TmpObj, pObjInfo, enmAddAttr);3322 rtFsIsoCore_Destroy(&TmpObj);3323 }3324 }3325 }3326 return rc;3327 }3328 #endif3329 3099 3330 3100
Note:
See TracChangeset
for help on using the changeset viewer.