33{
55
58
59
60
61 UDFPrint((
" UDFEjectReqWaiter: start\n"));
62 uint8 supported_evt_classes = 0;
66 uint32 space_check_counter = 0x7fffffff;
68
69
71 TargetDevObj =
Vcb->TargetDeviceObject;
72 UseEvent =
Vcb->UseEvent;
73 if(UseEvent) {
75 } else {
76 UDFPrint((
" Eject Button ignored\n"));
77 }
79 UDFPrint((
" Reading events... (0)\n"));
80 if(supported_evt_classes) {
83 if( !(supported_evt_classes &
evt_type) )
84 continue;
87
89 TargetDevObj,
93
96 break;
97 }
99 break;
102 }
103 }
104 }
105 if(!UseEvent)
106 break;
108 break;
109 }
110 supported_evt_classes = 0;
111
112
115
120stop_waiter:
121
123
124
125
126
129
133 UDFPrint((
" UDFEjectReqWaiter: exit 3\n"));
134 return;
135 }
136 BM_FlushPriod =
Vcb->BM_FlushPriod;
137 Tree_FlushPriod =
Vcb->Tree_FlushPriod;
138
139
140 if(space_check_counter > 2) {
141
144 }
145
147 if(
Vcb->LowFreeSpace && !OldLowFreeSpace) {
148
149 Vcb->Tree_FlushTime = Tree_FlushPriod+1;
150 Vcb->VCBFlags &= ~UDF_VCB_SKIP_EJECT_CHECK;
151 }
152 OldLowFreeSpace =
Vcb->LowFreeSpace;
153 space_check_counter = 0;
154 }
155 space_check_counter++;
156
158 SkipCount++;
159 SkipEjectCount++;
160 SkipEject = (SkipEjectCount <=
Vcb->SkipEjectCountLimit);
161 SkipFlush = (SkipEjectCount <=
Vcb->SkipCountLimit);
162 if(SkipEject || SkipFlush) {
163 Vcb->VCBFlags &= ~UDF_VCB_SKIP_EJECT_CHECK;
164 }
165 } else {
168 }
169
173 }
174
175 if(SkipFlush) {
177 Vcb->Tree_FlushTime = 0;
178 } else {
179 SkipCount = 0;
180 }
181 if(!SkipEject) {
182 SkipEjectCount = 0;
183 }
184
185 if(SkipEject && SkipFlush) {
186wait_eject:
190 goto stop_waiter;
191 }
193 }
194
196 goto wait_eject;
197 }
198
199
200 if(!SkipEject &&
203
206 TargetDevObj,
210
217 UDFPrint((
"SK=%x ASC=%x, ASCQ=%x, IE=%x\n",
218 Error->SenseKey,
Error->AdditionalSenseCode,
Error->AdditionalSenseCodeQualifier,
Error->LastError));
219
224 if((!
Vcb->Modified &&
226 ||
228
231 UDFPrint((
" UDFEjectReqWaiter: Unexpected write-in-progress on !Modified volume\n"));
232
236 goto device_failure;
237 }
238 }
242
243
244 UDFPrint((
" UDFEjectReqWaiter: Unexpected tray unlock encountered. Try to re-lock\n"));
245
248
249
250
251
252
255 TargetDevObj,
261
262 Vcb->LastModifiedTrack = 0;
263
264 }
265 }
266
268
269 if(!SkipFlush &&
271 (BM_FlushPriod || Tree_FlushPriod)) {
275 Vcb->BM_FlushTime +=
d;
276 Vcb->Tree_FlushTime +=
d;
277
279
281
282 UDFPrint((
" SkipCount=%x, SkipCountLimit=%x\n",
283 SkipCount,
284 Vcb->SkipCountLimit));
285
286 if( Tree_FlushPriod &&
287 (Tree_FlushPriod < Vcb->Tree_FlushTime)) {
288
289 UDFPrint((
" Tree_FlushPriod %I64x, Vcb->Tree_FlushTime %I64x\n",
290 Tree_FlushPriod,
291 Vcb->Tree_FlushTime));
292
293
296 goto skip_BM_flush;
297
298
299 if(!VcbAcquired) {
304 goto stop_waiter;
305 }
307 }
309 }
310
311 UDFPrint((
"UDF: Flushing Directory Tree....\n"));
312 if( BM_FlushPriod &&
313 (BM_FlushPriod < Vcb->BM_FlushTime)) {
316 } else {
319 }
324
325skip_BM_flush:
326 Vcb->Tree_FlushTime = 0;
327 }
328 if( BM_FlushPriod &&
329 (BM_FlushPriod < Vcb->BM_FlushTime)) {
330
331 UDFPrint((
" BM_FlushPriod %I64x, Vcb->BM_FlushTime %I64x\n",
332 BM_FlushPriod,
334
335
336
338 goto skip_BM_flush2;
340 goto skip_BM_flush2;
341
342 if(!VcbAcquired) {
347 goto stop_waiter;
348 }
350 }
352 }
353
355
356
359 }
360
361
362
363 AllFlushed =
365#ifndef UDF_READ_ONLY_BUILD
368
371
372 if(
Vcb->VerifyOnWrite) {
373 UDFPrint((
"UDF: Flushing cache for verify\n"));
374
377 }
378#ifdef UDF_DBG
379 UDFPrint((
"UDF: Flushing Free Space Bitmap....\n"));
380
381
382
384 UDFPrint((
"Error updating Main VDS\n"));
386 UDFPrint((
"Error updating Reserve VDS\n"));
387#else
390#endif
391
394 }
397 }
398#endif
401skip_BM_flush2:
402 Vcb->BM_FlushTime = 0;
403 }
404 if(FlushWCache) {
407 }
408
409 if(AllFlushed) {
410
412 }
413
414 if(VcbAcquired) {
417 }
418 if(!
Vcb->Tree_FlushTime &&
420 SkipCount = 0;
421 }
422 } else {
423
424 }
425
428
429 UDFPrint((
" UDFEjectReqWaiter: check removable media\n"));
432 }
433
435
436 if(!UseEvent) {
437 UDFPrint((
" Eject Button ignored\n"));
439 }
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
459
465
470 goto device_failure;
471 }
474 goto media_loss;
475 }
476 }
478 if(supported_evt_classes) {
481 if( !(supported_evt_classes &
evt_type) )
482 continue;
483
484
485
486
487
488
491
497
499 supported_evt_classes &= ~evt_type;
500 continue;
501 }
504 goto device_failure;
505 }
507 continue;
508 }
509
511 continue;
512 }
514 UDFPrint((
" EventStat_Class_Media:\n"));
517 continue;
518 }
519retry_media_presence_check:
522
528
531 UDFPrint((
" Buggy GET_EVENT media presence flag %x\n",
535 goto retry_media_presence_check;
536 }
537media_loss:
538 UDFPrint((
" Unexpected media loss. Check device status\n"));
541 } else
542
545 continue;
546 }
549 break;
550 }
552 UDFPrint((
" EventStat_Class_ExternalReq:\n"));
555 continue;
562 break;
563 }
564 continue;
565 }
566 }
567 if(!supported_evt_classes) {
569 }
572 }
573 } else {
574
575 UDFPrint((
" Reading Media Event...\n"));
578
584
587 goto device_failure;
590
596
598 goto device_failure;
601 }
603 }
606 }
607 }
608
609device_failure:
610
611
613
614 UDFPrint((
" UDFEjectReqWaiter: ejecting...\n"));
615#ifdef UDF_DELAYED_CLOSE
617 UDFPrint((
" UDFEjectReqWaiter: set UDF_VCB_FLAGS_NO_DELAYED_CLOSE\n"));
620#endif
621
622 UDFPrint((
" UDFEjectReqWaiter: UDFCloseAllSystemDelayedInDir\n"));
625#ifdef UDF_DELAYED_CLOSE
626 UDFPrint((
" UDFEjectReqWaiter: UDFCloseAllDelayed\n"));
628
629#endif
630
632
633 UDFPrint((
" UDFEjectReqWaiter: UDFDoDismountSequence\n"));
635 if (MediaLoss) {
636 Vcb->VCBFlags &= ~UDF_VCB_FLAGS_VOLUME_MOUNTED;
638 }
642
643 UDFPrint((
" UDFEjectReqWaiter: set WaiterStopped\n"));
647
648 UDFPrint((
" UDFEjectReqWaiter: exit 1\n"));
649 return;
650
653
654 if(VcbAcquired) {
657 }
658
659
660
661
662
663
664
665
667 }
668
669 return;
670}
int64 __fastcall UDFGetFreeSpace(IN PVCB Vcb)
#define SCSI_ADSENSE_LUN_NOT_READY
#define EventStat_MediaEvent_EjectReq
#define EventStat_ExtrnReqEvent_ExtrnReq
#define EventStat_MediaStat_Present
#define EventStat_ExtrnReqEvent_KeyDown
#define EventRetStat_Class_ExternReq
#define EventRetStat_Class_Media
#define EventRetStat_Class_Mask
#define EventStat_ExtrnReqEvent_KeyUp
#define EventStat_Class_ExternalReq
#define EventStat_ExtrnReqEvent_Mask
#define EventStat_MediaEvent_Mask
#define EventStat_Class_Media
#define EventStat_MediaStat_DoorOpen
#define DevCap_lock_state
#define SCSI_SENSE_NOT_READY
#define SCSI_SENSEQ_FORMAT_IN_PROGRESS
#define SCSI_SENSEQ_LONG_WRITE_IN_PROGRESS
struct _PREVENT_MEDIA_REMOVAL_USER_IN * PPREVENT_MEDIA_REMOVAL_USER_IN
#define IOCTL_CDRW_TEST_UNIT_READY
struct _GET_EVENT_USER_IN * PGET_EVENT_USER_IN
#define IOCTL_CDRW_GET_EVENT
#define IOCTL_CDRW_GET_LAST_ERROR
#define IOCTL_CDRW_GET_CAPABILITIES
VOID UDFCloseAllDelayed(IN PVCB Vcb)
#define INTEGRITY_TYPE_CLOSE
NTSTATUS NTAPI UDFTSendIOCTL(IN ULONG IoControlCode, IN PVCB Vcb, IN PVOID InputBuffer, IN ULONG InputBufferLength, OUT PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN OverrideVerify, OUT PIO_STATUS_BLOCK Iosb OPTIONAL)
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define RtlCompareMemory(s1, s2, l)
#define KeSetEvent(pEvt, foo, foo2)
#define KeQuerySystemTime(t)
OSSTATUS UDFFlushAllCachedAllocations(IN PVCB Vcb, IN uint32 AllocClass)
ULONG UDFFlushADirectory(IN PVCB Vcb, IN PUDF_FILE_INFO FI, OUT PIO_STATUS_BLOCK PtrIoStatus, IN ULONG FlushFlags)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
VOID UDFPreClrModified(IN PVCB Vcb)
VOID UDFClrModified(IN PVCB Vcb)
OSSTATUS UDFUpdateVolIdent(IN PVCB Vcb, IN UDF_VDS_RECORD Lba, IN PUNICODE_STRING VolIdent)
OSSTATUS UDFUpdateVDS(IN PVCB Vcb, IN uint32 block, IN uint32 lastblock, IN uint32 flags)
OSSTATUS UDFUpdateLogicalVolInt(PVCB Vcb, BOOLEAN Close)
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
OSSTATUS UDFDoDismountSequence(IN PVCB Vcb, IN PPREVENT_MEDIA_REMOVAL_USER_IN Buf, IN BOOLEAN Eject)
#define UDFCloseAllSystemDelayedInDir(Vcb, FI)
VOID UDFVFlush(IN PVCB Vcb)
VOID UDFVVerify(IN PVCB Vcb, IN ULONG Flags)
#define UDF_FLUSH_FLAGS_BREAKABLE
struct _UDFEjectWaitContext * PUDFEjectWaitContext
#define UDF_FLUSH_FLAGS_LITE
#define UDF_FLUSH_FLAGS_INTERRUPTED
union _EVENT_STAT_EXT_REQ_BLOCK::@863 Byte0
GET_EVENT_USER_OUT EjectReqBuffer
GET_CAPABILITIES_USER_OUT DevCap
GET_LAST_ERROR_USER_OUT Error
#define RtlCopyMemory(Destination, Source, Length)
#define UDF_VCB_FLAGS_NO_DELAYED_CLOSE
#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_LAST_WRITE
#define UDF_VCB_SKIP_EJECT_CHECK
#define UFD_VERIFY_FLAG_BG
#define UDF_PREALLOC_CLASS_DIR
#define UDF_PREALLOC_CLASS_FE
#define UDF_DEFAULT_FE_CHARGE
#define STATUS_INVALID_DEVICE_REQUEST
#define STATUS_DATA_OVERRUN
#define STATUS_NO_SUCH_DEVICE
#define STATUS_NO_MEDIA_IN_DEVICE
EVENT_STAT_EXT_REQ_BLOCK ExternalReq
EVENT_STAT_MEDIA_BLOCK MediaChange
VOID WCacheFlushAll__(IN PW_CACHE Cache, IN PVOID Context)
OSSTATUS WCacheFlushBlocks__(IN PW_CACHE Cache, IN PVOID Context, IN lba_t Lba, IN ULONG BCount)