2000-09-08 04:56:55 +02:00
|
|
|
/* shared_info.h: shared info for cygwin
|
2000-09-07 18:23:51 +02:00
|
|
|
|
2001-09-11 22:01:02 +02:00
|
|
|
Copyright 2000, 2001 Red Hat, Inc.
|
2000-09-07 18:23:51 +02:00
|
|
|
|
|
|
|
This file is part of Cygwin.
|
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
2000-09-08 04:56:55 +02:00
|
|
|
#include "tty.h"
|
|
|
|
|
2000-09-07 18:23:51 +02:00
|
|
|
/* Mount table entry */
|
|
|
|
|
|
|
|
class mount_item
|
|
|
|
{
|
2001-05-25 05:13:14 +02:00
|
|
|
public:
|
2000-09-07 18:23:51 +02:00
|
|
|
/* FIXME: Nasty static allocation. Need to have a heap in the shared
|
|
|
|
area [with the user being able to configure at runtime the max size]. */
|
|
|
|
/* Win32-style mounted partition source ("C:\foo\bar").
|
|
|
|
native_path[0] == 0 for unused entries. */
|
|
|
|
char native_path[MAX_PATH];
|
|
|
|
int native_pathlen;
|
|
|
|
|
|
|
|
/* POSIX-style mount point ("/foo/bar") */
|
|
|
|
char posix_path[MAX_PATH];
|
|
|
|
int posix_pathlen;
|
|
|
|
|
|
|
|
unsigned flags;
|
|
|
|
|
|
|
|
void init (const char *dev, const char *path, unsigned flags);
|
|
|
|
|
|
|
|
struct mntent *getmntent ();
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Warning: Decreasing this value will cause cygwin.dll to ignore existing
|
|
|
|
higher numbered registry entries. Don't change this number willy-nilly.
|
|
|
|
What we need is to have a more dynamic allocation scheme, but the current
|
|
|
|
scheme should be satisfactory for a long while yet. */
|
|
|
|
#define MAX_MOUNTS 30
|
|
|
|
|
2001-12-26 05:53:34 +01:00
|
|
|
#define MOUNT_VERSION 27 // increment when mount table changes and
|
|
|
|
#define MOUNT_VERSION_MAGIC CYGWIN_VERSION_MAGIC (MOUNT_MAGIC, MOUNT_VERSION)
|
2002-08-27 06:10:54 +02:00
|
|
|
#define CURR_MOUNT_MAGIC 0x4fe431cdU
|
2001-12-26 22:35:16 +01:00
|
|
|
#define MOUNT_INFO_CB 16488
|
2001-01-28 06:51:15 +01:00
|
|
|
|
2000-09-08 04:56:55 +02:00
|
|
|
class reg_key;
|
2001-12-26 07:18:41 +01:00
|
|
|
|
|
|
|
/* NOTE: Do not make gratuitous changes to the names or organization of the
|
|
|
|
below class. The layout is checksummed to determine compatibility between
|
|
|
|
different cygwin versions. */
|
2000-09-07 18:23:51 +02:00
|
|
|
class mount_info
|
|
|
|
{
|
2001-05-25 05:13:14 +02:00
|
|
|
public:
|
2001-01-28 06:51:15 +01:00
|
|
|
DWORD version;
|
2001-12-26 22:35:16 +01:00
|
|
|
unsigned cb;
|
2001-01-28 07:23:42 +01:00
|
|
|
DWORD sys_mount_table_counter;
|
2000-09-07 18:23:51 +02:00
|
|
|
int nmounts;
|
|
|
|
mount_item mount[MAX_MOUNTS];
|
|
|
|
|
|
|
|
/* cygdrive_prefix is used as the root of the path automatically
|
|
|
|
prepended to a path when the path has no associated mount.
|
|
|
|
cygdrive_flags are the default flags for the cygdrives. */
|
|
|
|
char cygdrive[MAX_PATH];
|
|
|
|
size_t cygdrive_len;
|
|
|
|
unsigned cygdrive_flags;
|
2001-05-25 05:13:14 +02:00
|
|
|
private:
|
2001-01-28 06:51:15 +01:00
|
|
|
int posix_sorted[MAX_MOUNTS];
|
|
|
|
int native_sorted[MAX_MOUNTS];
|
2000-09-07 18:23:51 +02:00
|
|
|
|
2001-05-25 05:13:14 +02:00
|
|
|
public:
|
2000-09-07 18:23:51 +02:00
|
|
|
/* 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 ();
|
|
|
|
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);
|
|
|
|
|
|
|
|
void from_registry ();
|
|
|
|
int add_reg_mount (const char * native_path, const char * posix_path,
|
|
|
|
unsigned mountflags);
|
|
|
|
int del_reg_mount (const char * posix_path, unsigned mountflags);
|
|
|
|
|
|
|
|
unsigned set_flags_from_win32_path (const char *path);
|
2001-05-01 04:03:10 +02:00
|
|
|
int conv_to_win32_path (const char *src_path, char *dst, DWORD &devn,
|
2001-06-03 04:31:16 +02:00
|
|
|
int &unit, unsigned *flags = NULL, bool no_normalize = 0);
|
2000-09-07 18:23:51 +02:00
|
|
|
int conv_to_posix_path (const char *src_path, char *posix_path,
|
|
|
|
int keep_rel_p);
|
|
|
|
struct mntent *getmntent (int x);
|
|
|
|
|
|
|
|
int write_cygdrive_info_to_registry (const char *cygdrive_prefix, unsigned flags);
|
|
|
|
int remove_cygdrive_info_from_registry (const char *cygdrive_prefix, unsigned flags);
|
2000-11-08 21:36:37 +01:00
|
|
|
int get_cygdrive_info (char *user, char *system, char* user_flags,
|
2001-09-07 23:32:07 +02:00
|
|
|
char* system_flags);
|
2000-09-07 18:23:51 +02:00
|
|
|
|
2001-05-25 05:13:14 +02:00
|
|
|
private:
|
2000-09-07 18:23:51 +02:00
|
|
|
|
|
|
|
void sort ();
|
|
|
|
void read_mounts (reg_key& r);
|
|
|
|
void mount_slash ();
|
|
|
|
void to_registry ();
|
|
|
|
|
2001-11-22 06:59:07 +01:00
|
|
|
int cygdrive_win32_path (const char *src, char *dst, int& unit);
|
2000-09-07 18:23:51 +02:00
|
|
|
void cygdrive_posix_path (const char *src, char *dst, int trailing_slash_p);
|
|
|
|
void read_cygdrive_info_from_registry ();
|
|
|
|
};
|
|
|
|
|
2000-09-08 04:56:55 +02:00
|
|
|
/******** Close-on-delete queue ********/
|
|
|
|
|
|
|
|
/* First pass at a file deletion queue structure.
|
|
|
|
|
|
|
|
We can't keep this list in the per-process info, since
|
|
|
|
one process may open a file, and outlive a process which
|
|
|
|
wanted to unlink the file - and the data would go away.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MAX_DELQUEUES_PENDING 100
|
|
|
|
|
|
|
|
class delqueue_list
|
|
|
|
{
|
|
|
|
char name[MAX_DELQUEUES_PENDING][MAX_PATH];
|
|
|
|
char inuse[MAX_DELQUEUES_PENDING];
|
|
|
|
int empty;
|
|
|
|
|
|
|
|
public:
|
|
|
|
void init ();
|
|
|
|
void queue_file (const char *dosname);
|
|
|
|
void process_queue ();
|
|
|
|
};
|
|
|
|
|
2000-09-07 18:23:51 +02:00
|
|
|
/******** Shared Info ********/
|
|
|
|
/* Data accessible to all tasks */
|
|
|
|
|
2001-12-26 05:53:34 +01:00
|
|
|
#define SHARED_VERSION (unsigned)(cygwin_version.api_major << 8 | \
|
|
|
|
cygwin_version.api_minor)
|
|
|
|
#define SHARED_VERSION_MAGIC CYGWIN_VERSION_MAGIC (SHARED_MAGIC, SHARED_VERSION)
|
|
|
|
|
2001-12-26 22:35:16 +01:00
|
|
|
#define SHARED_INFO_CB 47112
|
|
|
|
|
2002-10-22 18:18:55 +02:00
|
|
|
#define CURR_SHARED_MAGIC 0x359218a2U
|
2001-12-26 05:53:34 +01:00
|
|
|
|
2001-12-26 07:18:41 +01:00
|
|
|
/* NOTE: Do not make gratuitous changes to the names or organization of the
|
|
|
|
below class. The layout is checksummed to determine compatibility between
|
|
|
|
different cygwin versions. */
|
2000-09-07 18:23:51 +02:00
|
|
|
class shared_info
|
|
|
|
{
|
2001-12-26 22:35:16 +01:00
|
|
|
DWORD version;
|
|
|
|
DWORD cb;
|
2001-05-25 05:13:14 +02:00
|
|
|
public:
|
2002-10-22 18:18:55 +02:00
|
|
|
unsigned heap_chunk;
|
2001-01-28 07:23:42 +01:00
|
|
|
DWORD sys_mount_table_counter;
|
2000-09-07 18:23:51 +02:00
|
|
|
|
|
|
|
tty_list tty;
|
|
|
|
delqueue_list delqueue;
|
2001-09-09 21:06:50 +02:00
|
|
|
void initialize ();
|
|
|
|
unsigned heap_chunk_size ();
|
2000-09-07 18:23:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern shared_info *cygwin_shared;
|
2001-01-28 06:51:15 +01:00
|
|
|
extern mount_info *mount_table;
|
|
|
|
extern HANDLE cygwin_mount_h;
|
2000-09-07 18:23:51 +02:00
|
|
|
|
2002-10-15 09:03:45 +02:00
|
|
|
enum shared_locations
|
|
|
|
{
|
|
|
|
SH_CYGWIN_SHARED,
|
|
|
|
SH_MOUNT_TABLE,
|
|
|
|
SH_SHARED_CONSOLE,
|
|
|
|
SH_MYSELF,
|
|
|
|
SH_TOTAL_SIZE
|
|
|
|
};
|
2002-10-14 22:25:52 +02:00
|
|
|
void __stdcall memory_init ();
|
2000-09-07 18:23:51 +02:00
|
|
|
|
2001-01-28 06:51:15 +01:00
|
|
|
#define shared_align_past(p) \
|
|
|
|
((char *) (system_info.dwAllocationGranularity * \
|
|
|
|
(((DWORD) ((p) + 1) + system_info.dwAllocationGranularity - 1) / \
|
|
|
|
system_info.dwAllocationGranularity)))
|
|
|
|
|
|
|
|
#define cygwin_shared_address ((void *) 0xa000000)
|
2002-10-15 09:03:45 +02:00
|
|
|
|
|
|
|
#ifdef FHDEVN
|
|
|
|
struct console_state
|
|
|
|
{
|
|
|
|
tty_min tty_min_state;
|
|
|
|
dev_console dev_state;
|
|
|
|
};
|
|
|
|
#endif
|
2001-01-28 06:51:15 +01:00
|
|
|
|
2000-09-07 18:23:51 +02:00
|
|
|
char *__stdcall shared_name (const char *, int);
|
2002-10-15 09:03:45 +02:00
|
|
|
void *__stdcall open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, shared_locations);
|