1 How to determine if OpenAFS is installed?
3 When the OpenAFS Client Service is installed there will be several
6 HKLM\SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon
7 "ImagePath" = "path to afsd_service.exe"
9 HKLM\SOFTWARE\TransarcCorporation\AFS Client\CurrentVersion
10 "PathName" = "the path to the client installation directory"
15 BOOL IsAFSServerInstalled (void)
17 BOOL fInstalled = FALSE;
18 TCHAR szKey[] = TEXT("HKLM\SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon");
19 LPCTSTR pch = lstrchr (szKey, TEXT('\\'));
22 if (RegOpenKey (HKEY_LOCAL_MACHINE, &pch[1], &hk) == 0)
31 How to determine if OpenAFS is active?
33 The AFS Client Service is normally started automatically at system boot.
34 The state of the service may be queried by asking the Windows Service
37 BOOL IsAFSServiceRunning (void)
39 SERVICE_STATUS Status;
40 memset (&Status, 0x00, sizeof(Status));
41 Status.dwCurrentState = SERVICE_STOPPED;
44 if ((hManager = OpenSCManager (NULL, NULL, GENERIC_READ)) != NULL)
47 if ((hService = OpenService (hManager, TEXT("TransarcAFSDaemon"), GENERIC_READ)) != NULL)
49 QueryServiceStatus (hService, &Status);
50 CloseServiceHandle (hService);
52 CloseServiceHandle (hManager);
54 return (Status.dwCurrentState == SERVICE_RUNNING);
57 How to determine the AFS UNC Service Name?
59 The local UNC service name registered by the OpenAFS Client Service SMB/CIFS
60 Server depends on whether or not a Microsoft Loopback Adapter has been
61 installed and the contents of a registry value. The loopback adapter is
62 important because if the service cannot bind itself to a loopback adapter
63 then the registered SMB/CIFS service name must be unique to the WINS name
64 space. When the loopback adapter is installed, a globally common name such
67 If the loopback adapter is installed the UNC server name will be the value at:
69 HKLM\SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters
70 REG_SZ/REG_EXPAND_SZ "NetbiosName"
72 If this value is not present, the default is "AFS".
74 When the loopback adapter is not installed the UNC name will be:
76 %COMPUTERNAME%-%NetbiosName%
78 if the Computer Name is "MYHOST" and the Netbios Name is "AFS" then
79 the UNC server name will be:
83 At the moment there is no readily available code exported by a library to
84 determine if the loopback adapter is installed or not. What I will do if
85 someone requests it is add a new AFS pioctl operation which will return
86 the in use UNC Server Name.
89 How to determine the AFS unix mount point path?
91 On Unix systems the local mount point of the AFS file system is usually "/afs".
92 Some organizations have their own custom local mount point locations. To
93 determine what the locally configured unix mount point is for interpretting
94 Unix style paths there is a registry value:
96 HKLM\SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters
99 If this value does not exist the default value is "/afs".
101 What are AFS pioctl() operations and how do I call them?
103 AFS pioctl() operations are IPCs which can be used to communicate with the
104 AFS Client Service for the purposes of querying or changing the state of
107 The pioctl() function has a prototype of:
116 long pioctl(char *pathp, long opcode, struct ViceIoctl *blobp, int follow);
118 and can be loaded from the library "afsauthent.dll" at runtime. The default
119 calling convention is used.
122 How to test to see if a PATH is within AFS?
124 Given an arbitrary file path, you can test to see if the path is in the AFS
125 file system with the following function. It asks the AFS Client Service to
126 return the name of the cell in which the path exists. If the cell name cannot
127 be found, the path is not in the AFS file space.
129 BOOL IsPathInAFS(const CHAR *strPath)
131 struct ViceIoctl blob;
136 blob.out_size = sizeof(cellname);
139 code = pioctl((LPTSTR)((LPCTSTR)strPath), VIOC_FILE_CELL_NAME, &blob, 1);
146 What are AFS cells, volumes and mount points?
148 The AFS file system consists of a series of administrative domains called
149 "cells" each of which contain two or more volumes. A volume is a file system
150 unit which contains files, directories, mount points, symlinks and hard
153 Each cell has a minimum of two volumes. When an AFS client connects to a
154 cell it mounts the cell's "root.afs" volume at the local afs mount point path.
155 Each "root.afs" volume contains one or more mount points which allow the
156 AFS client to other volumes in both in the current cell as well as other
157 cells. There are two types of mount points: read-only and read-write.
158 By following a read-only mount point the client can obtain data from any
159 of the equivalent read-only volume replicas. By following a read-write mount
160 point the client is restricted to the one and only read-write copy of the
161 volume. Periodically replicated volumes have their read-write copy "released"
162 which results in a synchronization with the read-only copies.
164 By convention the first volume of every cell to contain real data is called
165 "root.cell". The name of the read-only mount point which joins the "root.afs"
166 volume to the "root.cell" volume is the name of the cell. The name of the
167 read-write mount point is the name of the cell prefaced by a dot. For
168 example, the "athena.mit.edu" cell's "root.afs" volume will contain mount points
171 "athena.mit.edu" -> "#athena.mit.edu:root.cell"
172 ".athena.mit.edu" -> "%athena.mit.edu:root.cell"
174 The '#' indicates a read-only mount point and the '%' indicates a read-write
175 mount point. The mount points are not limited to the local cell so additional
176 mount points might be included such as:
178 "andrew.cmu.edu" -> "#andrew.cmu.edu:root.cell"
179 "sipb.mit.edu" -> "#sipb.mit.edu:root.cell"
181 The mount points appear as directory entries to the operating system.
183 Volumes can also store files, hard links to files, and symlinks to files.
185 On Windows, hardlinks can be created and destroyed using the CreateHardLink()
186 and DeleteFile() Win32 APIs.
188 Creating, Listing and Destroying symlinks and mount points is performed by
189 the user via the OpenAFS provided command line tools: fs.exe and symlink.exe.
191 symlink make <name> <to>
195 fs mkmount <dir> <vol> [<cell>] [-rw]
199 These operations are performed via pioctl calls.