]> sourceware.org Git - newlib-cygwin.git/blob - winsup/cygwin/shared_info.h
088b3f90886f0c2d91c49be38f6fc19cbfcc7f7f
[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
21 /* Win32-style mounted partition source ("C:\foo\bar").
22 native_path[0] == 0 for unused entries. */
23 char native_path[MAX_PATH];
24 int native_pathlen;
25
26 /* POSIX-style mount point ("/foo/bar") */
27 char posix_path[MAX_PATH];
28 int posix_pathlen;
29
30 unsigned flags;
31
32 void init (const char *dev, const char *path, unsigned flags);
33
34 struct mntent *getmntent ();
35 };
36
37 /* Warning: Decreasing this value will cause cygwin.dll to ignore existing
38 higher numbered registry entries. Don't change this number willy-nilly.
39 What we need is to have a more dynamic allocation scheme, but the current
40 scheme should be satisfactory for a long while yet. */
41 #define MAX_MOUNTS 30
42
43 #define MOUNT_VERSION 0x01010103
44
45 class reg_key;
46 class mount_info
47 {
48 public:
49 DWORD version;
50 DWORD sys_mount_table_counter;
51 int nmounts;
52 mount_item mount[MAX_MOUNTS];
53
54 /* cygdrive_prefix is used as the root of the path automatically
55 prepended to a path when the path has no associated mount.
56 cygdrive_flags are the default flags for the cygdrives. */
57 char cygdrive[MAX_PATH];
58 size_t cygdrive_len;
59 unsigned cygdrive_flags;
60 private:
61 int posix_sorted[MAX_MOUNTS];
62 int native_sorted[MAX_MOUNTS];
63
64 public:
65 /* Increment when setting up a reg_key if mounts area had to be
66 created so we know when we need to import old mount tables. */
67 int had_to_create_mount_areas;
68
69 void init ();
70 int add_item (const char *dev, const char *path, unsigned flags, int reg_p);
71 int del_item (const char *path, unsigned flags, int reg_p);
72
73 void from_registry ();
74 int add_reg_mount (const char * native_path, const char * posix_path,
75 unsigned mountflags);
76 int del_reg_mount (const char * posix_path, unsigned mountflags);
77
78 unsigned set_flags_from_win32_path (const char *path);
79 int conv_to_win32_path (const char *src_path, char *dst, DWORD &devn,
80 int &unit, unsigned *flags = NULL, bool no_normalize = 0);
81 int conv_to_posix_path (const char *src_path, char *posix_path,
82 int keep_rel_p);
83 struct mntent *getmntent (int x);
84
85 int write_cygdrive_info_to_registry (const char *cygdrive_prefix, unsigned flags);
86 int remove_cygdrive_info_from_registry (const char *cygdrive_prefix, unsigned flags);
87 int get_cygdrive_info (char *user, char *system, char* user_flags,
88 char* system_flags);
89
90 void import_v1_mounts ();
91
92 private:
93
94 void sort ();
95 void read_mounts (reg_key& r);
96 void read_v1_mounts (reg_key r, unsigned which);
97 void mount_slash ();
98 void to_registry ();
99
100 int cygdrive_win32_path (const char *src, char *dst, int trailing_slash_p);
101 void cygdrive_posix_path (const char *src, char *dst, int trailing_slash_p);
102 void read_cygdrive_info_from_registry ();
103 };
104
105 /******** Close-on-delete queue ********/
106
107 /* First pass at a file deletion queue structure.
108
109 We can't keep this list in the per-process info, since
110 one process may open a file, and outlive a process which
111 wanted to unlink the file - and the data would go away.
112 */
113
114 #define MAX_DELQUEUES_PENDING 100
115
116 class delqueue_list
117 {
118 char name[MAX_DELQUEUES_PENDING][MAX_PATH];
119 char inuse[MAX_DELQUEUES_PENDING];
120 int empty;
121
122 public:
123 void init ();
124 void queue_file (const char *dosname);
125 void process_queue ();
126 };
127
128 /******** Shared Info ********/
129 /* Data accessible to all tasks */
130
131 class shared_info
132 {
133 DWORD inited;
134 public:
135 int heap_chunk_in_mb;
136 DWORD sys_mount_table_counter;
137
138 tty_list tty;
139 delqueue_list delqueue;
140 void initialize ();
141 unsigned heap_chunk_size ();
142 };
143
144 extern shared_info *cygwin_shared;
145 extern mount_info *mount_table;
146 extern HANDLE cygwin_mount_h;
147
148 void __stdcall memory_init (void);
149 void __stdcall shared_terminate (void);
150
151 #define shared_align_past(p) \
152 ((char *) (system_info.dwAllocationGranularity * \
153 (((DWORD) ((p) + 1) + system_info.dwAllocationGranularity - 1) / \
154 system_info.dwAllocationGranularity)))
155
156 #define cygwin_shared_address ((void *) 0xa000000)
157 #define mount_table_address shared_align_past (cygwin_shared)
158 #define cygheap_address shared_align_past ((mount_info *) shared_align_past (cygwin_shared))
159
160 char *__stdcall shared_name (const char *, int);
161 void *__stdcall open_shared (const char *name, HANDLE &shared_h, DWORD size, void *addr);
This page took 0.043365 seconds and 4 git commands to generate.