]> sourceware.org Git - newlib-cygwin.git/blob - winsup/cygwin/shared_info.h
* Makefile.in (DLL_OFILES): Add kernel32.o.
[newlib-cygwin.git] / winsup / cygwin / shared_info.h
1 /* shared_info.h: shared info for cygwin
2
3 Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008 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 #include "security.h"
13 #include "mtinfo.h"
14
15 /* Mount table entry */
16
17 class mount_item
18 {
19 public:
20 /* FIXME: Nasty static allocation. Need to have a heap in the shared
21 area [with the user being able to configure at runtime the max size]. */
22 /* Win32-style mounted partition source ("C:\foo\bar").
23 native_path[0] == 0 for unused entries. */
24 char native_path[CYG_MAX_PATH];
25 int native_pathlen;
26
27 /* POSIX-style mount point ("/foo/bar") */
28 char posix_path[CYG_MAX_PATH];
29 int posix_pathlen;
30
31 unsigned flags;
32
33 void init (const char *dev, const char *path, unsigned flags);
34
35 struct mntent *getmntent ();
36 int fnmunge (char *, const char *, int&);
37 int build_win32 (char *, const char *, unsigned *, unsigned);
38 };
39
40 /* Warning: Decreasing this value will cause cygwin.dll to ignore existing
41 higher numbered registry entries. Don't change this number willy-nilly.
42 What we need is to have a more dynamic allocation scheme, but the current
43 scheme should be satisfactory for a long while yet. */
44 #define MAX_MOUNTS 30
45
46 #define USER_VERSION 1 // increment when mount table changes and
47 #define USER_VERSION_MAGIC CYGWIN_VERSION_MAGIC (USER_MAGIC, USER_VERSION)
48 #define CURR_USER_MAGIC 0xb2232e71U
49
50 class reg_key;
51 struct device;
52
53 /* NOTE: Do not make gratuitous changes to the names or organization of the
54 below class. The layout is checksummed to determine compatibility between
55 different cygwin versions. */
56 class mount_info
57 {
58 public:
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[CYG_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 void init ();
75 int add_item (const char *dev, const char *path, unsigned flags);
76 int del_item (const char *path, unsigned flags);
77
78 bool from_fstab_line (char *line, bool user);
79 bool from_fstab (bool user);
80 void from_registry ();
81
82 unsigned set_flags_from_win32_path (const char *path);
83 int conv_to_win32_path (const char *src_path, char *dst, device&,
84 unsigned *flags = NULL);
85 int conv_to_posix_path (PWCHAR src_path, char *posix_path,
86 int keep_rel_p);
87 int conv_to_posix_path (const char *src_path, char *posix_path,
88 int keep_rel_p);
89 struct mntent *getmntent (int x);
90
91 int write_cygdrive_info (const char *cygdrive_prefix, unsigned flags);
92 int get_cygdrive_info (char *user, char *system, char* user_flags,
93 char* system_flags);
94 void cygdrive_posix_path (const char *src, char *dst, int trailing_slash_p);
95 int get_mounts_here (const char *parent_dir, int,
96 PUNICODE_STRING mount_points,
97 PUNICODE_STRING cygd);
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 read_cygdrive_info_from_registry ();
108 };
109
110 class user_info
111 {
112 public:
113 DWORD version;
114 DWORD cb;
115 bool warned_msdos;
116 mount_info mountinfo;
117 };
118 /******** Shared Info ********/
119 /* Data accessible to all tasks */
120
121 #define SHARED_VERSION (unsigned)(cygwin_version.api_major << 8 | \
122 cygwin_version.api_minor)
123 #define SHARED_VERSION_MAGIC CYGWIN_VERSION_MAGIC (SHARED_MAGIC, SHARED_VERSION)
124
125 #define SHARED_INFO_CB 31144
126
127 #define CURR_SHARED_MAGIC 0xbc77afb0U
128
129 /* NOTE: Do not make gratuitous changes to the names or organization of the
130 below class. The layout is checksummed to determine compatibility between
131 different cygwin versions. */
132 class shared_info
133 {
134 DWORD version;
135 DWORD cb;
136 public:
137 unsigned heap_chunk;
138 bool heap_slop_inited;
139 unsigned heap_slop;
140 DWORD sys_mount_table_counter;
141 tty_list tty;
142 LONG last_used_bindresvport;
143 mtinfo mt;
144
145 void initialize ();
146 unsigned heap_chunk_size ();
147 unsigned heap_slop_size ();
148 };
149
150 extern shared_info *cygwin_shared;
151 extern user_info *user_shared;
152 #define mount_table (&(user_shared->mountinfo))
153 extern HANDLE cygwin_user_h;
154
155 enum shared_locations
156 {
157 SH_CYGWIN_SHARED,
158 SH_USER_SHARED,
159 SH_SHARED_CONSOLE,
160 SH_MYSELF,
161 SH_TOTAL_SIZE,
162 SH_JUSTCREATE,
163 SH_JUSTOPEN
164
165 };
166 void __stdcall memory_init ();
167
168 #define shared_align_past(p) \
169 ((char *) (system_info.dwAllocationGranularity * \
170 (((DWORD) ((p) + 1) + system_info.dwAllocationGranularity - 1) / \
171 system_info.dwAllocationGranularity)))
172
173 #ifdef _FHANDLER_H_
174 struct console_state
175 {
176 tty_min tty_min_state;
177 dev_console dev_state;
178 };
179 #endif
180
181 HANDLE get_shared_parent_dir ();
182 HANDLE get_session_parent_dir ();
183 char *__stdcall shared_name (char *, const char *, int);
184 void *__stdcall open_shared (const char *name, int n, HANDLE &shared_h, DWORD size,
185 shared_locations&, PSECURITY_ATTRIBUTES psa = &sec_all,
186 DWORD access = FILE_MAP_READ | FILE_MAP_WRITE);
187 extern void user_shared_initialize (bool reinit);
This page took 0.04401 seconds and 5 git commands to generate.