190{
198 ULONG RequestedOptions;
199 ULONG RequestedDisposition;
203 ULONG ExtAttrLength = 0;
206
213
214
215
216
218 BOOLEAN DeleteOnCloseSpecified;
219
220
221
222
223
225
227
229
233
234 ULONG ReturnedInformation = 0;
235
238
246
252 ULONG TreeLength = 0;
253
254
260 ULONG SNameIndex = 0;
261
262 TmPrint((
"UDFCommonCreate:\n"));
263
266
268
271
272
274
277 }
278
281
284
285
286
288
289
293 }
294
295
296
297
298
300 TargetObjectName = PtrNewFileObject->FileName;
301 PtrRelatedFileObject = PtrNewFileObject->RelatedFileObject;
302
303
304
305 if (PtrRelatedFileObject) {
306 PtrRelatedCCB = (
PtrUDFCCB)(PtrRelatedFileObject->FsContext2);
309
310 PtrRelatedFCB = PtrRelatedCCB->
Fcb;
314 RelatedObjectName = PtrRelatedFileObject->FileName;
315 if (!(RelatedObjectName.
Length) || (RelatedObjectName.
Buffer[0] !=
L'\\')) {
318 }
319 }
320
321
322
324
325
328
329
331
332
333
334
336
337
338
340
341
342 switch(RequestedDisposition) {
344 AdPrint((
" Dispos: FILE_SUPERSEDE\n"));
345 break;
347 AdPrint((
" Dispos: FILE_OPEN\n"));
348 break;
350 AdPrint((
" Dispos: FILE_CREATE\n"));
351 break;
353 AdPrint((
" Dispos: FILE_OPEN_IF\n"));
354 break;
356 AdPrint((
" Dispos: FILE_OVERWRITE\n"));
357 break;
359 AdPrint((
" Dispos: FILE_OVERWRITE_IF\n"));
360 break;
361 default:
362 AdPrint((
" Dispos: *** Unknown ***\n"));
363 break;
364 }
365
366
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386#define OpenForBackup (RequestedOptions & FILE_OPEN_FOR_BACKUP_INTENT)
387
388
389
390
391
392
393#define DirectoryOnlyRequested (RequestedOptions & FILE_DIRECTORY_FILE)
394
395
396
397
398
399
400
401#define FileOnlyRequested (RequestedOptions & FILE_NON_DIRECTORY_FILE)
402
403
404
405
406
407
408#define NoBufferingSpecified (RequestedOptions & FILE_NO_INTERMEDIATE_BUFFERING)
409
410
411
412
413
415
416#define SequentialIoRequested (RequestedOptions & FILE_SEQUENTIAL_ONLY ? TRUE : FALSE)
417
418
419
420
421
422
423
424
425
426
428
429 if(DeleteOnCloseSpecified) {
431 }
432
433#define NoExtAttrKnowledge TRUE
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448#define OpenByFileId (RequestedOptions & FILE_OPEN_BY_FILE_ID)
449
450
452
453
454
455
457
458
459
461
462
466
467
468 WriteThroughRequested = WriteThroughRequested ||
470
471
472
473
474
475 if(PageFileManipulation) {
476 ReturnedInformation = 0;
477 AdPrint((
"Can't create a page file\n"));
479 }
480 if(ExtAttrLength) {
481 ReturnedInformation = 0;
482 AdPrint((
"Can't create file with EAs\n"));
484 }
485
487
488 if (
Vcb->SoftEjectReq) {
489 AdPrint((
" Eject requested\n"));
492 }
493
494
497 AdPrint((
" Volume is locked\n"));
500 }
501
504
505
506
510
512
514
515
516
517
518 if(
519 (
522#ifndef UDF_READ_ONLY_BUILD
524#endif
525 ) &&
526 (DeleteOnCloseSpecified ||
527 OpenTargetDirectory ||
533 ReturnedInformation = 0;
534 AdPrint((
" Write protected or dirty\n"));
536 }
537
538
539
540
541
542
543
544
545
546
547 if (!(PtrNewFileObject->FileName.Length) && (!PtrRelatedFileObject ||
549
551
552 AdPrint((
" Opening Volume\n"));
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567 if ((OpenTargetDirectory) || (PtrExtAttrBuffer)) {
569 }
570
572
574 }
575
576#ifndef UDF_READ_ONLY_BUILD
577 if (DeleteOnCloseSpecified) {
578
580 }
581
583
586 }
587#endif
588
590
591
592
593
594
598 } else {
599
604 }
605 }
606
610
611 } else {
612
615
616
617
618 UDFPrint((
" set UDF_IRP_CONTEXT_FLUSH2_REQUIRED\n"));
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637 }
638 }
639
640
641
643
644 if ((
Vcb->VCBHandleCount) &&
646
647 UDFPrint((
" !FILE_SHARE_READ + open handles (%d)\n",
Vcb->VCBHandleCount));
649 }
651
654
658
661 }
662#ifdef UDF_DELAYED_CLOSE
664#endif
665
669
671
674 UDFPrint((
" FILE_SHARE_READ + R/W handles: %d(%d) -> STATUS_SHARING_VIOLATION ?\n",
676 Vcb->VCBOpenCountRO));
677
678
679 }
680 }
681
685 Vcb->VolumeLockFileObject = PtrNewFileObject;
687 } else
689 UDFPrint((
" set UDF_IRP_CONTEXT_FLUSH_REQUIRED\n"));
691 }
692 }
693
696
699 goto op_vol_accs_dnd;
700
701 PtrNewCcb = (
PtrUDFCCB)(PtrNewFileObject->FsContext2);
703
706 AdPrint((
" Access violation (Volume)\n"));
707 goto op_vol_accs_dnd;
708 }
709
712 AdPrint((
" Sharing violation (Volume)\n"));
713op_vol_accs_dnd:
714 if(UndoLock) {
715 Vcb->VCBFlags &= ~UDF_VCB_FLAGS_VOLUME_LOCKED;
716 Vcb->VolumeLockFileObject =
NULL;
717 }
719 }
720
721
723
727 }
728
731 ReturnedInformation = 0;
732 AdPrint((
" Can't open anything on blank volume ;)\n"));
734 }
735
737 ReturnedInformation = 0;
738 AdPrint((
" Illegal share access\n"));
740 }
741
742
744
745
749 }
750 }
751
752
753
754
755
756
757
758
759
760
761
762
763
764
766
769
772 ReturnedInformation = 0;
773 AdPrint((
" Can't open by FileID on blank volume ;)\n"));
775 }
776
778 AdPrint((
" Invalid file ID\n"));
780 }
783 if ((RequestedDisposition !=
FILE_OPEN) &&
785 AdPrint((
" Illegal disposition for ID open\n"));
787 }
788
791 AdPrint((
" ID open failed\n"));
793 }
794
795
796
798 AdPrint((
" Init String failed\n"));
800 }
801
802 AbsolutePathName = TargetObjectName;
803 PtrRelatedFileObject =
NULL;
804 } else
805
806
807
808
809 if (PtrRelatedFileObject) {
810
811
812
813
814 UDFPrint((
" PtrRelatedFileObject %x, FCB %x\n", PtrRelatedFileObject, PtrRelatedFCB));
815
816
817
818
819
821
823 AdPrint((
" Related object must be a directory\n"));
829 AdPrint((
" exception when printing name\n"));
832 }
833
834
835
836
837
838
839
840
841 if (!(RelatedObjectName.
Length) || (RelatedObjectName.
Buffer[0] !=
L'\\')) {
842 AdPrint((
" Wrong pathname (1)\n"));
845 }
846
847
849 if (TargetObjectName.
Length && (TargetObjectName.
Buffer[0] ==
L'\\')) {
850 AdPrint((
" Wrong pathname (2)\n"));
853 }
854
855
856
857
858
861 if(RelatedObjectName.
Length &&
862 (RelatedObjectName.
Buffer[ (RelatedObjectName.
Length/
sizeof(
WCHAR)) - 1 ] !=
L'\\')) {
863 RC = MyAppendUnicodeToString(&AbsolutePathName,
L"\\");
865 }
866 if(!AbsolutePathName.
Length ||
869 if(TargetObjectName.
Length && TargetObjectName.
Buffer[0] !=
L'\\') {
870 RC = MyAppendUnicodeToString(&AbsolutePathName,
L"\\");
872 }
873 }
874
875 RC = MyAppendUnicodeStringToStringTag(&AbsolutePathName, &TargetObjectName,
MEM_USABS_TAG);
878
879 } else {
880
881
882
883
884
887 if (!TargetObjectName.
Length || TargetObjectName.
Buffer[0] !=
L'\\') {
888 AdPrint((
" Wrong target name (1)\n"));
890 }
891
892
896 }
897
898 if ((AbsolutePathName.
Length >=
sizeof(
WCHAR)*2) &&
899 (AbsolutePathName.
Buffer[1] ==
L'\\') &&
900 (AbsolutePathName.
Buffer[0] ==
L'\\')) {
901
902
904 (AbsolutePathName.
Buffer[2] ==
L'\\')) {
905 AdPrint((
" Wrong target name (2)\n"));
907 }
908
910 AbsolutePathName.
Buffer + 1,
911 AbsolutePathName.
Length );
912
914 }
917
919 }
920
922
923
924
925
926 if(!TargetObjectName.
Length) {
927 TargetObjectName = AbsolutePathName;
929 }
930
931
932
933
934
935
937 AdPrint((
" Opening RootDir\n"));
938
939
943 AdPrint((
" Can't overwrite RootDir\n"));
946 }
947
948#if 0
950#endif
951
952 if (DeleteOnCloseSpecified) {
953
954 AdPrint((
" Can't delete RootDir\n"));
956 }
957
958 PtrNewFcb =
Vcb->RootDirFCB;
961
963 PtrNewCcb = (
PtrUDFCCB)(PtrNewFileObject->FsContext2);
964 TreeLength = 1;
965
968 AdPrint((
" Access/Sharing violation (RootDir)\n"));
970 }
971
973
975 }
976
978 AdPrint((
" Opening file %ws %8.8x\n",AbsolutePathName.
Buffer, PtrNewFileObject));
980 AdPrint((
" Exception when printing FN\n"));
982
983
984
985 if(OpenExisting) {
986
987
988
989 if(OpenTargetDirectory)
991
992
993
994
998
1000 RelatedFileInfo = PtrRelatedFCB->
FileInfo;
1001
1003 NewFileInfo =
1004 LastGoodFileInfo = RelatedFileInfo;
1005
1006 RelatedFileInfo =
1007 OldRelatedFileInfo = RelatedFileInfo->
ParentFile;
1008 PtrRelatedFCB = PtrRelatedFCB->
ParentFcb;
1009
1011 TreeLength++;
1012
1015
1018 PtrNewFcb = NewFileInfo->
Fcb;
1019
1023 TreeLength++;
1024
1025 goto AlreadyOpened;
1026 }
1027
1029 ReturnedInformation = 0;
1030 AdPrint((
" Can't open File on blank volume ;)\n"));
1033 }
1034
1035
1036
1039 }
1040
1041
1042
1043 if(!
UDFIsNameValid(&AbsolutePathName, &StreamOpen, &SNameIndex)) {
1044 AdPrint((
" Absolute path is not valid\n"));
1046 }
1050 }
1051
1055 if (PtrRelatedFileObject) {
1056
1057
1058 RelatedFileInfo = PtrRelatedFCB->
FileInfo;
1059 if(RelatedFileInfo !=
Vcb->RootDirFCB->FileInfo) {
1063 }
1064 if(TargetObjectName.
Buffer != AbsolutePathName.
Buffer) {
1067 AdPrint((
" Init String 'TargetObjectName' failed\n"));
1069 }
1070 TailNameBuffer = TailName.
Buffer;
1071 } else {
1072 TailName = AbsolutePathName;
1073 }
1074 } else {
1075
1076 RelatedFileInfo =
Vcb->RootDirFCB->FileInfo;
1077 TailName = AbsolutePathName;
1078 }
1079
1080 if(StreamOpen) {
1084
1085
1088 }
1090
1093 LastGoodFileInfo = RelatedFileInfo;
1094
1096 TreeLength++;
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1111
1112
1114 LastGoodTail = TailName;
1115 while(LastGoodTail.
Buffer[0] ==
L'\\') {
1118 }
1119 }
1120
1121 TmpBuffer = TailName.
Buffer;
1127
1128
1129
1131
1132 if(!StreamOpen ||
1134
1135 break;
1136 }
1137 }
1138
1141
1143 AdPrint((
" Error opening path component\n"));
1144
1145
1146
1147
1152 }
1153
1155
1156 if(RelatedFileInfo && (TreeLength>1)) {
1157
1158
1161 }
1162
1164 AdPrint((
" Path component is too long\n"));
1166 }
1167
1169 if(Res2) {
1172 }
1173
1174
1175
1178
1179
1183 AdPrint((
" Traverse check failed\n"));
1184 goto Skip_open_attempt;
1185 }
1186
1187 if(CurName.
Buffer[0] !=
':') {
1188
1191 RelatedFileInfo,&NewFileInfo,
NULL);
1193
1197#ifdef UDF_DBG
1198 } else
1200 AdPrint((
" Not a directory\n"));
1201#endif
1202 } else
1204 AdPrint((
" Dloc is being initialized\n"));
1207 }
1208 } else {
1209
1212SuccessOpen_SDir:
1213
1214 StreamExists =
TRUE;
1217
1219 } else
1221#ifndef UDF_READ_ONLY_BUILD
1222
1223
1227 OpenTargetDirectory ) {
1230 goto SuccessOpen_SDir;
1231 }
1232#endif
1233 }
1234
1235
1236
1237 }
1238#if 0
1240#endif
1241
1242Skip_open_attempt:
1243
1244
1246
1247 if (!(PtrNewFcb = NewFileInfo->
Fcb)) {
1248
1249
1250
1251
1253 NULL, &PtrNewFcb, RelatedFileInfo, NewFileInfo,
1254 &LocalPath, &CurName);
1255
1258 AdPrint((
" Can't perform FirstOpen\n"));
1266 }
1268 }
1269 } else {
1270
1271
1272
1275 AdPrint((
" Fcb not valid\n"));
1281 }
1283 }
1284 }
1285
1286 Res2 = Res1;
1289
1292
1294
1295 LastGoodFileInfo = NewFileInfo;
1296 LastGoodName = CurName;
1297 TreeLength++;
1298
1299 if(!StreamOpen ||
1300 ((CurName.
Buffer[0] !=
L':') &&
1302
1305 RC = MyAppendUnicodeToString(&LocalPath,
L"\\");
1307 }
1308 RC = MyAppendUnicodeStringToStringTag(&LocalPath, &CurName,
MEM_USLOC_TAG);
1311
1312 } else {
1313 AdPrint((
" Can't open file\n"));
1314
1315
1317
1318 if(NewFileInfo) {
1319 PtrNewFcb = NewFileInfo->
Fcb;
1320
1321 if(PtrNewFcb &&
1322 PtrNewFcb->NTRequiredFCB) {
1323 NtReqFcb = PtrNewFcb->NTRequiredFCB;
1324 Res2 = Res1;
1327 }
1328
1329
1330
1331 if(PtrNewFcb &&
1332 !PtrNewFcb->ReferenceCount &&
1333 !PtrNewFcb->OpenHandleCount) {
1335 }
1336
1337
1338
1339 if(NewFileInfo->
Dloc &&
1341 (!PtrNewFcb || !PtrNewFcb->ReferenceCount)) {
1343 }
1344
1347 if(PtrNewFcb) {
1350 }
1352 } else {
1353
1354
1355
1356 NewFileInfo->
Fcb = PtrNewFcb;
1359 }
1360
1361
1362
1365 }
1366 }
1367
1368
1372 AdPrint((
" Return DeletePending (no err)\n"));
1374 }
1375
1376 OldRelatedFileInfo = RelatedFileInfo;
1377 RelatedFileInfo = NewFileInfo;
1378
1379 } else {
1380
1382
1385
1386
1387 break;
1388 }
1390
1391#ifdef UDF_DBG
1395 AdPrint((
" Hard error or damaged data structures\n"));
1396 }
1397#endif
1398
1400 }
1401
1405 ASSERT(!OpenTargetDirectory);
1406
1407
1408 break;
1409 }
1410 }
1411
1412
1413
1414
1415 if(OpenTargetDirectory) {
1416
1418 AdPrint((
" Not a directory (2)\n"));
1420 }
1423 AdPrint((
" Target name should not contain (back)slashes\n"));
1426 }
1427
1428 NewFileInfo = LastGoodFileInfo;
1430
1431
1433 &CurName, RelatedFileInfo))) {
1434
1436 AdPrint((
" Open Target: FILE_EXISTS\n"));
1437 } else
1439#ifdef UDF_DBG
1440
1441
1442 for(TmpBuffer = LastGoodTail.
Buffer; *TmpBuffer; TmpBuffer++) {
1443 if((*TmpBuffer) ==
L'\\') {
1445 AdPrint((
" Target name should not contain (back)slashes\n"));
1447 }
1448 }
1449#endif
1450
1452 AdPrint((
" Open Target: FILE_DOES_NOT_EXIST\n"));
1454 } else {
1455 AdPrint((
" Open Target: unexpected error\n"));
1459 }
1460
1461
1462
1463
1464
1465
1466 PtrNewFcb = NewFileInfo->
Fcb;
1472 AdPrint((
" Can't perform OpenFile operation for target\n"));
1474 }
1475 PtrNewCcb = (
PtrUDFCCB)(PtrNewFileObject->FsContext2);
1476
1480 AdPrint((
" Access/Share access check failed (Open Target)\n"));
1481 }
1482
1484 }
1485
1486
1487
1488
1492 if( ((RequestedDisposition ==
FILE_OPEN) ||
1494 ){
1496 AdPrint((
" File doesn't exist\n"));
1498 }
1499 } else {
1500
1501 AdPrint((
" Can't create due to unexpected error\n"));
1503 }
1504
1507 AdPrint((
" File doesn't exist (2)\n"));
1510 }
1511
1512#ifndef UDF_READ_ONLY_BUILD
1514#endif
1515 ReturnedInformation = 0;
1516 AdPrint((
" Write protected\n"));
1518#ifndef UDF_READ_ONLY_BUILD
1519 }
1520
1521 if(DeleteOnCloseSpecified &&
1523 AdPrint((
" Can't create r/o file marked for deletion\n"));
1525 }
1526
1527
1528 if(StreamOpen)
1530 for(TmpBuffer = LastGoodTail.
Buffer; *TmpBuffer; TmpBuffer++) {
1531 if((*TmpBuffer) ==
L'\\') {
1532 AdPrint((
" Target name should not contain (back)slashes\n"));
1534 }
1535 }
1538 StreamOpen ||
FALSE)) {
1539 AdPrint((
" Creation of _temporary_ directory not permited\n"));
1541 }
1542
1546 AdPrint((
" Creation of File/Dir not permitted\n"));
1548 }
1549
1550
1551
1552
1553
1554 RelatedFileInfo = OldRelatedFileInfo;
1555
1557 Vcb->UseExtendedFE || (StreamOpen && !StreamExists),
1558 (RequestedDisposition ==
FILE_CREATE), RelatedFileInfo, &NewFileInfo);
1560 AdPrint((
" Creation error\n"));
1561Creation_Err_1:
1562 if(NewFileInfo) {
1563 PtrNewFcb = NewFileInfo->
Fcb;
1565 if(PtrNewFcb &&
1566 !PtrNewFcb->ReferenceCount &&
1567 !PtrNewFcb->OpenHandleCount) {
1569 }
1570 if(NewFileInfo->
Dloc &&
1573 }
1575 if(PtrNewFcb) {
1578 }
1580 PtrNewFcb = PtrNewFcb;
1581 } else {
1582 NewFileInfo->
Fcb = PtrNewFcb;
1583 }
1585 }
1587 }
1588
1590 PtrRelatedFCB &&
1591 PtrRelatedFileObject &&
1594 }
1595#if 0
1597#endif
1598
1600
1603 AdPrint((
" Can't transform to directory\n"));
1604Undo_Create_1:
1610 }
1613 goto Creation_Err_1;
1614 }
1615#if 0
1617#endif
1619
1620
1621
1622
1623
1624
1625 }
1626
1627 if(StreamOpen && !StreamExists) {
1628
1629
1630
1631
1632 if (!(PtrNewFcb = NewFileInfo->
Fcb)) {
1633
1634
1635
1636
1638 NULL, &PtrNewFcb, RelatedFileInfo, NewFileInfo,
1639 &LocalPath, &LastGoodTail);
1641 AdPrint((
" Can't perform FirstOpenFile operation for file to contain stream\n"));
1645 goto Creation_Err_1;
1646 }
1647 } else {
1649 }
1650
1651
1652 TreeLength++;
1653 LastGoodFileInfo = NewFileInfo;
1654
1655 RC = MyAppendUnicodeToString(&LocalPath,
L"\\");
1657 RC = MyAppendUnicodeStringToStringTag(&LocalPath, &LastGoodTail,
MEM_USLOC_TAG);
1659 goto Creation_Err_1;
1665
1669
1670
1671
1672
1673 RelatedFileInfo = NewFileInfo;
1676 AdPrint((
" Can't create SDir\n"));
1678 goto Creation_Err_1;
1679 }
1680#if 0
1682#endif
1683
1684
1687
1688 if (!(PtrNewFcb = NewFileInfo->
Fcb)) {
1689
1690
1691
1692
1694 NULL, &PtrNewFcb, RelatedFileInfo, NewFileInfo,
1696 } else {
1698 }
1700 AdPrint((
" Can't perform OpenFile operation for SDir\n"));
1702 goto Creation_Err_1;
1703 }
1704
1705
1706 TreeLength++;
1707 LastGoodFileInfo = NewFileInfo;
1708
1711 AdPrint((
" Can't append UNC str\n"));
1713 goto Creation_Err_1;
1714 }
1720
1721
1722
1723
1724 RelatedFileInfo = NewFileInfo;
1727 RelatedFileInfo, &NewFileInfo);
1729 AdPrint((
" Can't create Stream\n"));
1731 goto Creation_Err_1;
1732 }
1733#if 0
1735#endif
1736
1737
1739 }
1740
1743
1744 if (!(PtrNewFcb = NewFileInfo->
Fcb)) {
1745
1746#ifndef IFS_40
1747
1750#endif
1751
1752
1753
1755 PtrNewFileObject, &PtrNewFcb, RelatedFileInfo, NewFileInfo,
1756 &LocalPath, &LastGoodTail);
1757 } else {
1759 }
1760
1762 AdPrint((
" Can't perform OpenFile operation for file or stream\n"));
1764 goto Undo_Create_1;
1765 }
1766
1767 PtrNewFcb->NTRequiredFCB->CommonFCBHeader.FileSize.QuadPart =
1768 PtrNewFcb->NTRequiredFCB->CommonFCBHeader.ValidDataLength.QuadPart = 0;
1770
1771 PtrNewFcb->NTRequiredFCB->CommonFCBHeader.AllocationSize.QuadPart =
AllocationSize;
1772 MmPrint((
" CcIsFileCached()\n"));
1774 MmPrint((
" CcSetFileSizes()\n"));
1778 }
1779 }
1780
1781
1782 TreeLength++;
1783 LastGoodFileInfo = NewFileInfo;
1784
1785
1786
1787 PtrNewCcb = (
PtrUDFCCB)(PtrNewFileObject->FsContext2);
1789
1791 AdPrint((
" Can't set Access Rights on Create\n"));
1796 }
1797
1798#ifdef IFS_40
1799
1802
1803
1804
1805
1808#endif
1809
1810
1815 } else {
1819 }
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1831
1833#endif
1834
1835 }
1836
1837AlreadyOpened:
1838
1839
1840
1841
1842
1843 ASSERT(NewFileInfo != OldRelatedFileInfo);
1844
1845
1848 PtrNewCcb = (
PtrUDFCCB)(PtrNewFileObject->FsContext2);
1849
1852 AdPrint((
" Object name collision\n"));
1854 }
1855
1856 NtReqFcb = PtrNewFcb->NTRequiredFCB;
1858
1859
1860
1861
1866 AdPrint((
" Can't open directory as a plain file\n"));
1867 } else {
1868 AdPrint((
" Can't supersede directory\n"));
1869 }
1872 }
1873
1875 AdPrint((
" This is not a directory\n"));
1878 }
1879
1881 AdPrint((
" Can't delete Read-Only file\n"));
1884 }
1885
1886
1891 AdPrint((
" Access/Share access check failed\n"));
1893 }
1894
1895 RestoreShareAccess =
TRUE;
1896
1898
1899
1900
1901
1902
1903
1905 MmPrint((
" MmFlushImageSection();\n"));
1908 MmFlushForWrite )) {
1909
1913 AdPrint((
" File is mapped or deletion in progress\n"));
1915 }
1917 }
1919
1920 !(PtrNewFcb->CachedOpenHandleCount) &&
1921 (
NtReqFcb->SectionObject.DataSectionObject) ) {
1922
1923
1924
1925
1926 MmPrint((
" CcFlushCache()\n"));
1928 MmPrint((
" CcPurgeCacheSection()\n"));
1930 }
1931 }
1932
1934 AdPrint((
" Directory in not empry\n"));
1936 }
1937
1938
1939 TmpFileAttributes =
1942
1943 if(DeleteOnCloseSpecified &&
1949 AdPrint((
" Read-only. DeleteOnClose attempt failed\n"));
1951 }
1952 }
1953
1954
1958
1959
1960#ifndef UDF_READ_ONLY_BUILD
1962
1965
1968
1970
1972 PtrNewFcb->FCBFlags &= ~UDF_FCB_READ_ONLY;
1973 }
1975 if(RestoreRO) {
1976
1978 }
1980 AdPrint((
" Can't supersede. DELETE permission required\n"));
1982 }
1983 } else {
1989 AdPrint((
" Can't overwrite. Permission denied\n"));
1991 }
1992 }
1993
1996 AdPrint((
" The Hidden and/or System bits do not match\n"));
1998 }
1999
2000
2001
2002 MmPrint((
" MmCanFileBeTruncated()\n"));
2005 AdPrint((
" Can't truncate. File is mapped\n"));
2007 }
2008
2011
2012#if 0
2014#endif
2015
2017
2019 AdPrint((
" Error during resize operation\n"));
2021 }
2022
2023
2024
2025
2026
2027
2029 NtReqFcb->CommonFCBHeader.FileSize.QuadPart =
2030 NtReqFcb->CommonFCBHeader.ValidDataLength.QuadPart = 0 ;
2031 PtrNewFcb->FCBFlags &= ~UDF_FCB_DELAY_CLOSE;
2032 MmPrint((
" CcSetFileSizes()\n"));
2035
2038
2042
2046 } else {
2047
2049
2053 }
2054 }
2055
2059
2060
2062 PtrRelatedFCB &&
2063 PtrRelatedFileObject &&
2066 }
2067#else
2069#endif
2070 } else {
2072 }
2073
2074
2076 PtrRelatedFCB &&
2077 PtrRelatedFileObject &&
2080 }
2081
2083
2085
2086
2087
2088
2089 if(RestoreVCBOpenCounter) {
2091 RestoreVCBOpenCounter =
FALSE;
2092 }
2093
2095
2096
2097
2098
2099#if 0
2102 } else {
2104 }
2105#endif
2106
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2120#ifndef UDF_READ_ONLY_BUILD
2121 if(WriteThroughRequested) {
2124 MmPrint((
" FO_WRITE_THROUGH\n"));
2125 }
2126#endif
2130 MmPrint((
" FO_SEQUENTIAL_ONLY\n"));
2131#ifndef UDF_READ_ONLY_BUILD
2133 PtrNewFileObject->Flags &= ~FO_WRITE_THROUGH;
2134 PtrNewFcb->FCBFlags &= ~UDF_FCB_WRITE_THROUGH;
2135 MmPrint((
" FILE_REMOVABLE_MEDIA + FO_SEQUENTIAL_ONLY => ~FO_WRITE_THROUGH\n"));
2136 }
2137#endif
2138 if(PtrNewFcb->FileInfo) {
2140 }
2141 }
2144 MmPrint((
" FO_NO_INTERMEDIATE_BUFFERING\n"));
2145 } else {
2147 MmPrint((
" FO_CACHE_SUPPORTED\n"));
2148 }
2149 }
2150
2152) {
2153 MmPrint((
" FO_FILE_FAST_IO_READ\n"));
2155 }
2156
2159
2162
2163 if(PtrNewCcb) {
2164 PtrNewCcb->TreeLength = TreeLength;
2165
2166#ifndef UDF_READ_ONLY_BUILD
2167 if(DeleteOnCloseSpecified) {
2170 }
2171#endif
2172
2174
2177 }
2181 }
2182 } else {
2184 }
2185
2186 if(StreamOpen)
2188
2189
2190
2194#ifdef UDF_DBG
2195
2196 if(PtrNewFcb->FileInfo) {
2197 ASSERT_REF(PtrNewFcb->ReferenceCount >= PtrNewFcb->FileInfo->RefCount);
2198 }
2199#endif
2200 AdPrint((
" FCB %x, CCB %x, FO %x, Flags %x\n", PtrNewFcb, PtrNewCcb, PtrNewFileObject, PtrNewFcb->FCBFlags));
2201
2203
2205
2206 if(RestoreShareAccess &&
NtReqFcb && PtrNewFileObject) {
2208 }
2210 if(PtrNewFileObject) {
2211 PtrNewFileObject->FsContext2 =
NULL;
2212 }
2213
2214
2215 if(LastGoodFileInfo && LastGoodFileInfo->
Fcb) {
2217 if(LastGoodFileInfo->
Fcb->NTRequiredFCB) {
2219 }
2220 }
2221
2224
2226
2227 if(
Vcb && (PtrNewFcb !=
Vcb->RootDirFCB) &&
2228 LastGoodFileInfo ) {
2230 } else {
2231 ASSERT(!LastGoodFileInfo);
2232 }
2233 } else {
2235 }
2236
2237
2239 Irp->IoStatus.Status = RC;
2240 Irp->IoStatus.Information = ReturnedInformation;
2241
2242
2244
2246 }
2247 } else {
2249 }
2250
2251 if(AcquiredVcb) {
2253 }
2254
2255 if(AbsolutePathName.
Buffer)
2259 if(TailNameBuffer)
2262
2263 return(RC);
2264}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define STATUS_PRIVILEGE_NOT_HELD
VOID UDFAttributesToUDF(IN PDIR_INDEX_ITEM FileDirNdx, IN tag *FileEntry, IN ULONG NTAttr)
ULONG UDFAttributesToNT(IN PDIR_INDEX_ITEM FileDirNdx, IN tag *FileEntry)
NTSTATUS MyCloneUnicodeString(IN PUNICODE_STRING Str1, IN PUNICODE_STRING Str2)
#define FILE_DELETE_ON_CLOSE
VOID NTAPI CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, OUT OPTIONAL PIO_STATUS_BLOCK IoStatus)
#define CcIsFileCached(FO)
NTSTATUS UDFCloseFileInfoChain(IN PVCB Vcb, IN PUDF_FILE_INFO fi, IN ULONG TreeLength, IN BOOLEAN VcbAcquired)
VOID UDFCloseAllDelayed(IN PVCB Vcb)
ULONG UDFCleanUpFcbChain(IN PVCB Vcb, IN PUDF_FILE_INFO fi, IN ULONG TreeLength, IN BOOLEAN VcbAcquired)
PDIR_INDEX_HDR UDFGetDirIndexByFileInfo(IN PUDF_FILE_INFO FileInfo)
#define NT_SUCCESS(StatCode)
_In_ PIO_STACK_LOCATION IrpSp
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK _In_ USHORT ShareAccess
VOID __fastcall UDFReleaseResFromCreate(IN PERESOURCE *PagingIoRes, IN PERESOURCE *Res1, IN PERESOURCE *Res2)
#define IsFileObjectReadOnly(FO)
#define FileOnlyRequested
VOID __fastcall UDFAcquireParent(IN PUDF_FILE_INFO RelatedFileInfo, IN PERESOURCE *Res1, IN PERESOURCE *Res2)
#define NoBufferingSpecified
#define SequentialIoRequested
#define DirectoryOnlyRequested
NTSTATUS UDFOpenFile(PVCB Vcb, PFILE_OBJECT PtrNewFileObject, PtrUDFFCB PtrNewFcb)
NTSTATUS UDFFirstOpenFile(IN PVCB Vcb, IN PFILE_OBJECT PtrNewFileObject, OUT PtrUDFFCB *PtrNewFcb, IN PUDF_FILE_INFO RelatedFileInfo, IN PUDF_FILE_INFO NewFileInfo, IN PUNICODE_STRING LocalPath, IN PUNICODE_STRING CurName)
VOID __fastcall UDFCleanUpFCB(PtrUDFFCB Fcb)
NTSTATUS UDFPostRequest(IN PtrUDFIrpContext PtrIrpContext, IN PIRP Irp)
VOID UDFReleaseIrpContext(PtrUDFIrpContext PtrIrpContext)
VOID __fastcall UDFCleanUpCCB(PtrUDFCCB Ccb)
#define INTEGRITY_TYPE_OPEN
#define UDFNotifyVolumeEvent(FileObject, EventCode)
#define CollectStatistics(VCB, Field)
__inline VOID UDFNotifyFullReportChange(PVCB V, PUDF_FILE_INFO FI, ULONG E, ULONG A)
#define CollectStatistics2(VCB, Field)
#define UDFReleaseResource(Resource)
NTSTATUS MyInitUnicodeString(IN PUNICODE_STRING Str1, IN PCWSTR Str2)
#define UDFConvertExclusiveToSharedLite(Resource)
#define UDFInterlockedDecrement(addr)
FAST_IO_POSSIBLE NTAPI UDFIsFastIoPossible(IN PtrUDFFCB Fcb)
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
NTSTATUS UDFGetOpenParamsByFileId(IN PVCB Vcb, IN LONGLONG Id, OUT PUNICODE_STRING *FName, OUT BOOLEAN *CaseSens)
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE _In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Out_ PIO_STATUS_BLOCK _In_opt_ PLARGE_INTEGER _In_ ULONG FileAttributes
VOID UDFFlushTryBreak(IN PVCB Vcb)
ULONG UDFFlushLogicalVolume(IN PtrUDFIrpContext PtrIrpContext, IN PIRP Irp, IN PVCB Vcb, IN ULONG FlushFlags)
#define FILE_OVERWRITE_IF
#define FILE_NO_INTERMEDIATE_BUFFERING
#define FILE_WRITE_THROUGH
_In_ PLIST_ENTRY _In_ PSTRING _In_ USHORT _In_opt_ PSTRING StreamName
VOID NTAPI CcSetFileSizes(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes)
BOOLEAN NTAPI CcPurgeCacheSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN UninitializeCacheMaps)
#define EXCEPTION_EXECUTE_HANDLER
BOOLEAN __fastcall UDFIsNameValid(IN PUNICODE_STRING SearchPattern, OUT BOOLEAN *StreamOpen, OUT ULONG *SNameIndex)
PWCHAR __fastcall UDFDissectName(IN PWCHAR Buffer, OUT PUSHORT Length)
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define FILE_DOES_NOT_EXIST
#define FILE_ATTRIBUTE_VALID_FLAGS
#define FILE_ATTRIBUTE_READONLY
#define FILE_ATTRIBUTE_HIDDEN
#define FILE_ATTRIBUTE_SYSTEM
#define FILE_DELETE_CHILD
#define FILE_SHARE_DELETE
#define FILE_WRITE_ATTRIBUTES
#define FILE_VALID_OPTION_FLAGS
#define FILE_ATTRIBUTE_ARCHIVE
#define FILE_ADD_SUBDIRECTORY
#define FILE_REMOVABLE_MEDIA
#define FILE_GENERIC_WRITE
#define FILE_ATTRIBUTE_TEMPORARY
#define FSRTL_VOLUME_LOCK
VOID NTAPI IoRemoveShareAccess(IN PFILE_OBJECT FileObject, IN PSHARE_ACCESS ShareAccess)
#define IoCompleteRequest
BOOLEAN NTAPI SeSinglePrivilegeCheck(_In_ LUID PrivilegeValue, _In_ KPROCESSOR_MODE PreviousMode)
Checks if a single privilege is present in the context of the calling thread.
#define STATUS_DELETE_PENDING
#define STATUS_USER_MAPPED_FILE
#define STATUS_FILE_INVALID
#define STATUS_EAS_NOT_SUPPORTED
NTSTATUS UDFVerifyVcb(IN PtrUDFIrpContext IrpContext, IN PVCB Vcb)
NTSTATUS UDFSetAccessRights(PFILE_OBJECT FileObject, PACCESS_STATE AccessState, PtrUDFFCB Fcb, PtrUDFCCB Ccb, ACCESS_MASK DesiredAccess, USHORT ShareAccess)
NTSTATUS UDFCheckAccessRights(PFILE_OBJECT FileObject, PACCESS_STATE AccessState, PtrUDFFCB Fcb, PtrUDFCCB Ccb, ACCESS_MASK DesiredAccess, USHORT ShareAccess)
#define UDFCloseAllSystemDelayedInDir(Vcb, FI)
#define _SEH2_AbnormalTermination()
#define _SEH2_EXCEPT(...)
BOOLEAN NTAPI MmCanFileBeTruncated(_In_ PSECTION_OBJECT_POINTERS SectionObjectPointer, _In_opt_ PLARGE_INTEGER NewFileSize)
BOOLEAN NTAPI MmFlushImageSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN MMFLUSH_TYPE FlushType)
#define STATUS_CANNOT_DELETE
#define UDF_FCB_READ_ONLY
struct _UDFFileControlBlock * PtrUDFFCB
#define UDF_IRP_CONTEXT_FLUSH2_REQUIRED
#define UDF_IRP_CONTEXT_FLUSH_REQUIRED
#define UDF_CCB_READ_ONLY
#define UDF_NTREQ_FCB_VALID
#define UDF_IRP_CONTEXT_CAN_BLOCK
#define UDF_CCB_VOLUME_OPEN
#define UDF_NODE_TYPE_CCB
#define UDF_FCB_POSTED_RENAME
struct _UDFContextControlBlock * PtrUDFCCB
#define UDF_CCB_CASE_SENSETIVE
#define UDF_FCB_ROOT_DIRECTORY
#define UDF_RESIDUAL_REFERENCE
#define UDF_NODE_TYPE_FCB
#define UDF_NTREQ_FCB_MODIFIED
#define UDF_NODE_TYPE_VCB
#define UDF_FCB_DELETE_ON_CLOSE
#define UDF_FCB_DIRECTORY
#define UDF_FCB_WRITE_THROUGH
#define UDF_CCB_DELETE_ON_CLOSE
PACCESS_STATE AccessState
ACCESS_MASK DesiredAccess
union _IO_STACK_LOCATION::@1579 Parameters
struct _IO_STACK_LOCATION::@3978::@3979 Create
UDFIdentifier NodeIdentifier
struct _UDFFileControlBlock * Fcb
UNICODE_STRING UnicodeStrSDir
struct _UDFFileControlBlock * ParentFcb
UDFIdentifier NodeIdentifier
PDEVICE_OBJECT TargetDeviceObject
UNICODE_STRING ObjectName
struct _UDFNTRequiredFCB * CommonFcb
struct _UDFFileControlBlock * Fcb
struct _UDF_FILE_INFO * ParentFile
#define RtlMoveMemory(Destination, Source, Length)
#define UDF_VCB_IC_DIRTY_RO
#define UDF_VCB_IC_IGNORE_SEQUENTIAL_IO
#define UDF_VCB_FLAGS_VOLUME_MOUNTED
#define UDF_VCB_FLAGS_VOLUME_LOCKED
#define UDF_VCB_FLAGS_VOLUME_READ_ONLY
#define UDF_VCB_FLAGS_RAW_DISK
#define UDF_VCB_FLAGS_MEDIA_READ_ONLY
#define UDF_VCB_IC_UPDATE_DIR_READ
#define UDF_VCB_IC_UPDATE_DIR_WRITE
#define UDF_VCB_IC_SHOW_BLANK_CD
#define UDF_VCB_IC_FORCE_WRITE_THROUGH
OSSTATUS UDFRecordDirectory__(IN PVCB Vcb, IN OUT PUDF_FILE_INFO DirInfo)
OSSTATUS UDFCloseFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
OSSTATUS UDFFlushFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN ULONG FlushFlags)
uint32 UDFCleanUpFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
OSSTATUS UDFUnlinkFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN BOOLEAN FreeSpace)
OSSTATUS UDFOpenStreamDir__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, OUT PUDF_FILE_INFO *_SDirInfo)
OSSTATUS UDFResizeFile__(IN PVCB Vcb, IN OUT PUDF_FILE_INFO FileInfo, IN int64 NewLength)
OSSTATUS UDFCreateFile__(IN PVCB Vcb, IN BOOLEAN IgnoreCase, IN PUNICODE_STRING _fn, IN uint32 ExtAttrSz, IN uint32 ImpUseLen, IN BOOLEAN Extended, IN BOOLEAN CreateNew, IN OUT PUDF_FILE_INFO DirInfo, OUT PUDF_FILE_INFO *_FileInfo)
OSSTATUS UDFCreateStreamDir__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, OUT PUDF_FILE_INFO *_SDirInfo)
OSSTATUS UDFOpenFile__(IN PVCB Vcb, IN BOOLEAN IgnoreCase, IN BOOLEAN NotDeleted, IN PUNICODE_STRING fn, IN PUDF_FILE_INFO DirInfo, OUT PUDF_FILE_INFO *_FileInfo, IN uint_di *IndexToOpen)
#define UDFStreamsSupported(Vcb)
#define UDFIsDirEmpty__(fi)
__inline PDIR_INDEX_ITEM UDFDirIndex(IN PDIR_INDEX_HDR hDirNdx, IN uint_di i)
__inline OSSTATUS UDFFindFile__(IN PVCB Vcb, IN BOOLEAN IgnoreCase, IN PUNICODE_STRING Name, IN PUDF_FILE_INFO DirInfo)
#define UDFIsADirectory(FileInfo)
#define UDFSetFileAllocMode__(fi, mode)
#define EXTENT_FLAG_ALLOC_SEQUENTIAL
#define STATUS_DIRECTORY_NOT_EMPTY
#define STATUS_FILE_IS_A_DIRECTORY
#define STATUS_NOT_A_DIRECTORY
#define STATUS_MEDIA_WRITE_PROTECTED
#define STATUS_ACCESS_DENIED
#define STATUS_OBJECT_PATH_NOT_FOUND
#define STATUS_INVALID_PARAMETER
#define STATUS_OBJECT_NAME_COLLISION
#define STATUS_SHARING_PAUSED
#define STATUS_FILE_DELETED
#define STATUS_SHARING_VIOLATION
#define STATUS_OBJECT_NAME_INVALID
#define STATUS_OBJECT_NAME_NOT_FOUND
#define UdfIllegalFcbAccess(Vcb, DesiredAccess)
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
#define SL_OPEN_PAGING_FILE
#define FO_SEQUENTIAL_ONLY
#define FILE_NOTIFY_CHANGE_SIZE
#define FILE_ACTION_MODIFIED
#define FO_OPENED_CASE_SENSITIVE
#define FO_FILE_FAST_IO_READ
#define FILE_NOTIFY_CHANGE_STREAM_NAME
#define FILE_NOTIFY_CHANGE_ATTRIBUTES
#define FILE_NOTIFY_CHANGE_FILE_NAME
#define FO_FILE_SIZE_CHANGED
#define IO_DISK_INCREMENT
#define FO_NO_INTERMEDIATE_BUFFERING
#define FO_CACHE_SUPPORTED
#define FILE_ACTION_ADDED_STREAM
#define FILE_NOTIFY_CHANGE_LAST_WRITE
#define SL_OPEN_TARGET_DIRECTORY
#define FILE_ACTION_ADDED
#define FILE_NOTIFY_CHANGE_DIR_NAME
#define SL_CASE_SENSITIVE
_In_opt_ PVOID _In_opt_ PUNICODE_STRING _In_ PSECURITY_DESCRIPTOR _In_ PACCESS_STATE AccessState