Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-06-03 06:31:16 +0400
committerChristopher Faylor <me@cgf.cx>2001-06-03 06:31:16 +0400
commit7ceb1cac3a8f2a6822825347d1536f4507680704 (patch)
tree0cb17e09dc70b202a0c5a27fa140a4a897893e55 /winsup/cygwin/cygheap.h
parentbb8251474cd5eaf5950a51e6b13dc6d5098ed0aa (diff)
* cygheap.cc (cygheap_root::cygheap_rot): Remove constructor.
(cygheap_root::~cygheap_root): Remove destructor. (cygheap_root::operator =): Remove. (cygheap_root::set): New method. * cygheap.h (cygheap_root): Reflect above changes. Store root info in mount-like structure. (cygheap_root:posix_ok): New method. (cygheap_root::ischroot_native): Ditto. (cygheap_root::unchroot): Ditto. (cygheap_root::exists): Ditto. (cygheap_root::posix_length): Ditto. (cygheap_root::posix_path): Ditto. (cygheap_root::native_length): Ditto. (cygheap_root::native_path): Ditto. * dir.cc (opendir): Remove special chroot test. * path.cc (path_prefix_p): Remove front end. (normalize_posix_path): Reorganize chroot tests to accomodate new convention of allowing paths using posix chroot prefix. (path_conv::check): Pass a "already ran normalize" option to conv_to_win32_path. Return if there is an error from this function. (mount_info::conv_to_win32_path): Add extra argument. Don't call normalize_posix_path if caller has already done so. Substitute chroot setting, if any, for root translation. Add chroot checking to final output step. * shared_info (mount_info): Accomodate additional argument to conv_to_win32_path. * syscalls.cc (chroot): Store both normalized posix path and native path in chroot.
Diffstat (limited to 'winsup/cygwin/cygheap.h')
-rw-r--r--winsup/cygwin/cygheap.h48
1 files changed, 41 insertions, 7 deletions
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h
index 6a8e56290..cc953a764 100644
--- a/winsup/cygwin/cygheap.h
+++ b/winsup/cygwin/cygheap.h
@@ -16,6 +16,7 @@ enum cygheap_types
HEAP_STR,
HEAP_ARGV,
HEAP_BUF,
+ HEAP_MOUNT,
HEAP_1_START,
HEAP_1_STR,
HEAP_1_ARGV,
@@ -37,18 +38,51 @@ struct _cmalloc_entry
char data[0];
};
+struct cygheap_root_mount_info
+{
+ char posix_path[MAX_PATH];
+ unsigned posix_pathlen;
+ char native_path[MAX_PATH];
+ unsigned native_pathlen;
+};
+
class cygheap_root
{
/* Root directory information.
This is used after a chroot is called. */
- size_t rootlen;
- char *root;
+ struct cygheap_root_mount_info *m;
+
public:
- cygheap_root (cygheap_root &nroot);
- ~cygheap_root ();
- char *operator =(const char *new_root);
- size_t length () const { return rootlen; }
- const char *path () const { return root; }
+ bool posix_ok (const char *path)
+ {
+ extern int path_prefix_p (const char *, const char *, int);
+ if (!m)
+ return 1;
+ return path_prefix_p (m->posix_path, path, m->posix_pathlen);
+ }
+ bool ischroot_native (const char *path)
+ {
+ if (!m)
+ return 1;
+ return strncasematch (m->native_path, path, m->native_pathlen)
+ && (path[m->native_pathlen] == '\\' || !path[m->native_pathlen]);
+
+ }
+ const char *unchroot (const char *path)
+ {
+ if (!m)
+ return path;
+ const char *p = path + m->posix_pathlen;
+ if (!*p)
+ p = "/";
+ return p;
+ }
+ bool exists () {return !!m;}
+ void set (const char *posix, const char *native);
+ size_t posix_length () const { return m->posix_pathlen; }
+ const char *posix_path () const { return m->posix_path; }
+ size_t native_length () const { return m->native_pathlen; }
+ const char *native_path () const { return m->native_path; }
};
class cygheap_user