2004-12-03 Pierre Humblet <pierre.humblet@ieee.org>
* registry.h (reg_key::reg_key): Change arguments. * shared_info.h (class mount_info): Remove had_to_create_mount_areas. * registry.cc (reg_key::reg_key): Change constructors to always handle HKLM and to avoid relying on HKCU. Do not set mount_table->had_to_create_mount_areas. * path.cc (mount_info::conv_to_win32_path): Improve update of sys_mount_table_counter. (mount_info::read_mounts): Use new reg_key constructor. (mount_info::add_reg_mount): Ditto. (mount_info::del_reg_mount): Ditto. (mount_info::read_cygdrive_info_from_registry): Ditto. (mount_info::write_cygdrive_info_to_registry): Ditto. Update cygwin_shared->sys_mount_table_counter after registry update. (mount_info::get_cygdrive_info): Ditto. * shared.cc (shared_info::heap_chunk_size): Use new reg_key constructor. * environ.cc (regopt): Ditto.
This commit is contained in:
parent
3263f819aa
commit
8151e674ba
|
@ -1,3 +1,22 @@
|
||||||
|
2004-12-03 Pierre Humblet <pierre.humblet@ieee.org>
|
||||||
|
|
||||||
|
* registry.h (reg_key::reg_key): Change arguments.
|
||||||
|
* shared_info.h (class mount_info): Remove had_to_create_mount_areas.
|
||||||
|
* registry.cc (reg_key::reg_key): Change constructors to always handle
|
||||||
|
HKLM and to avoid relying on HKCU.
|
||||||
|
Do not set mount_table->had_to_create_mount_areas.
|
||||||
|
* path.cc (mount_info::conv_to_win32_path): Improve update of
|
||||||
|
sys_mount_table_counter.
|
||||||
|
(mount_info::read_mounts): Use new reg_key constructor.
|
||||||
|
(mount_info::add_reg_mount): Ditto.
|
||||||
|
(mount_info::del_reg_mount): Ditto.
|
||||||
|
(mount_info::read_cygdrive_info_from_registry): Ditto.
|
||||||
|
(mount_info::write_cygdrive_info_to_registry): Ditto.
|
||||||
|
Update cygwin_shared->sys_mount_table_counter after registry update.
|
||||||
|
(mount_info::get_cygdrive_info): Ditto.
|
||||||
|
* shared.cc (shared_info::heap_chunk_size): Use new reg_key constructor.
|
||||||
|
* environ.cc (regopt): Ditto.
|
||||||
|
|
||||||
2004-12-01 Christopher Faylor <cgf@timesys.com>
|
2004-12-01 Christopher Faylor <cgf@timesys.com>
|
||||||
|
|
||||||
* include/features.h: Include sys/cdefs.h, like linux.
|
* include/features.h: Include sys/cdefs.h, like linux.
|
||||||
|
|
|
@ -640,29 +640,22 @@ static bool __stdcall
|
||||||
regopt (const char *name)
|
regopt (const char *name)
|
||||||
{
|
{
|
||||||
bool parsed_something = false;
|
bool parsed_something = false;
|
||||||
/* FIXME: should not be under mount */
|
|
||||||
reg_key r (KEY_READ, CYGWIN_INFO_PROGRAM_OPTIONS_NAME, NULL);
|
|
||||||
char buf[CYG_MAX_PATH];
|
char buf[CYG_MAX_PATH];
|
||||||
char lname[strlen (name) + 1];
|
char lname[strlen (name) + 1];
|
||||||
strlwr (strcpy (lname, name));
|
strlwr (strcpy (lname, name));
|
||||||
|
|
||||||
if (r.get_string (lname, buf, sizeof (buf) - 1, "") == ERROR_SUCCESS)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
parse_options (buf);
|
reg_key r (i, KEY_READ, CYGWIN_INFO_PROGRAM_OPTIONS_NAME, NULL);
|
||||||
parsed_something = true;
|
|
||||||
}
|
if (r.get_string (lname, buf, sizeof (buf) - 1, "") == ERROR_SUCCESS)
|
||||||
else
|
|
||||||
{
|
|
||||||
reg_key r1 (HKEY_LOCAL_MACHINE, KEY_READ, "SOFTWARE",
|
|
||||||
CYGWIN_INFO_CYGNUS_REGISTRY_NAME,
|
|
||||||
CYGWIN_INFO_CYGWIN_REGISTRY_NAME,
|
|
||||||
CYGWIN_INFO_PROGRAM_OPTIONS_NAME, NULL);
|
|
||||||
if (r1.get_string (lname, buf, sizeof (buf) - 1, "") == ERROR_SUCCESS)
|
|
||||||
{
|
{
|
||||||
parse_options (buf);
|
parse_options (buf);
|
||||||
parsed_something = true;
|
parsed_something = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MALLOC_CHECK;
|
MALLOC_CHECK;
|
||||||
return parsed_something;
|
return parsed_something;
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,8 +120,6 @@ create_shortcut_header (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CYGWIN_REGNAME (cygheap->cygwin_regname ?: CYGWIN_INFO_CYGWIN_REGISTRY_NAME)
|
|
||||||
|
|
||||||
/* Determine if path prefix matches current cygdrive */
|
/* Determine if path prefix matches current cygdrive */
|
||||||
#define iscygdrive(path) \
|
#define iscygdrive(path) \
|
||||||
(path_prefix_p (mount_table->cygdrive, (path), mount_table->cygdrive_len))
|
(path_prefix_p (mount_table->cygdrive, (path), mount_table->cygdrive_len))
|
||||||
|
@ -1400,8 +1398,9 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, device& dev,
|
||||||
bool chroot_ok = !cygheap->root.exists ();
|
bool chroot_ok = !cygheap->root.exists ();
|
||||||
while (sys_mount_table_counter < cygwin_shared->sys_mount_table_counter)
|
while (sys_mount_table_counter < cygwin_shared->sys_mount_table_counter)
|
||||||
{
|
{
|
||||||
|
int current = cygwin_shared->sys_mount_table_counter;
|
||||||
init ();
|
init ();
|
||||||
sys_mount_table_counter++;
|
sys_mount_table_counter = current;
|
||||||
}
|
}
|
||||||
MALLOC_CHECK;
|
MALLOC_CHECK;
|
||||||
|
|
||||||
|
@ -1753,7 +1752,7 @@ mount_info::read_mounts (reg_key& r)
|
||||||
char native_path[CYG_MAX_PATH];
|
char native_path[CYG_MAX_PATH];
|
||||||
int mount_flags;
|
int mount_flags;
|
||||||
|
|
||||||
posix_path_size = CYG_MAX_PATH;
|
posix_path_size = sizeof (posix_path);
|
||||||
/* FIXME: if maximum posix_path_size is 256, we're going to
|
/* FIXME: if maximum posix_path_size is 256, we're going to
|
||||||
run into problems if we ever try to store a mount point that's
|
run into problems if we ever try to store a mount point that's
|
||||||
over 256 but is under CYG_MAX_PATH. */
|
over 256 but is under CYG_MAX_PATH. */
|
||||||
|
@ -1788,27 +1787,23 @@ mount_info::read_mounts (reg_key& r)
|
||||||
void
|
void
|
||||||
mount_info::from_registry ()
|
mount_info::from_registry ()
|
||||||
{
|
{
|
||||||
/* Use current mount areas if either user or system mount areas
|
|
||||||
already exist. Otherwise, import old mounts. */
|
|
||||||
|
|
||||||
reg_key r;
|
|
||||||
|
|
||||||
/* Retrieve cygdrive-related information. */
|
/* Retrieve cygdrive-related information. */
|
||||||
read_cygdrive_info_from_registry ();
|
read_cygdrive_info_from_registry ();
|
||||||
|
|
||||||
nmounts = 0;
|
nmounts = 0;
|
||||||
|
|
||||||
/* First read mounts from user's table. */
|
/* First read mounts from user's table.
|
||||||
read_mounts (r);
|
Then read mounts from system-wide mount table while deimpersonated . */
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
/* Then read mounts from system-wide mount table. */
|
{
|
||||||
cygheap->user.deimpersonate ();
|
if (i)
|
||||||
reg_key r1 (HKEY_LOCAL_MACHINE, KEY_READ, "SOFTWARE",
|
cygheap->user.deimpersonate ();
|
||||||
CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME,
|
reg_key r (i, KEY_READ, CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, NULL);
|
||||||
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME,
|
read_mounts (r);
|
||||||
NULL);
|
if (i)
|
||||||
read_mounts (r1);
|
cygheap->user.reimpersonate ();
|
||||||
cygheap->user.reimpersonate ();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add_reg_mount: Add mount item to registry. Return zero on success,
|
/* add_reg_mount: Add mount item to registry. Return zero on success,
|
||||||
|
@ -1818,66 +1813,37 @@ mount_info::from_registry ()
|
||||||
int
|
int
|
||||||
mount_info::add_reg_mount (const char *native_path, const char *posix_path, unsigned mountflags)
|
mount_info::add_reg_mount (const char *native_path, const char *posix_path, unsigned mountflags)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res;
|
||||||
|
|
||||||
if (strchr (posix_path, '\\'))
|
|
||||||
{
|
|
||||||
set_errno (EINVAL);
|
|
||||||
goto err1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add the mount to the right registry location, depending on
|
/* Add the mount to the right registry location, depending on
|
||||||
whether MOUNT_SYSTEM is set in the mount flags. */
|
whether MOUNT_SYSTEM is set in the mount flags. */
|
||||||
if (!(mountflags & MOUNT_SYSTEM)) /* current_user mount */
|
|
||||||
|
reg_key reg (mountflags & MOUNT_SYSTEM, KEY_ALL_ACCESS,
|
||||||
|
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, NULL);
|
||||||
|
|
||||||
|
/* Start by deleting existing mount if one exists. */
|
||||||
|
res = reg.kill (posix_path);
|
||||||
|
if (res != ERROR_SUCCESS && res != ERROR_FILE_NOT_FOUND)
|
||||||
{
|
{
|
||||||
/* reg_key for user mounts in HKEY_CURRENT_USER. */
|
err:
|
||||||
reg_key reg_user;
|
__seterrno_from_win_error (res);
|
||||||
|
return -1;
|
||||||
/* Start by deleting existing mount if one exists. */
|
|
||||||
res = reg_user.kill (posix_path);
|
|
||||||
if (res != ERROR_SUCCESS && res != ERROR_FILE_NOT_FOUND)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
/* Create the new mount. */
|
|
||||||
reg_key subkey = reg_key (reg_user.get_key (),
|
|
||||||
KEY_ALL_ACCESS,
|
|
||||||
posix_path, NULL);
|
|
||||||
res = subkey.set_string ("native", native_path);
|
|
||||||
if (res != ERROR_SUCCESS)
|
|
||||||
goto err;
|
|
||||||
res = subkey.set_int ("flags", mountflags);
|
|
||||||
}
|
}
|
||||||
else /* local_machine mount */
|
|
||||||
|
/* Create the new mount. */
|
||||||
|
reg_key subkey (reg.get_key (), KEY_ALL_ACCESS, posix_path, NULL);
|
||||||
|
|
||||||
|
res = subkey.set_string ("native", native_path);
|
||||||
|
if (res != ERROR_SUCCESS)
|
||||||
|
goto err;
|
||||||
|
res = subkey.set_int ("flags", mountflags);
|
||||||
|
|
||||||
|
if (mountflags & MOUNT_SYSTEM)
|
||||||
{
|
{
|
||||||
/* reg_key for system mounts in HKEY_LOCAL_MACHINE. */
|
|
||||||
reg_key reg_sys (HKEY_LOCAL_MACHINE, KEY_ALL_ACCESS, "SOFTWARE",
|
|
||||||
CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME,
|
|
||||||
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
/* Start by deleting existing mount if one exists. */
|
|
||||||
res = reg_sys.kill (posix_path);
|
|
||||||
if (res != ERROR_SUCCESS && res != ERROR_FILE_NOT_FOUND)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
/* Create the new mount. */
|
|
||||||
reg_key subkey = reg_key (reg_sys.get_key (),
|
|
||||||
KEY_ALL_ACCESS,
|
|
||||||
posix_path, NULL);
|
|
||||||
res = subkey.set_string ("native", native_path);
|
|
||||||
if (res != ERROR_SUCCESS)
|
|
||||||
goto err;
|
|
||||||
res = subkey.set_int ("flags", mountflags);
|
|
||||||
|
|
||||||
sys_mount_table_counter++;
|
sys_mount_table_counter++;
|
||||||
cygwin_shared->sys_mount_table_counter++;
|
cygwin_shared->sys_mount_table_counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0; /* Success */
|
return 0; /* Success */
|
||||||
err:
|
|
||||||
__seterrno_from_win_error (res);
|
|
||||||
err1:
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* del_reg_mount: delete mount item from registry indicated in flags.
|
/* del_reg_mount: delete mount item from registry indicated in flags.
|
||||||
|
@ -1889,22 +1855,9 @@ mount_info::del_reg_mount (const char * posix_path, unsigned flags)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (!(flags & MOUNT_SYSTEM)) /* Delete from user registry */
|
reg_key reg (flags & MOUNT_SYSTEM, KEY_ALL_ACCESS,
|
||||||
{
|
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, NULL);
|
||||||
reg_key reg_user (KEY_ALL_ACCESS,
|
res = reg.kill (posix_path);
|
||||||
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, NULL);
|
|
||||||
res = reg_user.kill (posix_path);
|
|
||||||
}
|
|
||||||
else /* Delete from system registry */
|
|
||||||
{
|
|
||||||
sys_mount_table_counter++;
|
|
||||||
cygwin_shared->sys_mount_table_counter++;
|
|
||||||
reg_key reg_sys (HKEY_LOCAL_MACHINE, KEY_ALL_ACCESS, "SOFTWARE",
|
|
||||||
CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME,
|
|
||||||
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME,
|
|
||||||
NULL);
|
|
||||||
res = reg_sys.kill (posix_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res != ERROR_SUCCESS)
|
if (res != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -1912,6 +1865,12 @@ mount_info::del_reg_mount (const char * posix_path, unsigned flags)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags & MOUNT_SYSTEM)
|
||||||
|
{
|
||||||
|
sys_mount_table_counter++;
|
||||||
|
cygwin_shared->sys_mount_table_counter++;
|
||||||
|
}
|
||||||
|
|
||||||
return 0; /* Success */
|
return 0; /* Success */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1922,31 +1881,29 @@ mount_info::del_reg_mount (const char * posix_path, unsigned flags)
|
||||||
void
|
void
|
||||||
mount_info::read_cygdrive_info_from_registry ()
|
mount_info::read_cygdrive_info_from_registry ()
|
||||||
{
|
{
|
||||||
/* reg_key for user path prefix in HKEY_CURRENT_USER. */
|
/* First read cygdrive from user's registry.
|
||||||
reg_key r;
|
If failed, then read cygdrive from system-wide registry
|
||||||
/* First read cygdrive from user's registry. */
|
while deimpersonated. */
|
||||||
if (r.get_string (CYGWIN_INFO_CYGDRIVE_PREFIX, cygdrive, sizeof (cygdrive), "") != 0)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
/* Then read cygdrive from system-wide registry. */
|
if (i)
|
||||||
cygheap->user.deimpersonate ();
|
cygheap->user.deimpersonate ();
|
||||||
reg_key r2 (HKEY_LOCAL_MACHINE, KEY_READ, "SOFTWARE",
|
reg_key r (i, KEY_READ, CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, NULL);
|
||||||
CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME,
|
if (i)
|
||||||
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME,
|
cygheap->user.reimpersonate ();
|
||||||
NULL);
|
|
||||||
cygheap->user.reimpersonate ();
|
|
||||||
|
|
||||||
if (r2.get_string (CYGWIN_INFO_CYGDRIVE_PREFIX, cygdrive,
|
if (r.get_string (CYGWIN_INFO_CYGDRIVE_PREFIX, cygdrive, sizeof (cygdrive),
|
||||||
sizeof (cygdrive), ""))
|
CYGWIN_INFO_CYGDRIVE_DEFAULT_PREFIX) != ERROR_SUCCESS && i == 0)
|
||||||
strcpy (cygdrive, CYGWIN_INFO_CYGDRIVE_DEFAULT_PREFIX);
|
continue;
|
||||||
cygdrive_flags = r2.get_int (CYGWIN_INFO_CYGDRIVE_FLAGS, MOUNT_CYGDRIVE | MOUNT_BINARY);
|
|
||||||
slashify (cygdrive, cygdrive, 1);
|
/* Fetch user cygdrive_flags from registry; returns MOUNT_CYGDRIVE on error. */
|
||||||
cygdrive_len = strlen (cygdrive);
|
cygdrive_flags = r.get_int (CYGWIN_INFO_CYGDRIVE_FLAGS,
|
||||||
}
|
MOUNT_CYGDRIVE | MOUNT_BINARY);
|
||||||
else
|
/* Sanitize */
|
||||||
{
|
if (i == 0)
|
||||||
/* Fetch user cygdrive_flags from registry; returns MOUNT_CYGDRIVE on
|
cygdrive_flags &= ~MOUNT_SYSTEM;
|
||||||
error. */
|
else
|
||||||
cygdrive_flags = r.get_int (CYGWIN_INFO_CYGDRIVE_FLAGS, MOUNT_CYGDRIVE | MOUNT_BINARY);
|
cygdrive_flags |= MOUNT_SYSTEM;
|
||||||
slashify (cygdrive, cygdrive, 1);
|
slashify (cygdrive, cygdrive, 1);
|
||||||
cygdrive_len = strlen (cygdrive);
|
cygdrive_len = strlen (cygdrive);
|
||||||
}
|
}
|
||||||
|
@ -1959,22 +1916,6 @@ mount_info::read_cygdrive_info_from_registry ()
|
||||||
int
|
int
|
||||||
mount_info::write_cygdrive_info_to_registry (const char *cygdrive_prefix, unsigned flags)
|
mount_info::write_cygdrive_info_to_registry (const char *cygdrive_prefix, unsigned flags)
|
||||||
{
|
{
|
||||||
/* Determine whether to modify user or system cygdrive path prefix. */
|
|
||||||
HKEY top = (flags & MOUNT_SYSTEM) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
|
|
||||||
|
|
||||||
if (flags & MOUNT_SYSTEM)
|
|
||||||
{
|
|
||||||
sys_mount_table_counter++;
|
|
||||||
cygwin_shared->sys_mount_table_counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* reg_key for user path prefix in HKEY_CURRENT_USER or system path prefix in
|
|
||||||
HKEY_LOCAL_MACHINE. */
|
|
||||||
reg_key r (top, KEY_ALL_ACCESS, "SOFTWARE",
|
|
||||||
CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME,
|
|
||||||
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
/* Verify cygdrive prefix starts with a forward slash and if there's
|
/* Verify cygdrive prefix starts with a forward slash and if there's
|
||||||
another character, it's not a slash. */
|
another character, it's not a slash. */
|
||||||
if ((cygdrive_prefix == NULL) || (*cygdrive_prefix == 0) ||
|
if ((cygdrive_prefix == NULL) || (*cygdrive_prefix == 0) ||
|
||||||
|
@ -1989,6 +1930,8 @@ mount_info::write_cygdrive_info_to_registry (const char *cygdrive_prefix, unsign
|
||||||
/* Ensure that there is never a final slash */
|
/* Ensure that there is never a final slash */
|
||||||
nofinalslash (cygdrive_prefix, hold_cygdrive_prefix);
|
nofinalslash (cygdrive_prefix, hold_cygdrive_prefix);
|
||||||
|
|
||||||
|
reg_key r (flags & MOUNT_SYSTEM, KEY_ALL_ACCESS,
|
||||||
|
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, NULL);
|
||||||
int res;
|
int res;
|
||||||
res = r.set_string (CYGWIN_INFO_CYGDRIVE_PREFIX, hold_cygdrive_prefix);
|
res = r.set_string (CYGWIN_INFO_CYGDRIVE_PREFIX, hold_cygdrive_prefix);
|
||||||
if (res != ERROR_SUCCESS)
|
if (res != ERROR_SUCCESS)
|
||||||
|
@ -1998,15 +1941,18 @@ mount_info::write_cygdrive_info_to_registry (const char *cygdrive_prefix, unsign
|
||||||
}
|
}
|
||||||
r.set_int (CYGWIN_INFO_CYGDRIVE_FLAGS, flags);
|
r.set_int (CYGWIN_INFO_CYGDRIVE_FLAGS, flags);
|
||||||
|
|
||||||
|
if (flags & MOUNT_SYSTEM)
|
||||||
|
sys_mount_table_counter = ++cygwin_shared->sys_mount_table_counter;
|
||||||
|
|
||||||
/* This also needs to go in the in-memory copy of "cygdrive", but only if
|
/* This also needs to go in the in-memory copy of "cygdrive", but only if
|
||||||
appropriate:
|
appropriate:
|
||||||
1. setting user path prefix, or
|
1. setting user path prefix, or
|
||||||
2. overwriting (a previous) system path prefix */
|
2. overwriting (a previous) system path prefix */
|
||||||
if (!(flags & MOUNT_SYSTEM) || (mount_table->cygdrive_flags & MOUNT_SYSTEM))
|
if (!(flags & MOUNT_SYSTEM) || (mount_table->cygdrive_flags & MOUNT_SYSTEM))
|
||||||
{
|
{
|
||||||
slashify (cygdrive_prefix, mount_table->cygdrive, 1);
|
slashify (cygdrive_prefix, cygdrive, 1);
|
||||||
mount_table->cygdrive_flags = flags;
|
cygdrive_flags = flags;
|
||||||
mount_table->cygdrive_len = strlen (mount_table->cygdrive);
|
cygdrive_len = strlen (cygdrive);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2015,19 +1961,7 @@ mount_info::write_cygdrive_info_to_registry (const char *cygdrive_prefix, unsign
|
||||||
int
|
int
|
||||||
mount_info::remove_cygdrive_info_from_registry (const char *cygdrive_prefix, unsigned flags)
|
mount_info::remove_cygdrive_info_from_registry (const char *cygdrive_prefix, unsigned flags)
|
||||||
{
|
{
|
||||||
/* Determine whether to modify user or system cygdrive path prefix. */
|
reg_key r (flags & MOUNT_SYSTEM, KEY_ALL_ACCESS,
|
||||||
HKEY top = (flags & MOUNT_SYSTEM) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
|
|
||||||
|
|
||||||
if (flags & MOUNT_SYSTEM)
|
|
||||||
{
|
|
||||||
sys_mount_table_counter++;
|
|
||||||
cygwin_shared->sys_mount_table_counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* reg_key for user path prefix in HKEY_CURRENT_USER or system path prefix in
|
|
||||||
HKEY_LOCAL_MACHINE. */
|
|
||||||
reg_key r (top, KEY_ALL_ACCESS, "SOFTWARE",
|
|
||||||
CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME,
|
|
||||||
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME,
|
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
@ -2035,11 +1969,20 @@ mount_info::remove_cygdrive_info_from_registry (const char *cygdrive_prefix, uns
|
||||||
int res = r.killvalue (CYGWIN_INFO_CYGDRIVE_PREFIX);
|
int res = r.killvalue (CYGWIN_INFO_CYGDRIVE_PREFIX);
|
||||||
int res2 = r.killvalue (CYGWIN_INFO_CYGDRIVE_FLAGS);
|
int res2 = r.killvalue (CYGWIN_INFO_CYGDRIVE_FLAGS);
|
||||||
|
|
||||||
|
if (flags & MOUNT_SYSTEM)
|
||||||
|
sys_mount_table_counter = ++cygwin_shared->sys_mount_table_counter;
|
||||||
|
|
||||||
/* Reinitialize the cygdrive path prefix to reflect to removal from the
|
/* Reinitialize the cygdrive path prefix to reflect to removal from the
|
||||||
registry. */
|
registry. */
|
||||||
read_cygdrive_info_from_registry ();
|
read_cygdrive_info_from_registry ();
|
||||||
|
|
||||||
return (res != ERROR_SUCCESS) ? res : res2;
|
if (res == ERROR_SUCCESS)
|
||||||
|
res = res2;
|
||||||
|
if (res == ERROR_SUCCESS)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
__seterrno_from_win_error (res);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -2047,7 +1990,7 @@ mount_info::get_cygdrive_info (char *user, char *system, char* user_flags,
|
||||||
char* system_flags)
|
char* system_flags)
|
||||||
{
|
{
|
||||||
/* Get the user path prefix from HKEY_CURRENT_USER. */
|
/* Get the user path prefix from HKEY_CURRENT_USER. */
|
||||||
reg_key r;
|
reg_key r (false, KEY_READ, CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, NULL);
|
||||||
int res = r.get_string (CYGWIN_INFO_CYGDRIVE_PREFIX, user, CYG_MAX_PATH, "");
|
int res = r.get_string (CYGWIN_INFO_CYGDRIVE_PREFIX, user, CYG_MAX_PATH, "");
|
||||||
|
|
||||||
/* Get the user flags, if appropriate */
|
/* Get the user flags, if appropriate */
|
||||||
|
@ -2058,10 +2001,7 @@ mount_info::get_cygdrive_info (char *user, char *system, char* user_flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the system path prefix from HKEY_LOCAL_MACHINE. */
|
/* Get the system path prefix from HKEY_LOCAL_MACHINE. */
|
||||||
reg_key r2 (HKEY_LOCAL_MACHINE, KEY_READ, "SOFTWARE",
|
reg_key r2 (true, KEY_READ, CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, NULL);
|
||||||
CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME,
|
|
||||||
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME,
|
|
||||||
NULL);
|
|
||||||
int res2 = r2.get_string (CYGWIN_INFO_CYGDRIVE_PREFIX, system, CYG_MAX_PATH, "");
|
int res2 = r2.get_string (CYGWIN_INFO_CYGDRIVE_PREFIX, system, CYG_MAX_PATH, "");
|
||||||
|
|
||||||
/* Get the system flags, if appropriate */
|
/* Get the system flags, if appropriate */
|
||||||
|
|
|
@ -13,8 +13,12 @@ details. */
|
||||||
#include "registry.h"
|
#include "registry.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include <cygwin/version.h>
|
#include <cygwin/version.h>
|
||||||
|
#include "path.h"
|
||||||
static char NO_COPY cygnus_class[] = "cygnus";
|
#include "fhandler.h"
|
||||||
|
#include "dtable.h"
|
||||||
|
#include "cygerrno.h"
|
||||||
|
#include "cygheap.h"
|
||||||
|
static const char cygnus_class[] = "cygnus";
|
||||||
|
|
||||||
reg_key::reg_key (HKEY top, REGSAM access, ...)
|
reg_key::reg_key (HKEY top, REGSAM access, ...)
|
||||||
{
|
{
|
||||||
|
@ -24,30 +28,46 @@ reg_key::reg_key (HKEY top, REGSAM access, ...)
|
||||||
va_end (av);
|
va_end (av);
|
||||||
}
|
}
|
||||||
|
|
||||||
reg_key::reg_key (REGSAM access, ...)
|
/* Opens a key under the appropriate Cygwin key.
|
||||||
|
Do not use HKCU per MS KB 199190 */
|
||||||
|
|
||||||
|
reg_key::reg_key (bool isHKLM, REGSAM access, ...)
|
||||||
{
|
{
|
||||||
va_list av;
|
va_list av;
|
||||||
|
HKEY top;
|
||||||
|
|
||||||
new (this) reg_key (HKEY_CURRENT_USER, access, "SOFTWARE",
|
if (isHKLM)
|
||||||
CYGWIN_INFO_CYGNUS_REGISTRY_NAME,
|
top = HKEY_LOCAL_MACHINE;
|
||||||
CYGWIN_INFO_CYGWIN_REGISTRY_NAME, NULL);
|
else
|
||||||
|
{
|
||||||
HKEY top = key;
|
char name[128];
|
||||||
|
const char *names[2] = {cygheap->user.get_windows_id (name), ".DEFAULT"};
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
key_is_invalid = RegOpenKeyEx (HKEY_USERS, names[i], 0, access, &top);
|
||||||
|
if (key_is_invalid == ERROR_SUCCESS)
|
||||||
|
goto OK;
|
||||||
|
debug_printf ("HKU\\%s failed, Win32 error %ld", names[i], key_is_invalid);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
OK:
|
||||||
|
new (this) reg_key (top, access, "SOFTWARE",
|
||||||
|
CYGWIN_INFO_CYGNUS_REGISTRY_NAME,
|
||||||
|
CYGWIN_INFO_CYGWIN_REGISTRY_NAME, NULL);
|
||||||
|
if (top != HKEY_LOCAL_MACHINE)
|
||||||
|
RegCloseKey (top);
|
||||||
|
if (key_is_invalid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
top = key;
|
||||||
va_start (av, access);
|
va_start (av, access);
|
||||||
build_reg (top, KEY_READ, av);
|
build_reg (top, access, av);
|
||||||
va_end (av);
|
va_end (av);
|
||||||
if (top != key)
|
if (top != key)
|
||||||
RegCloseKey (top);
|
RegCloseKey (top);
|
||||||
}
|
}
|
||||||
|
|
||||||
reg_key::reg_key (REGSAM access)
|
|
||||||
{
|
|
||||||
new (this) reg_key (HKEY_CURRENT_USER, access, "SOFTWARE",
|
|
||||||
CYGWIN_INFO_CYGNUS_REGISTRY_NAME,
|
|
||||||
CYGWIN_INFO_CYGWIN_REGISTRY_NAME,
|
|
||||||
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
reg_key::build_reg (HKEY top, REGSAM access, va_list av)
|
reg_key::build_reg (HKEY top, REGSAM access, va_list av)
|
||||||
{
|
{
|
||||||
|
@ -62,16 +82,15 @@ reg_key::build_reg (HKEY top, REGSAM access, va_list av)
|
||||||
|
|
||||||
while ((name = va_arg (av, char *)) != NULL)
|
while ((name = va_arg (av, char *)) != NULL)
|
||||||
{
|
{
|
||||||
DWORD disp;
|
|
||||||
int res = RegCreateKeyExA (r,
|
int res = RegCreateKeyExA (r,
|
||||||
name,
|
name,
|
||||||
0,
|
0,
|
||||||
cygnus_class,
|
(char *) cygnus_class,
|
||||||
REG_OPTION_NON_VOLATILE,
|
REG_OPTION_NON_VOLATILE,
|
||||||
access,
|
access,
|
||||||
&sec_none_nih,
|
&sec_none_nih,
|
||||||
&key,
|
&key,
|
||||||
&disp);
|
NULL);
|
||||||
if (r != top)
|
if (r != top)
|
||||||
RegCloseKey (r);
|
RegCloseKey (r);
|
||||||
r = key;
|
r = key;
|
||||||
|
@ -81,12 +100,6 @@ reg_key::build_reg (HKEY top, REGSAM access, va_list av)
|
||||||
debug_printf ("failed to create key %s in the registry", name);
|
debug_printf ("failed to create key %s in the registry", name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we're considering the mounts key, check if it had to
|
|
||||||
be created and set had_to_create appropriately. */
|
|
||||||
if (strcmp (name, CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME) == 0)
|
|
||||||
if (disp == REG_CREATED_NEW_KEY)
|
|
||||||
mount_table->had_to_create_mount_areas++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,7 @@ private:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
reg_key (HKEY toplev, REGSAM access, ...);
|
reg_key (HKEY toplev, REGSAM access, ...);
|
||||||
reg_key (REGSAM access, ...);
|
reg_key (bool isHKLM, REGSAM access, ...);
|
||||||
reg_key (REGSAM access = KEY_ALL_ACCESS);
|
|
||||||
|
|
||||||
void *operator new (size_t, void *p) {return p;}
|
void *operator new (size_t, void *p) {return p;}
|
||||||
void build_reg (HKEY key, REGSAM access, va_list av);
|
void build_reg (HKEY key, REGSAM access, va_list av);
|
||||||
|
|
|
@ -250,22 +250,20 @@ shared_info::heap_chunk_size ()
|
||||||
{
|
{
|
||||||
if (!heap_chunk)
|
if (!heap_chunk)
|
||||||
{
|
{
|
||||||
/* Fetch misc. registry entries. */
|
/* Fetch from registry, first user then local machine. */
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
reg_key reg (i, KEY_READ, NULL);
|
||||||
|
|
||||||
reg_key reg (KEY_READ, NULL);
|
/* Note that reserving a huge amount of heap space does not result in
|
||||||
|
the use of swap since we are not committing it. */
|
||||||
|
/* FIXME: We should not be restricted to a fixed size heap no matter
|
||||||
|
what the fixed size is. */
|
||||||
|
|
||||||
/* Note that reserving a huge amount of heap space does not result in
|
if ((heap_chunk = reg.get_int ("heap_chunk_in_mb", 0)))
|
||||||
the use of swap since we are not committing it. */
|
break;
|
||||||
/* FIXME: We should not be restricted to a fixed size heap no matter
|
heap_chunk = 384; /* Default */
|
||||||
what the fixed size is. */
|
}
|
||||||
|
|
||||||
heap_chunk = reg.get_int ("heap_chunk_in_mb", 0);
|
|
||||||
if (!heap_chunk) {
|
|
||||||
reg_key r1 (HKEY_LOCAL_MACHINE, KEY_READ, "SOFTWARE",
|
|
||||||
CYGWIN_INFO_CYGNUS_REGISTRY_NAME,
|
|
||||||
CYGWIN_INFO_CYGWIN_REGISTRY_NAME, NULL);
|
|
||||||
heap_chunk = r1.get_int ("heap_chunk_in_mb", 384);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (heap_chunk < 4)
|
if (heap_chunk < 4)
|
||||||
heap_chunk = 4 * 1024 * 1024;
|
heap_chunk = 4 * 1024 * 1024;
|
||||||
|
|
|
@ -70,10 +70,6 @@ class mount_info
|
||||||
int native_sorted[MAX_MOUNTS];
|
int native_sorted[MAX_MOUNTS];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* Increment when setting up a reg_key if mounts area had to be
|
|
||||||
created so we know when we need to import old mount tables. */
|
|
||||||
int had_to_create_mount_areas;
|
|
||||||
|
|
||||||
void init ();
|
void init ();
|
||||||
int add_item (const char *dev, const char *path, unsigned flags, int reg_p);
|
int add_item (const char *dev, const char *path, unsigned flags, int reg_p);
|
||||||
int del_item (const char *path, unsigned flags, int reg_p);
|
int del_item (const char *path, unsigned flags, int reg_p);
|
||||||
|
|
Loading…
Reference in New Issue