1 /* shared_info.h: shared info for cygwin
3 Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008 Red Hat, Inc.
5 This file is part of Cygwin.
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
15 /* Mount table entry */
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
];
27 /* POSIX-style mount point ("/foo/bar") */
28 char posix_path
[CYG_MAX_PATH
];
33 void init (const char *dev
, const char *path
, unsigned flags
);
35 struct mntent
*getmntent ();
36 int fnmunge (char *, const char *, int&);
37 int build_win32 (char *, const char *, unsigned *, unsigned);
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. */
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
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. */
59 DWORD sys_mount_table_counter
;
61 mount_item mount
[MAX_MOUNTS
];
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
];
68 unsigned cygdrive_flags
;
70 int posix_sorted
[MAX_MOUNTS
];
71 int native_sorted
[MAX_MOUNTS
];
75 int add_item (const char *dev
, const char *path
, unsigned flags
);
76 int del_item (const char *path
, unsigned flags
);
78 bool from_fstab_line (char *line
, bool user
);
79 bool from_fstab (bool user
);
80 void from_registry ();
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
,
87 int conv_to_posix_path (const char *src_path
, char *posix_path
,
89 struct mntent
*getmntent (int x
);
91 int write_cygdrive_info (const char *cygdrive_prefix
, unsigned flags
);
92 int get_cygdrive_info (char *user
, char *system
, char* user_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
);
102 void read_mounts (reg_key
& r
);
106 int cygdrive_win32_path (const char *src
, char *dst
, int& unit
);
107 void read_cygdrive_info_from_registry ();
116 mount_info mountinfo
;
118 /******** Shared Info ********/
119 /* Data accessible to all tasks */
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)
125 #define SHARED_INFO_CB 31144
127 #define CURR_SHARED_MAGIC 0xbc77afb0U
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. */
138 bool heap_slop_inited
;
140 DWORD sys_mount_table_counter
;
142 LONG last_used_bindresvport
;
146 unsigned heap_chunk_size ();
147 unsigned heap_slop_size ();
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
;
155 enum shared_locations
166 void __stdcall
memory_init ();
168 #define shared_align_past(p) \
169 ((char *) (system_info.dwAllocationGranularity * \
170 (((DWORD) ((p) + 1) + system_info.dwAllocationGranularity - 1) / \
171 system_info.dwAllocationGranularity)))
176 tty_min tty_min_state
;
177 dev_console dev_state
;
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
);