]> sourceware.org Git - newlib-cygwin.git/blob - winsup/cygwin/shared_info.h
* exceptions.cc (set_process_mask): Set pending signals only when signals
[newlib-cygwin.git] / winsup / cygwin / shared_info.h
1 /* shared_info.h: shared info for cygwin
2
3 Copyright 2000, 2001 Red Hat, Inc.
4
5 This file is part of Cygwin.
6
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
9 details. */
10
11 #include "tty.h"
12
13 /* Mount table entry */
14
15 class mount_item
16 {
17 public:
18 /* FIXME: Nasty static allocation. Need to have a heap in the shared
19 area [with the user being able to configure at runtime the max size]. */
20 /* Win32-style mounted partition source ("C:\foo\bar").
21 native_path[0] == 0 for unused entries. */
22 char native_path[MAX_PATH];
23 int native_pathlen;
24
25 /* POSIX-style mount point ("/foo/bar") */
26 char posix_path[MAX_PATH];
27 int posix_pathlen;
28
29 unsigned flags;
30
31 void init (const char *dev, const char *path, unsigned flags);
32
33 struct mntent *getmntent ();
34 void fnmunge (char *, const char *);
35 void build_win32 (char *, const char *, unsigned *, unsigned);
36 };
37
38 /* Warning: Decreasing this value will cause cygwin.dll to ignore existing
39 higher numbered registry entries. Don't change this number willy-nilly.
40 What we need is to have a more dynamic allocation scheme, but the current
41 scheme should be satisfactory for a long while yet. */
42 #define MAX_MOUNTS 30
43
44 #define MOUNT_VERSION 27 // increment when mount table changes and
45 #define MOUNT_VERSION_MAGIC CYGWIN_VERSION_MAGIC (MOUNT_MAGIC, MOUNT_VERSION)
46 #define CURR_MOUNT_MAGIC 0x4fe431cdU
47 #define MOUNT_INFO_CB 16488
48
49 class reg_key;
50
51 /* NOTE: Do not make gratuitous changes to the names or organization of the
52 below class. The layout is checksummed to determine compatibility between
53 different cygwin versions. */
54 class mount_info
55 {
56 public:
57 DWORD version;
58 unsigned cb;
59 DWORD sys_mount_table_counter;
60 int nmounts;
61 mount_item mount[MAX_MOUNTS];
62
63 /* cygdrive_prefix is used as the root of the path automatically
64 prepended to a path when the path has no associated mount.
65 cygdrive_flags are the default flags for the cygdrives. */
66 char cygdrive[MAX_PATH];
67 size_t cygdrive_len;
68 unsigned cygdrive_flags;
69 private:
70 int posix_sorted[MAX_MOUNTS];
71 int native_sorted[MAX_MOUNTS];
72
73 public:
74 /* Increment when setting up a reg_key if mounts area had to be
75 created so we know when we need to import old mount tables. */
76 int had_to_create_mount_areas;
77
78 void init ();
79 int add_item (const char *dev, const char *path, unsigned flags, int reg_p);
80 int del_item (const char *path, unsigned flags, int reg_p);
81
82 void from_registry ();
83 int add_reg_mount (const char * native_path, const char * posix_path,
84 unsigned mountflags);
85 int del_reg_mount (const char * posix_path, unsigned mountflags);
86
87 unsigned set_flags_from_win32_path (const char *path);
88 int conv_to_win32_path (const char *src_path, char *dst, DWORD &devn,
89 int &unit, unsigned *flags = NULL, bool no_normalize = 0);
90 int conv_to_posix_path (const char *src_path, char *posix_path,
91 int keep_rel_p);
92 struct mntent *getmntent (int x);
93
94 int write_cygdrive_info_to_registry (const char *cygdrive_prefix, unsigned flags);
95 int remove_cygdrive_info_from_registry (const char *cygdrive_prefix, unsigned flags);
96 int get_cygdrive_info (char *user, char *system, char* user_flags,
97 char* system_flags);
98
99 private:
100
101 void sort ();
102 void read_mounts (reg_key& r);
103 void mount_slash ();
104 void to_registry ();
105
106 int cygdrive_win32_path (const char *src, char *dst, int& unit);
107 void cygdrive_posix_path (const char *src, char *dst, int trailing_slash_p);
108 void read_cygdrive_info_from_registry ();
109 };
110
111 /******** Close-on-delete queue ********/
112
113 /* First pass at a file deletion queue structure.
114
115 We can't keep this list in the per-process info, since
116 one process may open a file, and outlive a process which
117 wanted to unlink the file - and the data would go away.
118 */
119
120 #define MAX_DELQUEUES_PENDING 100
121
122 class delqueue_list
123 {
124 char name[MAX_DELQUEUES_PENDING][MAX_PATH];
125 char inuse[MAX_DELQUEUES_PENDING];
126 int empty;
127
128 public:
129 void init ();
130 void queue_file (const char *dosname);
131 void process_queue ();
132 };
133
134 /******** Shared Info ********/
135 /* Data accessible to all tasks */
136
137 #define SHARED_VERSION (unsigned)(cygwin_version.api_major << 8 | \
138 cygwin_version.api_minor)
139 #define SHARED_VERSION_MAGIC CYGWIN_VERSION_MAGIC (SHARED_MAGIC, SHARED_VERSION)
140
141 #define SHARED_INFO_CB 47112
142
143 #define CURR_SHARED_MAGIC 0x53f1a7f4U
144
145 /* NOTE: Do not make gratuitous changes to the names or organization of the
146 below class. The layout is checksummed to determine compatibility between
147 different cygwin versions. */
148 class shared_info
149 {
150 DWORD version;
151 DWORD cb;
152 public:
153 unsigned heap_chunk;
154 DWORD sys_mount_table_counter;
155
156 tty_list tty;
157 delqueue_list delqueue;
158 void initialize (const char *);
159 unsigned heap_chunk_size ();
160 };
161
162 extern shared_info *cygwin_shared;
163 extern mount_info *mount_table;
164 extern HANDLE cygwin_mount_h;
165
166 enum shared_locations
167 {
168 SH_CYGWIN_SHARED,
169 SH_MOUNT_TABLE,
170 SH_SHARED_CONSOLE,
171 SH_MYSELF,
172 SH_TOTAL_SIZE
173 };
174 void __stdcall memory_init ();
175
176 #define shared_align_past(p) \
177 ((char *) (system_info.dwAllocationGranularity * \
178 (((DWORD) ((p) + 1) + system_info.dwAllocationGranularity - 1) / \
179 system_info.dwAllocationGranularity)))
180
181 #define cygwin_shared_address ((void *) 0xa000000)
182
183 #ifdef FHDEVN
184 struct console_state
185 {
186 tty_min tty_min_state;
187 dev_console dev_state;
188 };
189 #endif
190
191 char *__stdcall shared_name (char *, const char *, int);
192 void *__stdcall open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, shared_locations);
This page took 0.042183 seconds and 5 git commands to generate.