2 * Copyright (c) 2000, Red Hat, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by DJ Delorie <dj@cygnus.com>
16 /* The purpose of this file is to hide all the details about accessing
17 Cygwin's mount table. If the format or location of the mount table
18 changes, this is the file to change to match it. */
23 #include "../cygwin/include/cygwin/version.h"
24 #include "../cygwin/include/sys/mount.h"
33 find2 (HKEY rkey
, int *istext
)
42 sprintf (buf
, "Software\\%s\\%s\\%s\\/",
43 CYGWIN_INFO_CYGNUS_REGISTRY_NAME
,
44 CYGWIN_INFO_CYGWIN_REGISTRY_NAME
,
45 CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME
);
47 if (RegOpenKeyEx (rkey
, buf
, 0, KEY_READ
, &key
) != ERROR_SUCCESS
)
50 if (RegQueryValueEx (key
, "native", 0, &type
, 0, &retvallen
)
53 retval
= new char[retvallen
+1];
54 if (RegQueryValueEx (key
, "native", 0, &type
, (BYTE
*)retval
, &retvallen
)
62 retvallen
= sizeof (flags
);
63 RegQueryValueEx (key
, "flags", 0, &type
, (BYTE
*)&flags
, &retvallen
);
68 *istext
= (flags
& MOUNT_BINARY
) ? 0 : 1;
73 find_root_mount (int *istext
)
76 if (rv
= find2 (HKEY_CURRENT_USER
, istext
))
78 return find2 (HKEY_LOCAL_MACHINE
, istext
);
82 create_mount (char *posix
, char *win32
, int istext
)
87 DWORD retvallen
= 0, disposition
;
92 sprintf (buf
, "Software\\%s\\%s\\%s\\%s",
93 CYGWIN_INFO_CYGNUS_REGISTRY_NAME
,
94 CYGWIN_INFO_CYGWIN_REGISTRY_NAME
,
95 CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME
,
98 if (RegCreateKeyEx (HKEY_CURRENT_USER
, buf
, 0, "Cygwin", 0, KEY_ALL_ACCESS
,
99 0, &key
, &disposition
) != ERROR_SUCCESS
)
102 RegSetValueEx (key
, "native", 0, REG_SZ
, (BYTE
*)win32
, strlen (win32
)+1);
106 flags
= MOUNT_BINARY
;
107 RegSetValueEx (key
, "flags", 0, REG_DWORD
, (BYTE
*)&flags
, sizeof (flags
));
111 remove1 (HKEY rkey
, char *posix
)
115 sprintf (buf
, "Software\\%s\\%s\\%s\\%s",
116 CYGWIN_INFO_CYGNUS_REGISTRY_NAME
,
117 CYGWIN_INFO_CYGWIN_REGISTRY_NAME
,
118 CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME
,
121 RegDeleteKey (rkey
, buf
);
125 remove_mount (char *posix
)
127 remove1 (HKEY_LOCAL_MACHINE
, posix
);
128 remove1 (HKEY_CURRENT_USER
, posix
);