Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

764 lines
26 KiB

  1. /*
  2. * INTERNAL.H
  3. *
  4. * Internal header for RSM Service
  5. *
  6. * Author: ErvinP
  7. *
  8. * (c) 2001 Microsoft Corporation
  9. *
  10. */
  11. typedef struct _SESSION SESSION;
  12. typedef struct _WORKITEM WORKITEM;
  13. typedef struct _WORKGROUP WORKGROUP;
  14. typedef struct _LIBRARY LIBRARY;
  15. typedef struct _TRANSPORT TRANSPORT;
  16. typedef struct _PICKER PICKER;
  17. typedef struct _SLOT SLOT;
  18. typedef struct _DRIVE DRIVE;
  19. typedef struct _MEDIA_POOL MEDIA_POOL;
  20. typedef struct _PHYSICAL_MEDIA PHYSICAL_MEDIA;
  21. typedef struct _MEDIA_PARTITION MEDIA_PARTITION;
  22. typedef struct _OPERATOR_REQUEST OPERATOR_REQUEST;
  23. typedef struct _MEDIA_TYPE_OBJECT MEDIA_TYPE_OBJECT;
  24. typedef struct _OBJECT_HEADER OBJECT_HEADER;
  25. /*
  26. * RSM Object Types
  27. *
  28. * The media hierarchy is as follows:
  29. * ------------------------------
  30. *
  31. * Library
  32. * Media Pool
  33. * Media Sub-Pool - a subset (child pool) of a media pool
  34. * ...
  35. *
  36. * Physical Media
  37. * - a connected set of partitions that have to move together
  38. * e.g. a cartridge or both sides of a disk
  39. *
  40. * Media Partition
  41. * - e.g. a side of a disk or catridge tape
  42. *
  43. *
  44. * Other library elements:
  45. * --------------------
  46. *
  47. * Drives - for reading/writing data on media
  48. *
  49. * Slots - for passively storing media
  50. *
  51. * Changers - for moving media between and amongst slots and drives.
  52. * A changer consists of a moving transport with
  53. * one or more pickers.
  54. *
  55. *
  56. * Logical media ID - a persistent GUID which identifies a media partition.
  57. *
  58. * Media type object - represents a recognized media type
  59. *
  60. */
  61. enum objectType {
  62. OBJECTTYPE_NONE = 0,
  63. OBJECTTYPE_LIBRARY,
  64. OBJECTTYPE_MEDIAPOOL,
  65. OBJECTTYPE_PHYSICALMEDIA,
  66. OBJECTTYPE_MEDIAPARTITION,
  67. OBJECTTYPE_DRIVE,
  68. OBJECTTYPE_SLOT,
  69. OBJECTTYPE_TRANSPORT,
  70. OBJECTTYPE_PICKER,
  71. OBJECTTYPE_MEDIATYPEOBJECT,
  72. // OBJECTTYPE_OPERATORREQUEST, // BUGBUG - keep in session queue
  73. };
  74. /*
  75. * This is a common header for all RSM objects that have GUIDs.
  76. * It is used to sort guid-identified objects in our hash table.
  77. */
  78. struct _OBJECT_HEADER {
  79. LIST_ENTRY hashListEntry;
  80. enum objectType objType;
  81. NTMS_GUID guid;
  82. ULONG refCount;
  83. BOOL isDeleted;
  84. };
  85. enum libraryTypes {
  86. LIBTYPE_NONE = 0,
  87. LIBTYPE_UNKNOWN,
  88. LIBTYPE_STANDALONE,
  89. LIBTYPE_AUTOMATED,
  90. };
  91. enum libraryStates {
  92. LIBSTATE_NONE = 0,
  93. LIBSTATE_INITIALIZING,
  94. LIBSTATE_ONLINE,
  95. LIBSTATE_OFFLINE,
  96. LIBSTATE_ERROR,
  97. };
  98. struct _LIBRARY {
  99. OBJECT_HEADER objHeader;
  100. enum libraryStates state;
  101. enum libraryTypes type;
  102. LIST_ENTRY allLibrariesListEntry; // entry in g_allLibrariesList
  103. ULONG numMediaPools;
  104. LIST_ENTRY mediaPoolsList;
  105. ULONG numDrives;
  106. DRIVE *drives;
  107. ULONG numSlots;
  108. SLOT *slots;
  109. /*
  110. * One (and only one) slot may be designated as a cleaner
  111. * slot. That slot may receive a cleaner cartridge (via InjectNtmsCleaner).
  112. * A cleaner cartridge has a limited number of cleans that it is good for.
  113. */
  114. #define NO_SLOT_INDEX (ULONG)(-1)
  115. ULONG cleanerSlotIndex; // index of cleaner slot or -1.
  116. ULONG numCleansLeftInCartridge;
  117. ULONG numTransports;
  118. TRANSPORT *transports;
  119. ULONG numTotalWorkItems;
  120. LIST_ENTRY freeWorkItemsList;
  121. LIST_ENTRY pendingWorkItemsList;
  122. LIST_ENTRY completeWorkItemsList;
  123. HANDLE somethingToDoEvent;
  124. /*
  125. * There is one thread per library. This is its handle.
  126. */
  127. HANDLE hThread;
  128. CRITICAL_SECTION lock;
  129. };
  130. enum mediaPoolTypes {
  131. MEDIAPOOLTYPE_NONE = 0,
  132. /*
  133. * These are the 3 standard pool types.
  134. */
  135. MEDIAPOOLTYPE_FREE,
  136. MEDIAPOOLTYPE_IMPORT,
  137. MEDIAPOOLTYPE_UNRECOGNIZED,
  138. MEDIAPOOLTYPE_OTHER,
  139. };
  140. struct _MEDIA_POOL {
  141. OBJECT_HEADER objHeader;
  142. /*
  143. * Entry in library's mediaPoolsList or
  144. * parent pool's childPoolsList.
  145. */
  146. LIST_ENTRY mediaPoolsListEntry;
  147. LIBRARY *owningLibrary;
  148. /*
  149. * A media pool has a (default?) media type.
  150. */
  151. MEDIA_TYPE_OBJECT *mediaTypeObj;
  152. /*
  153. * Media pools can be divided heirarchically into sub-pools.
  154. * If a pool is top-level, its parentPool pointer is NULL.
  155. */
  156. MEDIA_POOL *parentPool;
  157. ULONG numChildPools;
  158. LIST_ENTRY childPoolsList;
  159. ULONG numPhysMedia;
  160. LIST_ENTRY physMediaList;
  161. HANDLE newMediaEvent;
  162. WCHAR name[NTMS_OBJECTNAME_LENGTH];
  163. CRITICAL_SECTION lock;
  164. };
  165. // BUGBUG - should this be in physical media or mediaTypeObj ?
  166. enum physicalMediaTypes {
  167. PHYSICALMEDIATYPE_NONE = 0,
  168. PHYSICALMEDIATYPE_SINGLEPARTITION, // e.g. 1 disk,tape
  169. PHYSICALMEDIATYPE_CARTRIDGE,
  170. };
  171. enum physicalMediaStates {
  172. PHYSICALMEDIASTATE_NONE = 0,
  173. PHYSICALMEDIASTATE_INITIALIZING,
  174. PHYSICALMEDIASTATE_AVAILABLE, // i.e. in a slot
  175. PHYSICALMEDIASTATE_INUSE, // i.e. in a drive
  176. PHYSICALMEDIASTATE_RESERVED,
  177. };
  178. struct _PHYSICAL_MEDIA {
  179. OBJECT_HEADER objHeader;
  180. LIST_ENTRY physMediaListEntry; // entry in pool partition's physMediaList
  181. enum physicalMediaStates state;
  182. /*
  183. * Pointer to application-defined media type object.
  184. */
  185. MEDIA_TYPE_OBJECT *mediaTypeObj;
  186. MEDIA_POOL *owningMediaPool;
  187. SLOT *currentSlot;
  188. DRIVE *currentDrive;
  189. ULONG numPartitions;
  190. MEDIA_PARTITION *partitions;
  191. /*
  192. * The owning session of a physicalMedia also holds
  193. * the exclusive right to allocate partitions on it.
  194. */
  195. SESSION *owningSession;
  196. ULONG numPartitionsOwnedBySession;
  197. HANDLE mediaFreeEvent;
  198. CRITICAL_SECTION lock;
  199. };
  200. enum mediaPartitionTypes {
  201. MEDIAPARTITIONTYPE_NONE = 0,
  202. /*
  203. * Major types
  204. */
  205. MEDIAPARTITIONTYPE_TAPE,
  206. MEDIAPARTITIONTYPE_DISK,
  207. /*
  208. * Subtypes
  209. */
  210. // BUGBUG FINISH
  211. };
  212. enum mediaPartitionStates {
  213. MEDIAPARTITIONSTATE_NONE = 0,
  214. MEDIAPARTITIONSTATE_AVAILABLE,
  215. MEDIAPARTITIONSTATE_ALLOCATED,
  216. MEDIAPARTITIONSTATE_MOUNTED,
  217. MEDIAPARTITIONSTATE_INUSE,
  218. MEDIAPARTITIONSTATE_DECOMMISSIONED,
  219. };
  220. struct _MEDIA_PARTITION {
  221. OBJECT_HEADER objHeader;
  222. enum mediaPartitionTypes type;
  223. enum mediaPartitionTypes subType;
  224. enum mediaPartitionStates state;
  225. /*
  226. * When a media partition is 'complete',
  227. * it is no longer writeable.
  228. */
  229. BOOLEAN isComplete;
  230. /*
  231. * Can the owning physical medium be moved
  232. * into a new media pool ?
  233. */
  234. BOOLEAN allowImport;
  235. PHYSICAL_MEDIA *owningPhysicalMedia;
  236. /*
  237. * The logical media id is the persistent identifier
  238. * of a media partition that apps use to find it.
  239. */
  240. GUID logicalMediaGuid;
  241. SESSION *owningSession;
  242. };
  243. enum driveStates {
  244. DRIVESTATE_NONE = 0,
  245. DRIVESTATE_INITIALIZING,
  246. DRIVESTATE_AVAILABLE,
  247. DRIVESTATE_INUSE,
  248. DRIVESTATE_RESERVED,
  249. };
  250. struct _DRIVE {
  251. OBJECT_HEADER objHeader;
  252. enum driveStates state;
  253. ULONG driveIndex; // index into library's drives array
  254. PHYSICAL_MEDIA *insertedMedia;
  255. WCHAR path[MAX_PATH+1];
  256. LIBRARY *lib;
  257. };
  258. enum slotStates {
  259. SLOTSTATE_NONE = 0,
  260. SLOTSTATE_EMPTY,
  261. SLOTSTATE_OCCUPIED,
  262. };
  263. struct _SLOT {
  264. OBJECT_HEADER objHeader;
  265. enum slotStates state;
  266. UINT slotIndex; // index into library's slots array
  267. PHYSICAL_MEDIA *insertedMedia;
  268. /*
  269. * Is this the unique slot designated to hold the
  270. * library's cleaner cartridge ?
  271. */
  272. BOOLEAN isCleanerSlot;
  273. GUID slotId;
  274. LIBRARY *lib;
  275. };
  276. enum transportStates {
  277. TRANSPORTSTATE_NONE = 0,
  278. TRANSPORTSTATE_AVAILABLE,
  279. TRANSPORTSTATE_INUSE,
  280. };
  281. struct _TRANSPORT {
  282. OBJECT_HEADER objHeader;
  283. enum transportStates state;
  284. ULONG transportIndex; // index into library's transports array
  285. ULONG numPickers;
  286. PICKER *pickers;
  287. LIBRARY *lib;
  288. };
  289. struct _PICKER {
  290. OBJECT_HEADER objHeader;
  291. TRANSPORT *owningTransport;
  292. };
  293. struct _SESSION {
  294. #define SESSION_SIG 'SmsR'
  295. ULONG sig;
  296. LIST_ENTRY allSessionsListEntry; // entry in g_allSessionsList
  297. LIST_ENTRY operatorRequestList;
  298. CRITICAL_SECTION lock;
  299. WCHAR serverName[NTMS_COMPUTERNAME_LENGTH];
  300. WCHAR applicationName[NTMS_APPLICATIONNAME_LENGTH];
  301. WCHAR clientName[NTMS_COMPUTERNAME_LENGTH];
  302. WCHAR userName[NTMS_USERNAME_LENGTH];
  303. };
  304. struct _MEDIA_TYPE_OBJECT {
  305. OBJECT_HEADER objHeader;
  306. LIBRARY *lib;
  307. /*
  308. * The number of physical media pointing to this type
  309. * as their media type.
  310. */
  311. ULONG numPhysMediaReferences;
  312. // BUGBUG FINISH - media type characteristics
  313. CRITICAL_SECTION lock;
  314. };
  315. enum workItemStates {
  316. WORKITEMSTATE_NONE,
  317. /*
  318. * WorkItem is in one of the library queues:
  319. * free, pending, or complete.
  320. */
  321. WORKITEMSTATE_FREE,
  322. WORKITEMSTATE_PENDING,
  323. WORKITEMSTATE_COMPLETE,
  324. /*
  325. * WorkItem is not in any library queue.
  326. * It is in transit or being staged in a workGroup.
  327. */
  328. WORKITEMSTATE_STAGING,
  329. };
  330. struct _WORKITEM {
  331. enum workItemStates state;
  332. LIST_ENTRY libListEntry; // entry in one of a libraries workItem lists
  333. LIST_ENTRY workGroupListEntry; // entry in work group workItemList
  334. LIBRARY *owningLib;
  335. /*
  336. * The current work group with which this
  337. * work item is associated.
  338. */
  339. WORKGROUP *workGroup;
  340. // BUGBUG - ok to have a handle for each event ?
  341. HANDLE workItemCompleteEvent;
  342. /*
  343. * Fields describing the workItem's current operation.
  344. */
  345. struct {
  346. ULONG opcode;
  347. ULONG options;
  348. HRESULT resultStatus;
  349. DRIVE *drive;
  350. PHYSICAL_MEDIA *physMedia;
  351. MEDIA_PARTITION *mediaPartition;
  352. ULONG lParam;
  353. NTMS_GUID guidArg; // in/out guid used by some ops
  354. PVOID buf;
  355. ULONG bufLen;
  356. SYSTEMTIME timeQueued;
  357. SYSTEMTIME timeCompleted;
  358. /*
  359. * Request identifier, used to cancel a pending workItem.
  360. */
  361. NTMS_GUID requestGuid;
  362. //
  363. // BUGBUG - unscrubbed fields from NtmsDbWorkItem
  364. // clean this up.
  365. //
  366. // NtmsDbGuid m_PartitionId;
  367. // NtmsDbGuid m_AssocWorkItem;
  368. // short m_protected;
  369. // unsigned long m_Priority;
  370. } currentOp;
  371. };
  372. /*
  373. * A WORKGROUP is a collection of WORKITEMs,
  374. * not necessarily all on the same library.
  375. */
  376. struct _WORKGROUP {
  377. LIST_ENTRY workItemsList;
  378. ULONG numTotalWorkItems;
  379. ULONG numPendingWorkItems;
  380. HANDLE allWorkItemsCompleteEvent;
  381. HRESULT resultStatus;
  382. CRITICAL_SECTION lock;
  383. };
  384. struct _OPERATOR_REQUEST {
  385. LIST_ENTRY sessionOpReqsListEntry; // entry in session's operatorRequestList
  386. SESSION *invokingSession;
  387. ULONG numWaitingThreads; // num threads waiting for completion
  388. // BUGBUG - I don't think we need an op request thread
  389. HANDLE hThread; // thread spawned for op request
  390. enum NtmsOpreqCommand opRequestCommand;
  391. enum NtmsOpreqState state;
  392. NTMS_GUID arg1Guid;
  393. NTMS_GUID arg2Guid;
  394. WCHAR appMessage[NTMS_MESSAGE_LENGTH];
  395. WCHAR rsmMessage[NTMS_MESSAGE_LENGTH];
  396. // NOTIFYICONDATA notifyData; // BUGBUG - use this in RSM Monitor app ?
  397. NTMS_GUID opReqGuid;
  398. SYSTEMTIME timeSubmitted;
  399. HANDLE completedEvent;
  400. };
  401. /*
  402. * The number of free workItems with which we initialize a library.
  403. */
  404. #define MIN_LIBRARY_WORKITEMS 0
  405. /*
  406. * The maximum total number of workItems that we allow in a library pool.
  407. * We will allocate new workItems as needed up to this number.
  408. */
  409. #define MAX_LIBRARY_WORKITEMS 10000 // BUGBUG ?
  410. /*
  411. * List macros -- not defined in winnt.h for some reason.
  412. */
  413. #define InitializeListHead(ListHead) (\
  414. (ListHead)->Flink = (ListHead)->Blink = (ListHead))
  415. #define IsListEmpty(ListHead) \
  416. ((ListHead)->Flink == (ListHead))
  417. #define RemoveHeadList(ListHead) \
  418. (ListHead)->Flink;\
  419. {RemoveEntryList((ListHead)->Flink)}
  420. #define RemoveTailList(ListHead) \
  421. (ListHead)->Blink;\
  422. {RemoveEntryList((ListHead)->Blink)}
  423. #define RemoveEntryList(Entry) {\
  424. PLIST_ENTRY _EX_Blink;\
  425. PLIST_ENTRY _EX_Flink;\
  426. _EX_Flink = (Entry)->Flink;\
  427. _EX_Blink = (Entry)->Blink;\
  428. _EX_Blink->Flink = _EX_Flink;\
  429. _EX_Flink->Blink = _EX_Blink;\
  430. }
  431. #define InsertTailList(ListHead,Entry) {\
  432. PLIST_ENTRY _EX_Blink;\
  433. PLIST_ENTRY _EX_ListHead;\
  434. _EX_ListHead = (ListHead);\
  435. _EX_Blink = _EX_ListHead->Blink;\
  436. (Entry)->Flink = _EX_ListHead;\
  437. (Entry)->Blink = _EX_Blink;\
  438. _EX_Blink->Flink = (Entry);\
  439. _EX_ListHead->Blink = (Entry);\
  440. }
  441. #define InsertHeadList(ListHead,Entry) {\
  442. PLIST_ENTRY _EX_Flink;\
  443. PLIST_ENTRY _EX_ListHead;\
  444. _EX_ListHead = (ListHead);\
  445. _EX_Flink = _EX_ListHead->Flink;\
  446. (Entry)->Flink = _EX_Flink;\
  447. (Entry)->Blink = _EX_ListHead;\
  448. _EX_Flink->Blink = (Entry);\
  449. _EX_ListHead->Flink = (Entry);\
  450. }
  451. #define MIN(a, b) ((a) < (b) ? (a) : (b))
  452. #define MAX(a, b) ((a) > (b) ? (a) : (b))
  453. /*
  454. * Internal function prototypes
  455. */
  456. BOOLEAN RSMServiceGlobalInit();
  457. VOID RSMServiceGlobalShutdown();
  458. DWORD RSMServiceHandler(IN DWORD dwOpcode, IN DWORD dwEventType, IN PVOID pEventData, IN PVOID pData);
  459. BOOL InitializeRSMService();
  460. VOID ShutdownRSMService();
  461. VOID RSMServiceLoop();
  462. VOID StartLibraryManager();
  463. LIBRARY *NewRSMLibrary(ULONG numDrives, ULONG numSlots, ULONG numTransports);
  464. VOID FreeRSMLibrary(LIBRARY *lib);
  465. LIBRARY *FindLibrary(LPNTMS_GUID libId);
  466. SLOT *FindLibrarySlot(LIBRARY *lib, LPNTMS_GUID slotId);
  467. BOOL ValidateSessionHandle(HANDLE hSession);
  468. BOOL ValidateWStr(LPCWSTR str);
  469. BOOL ValidateAStr(LPCSTR s);
  470. BOOL ValidateBuffer(PVOID buf, ULONG len);
  471. WORKITEM *NewWorkItem(LIBRARY *lib);
  472. VOID FreeWorkItem(WORKITEM *workItem);
  473. VOID EnqueueFreeWorkItem(LIBRARY *lib, WORKITEM *workItem);
  474. WORKITEM *DequeueFreeWorkItem(LIBRARY *lib, BOOL allocOrYieldIfNeeded);
  475. VOID EnqueuePendingWorkItem(LIBRARY *lib, WORKITEM *workItem);
  476. WORKITEM *DequeuePendingWorkItem(LIBRARY *lib, WORKITEM *specificWorkItem);
  477. WORKITEM *DequeuePendingWorkItemByGuid(LIBRARY *lib, LPNTMS_GUID lpRequestId);
  478. VOID EnqueueCompleteWorkItem(LIBRARY *lib, WORKITEM *workItem);
  479. WORKITEM *DequeueCompleteWorkItem(LIBRARY *lib, WORKITEM *specificWorkItem);
  480. BOOL StartLibrary(LIBRARY *lib);
  481. VOID HaltLibrary(LIBRARY *lib);
  482. DWORD __stdcall LibraryThread(void *context);
  483. VOID Library_DoWork(LIBRARY *lib);
  484. OPERATOR_REQUEST *NewOperatorRequest(DWORD dwRequest, LPCWSTR lpMessage, LPNTMS_GUID lpArg1Id, LPNTMS_GUID lpArg2Id);
  485. VOID FreeOperatorRequest(OPERATOR_REQUEST *opReq);
  486. BOOL EnqueueOperatorRequest(SESSION *thisSession, OPERATOR_REQUEST *opReq);
  487. OPERATOR_REQUEST *DequeueOperatorRequest(SESSION *thisSession, OPERATOR_REQUEST *specificOpReq, LPNTMS_GUID specificOpReqGuid);
  488. OPERATOR_REQUEST *FindOperatorRequest(SESSION *thisSession, LPNTMS_GUID opReqGuid);
  489. HRESULT CompleteOperatorRequest(SESSION *thisSession, LPNTMS_GUID lpRequestId, enum NtmsOpreqState completeState);
  490. DWORD __stdcall OperatorRequestThread(void *context);
  491. SESSION *NewSession(LPCWSTR lpServer, LPCWSTR lpApplication, LPCWSTR lpClientName, LPCWSTR lpUserName);
  492. VOID FreeSession(SESSION *thisSession);
  493. ULONG WStrNCpy(WCHAR *dest, const WCHAR *src, ULONG maxWChars);
  494. ULONG AsciiToWChar(WCHAR *dest, const char *src, ULONG maxChars);
  495. ULONG WCharToAscii(char *dest, WCHAR *src, ULONG maxChars);
  496. BOOL WStringsEqualN(PWCHAR s, PWCHAR p, BOOL caseSensitive, ULONG maxLen);
  497. VOID ConvertObjectInfoAToWChar(LPNTMS_OBJECTINFORMATIONW wObjInfo, LPNTMS_OBJECTINFORMATIONA aObjInfo);
  498. VOID InitGuidHash();
  499. VOID InsertObjectInGuidHash(OBJECT_HEADER *obj);
  500. VOID RemoveObjectFromGuidHash(OBJECT_HEADER *obj);
  501. OBJECT_HEADER *FindObjectInGuidHash(NTMS_GUID *guid);
  502. MEDIA_POOL *NewMediaPool(LPCWSTR name, LPNTMS_GUID mediaType, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
  503. MEDIA_POOL *FindMediaPool(LPNTMS_GUID mediaPoolId);
  504. MEDIA_POOL *FindMediaPoolByName(PWSTR poolName);
  505. PHYSICAL_MEDIA *FindPhysicalMedia(LPNTMS_GUID physMediaId);
  506. VOID RefObject(PVOID objectPtr);
  507. VOID DerefObject(PVOID objectPtr);
  508. PHYSICAL_MEDIA *NewPhysicalMedia();
  509. HRESULT AllocatePhysicalMediaExclusive(SESSION *thisSession, PHYSICAL_MEDIA *physMedia, LPNTMS_GUID lpPartitionId, DWORD dwTimeoutMsec);
  510. HRESULT AllocateNextPartitionOnExclusiveMedia(SESSION *thisSession, PHYSICAL_MEDIA *physMedia, MEDIA_PARTITION **ppNextPartition);
  511. HRESULT AllocateMediaFromPool(SESSION *thisSession, MEDIA_POOL *mediaPool, DWORD dwTimeoutMsec, PHYSICAL_MEDIA **ppPhysMedia, BOOL opReqIfNeeded);
  512. MEDIA_PARTITION *FindMediaPartition(LPNTMS_GUID lpLogicalMediaId);
  513. HRESULT ReleaseMediaPartition(SESSION *thisSession, MEDIA_PARTITION *thisMediaPartition);
  514. MEDIA_POOL *FindMediaPoolByName(PWSTR poolName);
  515. MEDIA_POOL *FindMediaPoolByNameInLibrary(LIBRARY *lib, PWSTR poolName);
  516. HRESULT SetMediaPartitionState(MEDIA_PARTITION *mediaPart, enum mediaPartitionStates newState);
  517. HRESULT SetMediaPartitionComplete(MEDIA_PARTITION *mediaPart);
  518. HRESULT DeletePhysicalMedia(PHYSICAL_MEDIA *physMedia);
  519. VOID InsertPhysicalMediaInPool(MEDIA_POOL *mediaPool, PHYSICAL_MEDIA *physMedia);
  520. VOID RemovePhysicalMediaFromPool(PHYSICAL_MEDIA *physMedia);
  521. HRESULT MovePhysicalMediaToPool(MEDIA_POOL *destMediaPool, PHYSICAL_MEDIA *physMedia, BOOLEAN setMediaTypeToPoolType);
  522. BOOLEAN LockPhysicalMediaWithPool(PHYSICAL_MEDIA *physMedia);
  523. VOID UnlockPhysicalMediaWithPool(PHYSICAL_MEDIA *physMedia);
  524. BOOLEAN LockPhysicalMediaWithLibrary(PHYSICAL_MEDIA *physMedia);
  525. VOID UnlockPhysicalMediaWithLibrary(PHYSICAL_MEDIA *physMedia);
  526. HRESULT DeleteMediaPool(MEDIA_POOL *mediaPool);
  527. MEDIA_TYPE_OBJECT *NewMediaTypeObject();
  528. VOID DestroyMediaTypeObject(MEDIA_TYPE_OBJECT *mediaTypeObj);
  529. MEDIA_TYPE_OBJECT *FindMediaTypeObject(LPNTMS_GUID lpMediaTypeId);
  530. HRESULT DeleteMediaTypeObject(MEDIA_TYPE_OBJECT *mediaTypeObj);
  531. VOID SetMediaType(PHYSICAL_MEDIA *physMedia, MEDIA_TYPE_OBJECT *mediaTypeObj);
  532. WORKGROUP *NewWorkGroup();
  533. VOID FreeWorkGroup(WORKGROUP *workGroup);
  534. VOID FlushWorkGroup(WORKGROUP *workGroup);
  535. VOID FlushWorkItem(WORKITEM *workItem);
  536. HRESULT BuildMountWorkGroup(WORKGROUP *workGroup, LPNTMS_GUID lpMediaOrPartitionIds, LPNTMS_GUID lpDriveIds, DWORD dwCount, DWORD dwOptions, DWORD dwPriority);
  537. VOID BuildSingleMountWorkItem(WORKITEM *workItem, DRIVE *drive OPTIONAL, OBJECT_HEADER *mediaOrPartObj, ULONG dwOptions, int dwPriority);
  538. HRESULT BuildDismountWorkGroup(WORKGROUP *workGroup, LPNTMS_GUID lpMediaOrPartitionIds, DWORD dwCount, DWORD dwOptions);
  539. VOID BuildSingleDismountWorkItem(WORKITEM *workItem, OBJECT_HEADER *mediaOrPartObj, DWORD dwOptions);
  540. HRESULT ScheduleWorkGroup(WORKGROUP *workGroup);
  541. DRIVE *NewDrive(LIBRARY *lib, PWCHAR path);
  542. VOID FreeDrive(DRIVE *drive);
  543. DRIVE *FindDrive(LPNTMS_GUID driveId);
  544. VOID BuildEjectWorkItem(WORKITEM *workItem, PHYSICAL_MEDIA *physMedia, LPNTMS_GUID lpEjectOperation, ULONG dwAction);
  545. VOID BuildInjectWorkItem(WORKITEM *workItem, LPNTMS_GUID lpInjectOperation, ULONG dwAction);
  546. HRESULT StopCleanerInjection(LIBRARY *lib, LPNTMS_GUID lpInjectOperation);
  547. HRESULT StopCleanerEjection(LIBRARY *lib, LPNTMS_GUID lpEjectOperation);
  548. HRESULT DeleteLibrary(LIBRARY *lib);
  549. HRESULT DeleteDrive(DRIVE *drive);
  550. BOOL ServiceOneWorkItem(LIBRARY *lib, WORKITEM *workItem);
  551. BOOL ServiceRemove(LIBRARY *lib, WORKITEM *workItem);
  552. BOOL ServiceDisableChanger(LIBRARY *lib, WORKITEM *workItem);
  553. BOOL ServiceDisableLibrary(LIBRARY *lib, WORKITEM *workItem);
  554. BOOL ServiceEnableChanger(LIBRARY *lib, WORKITEM *workItem);
  555. BOOL ServiceEnableLibrary(LIBRARY *lib, WORKITEM *workItem);
  556. BOOL ServiceDisableDrive(LIBRARY *lib, WORKITEM *workItem);
  557. BOOL ServiceEnableDrive(LIBRARY *lib, WORKITEM *workItem);
  558. BOOL ServiceDisableMedia(LIBRARY *lib, WORKITEM *workItem);
  559. BOOL ServiceEnableMedia(LIBRARY *lib, WORKITEM *workItem);
  560. BOOL ServiceUpdateOmid(LIBRARY *lib, WORKITEM *workItem);
  561. BOOL ServiceInventory(LIBRARY *lib, WORKITEM *workItem);
  562. BOOL ServiceDoorAccess(LIBRARY *lib, WORKITEM *workItem);
  563. BOOL ServiceEject(LIBRARY *lib, WORKITEM *workItem);
  564. BOOL ServiceEjectCleaner(LIBRARY *lib, WORKITEM *workItem);
  565. BOOL ServiceInject(LIBRARY *lib, WORKITEM *workItem);
  566. BOOL ServiceInjectCleaner(LIBRARY *lib, WORKITEM *workItem);
  567. BOOL ServiceProcessOmid(LIBRARY *lib, WORKITEM *workItem);
  568. BOOL ServiceCleanDrive(LIBRARY *lib, WORKITEM *workItem);
  569. BOOL ServiceDismount(LIBRARY *lib, WORKITEM *workItem);
  570. BOOL ServiceMount(LIBRARY *lib, WORKITEM *workItem);
  571. BOOL ServiceWriteScratch(LIBRARY *lib, WORKITEM *workItem);
  572. BOOL ServiceClassify(LIBRARY *lib, WORKITEM *workItem);
  573. BOOL ServiceReserveCleaner(LIBRARY *lib, WORKITEM *workItem);
  574. BOOL ServiceReleaseCleaner(LIBRARY *lib, WORKITEM *workItem);
  575. /*
  576. * Externs for internal global data.
  577. */
  578. extern CRITICAL_SECTION g_globalServiceLock;
  579. extern LIST_ENTRY g_allLibrariesList;
  580. extern LIST_ENTRY g_allSessionsList;
  581. extern HANDLE g_terminateServiceEvent;
  582. extern HINSTANCE g_hInstance;