Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / afssvrcfg / partition_utils.cpp
blob22e1b85c39c2a42f90ead48b781735eafaba3c32
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 */
11 * INCLUDES ___________________________________________________________________
14 #include <winsock2.h>
15 #include <ws2tcpip.h>
17 extern "C" {
18 #include <afs/param.h>
19 #include <afs/stds.h>
22 #include "afscfg.h"
23 #include "partition_utils.h"
24 #include <afs\afs_cfgAdmin.h>
28 * DEFINITIONS _________________________________________________________________
31 static cfg_partitionEntry_t *pTable = 0; // Partition table
32 static int cPartitions = 0; // Count of partitions
36 * EXPORTED FUNCTIONS _________________________________________________________
39 cfg_partitionEntry_t *GetPartitionTable(int &nNumPartitions)
41 nNumPartitions = cPartitions;
43 return pTable;
46 int GetNumPartitions()
48 return cPartitions;
51 int ReadPartitionTable(afs_status_t *pStatus)
53 ASSERT(g_hServer);
55 FreePartitionTable();
57 cPartitions = 0;
58 pTable = 0;
60 int nResult = cfg_HostPartitionTableEnumerate(g_hServer, &pTable, &cPartitions, pStatus);
62 return nResult;
65 BOOL IsAnAfsPartition(LPCTSTR pszRootDir)
67 for (int ii = 0; ii < cPartitions; ii++) {
69 TCHAR ch1 = pTable[ii].deviceName[0];
70 if (_istupper(ch1))
71 ch1 = _totlower(ch1);
73 TCHAR ch2 = pszRootDir[0];
74 if (_istupper(ch2))
75 ch2 = _totlower(ch2);
77 if (ch1 == ch2)
78 return TRUE;
81 return FALSE;
84 BOOL DoesPartitionExist(LPCTSTR pszName)
86 for (int ii = 0; ii < cPartitions; ii++) {
87 if (lstrcmp(A2S(pTable[ii].partitionName), pszName) == 0)
88 return TRUE;
91 return FALSE;
94 void FreePartitionTable()
96 if (pTable) {
97 afs_status_t nStatus;
98 cfg_PartitionListDeallocate(pTable, &nStatus);
101 pTable = 0;
102 cPartitions = 0;