2 * Copyright 2000, International Business Machines Corporation and others.
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
10 #include <afs/param.h>
16 #include <WINNT\afsreg.h>
19 main(int argc, char **argv) {
22 char mountRoot[64]="/afs";
25 if (argc < 2 || argc > 3) {
26 fprintf(stderr, "afsshare.exe <submount> [<afs mount path>]\n");
30 if (RegCreateKeyEx( HKEY_LOCAL_MACHINE,
31 AFSREG_CLT_OPENAFS_SUBKEY "\\Submounts",
34 REG_OPTION_NON_VOLATILE,
35 (IsWow64()?KEY_WOW64_64KEY:0)|KEY_READ|KEY_WRITE,
38 NULL) == ERROR_SUCCESS)
41 if (RegDeleteValue(hkSubmounts, argv[1])) {
42 fprintf(stderr,"Submount Deletion failure for [%s]: %lX",
43 argv[1], GetLastError());
44 RegCloseKey(hkSubmounts);
48 if (RegCreateKeyEx( HKEY_LOCAL_MACHINE,
49 AFSREG_CLT_SVC_PARAM_SUBKEY,
52 REG_OPTION_NON_VOLATILE,
53 (IsWow64()?KEY_WOW64_64KEY:0)|KEY_READ,
56 NULL) == ERROR_SUCCESS)
58 DWORD dwSize = sizeof(mountRoot);
59 RegQueryValueEx (hkParameters, "MountRoot", NULL, NULL, (PBYTE)mountRoot, &dwSize);
60 RegCloseKey(hkParameters);
64 if ( !strncmp(mountRoot, argv[2], strlen(mountRoot)) )
65 mountstring = argv[2] + strlen(mountRoot);
67 mountstring = argv[2];
69 if (RegSetValueEx(hkSubmounts, argv[1], 0, REG_EXPAND_SZ, mountstring, (DWORD)strlen(mountstring)+1)) {
70 fprintf(stderr,"Submount Set failure for [%s]: %lX",
71 argv[1], GetLastError());
72 RegCloseKey(hkSubmounts);
76 RegCloseKey(hkSubmounts);
78 fprintf(stderr,"Submount access denied: %lX", GetLastError());