Source code of Windows XP (NT5)
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.

1727 lines
53 KiB

  1. /*
  2. * HrFSEntry.c v0.10
  3. * Generated in conjunction with Management Factory scripts:
  4. * script version: SNMPv1, 0.16, Apr 25, 1996
  5. * project: D:\TEMP\EXAMPLE\HOSTMIB
  6. ****************************************************************************
  7. * *
  8. * (C) Copyright 1995 DIGITAL EQUIPMENT CORPORATION *
  9. * *
  10. * This software is an unpublished work protected under the *
  11. * the copyright laws of the United States of America, all *
  12. * rights reserved. *
  13. * *
  14. * In the event this software is licensed for use by the United *
  15. * States Government, all use, duplication or disclosure by the *
  16. * United States Government is subject to restrictions as set *
  17. * forth in either subparagraph (c)(1)(ii) of the Rights in *
  18. * Technical Data And Computer Software Clause at DFARS *
  19. * 252.227-7013, or the Commercial Computer Software Restricted *
  20. * Rights Clause at FAR 52.221-19, whichever is applicable. *
  21. * *
  22. ****************************************************************************
  23. *
  24. * Facility:
  25. *
  26. * Windows NT SNMP Extension Agent
  27. *
  28. * Abstract:
  29. *
  30. * This module contains the code for dealing with the get, set, and
  31. * instance name routines for the HrFSEntry. Actual instrumentation code is
  32. * supplied by the developer.
  33. *
  34. * Functions:
  35. *
  36. * A get and set routine for each attribute in the class.
  37. *
  38. * The routines for instances within the class.
  39. *
  40. * Author:
  41. *
  42. * D. D. Burns @ Webenable Inc
  43. *
  44. * Revision History:
  45. *
  46. * V1.00 - 04/18/97 D. D. Burns Genned: Thu Nov 07 16:44:44 1996
  47. * V1.01 - 06/17/97 D. D. Burns Fix bug in Gen_HrFSTable_Cache() that
  48. * precluded finding "hrFSStorageIndex"
  49. * for drives w/volume labels.
  50. *
  51. */
  52. #include <windows.h>
  53. #include <malloc.h>
  54. #include <snmp.h>
  55. #include "mib.h"
  56. #include "smint.h"
  57. #include "hostmsmi.h"
  58. #include "user.h" /* Developer supplied include file */
  59. #include "HMCACHE.H" /* Cache-related definitions */
  60. #include "string.h" /* For string manipulation in "Gen_Hrstorage_Cache"*/
  61. #include "stdio.h" /* For sprintf */
  62. #include <winioctl.h> /* For PARTITION_INFORMATION */
  63. /*
  64. |==============================================================================
  65. | Function prototypes for this module.
  66. |
  67. */
  68. /* debug_print_hrFSTable - Prints a Row from HrFSTable sub-table */
  69. static void
  70. debug_print_hrFSTable(
  71. CACHEROW *row /* Row in hrFSTable table */
  72. );
  73. /*
  74. |==============================================================================
  75. | Create the list-head for the HrFStable cache.
  76. |
  77. | - Global so that code in "ProcessPartitions()" in "HRDISKST.C" can search
  78. | this cache.
  79. |
  80. | - This macro is defined in "HMCACHE.H".
  81. */
  82. CACHEHEAD_INSTANCE(hrFSTable_cache, debug_print_hrFSTable);
  83. /*
  84. * GetHrFSIndex
  85. * A unique value for each file system local to this host. The value for
  86. * each file system must remain constant at least from one r
  87. *
  88. * Gets the value for HrFSIndex.
  89. *
  90. * Arguments:
  91. *
  92. * outvalue address to return variable value
  93. * accesss Reserved for future security use
  94. * instance address of instance name as ordered native
  95. * data type(s)
  96. *
  97. * Return Codes:
  98. *
  99. * Standard PDU error codes.
  100. *
  101. * SNMP_ERRORSTATUS_NOERROR Successful get
  102. * SNMP_ERRORSTATUS_GENERR Catch-all failure code
  103. * mibtget.c v0.10
  104. *
  105. | =============== From WebEnable Design Spec Rev 3 04/11/97==================
  106. | hrFSIndex
  107. |
  108. | ACCESS SYNTAX
  109. | read-only INTEGER (1..2147483647)
  110. |
  111. | "A unique value for each file system local to this host. The value for each
  112. | file system must remain constant at least from one re-initialization of the
  113. | agent to the next re-initialization."
  114. |
  115. |
  116. | DISCUSSION:
  117. |
  118. | An entry is generated for each drive (network or not) returned by
  119. | "GetLogicalDrives".
  120. |
  121. |============================================================================
  122. | 1.3.6.1.2.1.25.3.8.1.1.<instance>
  123. | | | | |
  124. | | | | *hrFSIndex
  125. | | | *hrFSEntry
  126. | | *-hrFSTable
  127. | *-hrDevice
  128. */
  129. UINT
  130. GetHrFSIndex(
  131. OUT Integer *outvalue ,
  132. IN Access_Credential *access ,
  133. IN InstanceName *instance )
  134. {
  135. ULONG index; /* As fetched from instance structure */
  136. CACHEROW *row; /* Row entry fetched from cache */
  137. /*
  138. | Grab the instance information
  139. */
  140. index = GET_INSTANCE(0);
  141. /*
  142. | Use it to find the right entry in the cache
  143. */
  144. if ((row = FindTableRow(index, &hrFSTable_cache)) == NULL) {
  145. return SNMP_ERRORSTATUS_GENERR;
  146. }
  147. /*
  148. | Return the "hrFSIndex" value from this entry
  149. */
  150. *outvalue = row->attrib_list[HRFS_INDEX].u.unumber_value;
  151. return SNMP_ERRORSTATUS_NOERROR ;
  152. } /* end of GetHrFSIndex() */
  153. /*
  154. * GetHrFSMountPoint
  155. * The path name of the root of this file system.
  156. *
  157. * Gets the value for HrFSMountPoint.
  158. *
  159. * Arguments:
  160. *
  161. * outvalue address to return variable value
  162. * accesss Reserved for future security use
  163. * instance address of instance name as ordered native
  164. * data type(s)
  165. *
  166. * Return Codes:
  167. *
  168. * Standard PDU error codes.
  169. *
  170. * SNMP_ERRORSTATUS_NOERROR Successful get
  171. * SNMP_ERRORSTATUS_GENERR Catch-all failure code
  172. * mibtget.c v0.10
  173. *
  174. | =============== From WebEnable Design Spec Rev 3 04/11/97==================
  175. | hrFSMountPoint
  176. |
  177. | ACCESS SYNTAX
  178. | read-only InternationalDisplayString (SIZE(0..128))
  179. |
  180. | "The path name of the root of this file system."
  181. |
  182. | DISCUSSION:
  183. |
  184. | The value of this attribute is the proper value returned by
  185. | "GetLogicalDriveStrings" for the selected entry.
  186. |
  187. | RESOLVED >>>>>>>>
  188. | <POA-15> Just return an empty string for the Mount Point variables.
  189. | RESOLVED >>>>>>>>
  190. |
  191. |============================================================================
  192. | 1.3.6.1.2.1.25.3.8.1.2.<instance>
  193. | | | | |
  194. | | | | *hrFSMountPoint
  195. | | | *hrFSEntry
  196. | | *-hrFSTable
  197. | *-hrDevice
  198. */
  199. UINT
  200. GetHrFSMountPoint(
  201. OUT InternationalDisplayString *outvalue ,
  202. IN Access_Credential *access ,
  203. IN InstanceName *instance )
  204. {
  205. ULONG index; /* As fetched from instance structure */
  206. CACHEROW *row; /* Row entry fetched from cache */
  207. /*
  208. | Grab the instance information
  209. */
  210. index = GET_INSTANCE(0);
  211. /*
  212. | Use it to find the right entry in the cache
  213. */
  214. if ((row = FindTableRow(index, &hrFSTable_cache)) == NULL) {
  215. return SNMP_ERRORSTATUS_GENERR;
  216. }
  217. /*
  218. | The cache has the device string in it, but we return the empty string
  219. | per the spec.
  220. */
  221. #if 1
  222. /* Return the empty string */
  223. outvalue->string = "";
  224. outvalue->length = 0;
  225. #else
  226. /* Return the cached string */
  227. outvalue->string = row->attrib_list[HRFS_MOUNTPT].u.string_value;
  228. outvalue->length = strlen(outvalue->string);
  229. /* "Truncate" here to meet RFC as needed*/
  230. if ((outvalue->length = strlen(outvalue->string)) > 128) {
  231. outvalue->length = 128;
  232. }
  233. #endif
  234. return SNMP_ERRORSTATUS_NOERROR ;
  235. } /* end of GetHrFSMountPoint() */
  236. /*
  237. * GetHrFSRemoteMountPoint
  238. * A description of the name and/or address of the server that this file
  239. * system is mounted from. This may also include parameters
  240. *
  241. * Gets the value for HrFSRemoteMountPoint.
  242. *
  243. * Arguments:
  244. *
  245. * outvalue address to return variable value
  246. * accesss Reserved for future security use
  247. * instance address of instance name as ordered native
  248. * data type(s)
  249. *
  250. * Return Codes:
  251. *
  252. * Standard PDU error codes.
  253. *
  254. * SNMP_ERRORSTATUS_NOERROR Successful get
  255. * SNMP_ERRORSTATUS_GENERR Catch-all failure code
  256. * mibtget.c v0.10
  257. *
  258. | =============== From WebEnable Design Spec Rev 3 04/11/97==================
  259. | hrFSRemoteMountPoint
  260. |
  261. | ACCESS SYNTAX
  262. | read-only InternationalDisplayString (SIZE(0..128))
  263. |
  264. | "A description of the name and/or address of the server that this file system
  265. | is mounted from. This may also include parameters such as the mount point on
  266. | the remote file system. If this is not a remote file system, this string
  267. | should have a length of zero."
  268. |
  269. | DISCUSSION:
  270. |
  271. | <POA-15> The starting point for deriving this attribute's value is the logical
  272. | drive name, which would already be known to represent a network drive. I can
  273. | find no Win32 API function that maps a network logical drive to it's server.
  274. |
  275. | RESOLVED >>>>>>>>
  276. | <POA-15> Just return an empty string for the Mount Point variables.
  277. | RESOLVED >>>>>>>>
  278. |
  279. |============================================================================
  280. | 1.3.6.1.2.1.25.3.8.1.3.<instance>
  281. | | | | |
  282. | | | | *hrFSRemoteMountPoint
  283. | | | *hrFSEntry
  284. | | *-hrFSTable
  285. | *-hrDevice
  286. */
  287. UINT
  288. GetHrFSRemoteMountPoint(
  289. OUT InternationalDisplayString *outvalue ,
  290. IN Access_Credential *access ,
  291. IN InstanceName *instance )
  292. {
  293. /* Return the empty string */
  294. outvalue->string = "";
  295. outvalue->length = 0;
  296. return SNMP_ERRORSTATUS_NOERROR ;
  297. } /* end of GetHrFSRemoteMountPoint() */
  298. /*
  299. * GetHrFSType
  300. * The value of this object identifies the type of this file system.
  301. *
  302. * Gets the value for HrFSType.
  303. *
  304. * Arguments:
  305. *
  306. * outvalue address to return variable value
  307. * accesss Reserved for future security use
  308. * instance address of instance name as ordered native
  309. * data type(s)
  310. *
  311. * Return Codes:
  312. *
  313. * Standard PDU error codes.
  314. *
  315. * SNMP_ERRORSTATUS_NOERROR Successful get
  316. * SNMP_ERRORSTATUS_GENERR Catch-all failure code
  317. * mibtget.c v0.10
  318. *
  319. | =============== From WebEnable Design Spec Rev 3 04/11/97==================
  320. | hrFSType
  321. |
  322. | ACCESS SYNTAX
  323. | read-only OBJECT IDENTIFIER
  324. |
  325. | "The value of this object identifies the type of this file system."
  326. |
  327. | DISCUSSION:
  328. |
  329. | -- Registration for some popular File System types,
  330. | -- for use with hrFSType.
  331. |
  332. | hrFSTypes OBJECT IDENTIFIER ::= { hrDevice 9 }
  333. |
  334. | hrFSOther OBJECT IDENTIFIER ::= { hrFSTypes 1 }
  335. | hrFSUnknown OBJECT IDENTIFIER ::= { hrFSTypes 2 }
  336. | hrFSBerkeleyFFS OBJECT IDENTIFIER ::= { hrFSTypes 3 }
  337. | hrFSSys5FS OBJECT IDENTIFIER ::= { hrFSTypes 4 }
  338. | -- DOS
  339. | hrFSFat OBJECT IDENTIFIER ::= { hrFSTypes 5 }
  340. | -- OS/2 High Performance File System
  341. | hrFSHPFS OBJECT IDENTIFIER ::= { hrFSTypes 6 }
  342. | -- Macintosh Hierarchical File System
  343. | hrFSHFS OBJECT IDENTIFIER ::= { hrFSTypes 7 }
  344. |
  345. |
  346. | -- Macintosh File System
  347. | hrFSMFS OBJECT IDENTIFIER ::= { hrFSTypes 8 }
  348. | -- Windows NT
  349. | hrFSNTFS OBJECT IDENTIFIER ::= { hrFSTypes 9 }
  350. | hrFSVNode OBJECT IDENTIFIER ::= { hrFSTypes 10 }
  351. | hrFSJournaled OBJECT IDENTIFIER ::= { hrFSTypes 11 }
  352. | -- CD File systems
  353. | hrFSiso9660 OBJECT IDENTIFIER ::= { hrFSTypes 12 }
  354. | hrFSRockRidge OBJECT IDENTIFIER ::= { hrFSTypes 13 }
  355. |
  356. | hrFSNFS OBJECT IDENTIFIER ::= { hrFSTypes 14 }
  357. | hrFSNetware OBJECT IDENTIFIER ::= { hrFSTypes 15 }
  358. | -- Andrew File System
  359. | hrFSAFS OBJECT IDENTIFIER ::= { hrFSTypes 16 }
  360. | -- OSF DCE Distributed File System
  361. | hrFSDFS OBJECT IDENTIFIER ::= { hrFSTypes 17 }
  362. | hrFSAppleshare OBJECT IDENTIFIER ::= { hrFSTypes 18 }
  363. | hrFSRFS OBJECT IDENTIFIER ::= { hrFSTypes 19 }
  364. | -- Data General
  365. | hrFSDGCFS OBJECT IDENTIFIER ::= { hrFSTypes 20 }
  366. | -- SVR4 Boot File System
  367. | hrFSBFS OBJECT IDENTIFIER ::= { hrFSTypes 21 }
  368. |
  369. | Win32 API function "GetVolumeInformation" can provide us with the
  370. | information needed to select the correct OID for this attribute's value.
  371. |
  372. |============================================================================
  373. | 1.3.6.1.2.1.25.3.9.n
  374. | | | |
  375. | | | *-Type indicator
  376. | | *-hrFSTypes
  377. | *-hrDevice
  378. |
  379. | 1.3.6.1.2.1.25.3.8.1.4.<instance>
  380. | | | | |
  381. | | | | *hrFSType
  382. | | | *hrFSEntry
  383. | | *-hrFSTable
  384. | *-hrDevice
  385. */
  386. UINT
  387. GetHrFSType(
  388. OUT ObjectIdentifier *outvalue ,
  389. IN Access_Credential *access ,
  390. IN InstanceName *instance )
  391. {
  392. ULONG index; /* As fetched from instance structure */
  393. CACHEROW *row; /* Row entry fetched from cache */
  394. /*
  395. | Grab the instance information
  396. */
  397. index = GET_INSTANCE(0);
  398. /*
  399. | Use it to find the right entry in the cache
  400. */
  401. if ((row = FindTableRow(index, &hrFSTable_cache)) == NULL) {
  402. return SNMP_ERRORSTATUS_GENERR;
  403. }
  404. /*
  405. | By convention with the cache-building function "Gen_HrFSTable_Cache()",
  406. | the cached value is the right-most arc we must return as the value.
  407. |
  408. | Hence whatever cache entry we retrieve, we tack the number retrieved
  409. | from the cache for this attribute onto { hrFSTypes ... }.
  410. */
  411. if ( (outvalue->ids = SNMP_malloc(10 * sizeof( UINT ))) == NULL) {
  412. return SNMP_ERRORSTATUS_GENERR;
  413. }
  414. outvalue->idLength = 10;
  415. /*
  416. | Load in the full hrFSType OID:
  417. |
  418. | 1.3.6.1.2.1.25.3.9.n
  419. | | | |
  420. | | | *-Type indicator
  421. | | *-hrFSTypes
  422. | *-hrDevice
  423. */
  424. outvalue->ids[0] = 1;
  425. outvalue->ids[1] = 3;
  426. outvalue->ids[2] = 6;
  427. outvalue->ids[3] = 1;
  428. outvalue->ids[4] = 2;
  429. outvalue->ids[5] = 1;
  430. outvalue->ids[6] = 25;
  431. outvalue->ids[7] = 3;
  432. outvalue->ids[8] = 9;
  433. /* Cached FS Type indicator */
  434. outvalue->ids[9] = row->attrib_list[HRFS_TYPE].u.unumber_value;
  435. return SNMP_ERRORSTATUS_NOERROR ;
  436. } /* end of GetHrFSType() */
  437. /*
  438. * GetHrFSAccess
  439. * An indication if this file system is logically configured by the
  440. * operating system to be readable and writable or only readable.
  441. *
  442. * Gets the value for HrFSAccess.
  443. *
  444. * Arguments:
  445. *
  446. * outvalue address to return variable value
  447. * accesss Reserved for future security use
  448. * instance address of instance name as ordered native
  449. * data type(s)
  450. *
  451. * Return Codes:
  452. *
  453. * Standard PDU error codes.
  454. *
  455. * SNMP_ERRORSTATUS_NOERROR Successful get
  456. * SNMP_ERRORSTATUS_GENERR Catch-all failure code
  457. * mibtget.c v0.10
  458. *
  459. | =============== From WebEnable Design Spec Rev 3 04/11/97==================
  460. | hrFSAccess
  461. |
  462. | ACCESS SYNTAX
  463. | read-only INTEGER {readWrite(1),readOnly(2)}
  464. |
  465. | "An indication if this file system is logically configured by the operating
  466. | system to be readable and writable or only readable. This does not represent
  467. | any local access-control policy, except one that is applied to the file system
  468. | as a whole."
  469. |
  470. | DISCUSSION:
  471. |
  472. | Win32 API function "GetVolumeInformation" can provide us with the information
  473. | needed to select the correct OID for this attribute's value.
  474. |
  475. |============================================================================
  476. | 1.3.6.1.2.1.25.3.8.1.5.<instance>
  477. | | | | |
  478. | | | | *hrFSAccess
  479. | | | *hrFSEntry
  480. | | *-hrFSTable
  481. | *-hrDevice
  482. */
  483. UINT
  484. GetHrFSAccess(
  485. OUT INTAccess *outvalue ,
  486. IN Access_Credential *access ,
  487. IN InstanceName *instance )
  488. {
  489. ULONG index; /* As fetched from instance structure */
  490. CACHEROW *row; /* Row entry fetched from cache */
  491. /*
  492. | Grab the instance information
  493. */
  494. index = GET_INSTANCE(0);
  495. /*
  496. | Use it to find the right entry in the cache
  497. */
  498. if ((row = FindTableRow(index, &hrFSTable_cache)) == NULL) {
  499. return SNMP_ERRORSTATUS_GENERR;
  500. }
  501. /*
  502. | Return the "hrFSAccess" value from this entry
  503. */
  504. *outvalue = row->attrib_list[HRFS_ACCESS].u.unumber_value;
  505. return SNMP_ERRORSTATUS_NOERROR ;
  506. } /* end of GetHrFSAccess() */
  507. /*
  508. * GetHrFSBootable
  509. * A falg indicating whether this file system is bootable.
  510. *
  511. * Gets the value for HrFSBootable.
  512. *
  513. * Arguments:
  514. *
  515. * outvalue address to return variable value
  516. * accesss Reserved for future security use
  517. * instance address of instance name as ordered native
  518. * data type(s)
  519. *
  520. * Return Codes:
  521. *
  522. * Standard PDU error codes.
  523. *
  524. * SNMP_ERRORSTATUS_NOERROR Successful get
  525. * SNMP_ERRORSTATUS_GENERR Catch-all failure code
  526. * mibtget.c v0.10
  527. *
  528. | =============== From WebEnable Design Spec Rev 3 04/11/97==================
  529. | hrFSBootable
  530. |
  531. | ACCESS SYNTAX
  532. | read-only Boolean
  533. |
  534. | "A flag indicating whether this file system is bootable."
  535. |
  536. | DISCUSSION:
  537. |
  538. | Win32 API function "CreatFile" and DeviceIoControlcan provide us with the
  539. | information needed to select the correct OID for this attribute's value.
  540. |
  541. |============================================================================
  542. | 1.3.6.1.2.1.25.3.8.1.6.<instance>
  543. | | | | |
  544. | | | | *hrFSBootable
  545. | | | *hrFSEntry
  546. | | *-hrFSTable
  547. | *-hrDevice
  548. */
  549. UINT
  550. GetHrFSBootable(
  551. OUT Boolean *outvalue ,
  552. IN Access_Credential *access ,
  553. IN InstanceName *instance )
  554. {
  555. ULONG index; /* As fetched from instance structure */
  556. CACHEROW *row; /* Row entry fetched from cache */
  557. /*
  558. | Grab the instance information
  559. */
  560. index = GET_INSTANCE(0);
  561. /*
  562. | Use it to find the right entry in the cache
  563. */
  564. if ((row = FindTableRow(index, &hrFSTable_cache)) == NULL) {
  565. return SNMP_ERRORSTATUS_GENERR;
  566. }
  567. /*
  568. | Return the "hrFSBootable" value from this entry
  569. */
  570. *outvalue = row->attrib_list[HRFS_BOOTABLE].u.unumber_value;
  571. return SNMP_ERRORSTATUS_NOERROR ;
  572. } /* end of GetHrFSBootable() */
  573. /*
  574. * GetHrFSStorageIndex
  575. * The index of the hrStorageEntry that represents information about this
  576. * file system. If there is no such information available,
  577. *
  578. * Gets the value for HrFSStorageIndex.
  579. *
  580. * Arguments:
  581. *
  582. * outvalue address to return variable value
  583. * accesss Reserved for future security use
  584. * instance address of instance name as ordered native
  585. * data type(s)
  586. *
  587. * Return Codes:
  588. *
  589. * Standard PDU error codes.
  590. *
  591. * SNMP_ERRORSTATUS_NOERROR Successful get
  592. * SNMP_ERRORSTATUS_GENERR Catch-all failure code
  593. * mibtget.c v0.10
  594. *
  595. | =============== From WebEnable Design Spec Rev 3 04/11/97==================
  596. | hrFSStorageIndex
  597. |
  598. | ACCESS SYNTAX
  599. | read-only INTEGER (0..2147483647)
  600. |
  601. | "The index of the hrStorageEntry that represents information about this file
  602. | system. If there is no such information available, then this value shall be
  603. | zero. The relevant storage entry will be useful in tracking the percent usage
  604. | of this file system and diagnosing errors that may occur when it runs out of
  605. | space."
  606. |
  607. | DISCUSSION:
  608. |
  609. |============================================================================
  610. | 1.3.6.1.2.1.25.3.8.1.7.<instance>
  611. | | | | |
  612. | | | | *hrFSStorageIndex
  613. | | | *hrFSEntry
  614. | | *-hrFSTable
  615. | *-hrDevice
  616. */
  617. UINT
  618. GetHrFSStorageIndex(
  619. OUT Integer *outvalue ,
  620. IN Access_Credential *access ,
  621. IN InstanceName *instance )
  622. {
  623. ULONG index; /* As fetched from instance structure */
  624. CACHEROW *row; /* Row entry fetched from cache */
  625. /*
  626. | Grab the instance information
  627. */
  628. index = GET_INSTANCE(0);
  629. /*
  630. | Use it to find the right entry in the cache
  631. */
  632. if ((row = FindTableRow(index, &hrFSTable_cache)) == NULL) {
  633. return SNMP_ERRORSTATUS_GENERR;
  634. }
  635. /*
  636. | Return the "hrFSStorageIndex" value from this entry
  637. */
  638. *outvalue = row->attrib_list[HRFS_STORINDX].u.unumber_value;
  639. return SNMP_ERRORSTATUS_NOERROR ;
  640. } /* end of GetHrFSStorageIndex() */
  641. /*
  642. * GetHrFSLastFullBackupDate
  643. * The last date at which this complete file system was copied to another
  644. * storage device for backup. This information is useful fo
  645. *
  646. * Gets the value for HrFSLastFullBackupDate.
  647. *
  648. * Arguments:
  649. *
  650. * outvalue address to return variable value
  651. * accesss Reserved for future security use
  652. * instance address of instance name as ordered native
  653. * data type(s)
  654. *
  655. * Return Codes:
  656. *
  657. * Standard PDU error codes.
  658. *
  659. * SNMP_ERRORSTATUS_NOERROR Successful get
  660. * SNMP_ERRORSTATUS_GENERR Catch-all failure code
  661. * mibtget.c v0.10
  662. *
  663. | =============== From WebEnable Design Spec Rev 3 04/11/97==================
  664. | hrFSLastFullBackupDate
  665. |
  666. | ACCESS SYNTAX
  667. | read-write DateAndTime
  668. |
  669. | "The last date at which this complete file system was copied to another
  670. | storage device for backup. This information is useful for ensuring that
  671. | backups are being performed regularly. If this information is not known, then
  672. | this variable shall have the value corresponding to January 1, year 0000,
  673. | 00:00:00.0, which is encoded as (hex)'00 00 01 01 00 00 00 00'."
  674. |
  675. | DISCUSSION:
  676. |
  677. | This metric is apparently not recorded and is not made available through
  678. | any documented Win32 API function. Consequently, we return the appropriate
  679. | "not known" value.
  680. |
  681. |============================================================================
  682. | 1.3.6.1.2.1.25.3.8.1.8.<instance>
  683. | | | | |
  684. | | | | *hrFSLastFullBackupDate
  685. | | | *hrFSEntry
  686. | | *-hrFSTable
  687. | *-hrDevice
  688. */
  689. UINT
  690. GetHrFSLastFullBackupDate(
  691. OUT DateAndTime *outvalue ,
  692. IN Access_Credential *access ,
  693. IN InstanceName *instance )
  694. {
  695. outvalue->length = 8;
  696. outvalue->string = "\0\0\1\1\0\0\0\0";
  697. return SNMP_ERRORSTATUS_NOERROR ;
  698. } /* end of GetHrFSLastFullBackupDate() */
  699. /*
  700. * SetHrFSLastFullBackupDate
  701. * The last date at which this complete file system was copied to another
  702. * storage device for backup. This information is useful fo
  703. *
  704. * Sets the HrFSLastFullBackupDate value.
  705. *
  706. * Arguments:
  707. *
  708. * invalue address of value to set the variable
  709. * outvalue address to return the set variable value
  710. * access Reserved for future security use
  711. * instance address of instance name as ordered native
  712. * data type(s)
  713. *
  714. * Return Codes:
  715. *
  716. * Standard PDU error codes.
  717. *
  718. * SNMP_ERRORSTATUS_NOERROR Successful get
  719. * SNMP_ERRORSTATUS_BADVALUE Set value not in range
  720. * SNMP_ERRORSTATUS_GENERR Catch-all failure code
  721. * mibtset.ntc v0.10
  722. */
  723. UINT
  724. SetHrFSLastFullBackupDate(
  725. IN DateAndTime *invalue ,
  726. OUT DateAndTime *outvalue ,
  727. IN Access_Credential *access ,
  728. IN InstanceName *instance )
  729. {
  730. return SNMP_ERRORSTATUS_NOSUCHNAME ;
  731. } /* end of SetHrFSLastFullBackupDate() */
  732. /*
  733. * GetHrFSLastPartialBackupDate
  734. * The last date at which a portion of thes file system was copied to
  735. * another storage device for backup. This information is usefu
  736. *
  737. * Gets the value for HrFSLastPartialBackupDate.
  738. *
  739. * Arguments:
  740. *
  741. * outvalue address to return variable value
  742. * accesss Reserved for future security use
  743. * instance address of instance name as ordered native
  744. * data type(s)
  745. *
  746. * Return Codes:
  747. *
  748. * Standard PDU error codes.
  749. *
  750. * SNMP_ERRORSTATUS_NOERROR Successful get
  751. * SNMP_ERRORSTATUS_GENERR Catch-all failure code
  752. * mibtget.c v0.10
  753. *
  754. | =============== From WebEnable Design Spec Rev 3 04/11/97==================
  755. | hrFSLastPartialBackupDate
  756. |
  757. | ACCESS SYNTAX
  758. | read-write DateAndTime
  759. |
  760. | "The last date at which a portion of this file system was copied to another
  761. | storage device for backup. This information is useful for ensuring that
  762. | backups are being performed regularly. If this information is not known,
  763. | then this variable shall have the value corresponding to
  764. | January 1, year 0000, 00:00:00.0, which is encoded as
  765. | (hex)'00 00 01 01 00 00 00 00'."
  766. |
  767. | DISCUSSION:
  768. |
  769. | This metric is apparently not recorded and is not made available through
  770. | any documented Win32 API function. Consequently, we return the appropriate
  771. | "not known" value.
  772. |
  773. |============================================================================
  774. | 1.3.6.1.2.1.25.3.8.1.9.<instance>
  775. | | | | |
  776. | | | | *hrFSLastPartialBackupDate
  777. | | | *hrFSEntry
  778. | | *-hrFSTable
  779. | *-hrDevice
  780. */
  781. UINT
  782. GetHrFSLastPartialBackupDate(
  783. OUT DateAndTime *outvalue ,
  784. IN Access_Credential *access ,
  785. IN InstanceName *instance )
  786. {
  787. outvalue->length = 8;
  788. outvalue->string = "\0\0\1\1\0\0\0\0";
  789. return SNMP_ERRORSTATUS_NOERROR ;
  790. } /* end of GetHrFSLastPartialBackupDate() */
  791. /*
  792. * SetHrFSLastPartialBackupDate
  793. * The last date at which a portion of thes file system was copied to
  794. * another storage device for backup. This information is usefu
  795. *
  796. * Sets the HrFSLastPartialBackupDate value.
  797. *
  798. * Arguments:
  799. *
  800. * invalue address of value to set the variable
  801. * outvalue address to return the set variable value
  802. * access Reserved for future security use
  803. * instance address of instance name as ordered native
  804. * data type(s)
  805. *
  806. * Return Codes:
  807. *
  808. * Standard PDU error codes.
  809. *
  810. * SNMP_ERRORSTATUS_NOERROR Successful get
  811. * SNMP_ERRORSTATUS_BADVALUE Set value not in range
  812. * SNMP_ERRORSTATUS_GENERR Catch-all failure code
  813. * mibtset.ntc v0.10
  814. */
  815. UINT
  816. SetHrFSLastPartialBackupDate(
  817. IN DateAndTime *invalue ,
  818. OUT DateAndTime *outvalue ,
  819. IN Access_Credential *access ,
  820. IN InstanceName *instance )
  821. {
  822. return SNMP_ERRORSTATUS_NOSUCHNAME ;
  823. } /* end of SetHrFSLastPartialBackupDate() */
  824. /*
  825. * HrFSEntryFindInstance
  826. *
  827. * This routine is used to verify that the specified instance is
  828. * valid.
  829. *
  830. * Arguments:
  831. *
  832. * FullOid Address for the full oid - group, variable,
  833. * and instance information
  834. * instance Address for instance specification as an oid
  835. *
  836. * Return Codes:
  837. *
  838. * SNMP_ERRORSTATUS_NOERROR Instance found and valid
  839. * SNMP_ERRORSTATUS_NOSUCHNAME Invalid instance
  840. *
  841. */
  842. UINT
  843. HrFSEntryFindInstance( IN ObjectIdentifier *FullOid ,
  844. IN OUT ObjectIdentifier *instance )
  845. {
  846. UINT tmp_instance ;
  847. //
  848. // Developer instrumentation code to find appropriate instance goes here.
  849. // For non-tables, it is not necessary to modify this routine. However, if
  850. // there is any context that needs to be set, it can be done here.
  851. //
  852. if ( FullOid->idLength <= HRFSENTRY_VAR_INDEX )
  853. // No instance was specified
  854. return SNMP_ERRORSTATUS_NOSUCHNAME ;
  855. else if ( FullOid->idLength != HRFSENTRY_VAR_INDEX + 1 )
  856. // Instance length is more than 1
  857. return SNMP_ERRORSTATUS_NOSUCHNAME ;
  858. else
  859. // The only valid instance for a non-table are instance 0. If this
  860. // is a non-table, the following code validates the instances. If this
  861. // is a table, developer modification is necessary below.
  862. tmp_instance = FullOid->ids[ HRFSENTRY_VAR_INDEX ] ;
  863. /*
  864. | For hrFSTable, the instance arc(s) is a single arc, and it must
  865. | correctly select an entry in the hrFSTable cache.
  866. | Check that here.
  867. */
  868. if ( FindTableRow(tmp_instance, &hrFSTable_cache) == NULL ) {
  869. return SNMP_ERRORSTATUS_NOSUCHNAME ;
  870. }
  871. else
  872. {
  873. // the instance is valid. Create the instance portion of the OID
  874. // to be returned from this call.
  875. instance->ids[ 0 ] = tmp_instance ;
  876. instance->idLength = 1 ;
  877. }
  878. return SNMP_ERRORSTATUS_NOERROR ;
  879. } /* end of HrFSEntryFindInstance() */
  880. /*
  881. * HrFSEntryFindNextInstance
  882. *
  883. * This routine is called to get the next instance. If no instance
  884. * was passed than return the first instance (1).
  885. *
  886. * Arguments:
  887. *
  888. * FullOid Address for the full oid - group, variable,
  889. * and instance information
  890. * instance Address for instance specification as an oid
  891. *
  892. * Return Codes:
  893. *
  894. * SNMP_ERRORSTATUS_NOERROR Instance found and valid
  895. * SNMP_ERRORSTATUS_NOSUCHNAME Invalid instance
  896. *
  897. */
  898. UINT
  899. HrFSEntryFindNextInstance( IN ObjectIdentifier *FullOid ,
  900. IN OUT ObjectIdentifier *instance )
  901. {
  902. //
  903. // Developer supplied code to find the next instance of class goes here.
  904. // If this is a class with cardinality 1, no modification of this routine
  905. // is necessary unless additional context needs to be set.
  906. // If the FullOid does not specify an instance, then the only instance
  907. // of the class is returned. If this is a table, the first row of the
  908. // table is returned.
  909. //
  910. // If an instance is specified and this is a non-table class, then NOSUCHNAME
  911. // is returned so that correct MIB rollover processing occurs. If this is
  912. // a table, then the next instance is the one following the current instance.
  913. // If there are no more instances in the table, return NOSUCHNAME.
  914. //
  915. CACHEROW *row;
  916. ULONG tmp_instance;
  917. if ( FullOid->idLength <= HRFSENTRY_VAR_INDEX )
  918. {
  919. /*
  920. | Too short: must return the instance arc that selects the first
  921. | entry in the table if there is one.
  922. */
  923. tmp_instance = 0;
  924. }
  925. else {
  926. /*
  927. | There is at least one instance arc. Even if it is the only arc
  928. | we use it as the "index" in a request for the "NEXT" one.
  929. */
  930. tmp_instance = FullOid->ids[ HRFSENTRY_VAR_INDEX ] ;
  931. }
  932. /* Now go off and try to find the next instance in the table */
  933. if ((row = FindNextTableRow(tmp_instance, &hrFSTable_cache)) == NULL) {
  934. return SNMP_ERRORSTATUS_NOSUCHNAME ;
  935. }
  936. instance->ids[ 0 ] = row->index ;
  937. instance->idLength = 1 ;
  938. return SNMP_ERRORSTATUS_NOERROR ;
  939. } /* end of HrFSEntryFindNextInstance() */
  940. /*
  941. * HrFSEntryConvertInstance
  942. *
  943. * This routine is used to convert the object id specification of an
  944. * instance into an ordered native representation. The object id format
  945. * is that object identifier that is returned from the Find Instance
  946. * or Find Next Instance routines. It is NOT the full object identifier
  947. * that contains the group and variable object ids as well. The native
  948. * representation is an argc/argv-like structure that contains the
  949. * ordered variables that define the instance. This is specified by
  950. * the MIB's INDEX clause. See RFC 1212 for information about the INDEX
  951. * clause.
  952. *
  953. *
  954. * Arguments:
  955. *
  956. * oid_spec Address of the object id instance specification
  957. * native_spec Address to return the ordered native instance
  958. * specification
  959. *
  960. * Return Codes:
  961. *
  962. * SUCCESS Conversion complete successfully
  963. * FAILURE Unable to convert object id into native format
  964. *
  965. */
  966. UINT
  967. HrFSEntryConvertInstance( IN ObjectIdentifier *oid_spec ,
  968. IN OUT InstanceName *native_spec )
  969. {
  970. static char *array; /* The address of this (char *) is passed back */
  971. /* as though it were an array of length 1 of these */
  972. /* types. */
  973. static ULONG inst; /* The address of this ULONG is passed back */
  974. /* (Obviously, no "free()" action is needed) */
  975. /* We only expect the one arc in "oid_spec" */
  976. inst = oid_spec->ids[0];
  977. array = (char *) &inst;
  978. native_spec->count = 1;
  979. native_spec->array = &array;
  980. return SUCCESS ;
  981. } /* end of HrFSEntryConvertInstance() */
  982. /*
  983. * HrFSEntryFreeInstance
  984. *
  985. * This routine is used to free an ordered native representation of an
  986. * instance name.
  987. *
  988. * Arguments:
  989. *
  990. * instance Address to return the ordered native instance
  991. * specification
  992. *
  993. * Return Codes:
  994. *
  995. *
  996. */
  997. void
  998. HrFSEntryFreeInstance( IN OUT InstanceName *instance )
  999. {
  1000. /* No action needed for hrFSTable */
  1001. } /* end of HrFSEntryFreeInstance() */
  1002. /*
  1003. | End of Generated Code
  1004. */
  1005. /* Gen_HrFSTable_Cache - Generate a initial cache for HrFSTable */
  1006. /* Gen_HrFSTable_Cache - Generate a initial cache for HrFSTable */
  1007. /* Gen_HrFSTable_Cache - Generate a initial cache for HrFSTable */
  1008. BOOL
  1009. Gen_HrFSTable_Cache(
  1010. void
  1011. )
  1012. /*
  1013. | EXPLICIT INPUTS:
  1014. |
  1015. | None.
  1016. |
  1017. | IMPLICIT INPUTS:
  1018. |
  1019. | The module-local head of the cache for the HrFSTable,
  1020. | "hrFSTable_cache".
  1021. |
  1022. | OUTPUTS:
  1023. |
  1024. | On Success:
  1025. | Function returns TRUE indicating that the cache has been fully
  1026. | populated with all "static" cache-able values.
  1027. |
  1028. | On any Failure:
  1029. | Function returns FALSE (indicating "not enough storage").
  1030. |
  1031. | THE BIG PICTURE:
  1032. |
  1033. | At subagent startup time, the cache for each table in the MIB is
  1034. | populated with rows for each row in the table. This function is
  1035. | invoked by the start-up code in "UserMibInit()" ("MIB.C") to
  1036. | populate the cache for the HrStorage table.
  1037. |
  1038. | OTHER THINGS TO KNOW:
  1039. |
  1040. | There is one of these function for every table that has a cache.
  1041. | Each is found in the respective source file.
  1042. |
  1043. |=============== From WebEnable Design Spec Rev 3 04/11/97==================
  1044. | DISCUSSION:
  1045. |
  1046. | It appears that there is a one-to-one correspondence between NT logical drives
  1047. | and "file systems" as defined by this table. As a consequence, the contents
  1048. | of this table is almost identical to the hrStorageTable except that remote
  1049. | network drives (in unix-speak, remotely mounted file systems) are included
  1050. | in this table while excluded from hrStorageTable.
  1051. |
  1052. | To this end, a combination of Win32 API functions "GetLogicalDrives",
  1053. | "GetVolumeInformation", "GetDriveType" and "GetDiskFreeSpace" are used to
  1054. | acquire the information for the SNMP attributes in this table.
  1055. |
  1056. |============================================================================
  1057. | 1.3.6.1.2.1.25.3.8.1...
  1058. | | | |
  1059. | | | *hrFSEntry
  1060. | | *-hrFSTable
  1061. | *-hrDevice
  1062. |
  1063. */
  1064. {
  1065. CHAR temp[8]; /* Temporary buffer for first call */
  1066. LPSTR pDrvStrings; /* --> allocated storage for drive strings */
  1067. LPSTR pOriginal_DrvStrings; /* (Needed for final deallocation */
  1068. DWORD DS_request_len; /* Storage actually needed */
  1069. DWORD DS_current_len; /* Storage used on 2nd call */
  1070. ULONG table_index=0; /* hrFSTable index counter */
  1071. CACHEROW *row; /* --> Cache structure for row-being built */
  1072. UINT i; /* Handy-Dandy loop index */
  1073. #define PHYS_SIZE 32
  1074. CHAR phys_name[PHYS_SIZE]; /* Buffer where a string like "\\.C:" (for */
  1075. /* example) is built for drive access. */
  1076. /*
  1077. | Blow away any old copy of the cache
  1078. */
  1079. DestroyTable(&hrFSTable_cache);
  1080. /*
  1081. | We're going to call GetLogicalDriveStrings() twice, once to get the proper
  1082. | buffer size, and the second time to actually get the drive strings.
  1083. */
  1084. if ((DS_request_len = GetLogicalDriveStrings(2, temp)) == 0) {
  1085. /* Request failed altogether, can't initialize */
  1086. return ( FALSE );
  1087. }
  1088. /*
  1089. | Grab enough storage for the drive strings plus one null byte at the end
  1090. */
  1091. if ( (pOriginal_DrvStrings = pDrvStrings = malloc( (DS_request_len + 1) ) )
  1092. == NULL) {
  1093. /* Storage Request failed altogether, can't initialize */
  1094. return ( FALSE );
  1095. }
  1096. /* Go for all of the strings */
  1097. if ((DS_current_len = GetLogicalDriveStrings(DS_request_len, pDrvStrings))
  1098. == 0) {
  1099. /* Request failed altogether, can't initialize */
  1100. free( pOriginal_DrvStrings );
  1101. return ( FALSE );
  1102. }
  1103. /*
  1104. |==============================================================================
  1105. | As long as we've got an unprocessed drive-string which may correspond to
  1106. | a File-System for which we need a table-row entry . . .
  1107. */
  1108. while ( strlen(pDrvStrings) > 0 ) {
  1109. UINT drivetype; /* Type of the drive from "GetDriveType()" */
  1110. ULONG fs_type; /* derived File-System type (last-arc value) */
  1111. UINT bootable; /* derived "bootable" value (Boolean) */
  1112. UINT readwrite; /* derived "readwrite" value (0 or 1) */
  1113. UINT storage_index; /* Index into hrStorageTable to matching slot*/
  1114. CACHEROW *row_hrstorage; /* As returned by FindNextTableRow() */
  1115. /*
  1116. | Get the drive-type so we can decide whether it should participate in
  1117. | this table. We do both locals and remotes (unlike hrStorage, from
  1118. | which this code was ripped off).
  1119. */
  1120. drivetype = GetDriveType(pDrvStrings);
  1121. if ( drivetype == DRIVE_UNKNOWN
  1122. || drivetype == DRIVE_NO_ROOT_DIR
  1123. ) {
  1124. /* Step to next string, if any */
  1125. pDrvStrings += strlen(pDrvStrings) + 1;
  1126. continue;
  1127. }
  1128. /*
  1129. | OK, we want this one in the table, get a row-entry created.
  1130. */
  1131. if ((row = CreateTableRow( HRFS_ATTRIB_COUNT ) ) == NULL) {
  1132. return ( FALSE ); // Out of memory
  1133. }
  1134. /* =========== hrFSIndex ==========*/
  1135. row->attrib_list[HRFS_INDEX].attrib_type = CA_NUMBER;
  1136. row->attrib_list[HRFS_INDEX].u.unumber_value = (table_index += 1) ;
  1137. /* =========== hrFSMountPoint ==========
  1138. | Note: We store the device string in the cache, but the "GET" function
  1139. | always returns an empty string, per the spec.
  1140. */
  1141. row->attrib_list[HRFS_MOUNTPT].attrib_type = CA_STRING;
  1142. /* Get some space */
  1143. if ( (row->attrib_list[HRFS_MOUNTPT].u.string_value
  1144. = ( LPSTR ) malloc(strlen(pDrvStrings) + 1)) == NULL) {
  1145. return ( FALSE ); /* out of memory */
  1146. }
  1147. /* Copy the Value into the space */
  1148. strcpy(row->attrib_list[HRFS_MOUNTPT].u.string_value, pDrvStrings);
  1149. /*
  1150. | The GET functions for "computed" attributes expect to be able to use
  1151. | the value of the "hrFSMountPoint" cache value stored above to lookup
  1152. | (using system calls) their respective values. We may or may not actually
  1153. | report this stored-value as the value of the attribute in initial
  1154. | release.
  1155. */
  1156. /* =========== hrFSRemoteMountPoint ==========*/
  1157. row->attrib_list[HRFS_RMOUNTPT].attrib_type = CA_COMPUTED;
  1158. /* =========== hrFSType ==========
  1159. | =========== hrFSAccess ==========
  1160. | =========== hrFSBootable ==========
  1161. |
  1162. | We use the first two characters of the drive string (e.g. "C:") to
  1163. | create the special string (e.g. "\\.\C:") needed to obtain a "CreateFile"
  1164. | handle to the device "C" or partition "C".
  1165. |
  1166. | With that, a DeviceIoControl call for partition information gives
  1167. | us an idea as to the type and bootability of the device or partition.
  1168. |
  1169. | If any step in this process fails, the type is "hrFSUnknown", bootable
  1170. | is "FALSE" and Access is presumed "read-write".
  1171. |
  1172. | For hrFSType we store a single number as the cached value of the
  1173. | hrFSType attribute. When this attribute is fetched, the cached number
  1174. | forms the last arc in the OBJECT IDENTIFIER that actually specifies the
  1175. | type: { hrFSTypes x }, where "x" is what gets stored.
  1176. */
  1177. fs_type = 2; /* 2 = last arc value for "hrFSUnknown" */
  1178. bootable = 0; /* if unknown, "not bootable" */
  1179. readwrite = 1; /* if unknown, "read-write" */
  1180. /* If we have room in the buffer to build the handle-name string */
  1181. if ((strlen(pDrvStrings) + strlen("\\\\.\\")) < PHYS_SIZE) {
  1182. HANDLE hdrv; /* Handle to device */
  1183. PARTITION_INFORMATION part_info; /* Partition Info from device */
  1184. DWORD bytes_out; /* Bytes retnd into part_info */
  1185. /* Build it for device A: "\\.\A:" */
  1186. sprintf(phys_name, "\\\\.\\%2.2s", pDrvStrings);
  1187. /*
  1188. | Suppress any attempt by the system to make the user put a volume in a
  1189. | removable drive ("CreateFile" will just fail).
  1190. */
  1191. SetErrorMode(SEM_FAILCRITICALERRORS);
  1192. /* Attempt to get a handle using this physical name string */
  1193. if ((hdrv = CreateFile(phys_name, // Device
  1194. GENERIC_READ, // Access
  1195. FILE_SHARE_READ |
  1196. FILE_SHARE_WRITE, // Share Mode
  1197. NULL, // Security
  1198. OPEN_EXISTING, // CreationDistribution
  1199. FILE_ATTRIBUTE_NORMAL, // FlagsandAttributes
  1200. NULL // Template file
  1201. )) != INVALID_HANDLE_VALUE) {
  1202. /*
  1203. | Device is Open
  1204. |
  1205. | Try for Partition Information on the "device" we opened
  1206. |
  1207. | (Not supported by Floppy drivers, so this'll probably fail).
  1208. */
  1209. if (DeviceIoControl(hdrv, // device handle
  1210. // IoControlCode (op-code)
  1211. IOCTL_DISK_GET_PARTITION_INFO,
  1212. NULL, // "input buffer"
  1213. 0, // "input buffer size"
  1214. &part_info, // "output buffer"
  1215. // "output buffer size"
  1216. sizeof(PARTITION_INFORMATION),
  1217. &bytes_out, // bytes written to part_info
  1218. NULL // no Overlapped I/o
  1219. )) {
  1220. /*
  1221. | We've got Partition Information for the device: use it
  1222. */
  1223. bootable = part_info.BootIndicator;
  1224. /*
  1225. | Assign an OID Type "last-arc number" for those file system
  1226. | types we recognize.
  1227. */
  1228. switch (part_info.PartitionType) {
  1229. case PARTITION_UNIX: // Unix
  1230. fs_type = 3; // "hrFSBerkeleyFFS"
  1231. break;
  1232. case PARTITION_FAT_12: // 12-bit FAT entries
  1233. case PARTITION_FAT_16: // 16-bit FAT entries
  1234. case PARTITION_HUGE: // Huge partition MS-DOS V4
  1235. case PARTITION_FAT32: // FAT32
  1236. case PARTITION_FAT32_XINT13: // FAT32 using extended int13 services
  1237. fs_type = 5; // "hrFSFat"
  1238. break;
  1239. case PARTITION_IFS: // IFS Partition
  1240. case VALID_NTFT: // NTFT uses high order bits
  1241. fs_type = 9; // "hrFSNTFS"
  1242. break;
  1243. case PARTITION_XENIX_1: // Xenix
  1244. case PARTITION_XENIX_2: // Xenix
  1245. case PARTITION_XINT13: // Win95 partition using extended int13 services
  1246. case PARTITION_XINT13_EXTENDED: // Same as type 5 but uses extended int13 services
  1247. case PARTITION_EXTENDED: // Extended partition entry
  1248. case PARTITION_PREP: // PowerPC Reference Platform (PReP) Boot Partition
  1249. fs_type = 1; // "hrFSOther"
  1250. break;
  1251. case PARTITION_ENTRY_UNUSED: // Entry unused
  1252. default:
  1253. /* This will translate to fs_type = 2 "unknown" */
  1254. break;
  1255. }
  1256. } /* If (we managed to get partition information) */
  1257. CloseHandle(hdrv);
  1258. } /* if (we managed to "CreateFile" the device) */
  1259. SetErrorMode(0); /* Turn error suppression mode off */
  1260. } /* if (we managed to build a device name) */
  1261. /* =========== hrFSType ========== */
  1262. row->attrib_list[HRFS_TYPE].attrib_type = CA_NUMBER;
  1263. row->attrib_list[HRFS_TYPE].u.unumber_value = fs_type;
  1264. /* =========== hrFSAccess ========== */
  1265. /* Quick check: if its a CD-ROM, we presume it is readonly */
  1266. if (drivetype == DRIVE_CDROM) {
  1267. readwrite = 2;
  1268. }
  1269. row->attrib_list[HRFS_ACCESS].attrib_type = CA_NUMBER;
  1270. row->attrib_list[HRFS_ACCESS].u.unumber_value = readwrite;
  1271. /* =========== hrFSBootable ========== */
  1272. row->attrib_list[HRFS_BOOTABLE].attrib_type = CA_NUMBER;
  1273. row->attrib_list[HRFS_BOOTABLE].u.unumber_value = bootable;
  1274. /* =========== hrFSStorageIndex ==========
  1275. | Strategy:
  1276. |
  1277. | We wander up the hrStorage table looking for an exact match between
  1278. | the storage attribute "hrStorageDescr" (which contains the DOS drive
  1279. | string as returned by GetLogicalDriveStrings()) and the current drive
  1280. | string.
  1281. |
  1282. | The first exact match: the index of that hrStorageTable row gets
  1283. | stored here as the value of "hrFSStorageIndex".
  1284. |
  1285. | No Match: Store zero per the RFC spec.
  1286. |
  1287. | Come PnP, this attribute has to become "computed", as entries may come
  1288. | and go from the hrStorage table.
  1289. |
  1290. | NOTE: The length of the comparison of the match is limited by the
  1291. | drive string we generate in this function, as the "description"
  1292. | from the hrStorage table may have other stuff appended to the
  1293. | end of the drive-string.
  1294. */
  1295. row->attrib_list[HRFS_STORINDX].attrib_type = CA_NUMBER;
  1296. storage_index = 0; /* Presume failure */
  1297. /* Scan the hrStorageTable cache */
  1298. for (row_hrstorage = FindNextTableRow(0, &hrStorage_cache);
  1299. row_hrstorage != NULL;
  1300. row_hrstorage = FindNextTableRow(i, &hrStorage_cache)
  1301. ) {
  1302. /* Obtain the actual row index */
  1303. i = row_hrstorage->index;
  1304. /* If (this entry has an exact match on drive-strings) */
  1305. if (strncmp(row_hrstorage->attrib_list[HRST_DESCR].u.string_value,
  1306. pDrvStrings,strlen(pDrvStrings)) == 0) {
  1307. /* We found a match, record it and break out */
  1308. storage_index = i;
  1309. break;
  1310. }
  1311. }
  1312. row->attrib_list[HRFS_STORINDX].u.unumber_value = storage_index;
  1313. /* =========== hrFSLastFullBackupDate ==========*/
  1314. row->attrib_list[HRFS_LASTFULL].attrib_type = CA_COMPUTED;
  1315. /* =========== hrFSLastPartialBackupDate ==========*/
  1316. row->attrib_list[HRFS_LASTPART].attrib_type = CA_COMPUTED;
  1317. /*
  1318. | ======================================================
  1319. | Now insert the filled-in CACHEROW structure into the
  1320. | cache-list for the hrFSTable.
  1321. */
  1322. if (AddTableRow(row->attrib_list[HRFS_INDEX].u.unumber_value, /* Index */
  1323. row, /* Row */
  1324. &hrFSTable_cache /* Cache */
  1325. ) == FALSE) {
  1326. return ( FALSE ); /* Internal Logic Error! */
  1327. }
  1328. /* Step to next string, if any */
  1329. pDrvStrings += strlen(pDrvStrings) + 1;
  1330. } /* while (drive-strings remain . . .) */
  1331. free( pOriginal_DrvStrings );
  1332. #if defined(CACHE_DUMP)
  1333. PrintCache(&hrFSTable_cache);
  1334. #endif
  1335. /*
  1336. | Initialization of this table's cache succeeded
  1337. */
  1338. return (TRUE);
  1339. }
  1340. /* PartitionTypeToLastArc - Convert Partition Type to Last OID Arc value */
  1341. /* PartitionTypeToLastArc - Convert Partition Type to Last OID Arc value */
  1342. /* PartitionTypeToLastArc - Convert Partition Type to Last OID Arc value */
  1343. ULONG
  1344. PartitionTypeToLastArc (
  1345. BYTE p_type
  1346. )
  1347. /*
  1348. | EXPLICIT INPUTS:
  1349. |
  1350. | Disk Partition Type as returned in PARTITION_INFORMATINO
  1351. |
  1352. | IMPLICIT INPUTS:
  1353. |
  1354. | None.
  1355. |
  1356. | OUTPUTS:
  1357. |
  1358. | On Success:
  1359. | Function returns the value that should be used as the Last-Arc "x"
  1360. | in a "hrFSTypes" Object Identifier.
  1361. |
  1362. | On any Failure:
  1363. | Function returns the last-arc value for "UNKNOWN".
  1364. |
  1365. | THE BIG PICTURE:
  1366. |
  1367. | In more than one spot we need to be able to translate from
  1368. | a Partition Type to our "Last-Arc" value.
  1369. |
  1370. | OTHER THINGS TO KNOW:
  1371. |
  1372. */
  1373. {
  1374. ULONG last_arc = 2; /* "2" = "UNKNOWN" */
  1375. /*
  1376. | Assign an OID Type "last-arc number" for those file system
  1377. | types we recognize.
  1378. */
  1379. switch ( p_type ) {
  1380. case PARTITION_UNIX: // Unix
  1381. last_arc = 3; // "hrFSBerkeleyFFS"
  1382. break;
  1383. case PARTITION_FAT_12: // 12-bit FAT entries
  1384. case PARTITION_FAT_16: // 16-bit FAT entries
  1385. case PARTITION_HUGE: // Huge partition MS-DOS V4
  1386. case PARTITION_FAT32: // FAT32
  1387. case PARTITION_FAT32_XINT13: // FAT32 using extended int13 services
  1388. last_arc = 5; // "hrFSFat"
  1389. break;
  1390. case PARTITION_IFS: // IFS Partition
  1391. case VALID_NTFT: // NTFT uses high order bits
  1392. last_arc = 9; // "hrFSNTFS"
  1393. break;
  1394. case PARTITION_XENIX_1: // Xenix
  1395. case PARTITION_XENIX_2: // Xenix
  1396. case PARTITION_XINT13: // Win95 partition using extended int13 services
  1397. case PARTITION_XINT13_EXTENDED: // Same as type 5 but uses extended int13 services
  1398. case PARTITION_EXTENDED: // Extended partition entry
  1399. case PARTITION_PREP: // PowerPC Reference Platform (PReP) Boot Partition
  1400. last_arc = 1; // "hrFSOther"
  1401. break;
  1402. case PARTITION_ENTRY_UNUSED: // Entry unused
  1403. default:
  1404. /* This will translate to "unknown" */
  1405. break;
  1406. }
  1407. return ( last_arc );
  1408. }
  1409. #if defined(CACHE_DUMP)
  1410. /* debug_print_hrFSTable - Prints a Row from HrFSTable sub-table */
  1411. /* debug_print_hrFSTable - Prints a Row from HrFSTable sub-table */
  1412. /* debug_print_hrFSTable - Prints a Row from HrFSTable sub-table */
  1413. static void
  1414. debug_print_hrFSTable(
  1415. CACHEROW *row /* Row in hrFSTable table */
  1416. )
  1417. /*
  1418. | EXPLICIT INPUTS:
  1419. |
  1420. | "row" - points to the row to be dumped, if NULL, the function
  1421. | merely prints a suitable title.
  1422. |
  1423. | IMPLICIT INPUTS:
  1424. |
  1425. | - Symbols used to reference the attributes in the row entry.
  1426. | - File handle defined by OFILE, presumed to be open.
  1427. |
  1428. | OUTPUTS:
  1429. |
  1430. | On Success:
  1431. | Function prints a dump of the row in ASCII for debugging purposes
  1432. | on file handle OFILE.
  1433. |
  1434. | THE BIG PICTURE:
  1435. |
  1436. | Debugging only.
  1437. |
  1438. | OTHER THINGS TO KNOW:
  1439. */
  1440. {
  1441. if (row == NULL) {
  1442. fprintf(OFILE, "=====================\n");
  1443. fprintf(OFILE, "hrFSTable Table Cache\n");
  1444. fprintf(OFILE, "=====================\n");
  1445. return;
  1446. }
  1447. fprintf(OFILE, "hrFSIndex. . . . . . . . %d\n",
  1448. row->attrib_list[HRFS_INDEX].u.unumber_value);
  1449. fprintf(OFILE, "hrFSMountPoint . . . . . \"%s\" (ALWAYS RETURNED AS EMPTY STRING) \n",
  1450. row->attrib_list[HRFS_MOUNTPT].u.string_value);
  1451. fprintf(OFILE, "hrFSRemoteMountPoint . . \"%s\"\n",
  1452. row->attrib_list[HRFS_RMOUNTPT].u.string_value);
  1453. fprintf(OFILE, "hrFSType . . . . . . . . %d ",
  1454. row->attrib_list[HRFS_TYPE].u.unumber_value);
  1455. switch (row->attrib_list[HRFS_TYPE].u.unumber_value) {
  1456. case 1: fprintf(OFILE, "(hrFSOther)\n"); break;
  1457. case 2: fprintf(OFILE, "(hrFSUnknown)\n"); break;
  1458. case 3: fprintf(OFILE, "(hrFSBerkeleyFFS)\n"); break;
  1459. case 5: fprintf(OFILE, "(hrFSFat)\n"); break;
  1460. case 9: fprintf(OFILE, "(hrFSNTFS)\n"); break;
  1461. default:
  1462. fprintf(OFILE, "(???)\n");
  1463. }
  1464. fprintf(OFILE, "hrFSAccess . . . . . . . %d ",
  1465. row->attrib_list[HRFS_ACCESS].u.number_value);
  1466. switch (row->attrib_list[HRFS_ACCESS].u.unumber_value) {
  1467. case 1: fprintf(OFILE, "(readWrite)\n"); break;
  1468. case 2: fprintf(OFILE, "(readOnly)\n"); break;
  1469. default:
  1470. fprintf(OFILE, "(???)\n"); break;
  1471. }
  1472. fprintf(OFILE, "hrFSBootable . . . . . . %d ",
  1473. row->attrib_list[HRFS_BOOTABLE].u.number_value);
  1474. switch (row->attrib_list[HRFS_BOOTABLE].u.unumber_value) {
  1475. case 0: fprintf(OFILE, "(FALSE)\n"); break;
  1476. case 1: fprintf(OFILE, "(TRUE)\n"); break;
  1477. default:
  1478. fprintf(OFILE, "(???)\n"); break;
  1479. }
  1480. fprintf(OFILE, "hrFSStorageIndex . . . . %d\n",
  1481. row->attrib_list[HRFS_STORINDX].u.number_value);
  1482. }
  1483. #endif