00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#include "UdfProcs.h"
00023
00024
00025
00026
00027
00028 #define BugCheckFileId (UDFS_BUG_CHECK_CREATE)
00029
00030
00031
00032
00033
00034 #define Dbg (UDFS_DEBUG_LEVEL_CREATE)
00035
00036
00037
00038
00039
00040
NTSTATUS
00041
UdfNormalizeFileNames (
00042 IN
PIRP_CONTEXT IrpContext,
00043 IN
PVCB Vcb,
00044 IN BOOLEAN OpenByFileId,
00045 IN BOOLEAN IgnoreCase,
00046 IN TYPE_OF_OPEN RelatedTypeOfOpen,
00047 IN
PCCB RelatedCcb OPTIONAL,
00048 IN PUNICODE_STRING RelatedFileName OPTIONAL,
00049 IN OUT PUNICODE_STRING FileName,
00050 IN OUT PUNICODE_STRING RemainingName
00051 );
00052
00053
NTSTATUS
00054
UdfOpenExistingFcb (
00055 IN
PIRP_CONTEXT IrpContext,
00056 IN
PIO_STACK_LOCATION IrpSp,
00057 IN OUT
PFCB *CurrentFcb,
00058 IN
PLCB OpenLcb,
00059 IN TYPE_OF_OPEN TypeOfOpen,
00060 IN BOOLEAN IgnoreCase,
00061 IN
PCCB RelatedCcb OPTIONAL
00062 );
00063
00064
NTSTATUS
00065
UdfOpenObjectByFileId (
00066 IN
PIRP_CONTEXT IrpContext,
00067 IN
PIO_STACK_LOCATION IrpSp,
00068 IN
PVCB Vcb,
00069 IN OUT
PFCB *CurrentFcb
00070 );
00071
00072
NTSTATUS
00073
UdfOpenObjectFromDirContext (
00074 IN
PIRP_CONTEXT IrpContext,
00075 IN
PIO_STACK_LOCATION IrpSp,
00076 IN
PVCB Vcb,
00077 IN OUT
PFCB *CurrentFcb,
00078 IN BOOLEAN ShortNameMatch,
00079 IN BOOLEAN IgnoreCase,
00080 IN
PDIR_ENUM_CONTEXT DirContext,
00081 IN BOOLEAN PerformUserOpen,
00082 IN
PCCB RelatedCcb OPTIONAL
00083 );
00084
00085
NTSTATUS
00086
UdfCompleteFcbOpen (
00087 IN
PIRP_CONTEXT IrpContext,
00088
PIO_STACK_LOCATION IrpSp,
00089 IN
PVCB Vcb,
00090 IN OUT
PFCB *CurrentFcb,
00091 IN
PLCB OpenLcb,
00092 IN TYPE_OF_OPEN TypeOfOpen,
00093 IN ULONG UserCcbFlags,
00094 IN ACCESS_MASK DesiredAccess
00095 );
00096
00097
#ifdef ALLOC_PRAGMA
00098
#pragma alloc_text(PAGE, UdfCommonCreate)
00099
#pragma alloc_text(PAGE, UdfCompleteFcbOpen)
00100
#pragma alloc_text(PAGE, UdfNormalizeFileNames)
00101
#pragma alloc_text(PAGE, UdfOpenObjectByFileId)
00102
#pragma alloc_text(PAGE, UdfOpenExistingFcb)
00103
#pragma alloc_text(PAGE, UdfOpenObjectFromDirContext)
00104
#endif
00105
00106
00107
NTSTATUS
00108 UdfCommonCreate (
00109 IN
PIRP_CONTEXT IrpContext,
00110 IN
PIRP Irp
00111 )
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 {
00150
NTSTATUS Status = STATUS_SUCCESS;
00151
PIO_STACK_LOCATION IrpSp =
IoGetCurrentIrpStackLocation(
Irp );
00152
00153
PFILE_OBJECT FileObject;
00154
00155
DIR_ENUM_CONTEXT DirContext;
00156 BOOLEAN CleanupDirContext =
FALSE;
00157
00158 BOOLEAN FoundEntry;
00159
00160
PVCB Vcb;
00161
00162 BOOLEAN OpenByFileId;
00163 BOOLEAN IgnoreCase;
00164 ULONG CreateDisposition;
00165
00166 BOOLEAN ShortNameMatch;
00167
00168 BOOLEAN VolumeOpen =
FALSE;
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
TYPE_OF_OPEN RelatedTypeOfOpen =
UnopenedFileObject;
00185
PFILE_OBJECT RelatedFileObject;
00186
PCCB RelatedCcb =
NULL;
00187
00188
PFCB NextFcb;
00189
PFCB CurrentFcb =
NULL;
00190
00191
PLCB CurrentLcb =
NULL;
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211 PUNICODE_STRING
FileName;
00212 PUNICODE_STRING RelatedFileName;
00213
00214 UNICODE_STRING RemainingName;
00215 UNICODE_STRING FinalName;
00216
00217
PAGED_CODE();
00218
00219
00220
00221
00222
00223
00224
if (IrpContext->Vcb ==
NULL) {
00225
00226
UdfCompleteRequest( IrpContext,
Irp, STATUS_SUCCESS );
00227
return STATUS_SUCCESS;
00228 }
00229
00230
00231
00232
00233
00234 OpenByFileId =
BooleanFlagOn( IrpSp->
Parameters.Create.Options, FILE_OPEN_BY_FILE_ID );
00235 IgnoreCase = !
BooleanFlagOn( IrpSp->
Flags,
SL_CASE_SENSITIVE );
00236 CreateDisposition = (IrpSp->
Parameters.Create.Options >> 24) & 0x000000ff;
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
if (
FlagOn( IrpSp->
Flags,
SL_OPEN_PAGING_FILE |
SL_OPEN_TARGET_DIRECTORY) ||
00249 (IrpSp->
Parameters.Create.EaLength != 0) ||
00250 (CreateDisposition == FILE_CREATE)) {
00251
00252
UdfCompleteRequest( IrpContext,
Irp, STATUS_ACCESS_DENIED );
00253
return STATUS_ACCESS_DENIED;
00254 }
00255
00256
00257
00258
00259
00260 Vcb = IrpContext->Vcb;
00261 NextFcb = Vcb->
RootIndexFcb;
00262
00263
00264
00265
00266
00267 FileObject = IrpSp->
FileObject;
00268 RelatedFileObject =
NULL;
00269
00270
FileName = &FileObject->
FileName;
00271
00272
00273
00274
00275
00276
00277
if ((FileObject->
RelatedFileObject !=
NULL) && !OpenByFileId) {
00278
00279 RelatedFileObject = FileObject->
RelatedFileObject;
00280 FileObject->
Vpb = RelatedFileObject->
Vpb;
00281
00282 RelatedTypeOfOpen =
UdfDecodeFileObject( RelatedFileObject, &NextFcb, &RelatedCcb );
00283
00284
00285
00286
00287
00288
if (RelatedTypeOfOpen <
UserVolumeOpen) {
00289
00290
UdfCompleteRequest( IrpContext,
Irp, STATUS_INVALID_PARAMETER );
00291
return STATUS_INVALID_PARAMETER;
00292 }
00293
00294
00295
00296
00297
00298 RelatedFileName = &RelatedFileObject->
FileName;
00299 }
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
Status =
UdfNormalizeFileNames( IrpContext,
00314 Vcb,
00315 OpenByFileId,
00316 IgnoreCase,
00317 RelatedTypeOfOpen,
00318 RelatedCcb,
00319 RelatedFileName,
00320
FileName,
00321 &RemainingName );
00322
00323
00324
00325
00326
00327
if (!
NT_SUCCESS(
Status )) {
00328
00329
UdfCompleteRequest( IrpContext,
Irp,
Status );
00330
return Status;
00331 }
00332
00333
00334
00335
00336
00337
00338
if ((
FileName->Length == 0) &&
00339 (RelatedTypeOfOpen <=
UserVolumeOpen) &&
00340 !OpenByFileId) {
00341
00342 VolumeOpen =
TRUE;
00343
UdfAcquireVcbExclusive( IrpContext, Vcb,
FALSE );
00344
00345 }
else {
00346
00347
UdfAcquireVcbShared( IrpContext, Vcb,
FALSE );
00348 }
00349
00350
00351
00352
00353
00354
try {
00355
00356
00357
00358
00359
00360
00361
UdfVerifyVcb( IrpContext, Vcb );
00362
00363
00364
00365
00366
00367
if (
FlagOn( Vcb->
VcbState,
VCB_STATE_LOCKED )) {
00368
00369
try_leave(
Status = STATUS_ACCESS_DENIED );
00370 }
00371
00372
00373
00374
00375
00376
00377
if (OpenByFileId) {
00378
00379
00380
00381
00382
00383
if ((CreateDisposition != FILE_OPEN) &&
00384 (CreateDisposition != FILE_OPEN_IF)) {
00385
00386
try_leave(
Status = STATUS_ACCESS_DENIED );
00387 }
00388
00389
try_leave(
Status =
UdfOpenObjectByFileId( IrpContext,
00390 IrpSp,
00391 Vcb,
00392 &CurrentFcb ));
00393 }
00394
00395
00396
00397
00398
00399
00400
if (VolumeOpen) {
00401
00402
00403
00404
00405
00406
if ((CreateDisposition != FILE_OPEN) &&
00407 (CreateDisposition != FILE_OPEN_IF)) {
00408
00409
try_leave(
Status = STATUS_ACCESS_DENIED );
00410 }
00411
00412
00413
00414
00415
00416
if (
FlagOn( IrpSp->
Parameters.Create.Options, FILE_DIRECTORY_FILE )) {
00417
00418
try_leave(
Status = STATUS_NOT_A_DIRECTORY );
00419 }
00420
00421
00422
00423
00424
00425 CurrentFcb = Vcb->
VolumeDasdFcb;
00426
UdfAcquireFcbExclusive( IrpContext, CurrentFcb,
FALSE );
00427
00428
try_leave(
Status =
UdfOpenExistingFcb( IrpContext,
00429 IrpSp,
00430 &CurrentFcb,
00431
NULL,
00432
UserVolumeOpen,
00433
FALSE,
00434
NULL ));
00435 }
00436
00437
00438
00439
00440
00441
00442
UdfAcquireFcbExclusive( IrpContext, NextFcb,
FALSE );
00443 CurrentFcb = NextFcb;
00444
00445
00446
00447
00448
00449
if (RemainingName.Length != 0) {
00450
00451
00452
00453
00454
00455 CurrentLcb =
UdfFindPrefix( IrpContext,
00456 &CurrentFcb,
00457 &RemainingName,
00458 IgnoreCase );
00459 }
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
if (RemainingName.Length == 0) {
00473
00474
00475
00476
00477
00478
00479
if (
SafeNodeType( CurrentFcb ) ==
UDFS_NTC_FCB_DATA) {
00480
00481
if (
FlagOn( IrpContext->Flags,
IRP_CONTEXT_FLAG_TRAIL_BACKSLASH ) ||
00482
FlagOn( IrpSp->
Parameters.Create.Options, FILE_DIRECTORY_FILE )) {
00483
00484
try_leave(
Status = STATUS_NOT_A_DIRECTORY );
00485 }
00486
00487
00488
00489
00490
00491
if ((CreateDisposition != FILE_OPEN) &&
00492 (CreateDisposition != FILE_OPEN_IF)) {
00493
00494
try_leave(
Status = STATUS_ACCESS_DENIED );
00495 }
00496
00497
try_leave(
Status =
UdfOpenExistingFcb( IrpContext,
00498 IrpSp,
00499 &CurrentFcb,
00500 CurrentLcb,
00501
UserFileOpen,
00502 IgnoreCase,
00503 RelatedCcb ));
00504
00505
00506
00507
00508
00509
00510 }
else if (
FlagOn( IrpSp->
Parameters.Create.Options, FILE_NON_DIRECTORY_FILE )) {
00511
00512
try_leave(
Status = STATUS_FILE_IS_A_DIRECTORY );
00513
00514
00515
00516
00517
00518 }
else {
00519
00520
00521
00522
00523
00524
if ((CreateDisposition != FILE_OPEN) &&
00525 (CreateDisposition != FILE_OPEN_IF)) {
00526
00527
try_leave(
Status = STATUS_ACCESS_DENIED );
00528 }
00529
00530
try_leave(
Status =
UdfOpenExistingFcb( IrpContext,
00531 IrpSp,
00532 &CurrentFcb,
00533 CurrentLcb,
00534
UserDirectoryOpen,
00535 IgnoreCase,
00536 RelatedCcb ));
00537 }
00538 }
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
if (!
FlagOn( CurrentFcb->
FileAttributes, FILE_ATTRIBUTE_DIRECTORY )) {
00551
00552
try_leave(
Status = STATUS_OBJECT_PATH_NOT_FOUND );
00553 }
00554
00555
00556
00557
00558
00559
if (!
FlagOn( IrpContext->Flags,
IRP_CONTEXT_FLAG_WAIT )) {
00560
00561
UdfRaiseStatus( IrpContext, STATUS_CANT_WAIT );
00562 }
00563
00564
00565
00566
00567
00568
UdfInitializeDirContext( IrpContext, &DirContext );
00569 CleanupDirContext =
TRUE;
00570
00571
while (
TRUE) {
00572
00573 ShortNameMatch =
FALSE;
00574
00575
00576
00577
00578
00579
UdfDissectName( IrpContext,
00580 &RemainingName,
00581 &FinalName );
00582
00583
00584
00585
00586
00587 FoundEntry =
UdfFindDirEntry( IrpContext,
00588 CurrentFcb,
00589 &FinalName,
00590 IgnoreCase,
00591
FALSE,
00592 &DirContext );
00593
00594
00595
00596
00597
00598
00599
if (!FoundEntry &&
UdfCandidateShortName( IrpContext, &FinalName)) {
00600
00601
00602
00603
00604
00605
00606 ShortNameMatch =
00607 FoundEntry =
UdfFindDirEntry( IrpContext,
00608 CurrentFcb,
00609 &FinalName,
00610 IgnoreCase,
00611
TRUE,
00612 &DirContext );
00613 }
00614
00615
00616
00617
00618
00619
00620
if (!FoundEntry) {
00621
00622
if ((CreateDisposition == FILE_OPEN) ||
00623 (CreateDisposition == FILE_OVERWRITE)) {
00624
00625
try_leave(
Status = STATUS_OBJECT_NAME_NOT_FOUND );
00626 }
00627
00628
00629
00630
00631
00632
try_leave(
Status = STATUS_ACCESS_DENIED );
00633 }
00634
00635
00636
00637
00638
00639
00640
if (IgnoreCase && !ShortNameMatch) {
00641
00642
ASSERT( FinalName.Length == DirContext.
ObjectName.Length );
00643
00644 RtlCopyMemory( FinalName.Buffer,
00645 DirContext.
ObjectName.Buffer,
00646 DirContext.
ObjectName.Length );
00647 }
00648
00649
00650
00651
00652
00653
if (RemainingName.Length == 0) {
00654
00655
break;
00656 }
00657
00658
00659
00660
00661
00662
if (!
FlagOn( DirContext.
Fid->
Flags,
NSR_FID_F_DIRECTORY )) {
00663
00664
try_leave(
Status = STATUS_OBJECT_PATH_NOT_FOUND );
00665 }
00666
00667
00668
00669
00670
00671
UdfOpenObjectFromDirContext( IrpContext,
00672 IrpSp,
00673 Vcb,
00674 &CurrentFcb,
00675 ShortNameMatch,
00676 IgnoreCase,
00677 &DirContext,
00678
FALSE,
00679
NULL );
00680 }
00681
00682
00683
00684
00685
00686
if ((
FlagOn( IrpContext->Flags,
IRP_CONTEXT_FLAG_TRAIL_BACKSLASH ) ||
00687
FlagOn( IrpSp->
Parameters.Create.Options, FILE_DIRECTORY_FILE )) &&
00688 !
FlagOn( DirContext.
Fid->
Flags,
NSR_FID_F_DIRECTORY )) {
00689
00690
try_leave(
Status = STATUS_NOT_A_DIRECTORY );
00691
00692 }
00693
00694
if (
FlagOn( IrpSp->
Parameters.Create.Options, FILE_NON_DIRECTORY_FILE ) &&
00695
FlagOn( DirContext.
Fid->
Flags,
NSR_FID_F_DIRECTORY )) {
00696
00697
try_leave(
Status = STATUS_FILE_IS_A_DIRECTORY );
00698 }
00699
00700
00701
00702
00703
00704
if ((CreateDisposition != FILE_OPEN) &&
00705 (CreateDisposition != FILE_OPEN_IF)) {
00706
00707
try_leave(
Status = STATUS_ACCESS_DENIED );
00708 }
00709
00710
00711
00712
00713
00714
try_leave(
Status =
UdfOpenObjectFromDirContext( IrpContext,
00715 IrpSp,
00716 Vcb,
00717 &CurrentFcb,
00718 ShortNameMatch,
00719 IgnoreCase,
00720 &DirContext,
00721
TRUE,
00722 RelatedCcb ));
00723 } finally {
00724
00725
00726
00727
00728
00729
if (CleanupDirContext) {
00730
00731
UdfCleanupDirContext( IrpContext, &DirContext );
00732 }
00733
00734
00735
00736
00737
00738
00739
if (AbnormalTermination()) {
00740
00741
00742
00743
00744
00745
00746
00747
if (CurrentFcb !=
NULL) {
00748
00749 BOOLEAN RemovedFcb;
00750
00751
UdfTeardownStructures( IrpContext, CurrentFcb,
FALSE, &RemovedFcb );
00752
00753
if (RemovedFcb) {
00754
00755 CurrentFcb =
NULL;
00756 }
00757 }
00758
00759
00760
00761
00762
00763 IrpContext =
NULL;
00764
Irp =
NULL;
00765
00766
00767
00768
00769
00770
00771 }
else if (
Status == STATUS_PENDING) {
00772
00773 IrpContext =
NULL;
00774
Irp =
NULL;
00775 }
00776
00777
00778
00779
00780
00781
if (CurrentFcb !=
NULL) {
00782
00783
UdfReleaseFcb( IrpContext, CurrentFcb );
00784 }
00785
00786
00787
00788
00789
00790
UdfReleaseVcb( IrpContext, Vcb );
00791
00792
00793
00794
00795
00796
00797
UdfCompleteRequest( IrpContext,
Irp,
Status );
00798 }
00799
00800
return Status;
00801 }
00802
00803
00804
00805
00806
00807
00808
NTSTATUS
00809 UdfNormalizeFileNames (
00810 IN
PIRP_CONTEXT IrpContext,
00811 IN
PVCB Vcb,
00812 IN BOOLEAN OpenByFileId,
00813 IN BOOLEAN IgnoreCase,
00814 IN TYPE_OF_OPEN RelatedTypeOfOpen,
00815 IN
PCCB RelatedCcb OPTIONAL,
00816 IN PUNICODE_STRING RelatedFileName OPTIONAL,
00817 IN OUT PUNICODE_STRING FileName,
00818 IN OUT PUNICODE_STRING RemainingName
00819 )
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860 {
00861 ULONG RemainingNameLength;
00862 ULONG RelatedNameLength = 0;
00863 ULONG SeparatorLength = 0;
00864
00865 ULONG BufferLength;
00866
00867 UNICODE_STRING NewFileName;
00868
00869
PAGED_CODE();
00870
00871
00872
00873
00874
00875
00876
if (!
FlagOn( IrpContext->Flags,
IRP_CONTEXT_FLAG_FULL_NAME )) {
00877
00878
00879
00880
00881
00882
if (!OpenByFileId) {
00883
00884
00885
00886
00887
00888
00889
00890
00891
if ((
FileName->Length >
sizeof( WCHAR )) &&
00892 (
FileName->Buffer[1] ==
L'\\') &&
00893 (
FileName->Buffer[0] ==
L'\\')) {
00894
00895
00896
00897
00898
00899
if ((
FileName->Length > 2 *
sizeof( WCHAR )) &&
00900 (
FileName->Buffer[2] ==
L'\\')) {
00901
00902
return STATUS_OBJECT_NAME_INVALID;
00903 }
00904
00905
00906
00907
00908
00909 RtlMoveMemory(
FileName->Buffer,
00910
FileName->Buffer + 1,
00911
FileName->Length );
00912
00913
FileName->Length -=
sizeof( WCHAR );
00914 }
00915
00916
00917
00918
00919
00920
00921
if (((
FileName->Length >
sizeof( WCHAR)) ||
00922 ((
FileName->Length ==
sizeof( WCHAR )) && (RelatedTypeOfOpen ==
UserDirectoryOpen))) &&
00923 (
FileName->Buffer[ (
FileName->Length/2) - 1 ] ==
L'\\')) {
00924
00925
SetFlag( IrpContext->Flags,
IRP_CONTEXT_FLAG_TRAIL_BACKSLASH );
00926
FileName->Length -=
sizeof( WCHAR );
00927 }
00928
00929
00930
00931
00932
00933 RemainingNameLength =
FileName->Length;
00934
00935
00936
00937
00938
00939
00940
if (RelatedTypeOfOpen !=
UnopenedFileObject) {
00941
00942
00943
00944
00945
00946
00947
00948
if (
FileName->Length != 0) {
00949
00950
00951
00952
00953
00954
if (RelatedTypeOfOpen <=
UserVolumeOpen) {
00955
00956
return STATUS_INVALID_PARAMETER;
00957
00958
00959
00960
00961
00962 }
else if (
FileName->Buffer[0] ==
L'\\' ) {
00963
00964
return STATUS_INVALID_PARAMETER;
00965
00966
00967
00968
00969
00970
00971 }
else if (RelatedTypeOfOpen ==
UserFileOpen) {
00972
00973
return STATUS_OBJECT_PATH_NOT_FOUND;
00974 }
00975 }
00976
00977
00978
00979
00980
00981
00982
00983
00984
if (!
FlagOn( RelatedCcb->Flags,
CCB_FLAG_OPEN_BY_ID )) {
00985
00986
00987
00988
00989
00990
00991
if ((
FileName->Length != 0) &&
00992 (RelatedCcb->Fcb != Vcb->RootIndexFcb)) {
00993
00994 SeparatorLength =
sizeof( WCHAR );
00995 }
00996
00997 RelatedNameLength = RelatedFileName->Length;
00998 }
00999
01000
01001
01002
01003
01004
01005 }
else if (
FileName->Length != 0) {
01006
01007
if (
FileName->Buffer[0] !=
L'\\') {
01008
01009
return STATUS_INVALID_PARAMETER;
01010 }
01011
01012
01013
01014
01015
01016
01017 RemainingNameLength -=
sizeof( WCHAR );
01018 SeparatorLength =
sizeof( WCHAR );
01019 }
01020
01021
01022
01023
01024
01025 BufferLength = RelatedNameLength + SeparatorLength + RemainingNameLength;
01026
01027
01028
01029
01030
01031
if (BufferLength > MAXUSHORT) {
01032
01033
return STATUS_INVALID_PARAMETER;
01034 }
01035
01036
01037
01038
01039
01040
if (
FileName->MaximumLength < BufferLength) {
01041
01042 NewFileName.Buffer =
FsRtlAllocatePoolWithTag(
UdfPagedPool,
01043 BufferLength,
01044
TAG_FILE_NAME );
01045
01046 NewFileName.MaximumLength = (
USHORT) BufferLength;
01047
01048 }
else {
01049
01050 NewFileName.Buffer =
FileName->Buffer;
01051 NewFileName.MaximumLength =
FileName->MaximumLength;
01052 }
01053
01054
01055
01056
01057
01058
01059
01060
if (RelatedNameLength != 0) {
01061
01062
01063
01064
01065
01066
if (RemainingNameLength != 0) {
01067
01068 RtlMoveMemory(
Add2Ptr( NewFileName.Buffer, RelatedNameLength + SeparatorLength, PVOID ),
01069
FileName->Buffer,
01070 RemainingNameLength );
01071 }
01072
01073 RtlCopyMemory( NewFileName.Buffer,
01074 RelatedFileName->Buffer,
01075 RelatedNameLength );
01076
01077
01078
01079
01080
01081
if (SeparatorLength != 0) {
01082
01083 *(
Add2Ptr( NewFileName.Buffer, RelatedNameLength, PWCHAR )) =
L'\\';
01084 }
01085
01086
01087
01088
01089
01090
if (NewFileName.Buffer !=
FileName->Buffer) {
01091
01092
if (
FileName->Buffer !=
NULL) {
01093
01094
ExFreePool(
FileName->Buffer );
01095 }
01096
01097
FileName->Buffer = NewFileName.Buffer;
01098
FileName->MaximumLength = NewFileName.MaximumLength;
01099 }
01100
01101
01102
01103
01104
01105
FileName->Length = (
USHORT) (RelatedNameLength + SeparatorLength + RemainingNameLength);
01106 }
01107
01108
01109
01110
01111
01112 RemainingName->MaximumLength =
01113 RemainingName->Length = (
USHORT) RemainingNameLength;
01114
01115 RemainingName->Buffer =
Add2Ptr(
FileName->Buffer,
01116 RelatedNameLength + SeparatorLength,
01117 PWCHAR );
01118
01119
01120
01121
01122
01123
if (IgnoreCase && (RemainingNameLength != 0)) {
01124
01125
UdfUpcaseName( IrpContext,
01126 RemainingName,
01127 RemainingName );
01128 }
01129
01130
01131
01132
01133
01134
if (
FsRtlDoesNameContainWildCards( RemainingName )) {
01135
01136
return STATUS_OBJECT_NAME_INVALID;
01137 }
01138
01139
01140
01141
01142
01143
01144 }
else {
01145
01146
01147
01148
01149
01150
if (
FileName->Length !=
sizeof(
FILE_ID )) {
01151
01152
return STATUS_INVALID_PARAMETER;
01153 }
01154 }
01155
01156
SetFlag( IrpContext->Flags,
IRP_CONTEXT_FLAG_FULL_NAME );
01157
01158
01159
01160
01161
01162
01163
01164
01165 }
else {
01166
01167
01168
01169
01170
01171 *RemainingName = *
FileName;
01172
01173
01174
01175
01176
01177
if (RemainingName->Length != 0) {
01178
01179
01180
01181
01182
01183
if (RelatedTypeOfOpen !=
UnopenedFileObject) {
01184
01185
01186
01187
01188
01189
01190
if (!
FlagOn( RelatedCcb->Flags,
CCB_FLAG_OPEN_BY_ID )) {
01191
01192
01193
01194
01195
01196
01197
01198 RemainingName->Buffer =
Add2Ptr( RemainingName->Buffer,
01199 RelatedFileName->Length,
01200 PWCHAR );
01201
01202 RemainingName->Length -= RelatedFileName->Length;
01203 }
01204 }
01205
01206
01207
01208
01209
01210
if (RemainingName->Length != 0) {
01211
01212
if (*(RemainingName->Buffer) ==
L'\\') {
01213
01214 RemainingName->Buffer =
Add2Ptr( RemainingName->Buffer,
01215
sizeof( WCHAR ),
01216 PWCHAR );
01217
01218 RemainingName->Length -=
sizeof( WCHAR );
01219 }
01220 }
01221 }
01222
01223
01224
01225
01226
01227
if (IgnoreCase && (RemainingName->Length != 0)) {
01228
01229
UdfUpcaseName( IrpContext,
01230 RemainingName,
01231 RemainingName );
01232 }
01233 }
01234
01235
return STATUS_SUCCESS;
01236 }
01237
01238
01239
01240
01241
01242
01243
NTSTATUS
01244 UdfOpenObjectByFileId (
01245 IN
PIRP_CONTEXT IrpContext,
01246 IN
PIO_STACK_LOCATION IrpSp,
01247 IN
PVCB Vcb,
01248 IN OUT
PFCB *CurrentFcb
01249 )
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290 {
01291
NTSTATUS Status = STATUS_ACCESS_DENIED;
01292
01293 BOOLEAN UnlockVcb =
FALSE;
01294 BOOLEAN Found;
01295 BOOLEAN FcbExisted;
01296
01297
ICB_SEARCH_CONTEXT IcbContext;
01298 BOOLEAN CleanupIcbContext =
FALSE;
01299
01300
NODE_TYPE_CODE NodeTypeCode;
01301
TYPE_OF_OPEN TypeOfOpen;
01302
01303
FILE_ID FileId;
01304
01305
PFCB NextFcb =
NULL;
01306
01307
PAGED_CODE();
01308
01309
01310
01311
01312
01313
ASSERT_IRP_CONTEXT( IrpContext );
01314
ASSERT_VCB( Vcb );
01315
01316
01317
01318
01319
01320 RtlCopyMemory( &FileId, IrpSp->FileObject->FileName.Buffer,
sizeof(
FILE_ID ));
01321
01322
01323
01324
01325
01326
01327
if (
UdfGetFidReservedZero( FileId )) {
01328
01329
return STATUS_INVALID_PARAMETER;
01330 }
01331
01332
01333
01334
01335
01336
01337
if (
UdfIsFidDirectory( FileId )) {
01338
01339 TypeOfOpen =
UserDirectoryOpen;
01340 NodeTypeCode =
UDFS_NTC_FCB_INDEX;
01341
01342 }
else {
01343
01344 TypeOfOpen =
UserFileOpen;
01345 NodeTypeCode =
UDFS_NTC_FCB_DATA;
01346 }
01347
01348
01349
01350
01351
01352
try {
01353
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
UdfLockVcb( IrpContext, Vcb );
01364 UnlockVcb =
TRUE;
01365
01366 NextFcb =
UdfCreateFcb( IrpContext, FileId, NodeTypeCode, &FcbExisted );
01367
01368
01369
01370
01371
01372
if (!FcbExisted) {
01373
01374
01375
01376
01377
01378
if (!
FlagOn( IrpContext->Flags,
IRP_CONTEXT_FLAG_WAIT )) {
01379
01380
UdfRaiseStatus( IrpContext, STATUS_CANT_WAIT );
01381 }
01382
01383
01384
01385
01386
01387
01388
try {
01389
01390 NextFcb->
FileId = FileId;
01391
01392
UdfInitializeIcbContextFromFcb( IrpContext, &IcbContext, NextFcb );
01393 CleanupIcbContext =
TRUE;
01394
01395
UdfLookupActiveIcb( IrpContext, &IcbContext );
01396
01397
UdfInitializeFcbFromIcbContext( IrpContext,
01398 NextFcb,
01399 &IcbContext );
01400
01401
UdfCleanupIcbContext( IrpContext, &IcbContext );
01402 CleanupIcbContext =
FALSE;
01403
01404 } except(
UdfExceptionFilter( IrpContext, GetExceptionInformation() )) {
01405
01406
01407
01408
01409
01410
01411
Status = STATUS_INVALID_PARAMETER;
01412 }
01413
01414
01415
01416
01417
01418
if (
Status == STATUS_INVALID_PARAMETER) {
01419
01420
try_leave( NOTHING );
01421 }
01422 }
01423
01424
01425
01426
01427
01428
01429
if (
FlagOn( NextFcb->
FileAttributes, FILE_ATTRIBUTE_DIRECTORY )) {
01430
01431
if (
FlagOn( IrpSp->Parameters.Create.Options, FILE_NON_DIRECTORY_FILE )) {
01432
01433
try_leave(
Status = STATUS_FILE_IS_A_DIRECTORY );
01434 }
01435
01436 }
else if (
FlagOn( IrpSp->Parameters.Create.Options, FILE_DIRECTORY_FILE )) {
01437
01438
try_leave(
Status = STATUS_NOT_A_DIRECTORY );
01439 }
01440
01441
01442
01443
01444
01445
01446
01447
01448
if (!
UdfAcquireFcbExclusive( IrpContext, NextFcb,
TRUE )) {
01449
01450 NextFcb->
FcbReference += 1;
01451
UdfUnlockVcb( IrpContext, Vcb );
01452
01453
UdfAcquireFcbExclusive( IrpContext, NextFcb,
FALSE );
01454
01455
UdfLockVcb( IrpContext, Vcb );
01456 NextFcb->
FcbReference -= 1;
01457 }
01458
01459
UdfUnlockVcb( IrpContext, Vcb );
01460 UnlockVcb =
FALSE;
01461
01462
01463
01464
01465
01466 *CurrentFcb = NextFcb;
01467
01468
01469
01470
01471
01472
if (!
UdfIllegalFcbAccess( IrpContext,
01473 TypeOfOpen,
01474 IrpSp->Parameters.Create.SecurityContext->DesiredAccess )) {
01475
01476
01477
01478
01479
01480
Status =
UdfCompleteFcbOpen( IrpContext,
01481 IrpSp,
01482 Vcb,
01483 CurrentFcb,
01484
NULL,
01485 TypeOfOpen,
01486
CCB_FLAG_OPEN_BY_ID,
01487 IrpSp->Parameters.Create.SecurityContext->DesiredAccess );
01488 }
01489
01490 } finally {
01491
01492
if (UnlockVcb) {
01493
01494
UdfUnlockVcb( IrpContext, Vcb );
01495 }
01496
01497
if (CleanupIcbContext) {
01498
01499
UdfCleanupIcbContext( IrpContext, &IcbContext );
01500 }
01501
01502
01503
01504
01505
01506
if (NextFcb && !
FlagOn( NextFcb->
FcbState,
FCB_STATE_INITIALIZED )) {
01507
01508
UdfDeleteFcb( IrpContext, NextFcb );
01509 }
01510
01511 }
01512
01513
return Status;
01514 }
01515
01516
01517
01518
01519
01520
01521
NTSTATUS
01522 UdfOpenExistingFcb (
01523 IN
PIRP_CONTEXT IrpContext,
01524 IN
PIO_STACK_LOCATION IrpSp,
01525 IN OUT
PFCB *CurrentFcb,
01526 IN
PLCB OpenLcb,
01527 IN TYPE_OF_OPEN TypeOfOpen,
01528 IN BOOLEAN IgnoreCase,
01529 IN
PCCB RelatedCcb OPTIONAL
01530 )
01531
01532
01533
01534
01535
01536
01537
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562
01563
01564 {
01565 ULONG CcbFlags = 0;
01566
01567
NTSTATUS Status = STATUS_ACCESS_DENIED;
01568
01569
PAGED_CODE();
01570
01571
01572
01573
01574
01575
ASSERT_IRP_CONTEXT( IrpContext );
01576
ASSERT_EXCLUSIVE_FCB( *CurrentFcb );
01577
ASSERT_OPTIONAL_CCB( RelatedCcb );
01578
01579
01580
01581
01582
01583
if (!
UdfIllegalFcbAccess( IrpContext,
01584 TypeOfOpen,
01585 IrpSp->Parameters.Create.SecurityContext->DesiredAccess )) {
01586
01587
01588
01589
01590
01591
if (IgnoreCase) {
01592
01593
SetFlag( CcbFlags,
CCB_FLAG_IGNORE_CASE );
01594 }
01595
01596
01597
01598
01599
01600
01601
if (ARGUMENT_PRESENT( RelatedCcb )) {
01602
01603
if (
FlagOn( RelatedCcb->Flags,
CCB_FLAG_OPEN_BY_ID |
CCB_FLAG_OPEN_RELATIVE_BY_ID )) {
01604
01605
SetFlag( CcbFlags,
CCB_FLAG_OPEN_RELATIVE_BY_ID );
01606 }
01607 }
01608
01609
01610
01611
01612
01613
Status =
UdfCompleteFcbOpen( IrpContext,
01614 IrpSp,
01615 (*CurrentFcb)->Vcb,
01616 CurrentFcb,
01617 OpenLcb,
01618 TypeOfOpen,
01619 CcbFlags,
01620 IrpSp->Parameters.Create.SecurityContext->DesiredAccess );
01621 }
01622
01623
return Status;
01624 }
01625
01626
01627
01628
01629
01630
01631
NTSTATUS
01632 UdfOpenObjectFromDirContext (
01633 IN
PIRP_CONTEXT IrpContext,
01634 IN
PIO_STACK_LOCATION IrpSp,
01635 IN
PVCB Vcb,
01636 IN OUT
PFCB *CurrentFcb,
01637 IN BOOLEAN ShortNameMatch,
01638 IN BOOLEAN IgnoreCase,
01639 IN
PDIR_ENUM_CONTEXT DirContext,
01640 IN BOOLEAN PerformUserOpen,
01641 IN
PCCB RelatedCcb OPTIONAL
01642 )
01643
01644
01645
01646
01647
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672
01673
01674
01675
01676
01677
01678
01679
01680
01681
01682
01683
01684
01685
01686
01687
01688
01689
01690
01691 {
01692 ULONG CcbFlags = 0;
01693
FILE_ID FileId;
01694
01695 BOOLEAN UnlockVcb =
FALSE;
01696 BOOLEAN FcbExisted;
01697
01698
PFCB NextFcb =
NULL;
01699
PFCB ParentFcb =
NULL;
01700
01701
TYPE_OF_OPEN TypeOfOpen;
01702
NODE_TYPE_CODE NodeTypeCode;
01703
01704
ICB_SEARCH_CONTEXT IcbContext;
01705 BOOLEAN CleanupIcbContext =
FALSE;
01706
01707
PLCB OpenLcb;
01708
01709
NTSTATUS Status;
01710
01711
PAGED_CODE();
01712
01713
01714
01715
01716
01717
01718
if (
FlagOn( DirContext->Fid->Flags,
NSR_FID_F_DIRECTORY )) {
01719
01720 TypeOfOpen =
UserDirectoryOpen;
01721 NodeTypeCode =
UDFS_NTC_FCB_INDEX;
01722
01723 }
else {
01724
01725 TypeOfOpen =
UserFileOpen;
01726 NodeTypeCode =
UDFS_NTC_FCB_DATA;
01727 }
01728
01729
01730
01731
01732
01733
if (PerformUserOpen &&
01734
UdfIllegalFcbAccess( IrpContext,
01735 TypeOfOpen,
01736 IrpSp->Parameters.Create.SecurityContext->DesiredAccess )) {
01737
01738
return STATUS_ACCESS_DENIED;
01739 }
01740
01741
01742
01743
01744
01745
try {
01746
01747
01748
01749
01750
01751
if (ARGUMENT_PRESENT( RelatedCcb ) &&
01752
FlagOn( RelatedCcb->Flags,
CCB_FLAG_OPEN_BY_ID |
CCB_FLAG_OPEN_RELATIVE_BY_ID )) {
01753
01754
SetFlag( CcbFlags,
CCB_FLAG_OPEN_RELATIVE_BY_ID );
01755 }
01756
01757
if (IgnoreCase) {
01758
01759
SetFlag( CcbFlags,
CCB_FLAG_IGNORE_CASE );
01760 }
01761
01762
01763
01764
01765
01766
UdfSetFidFromLbAddr( FileId, DirContext->Fid->Icb.Start );
01767
01768
if (TypeOfOpen ==
UserDirectoryOpen) {
01769
01770
UdfSetFidDirectory( FileId );
01771 }
01772
01773
01774
01775
01776
01777
UdfLockVcb( IrpContext, Vcb );
01778 UnlockVcb =
TRUE;
01779
01780
01781
01782
01783
01784 NextFcb =
UdfCreateFcb( IrpContext, FileId, NodeTypeCode, &FcbExisted );
01785
01786
01787
01788
01789
01790
01791
01792
if (!FcbExisted) {
01793
01794
01795
01796
01797
01798 NextFcb->
RootExtentLength = DirContext->Fid->Icb.Length.Length;
01799
01800
UdfInitializeIcbContextFromFcb( IrpContext, &IcbContext, NextFcb );
01801 CleanupIcbContext =
TRUE;
01802
01803
UdfLookupActiveIcb( IrpContext, &IcbContext );
01804
01805
UdfInitializeFcbFromIcbContext( IrpContext,
01806 NextFcb,
01807 &IcbContext );
01808
01809
UdfCleanupIcbContext( IrpContext, &IcbContext );
01810 CleanupIcbContext =
FALSE;
01811
01812 }
01813
01814
01815
01816
01817
01818
01819
if (!
UdfAcquireFcbExclusive( IrpContext, NextFcb,
TRUE )) {
01820
01821 NextFcb->
FcbReference += 1;
01822
01823
UdfUnlockVcb( IrpContext, Vcb );
01824
01825
UdfReleaseFcb( IrpContext, *CurrentFcb );
01826
UdfAcquireFcbExclusive( IrpContext, NextFcb,
FALSE );
01827
UdfAcquireFcbExclusive( IrpContext, *CurrentFcb,
FALSE );
01828
01829
UdfLockVcb( IrpContext, Vcb );
01830 NextFcb->
FcbReference -= 1;
01831 }
01832
01833
01834
01835
01836
01837 ParentFcb = *CurrentFcb;
01838 *CurrentFcb = NextFcb;
01839
01840
01841
01842
01843
01844 OpenLcb =
UdfInsertPrefix( IrpContext,
01845 NextFcb,
01846 ( ShortNameMatch?
01847 &DirContext->ShortObjectName :
01848 &DirContext->CaseObjectName ),
01849 ShortNameMatch,
01850 IgnoreCase,
01851 ParentFcb );
01852
01853
01854
01855
01856
01857
DebugTrace(( +1,
Dbg,
01858
"UdfOpenObjectFromDirContext, PFcb %08x Vcb %d/%d Fcb %d/%d\n", ParentFcb,
01859 Vcb->VcbReference,
01860 Vcb->VcbUserReference,
01861 ParentFcb->
FcbReference,
01862 ParentFcb->
FcbUserReference ));
01863
01864
UdfIncrementReferenceCounts( IrpContext, ParentFcb, 1, 1 );
01865
01866
DebugTrace(( -1,
Dbg,
01867
"UdfOpenObjectFromDirContext, Vcb %d/%d Fcb %d/%d\n",
01868 Vcb->VcbReference,
01869 Vcb->VcbUserReference,
01870 ParentFcb->
FcbReference,
01871 ParentFcb->
FcbUserReference ));
01872
01873
UdfUnlockVcb( IrpContext, Vcb );
01874 UnlockVcb =
FALSE;
01875
01876
01877
01878
01879
01880
UdfInitializeLcbFromDirContext( IrpContext,
01881 OpenLcb,
01882 DirContext );
01883
01884
01885
01886
01887
01888
UdfReleaseFcb( IrpContext, ParentFcb );
01889 ParentFcb =
NULL;
01890
01891
01892
01893
01894
01895
if (PerformUserOpen) {
01896
01897
Status =
UdfCompleteFcbOpen( IrpContext,
01898 IrpSp,
01899 Vcb,
01900 CurrentFcb,
01901 OpenLcb,
01902 TypeOfOpen,
01903 CcbFlags,
01904 IrpSp->Parameters.Create.SecurityContext->DesiredAccess );
01905 }
01906
01907 } finally {
01908
01909
01910
01911
01912
01913
if (UnlockVcb) {
01914
01915
UdfUnlockVcb( IrpContext, Vcb );
01916 }
01917
01918
01919
01920
01921
01922
if (ParentFcb !=
NULL) {
01923
01924
UdfReleaseFcb( IrpContext, ParentFcb );
01925 }
01926
01927
01928
01929
01930
01931
if (NextFcb && !
FlagOn( NextFcb->
FcbState,
FCB_STATE_INITIALIZED )) {
01932
01933
UdfDeleteFcb( IrpContext, NextFcb );
01934 }
01935
01936
01937
01938
01939
01940
if (CleanupIcbContext) {
01941
01942
UdfCleanupIcbContext( IrpContext, &IcbContext );
01943 }
01944 }
01945
01946
return Status;
01947 }
01948
01949
01950
01951
01952
01953
01954
NTSTATUS
01955 UdfCompleteFcbOpen (
01956 IN
PIRP_CONTEXT IrpContext,
01957
PIO_STACK_LOCATION IrpSp,
01958 IN
PVCB Vcb,
01959 IN OUT
PFCB *CurrentFcb,
01960 IN
PLCB OpenLcb OPTIONAL,
01961 IN TYPE_OF_OPEN TypeOfOpen,
01962 IN ULONG UserCcbFlags,
01963 IN ACCESS_MASK DesiredAccess
01964 )
01965
01966
01967
01968
01969
01970
01971
01972
01973
01974
01975
01976
01977
01978
01979
01980
01981
01982
01983
01984
01985
01986
01987
01988
01989
01990
01991
01992
01993
01994
01995
01996
01997
01998
01999
02000 {
02001
NTSTATUS Status;
02002
NTSTATUS OplockStatus = STATUS_SUCCESS;
02003 ULONG Information = FILE_OPENED;
02004
02005 BOOLEAN LockVolume =
FALSE;
02006
02007
PFCB Fcb = *CurrentFcb;
02008
PCCB Ccb;
02009
02010
PAGED_CODE();
02011
02012
02013
02014
02015
02016
02017
if ((TypeOfOpen <=
UserVolumeOpen) &&
02018 !
FlagOn( IrpSp->
Parameters.Create.ShareAccess, FILE_SHARE_READ )) {
02019
02020
02021
02022
02023
02024
if (Vcb->VcbCleanup != 0) {
02025
02026
return STATUS_SHARING_VIOLATION;
02027 }
02028
02029
02030
02031
02032
02033
if (!
FlagOn( IrpContext->Flags,
IRP_CONTEXT_FLAG_WAIT )) {
02034
02035
UdfRaiseStatus( IrpContext, STATUS_CANT_WAIT );
02036 }
02037
02038 LockVolume =
TRUE;
02039
02040
02041
02042
02043
02044
02045
Status =
UdfPurgeVolume( IrpContext, Vcb,
FALSE );
02046
02047
if (
Status != STATUS_SUCCESS) {
02048
02049
return Status;
02050 }
02051
02052
02053
02054
02055
02056
UdfFspClose( Vcb );
02057
02058
if (Vcb->VcbUserReference > Vcb->VcbResidualUserReference) {
02059
02060
return STATUS_SHARING_VIOLATION;
02061 }
02062 }
02063
02064
02065
02066
02067
02068
02069
if (Fcb->
FcbCleanup != 0) {
02070
02071
02072
02073
02074
02075
02076
if (TypeOfOpen ==
UserFileOpen) {
02077
02078
02079
02080
02081
02082
02083
02084 IrpContext->TeardownFcb = CurrentFcb;
02085
02086
if (
FsRtlCurrentBatchOplock( &Fcb->Oplock )) {
02087
02088
02089
02090
02091
02092
02093 Information = FILE_OPBATCH_BREAK_UNDERWAY;
02094
02095 OplockStatus =
FsRtlCheckOplock( &Fcb->Oplock,
02096 IrpContext->Irp,
02097 IrpContext,
02098
UdfOplockComplete,
02099
UdfPrePostIrp );
02100
02101
if (OplockStatus == STATUS_PENDING) {
02102
02103
return STATUS_PENDING;
02104 }
02105 }
02106
02107
02108
02109
02110
02111
Status =
IoCheckShareAccess( DesiredAccess,
02112 IrpSp->
Parameters.Create.ShareAccess,
02113 IrpSp->
FileObject,
02114 &Fcb->
ShareAccess,
02115
FALSE );
02116
02117
if (!
NT_SUCCESS(
Status )) {
02118
02119
return Status;
02120 }
02121
02122
02123
02124
02125
02126
02127 OplockStatus =
FsRtlCheckOplock( &Fcb->Oplock,
02128 IrpContext->Irp,
02129 IrpContext,
02130
UdfOplockComplete,
02131
UdfPrePostIrp );
02132
02133
if (OplockStatus == STATUS_PENDING) {
02134
02135
return STATUS_PENDING;
02136 }
02137
02138 IrpContext->TeardownFcb =
NULL;
02139
02140
02141
02142
02143
02144 }
else {
02145
02146
Status =
IoCheckShareAccess( DesiredAccess,
02147 IrpSp->
Parameters.Create.ShareAccess,
02148 IrpSp->
FileObject,
02149 &Fcb->
ShareAccess,
02150
FALSE );
02151
02152
if (!
NT_SUCCESS(
Status )) {
02153
02154
return Status;
02155 }
02156 }
02157 }
02158
02159
02160
02161
02162
02163 Ccb =
UdfCreateCcb( IrpContext, Fcb, OpenLcb, UserCcbFlags );
02164
02165
02166
02167
02168
02169
if (Fcb->
FcbCleanup == 0) {
02170
02171
IoSetShareAccess( DesiredAccess,
02172 IrpSp->
Parameters.Create.ShareAccess,
02173 IrpSp->
FileObject,
02174 &Fcb->
ShareAccess );
02175
02176 }
else {
02177
02178
IoUpdateShareAccess( IrpSp->
FileObject, &Fcb->
ShareAccess );
02179 }
02180
02181
02182
02183
02184
02185
UdfSetFileObject( IrpContext, IrpSp->
FileObject, TypeOfOpen, Fcb, Ccb );
02186
02187
02188
02189
02190
02191
if (TypeOfOpen ==
UserFileOpen) {
02192
02193
if (
FlagOn( IrpSp->
Parameters.Create.Options, FILE_NO_INTERMEDIATE_BUFFERING )) {
02194
02195
SetFlag( IrpSp->
FileObject->
Flags,
FO_NO_INTERMEDIATE_BUFFERING );
02196
02197 }
else {
02198
02199
SetFlag( IrpSp->
FileObject->
Flags,
FO_CACHE_SUPPORTED );
02200 }
02201 }
02202
02203
02204
02205
02206
UdfLockVcb( IrpContext, Vcb );
02207
02208
UdfIncrementCleanupCounts( IrpContext, Fcb );
02209
02210
DebugTrace(( +1,
Dbg,
02211
"UdfCompleteFcbOpen, Fcb %08x Vcb %d/%d Fcb %d/%d\n", Fcb,
02212 Vcb->VcbReference,
02213 Vcb->VcbUserReference,
02214 Fcb->
FcbReference,
02215 Fcb->
FcbUserReference ));
02216
02217
UdfIncrementReferenceCounts( IrpContext, Fcb, 1, 1 );
02218
02219
DebugTrace(( -1,
Dbg,
02220
"UdfCompleteFcbOpen, Vcb %d/%d Fcb %d/%d\n",
02221 Vcb->VcbReference,
02222 Vcb->VcbUserReference,
02223 Fcb->
FcbReference,
02224 Fcb->
FcbUserReference ));
02225
02226
if (LockVolume) {
02227
02228 Vcb->VolumeLockFileObject = IrpSp->
FileObject;
02229
SetFlag( Vcb->VcbState,
VCB_STATE_LOCKED );
02230 }
02231
02232
UdfUnlockVcb( IrpContext, Vcb );
02233
02234
UdfLockFcb( IrpContext, Fcb );
02235
02236
if (TypeOfOpen ==
UserFileOpen) {
02237
02238 Fcb->IsFastIoPossible =
UdfIsFastIoPossible( Fcb );
02239
02240 }
else {
02241
02242 Fcb->IsFastIoPossible =
FastIoIsNotPossible;
02243 }
02244
02245
UdfUnlockFcb( IrpContext, Fcb );
02246
02247
02248
02249
02250
02251 IrpContext->Irp->IoStatus.Information = Information;
02252
02253
02254
02255
02256
02257 IrpSp->
FileObject->
SectionObjectPointer = &Fcb->
FcbNonpaged->
SegmentObject;
02258
return OplockStatus;
02259 }
02260