* dtable.cc (dtable::build_fhandler_from_name): Just pass posix path along to
set_name via return_and_clear_normalized_path. (dtable::build_fhandler): New method with const char * argument. (dtable::reset_unix_path_name): Eliminate. (dtable::dup_worker): Use correct build_fhandler method. * mmap.cc (mmap_record::alloc_fh): Ditto. * dtable.h (dtable::build_fhandler): New method. (dtable::reset_unix_path_name): Eliminate. * fhandler.cc (fhandler_base::set_name): Assume that unix_name has already been cmalloced. (fhandler_base::reset_unix_path_name): Eliminate. (fhandler_base::~fhandler_base): Coercion for cfree. * fhandler.h (fhandler_base::unix_path_name): Make const char *. (fhandler_base::win32_path_name): Ditto. (fhandler_base::reset_unix_path_name): Eliminate. * fhandler_disk_file.cc (fhandler_cygdrive::set_drives): Accommodate const char *ness of win32_path_name. * fhandler_socket.cc (fhandler_socket::fstat): Accommodate new set_name requirements. * path.cc (path_conv::return_and_clear_normalized_path): New method. (path_conv::clear_normalized_path): Eliminate. (path_conv::~path_conv): Ditto. (path_conv::check): Accommodate new build_fhandler method. * path.h (path_conv::~path_conv): Eliminate. (path_conv::clear_normalized_path): Ditto. (path_conv::return_and_clear_normalized_path): Declare new method.
This commit is contained in:
parent
7a364eb364
commit
ff93854697
|
@ -1,3 +1,32 @@
|
|||
2002-05-24 Christopher Faylor <cgf@redhat.com>
|
||||
|
||||
* dtable.cc (dtable::build_fhandler_from_name): Just pass posix path
|
||||
along to set_name via return_and_clear_normalized_path.
|
||||
(dtable::build_fhandler): New method with const char * argument.
|
||||
(dtable::reset_unix_path_name): Eliminate.
|
||||
(dtable::dup_worker): Use correct build_fhandler method.
|
||||
* mmap.cc (mmap_record::alloc_fh): Ditto.
|
||||
* dtable.h (dtable::build_fhandler): New method.
|
||||
(dtable::reset_unix_path_name): Eliminate.
|
||||
* fhandler.cc (fhandler_base::set_name): Assume that unix_name has
|
||||
already been cmalloced.
|
||||
(fhandler_base::reset_unix_path_name): Eliminate.
|
||||
(fhandler_base::~fhandler_base): Coercion for cfree.
|
||||
* fhandler.h (fhandler_base::unix_path_name): Make const char *.
|
||||
(fhandler_base::win32_path_name): Ditto.
|
||||
(fhandler_base::reset_unix_path_name): Eliminate.
|
||||
* fhandler_disk_file.cc (fhandler_cygdrive::set_drives): Accommodate
|
||||
const char *ness of win32_path_name.
|
||||
* fhandler_socket.cc (fhandler_socket::fstat): Accommodate new set_name
|
||||
requirements.
|
||||
* path.cc (path_conv::return_and_clear_normalized_path): New method.
|
||||
(path_conv::clear_normalized_path): Eliminate.
|
||||
(path_conv::~path_conv): Ditto.
|
||||
(path_conv::check): Accommodate new build_fhandler method.
|
||||
* path.h (path_conv::~path_conv): Eliminate.
|
||||
(path_conv::clear_normalized_path): Ditto.
|
||||
(path_conv::return_and_clear_normalized_path): Declare new method.
|
||||
|
||||
2002-05-23 Christopher Faylor <cgf@redhat.com>
|
||||
|
||||
* path.cc (path_conv::check): Make sure any trailing path component is
|
||||
|
|
|
@ -287,14 +287,22 @@ dtable::build_fhandler_from_name (int fd, const char *name, HANDLE handle,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
fhandler_base *fh = build_fhandler (fd, pc.get_devn (), pc.normalized_path, pc, pc.get_unitn ());
|
||||
pc.clear_normalized_path ();
|
||||
fhandler_base *fh = build_fhandler (fd, pc.get_devn (),
|
||||
pc.return_and_clear_normalized_path (),
|
||||
pc, pc.get_unitn ());
|
||||
return fh;
|
||||
}
|
||||
|
||||
fhandler_base *
|
||||
dtable::build_fhandler (int fd, DWORD dev, const char *unix_name,
|
||||
const char *win32_name, int unit)
|
||||
{
|
||||
return build_fhandler (fd, dev, cstrdup (unix_name), win32_name, unit);
|
||||
}
|
||||
|
||||
#define cnew(name) new ((void *) ccalloc (HEAP_FHANDLER, 1, sizeof (name))) name
|
||||
fhandler_base *
|
||||
dtable::build_fhandler (int fd, DWORD dev, const char *unix_name,
|
||||
dtable::build_fhandler (int fd, DWORD dev, char *unix_name,
|
||||
const char *win32_name, int unit)
|
||||
{
|
||||
fhandler_base *fh;
|
||||
|
@ -400,7 +408,7 @@ dtable::build_fhandler (int fd, DWORD dev, const char *unix_name,
|
|||
fhandler_base *
|
||||
dtable::dup_worker (fhandler_base *oldfh)
|
||||
{
|
||||
fhandler_base *newfh = build_fhandler (-1, oldfh->get_device (), NULL);
|
||||
fhandler_base *newfh = build_fhandler (-1, oldfh->get_device ());
|
||||
*newfh = *oldfh;
|
||||
newfh->set_io_handle (NULL);
|
||||
if (oldfh->dup (newfh))
|
||||
|
@ -478,14 +486,6 @@ done:
|
|||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
dtable::reset_unix_path_name (int fd, const char *name)
|
||||
{
|
||||
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "reset_unix_name");
|
||||
fds[fd]->reset_unix_path_name (name);
|
||||
ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "reset_unix_name");
|
||||
}
|
||||
|
||||
select_record *
|
||||
dtable::select_read (int fd, select_record *s)
|
||||
{
|
||||
|
|
|
@ -50,6 +50,8 @@ public:
|
|||
void fixup_after_fork (HANDLE);
|
||||
fhandler_base *build_fhandler (int fd, DWORD dev, const char *unix_name,
|
||||
const char *win32_name = NULL, int unit = -1);
|
||||
fhandler_base *build_fhandler (int fd, DWORD dev, char *unix_name = NULL,
|
||||
const char *win32_name = NULL, int unit = -1);
|
||||
fhandler_base *build_fhandler_from_name (int fd, const char *name, HANDLE h,
|
||||
path_conv& pc,
|
||||
unsigned opts = PC_SYM_FOLLOW,
|
||||
|
@ -63,7 +65,6 @@ public:
|
|||
ReleaseResourceLock (LOCK_FD_LIST, READ_LOCK, "not open");
|
||||
return res;
|
||||
}
|
||||
void reset_unix_path_name (int fd, const char *name);
|
||||
int find_unused_handle (int start);
|
||||
int find_unused_handle () { return find_unused_handle (first_fd_for_open);}
|
||||
void release (int fd);
|
||||
|
|
|
@ -161,8 +161,9 @@ fhandler_base::set_name (const char *unix_path, const char *win32_path, int unit
|
|||
else
|
||||
{
|
||||
const char *fmt = get_native_name ();
|
||||
win32_path_name = (char *) cmalloc (HEAP_STR, strlen(fmt) + 16);
|
||||
__small_sprintf (win32_path_name, fmt, unit);
|
||||
char *w = (char *) cmalloc (HEAP_STR, strlen(fmt) + 16);
|
||||
__small_sprintf (w, fmt, unit);
|
||||
win32_path_name = w;
|
||||
}
|
||||
|
||||
if (win32_path_name == NULL)
|
||||
|
@ -178,12 +179,15 @@ fhandler_base::set_name (const char *unix_path, const char *win32_path, int unit
|
|||
path_conv. Ideally, we should pass in a format string and build the
|
||||
unix_path, too. */
|
||||
if (!is_device () || *win32_path_name != '\\')
|
||||
unix_path_name = cstrdup (unix_path);
|
||||
unix_path_name = unix_path;
|
||||
else
|
||||
{
|
||||
unix_path_name = cstrdup (win32_path_name);
|
||||
for (char *p = unix_path_name; (p = strchr (p, '\\')); p++)
|
||||
*p = '/';
|
||||
char *p = cstrdup (win32_path_name);
|
||||
unix_path_name = p;
|
||||
while ((p = strchr (p, '\\')) != NULL)
|
||||
*p++ = '/';
|
||||
if (unix_path)
|
||||
cfree ((void *) unix_path);
|
||||
}
|
||||
|
||||
if (unix_path_name == NULL)
|
||||
|
@ -194,13 +198,6 @@ fhandler_base::set_name (const char *unix_path, const char *win32_path, int unit
|
|||
namehash = hash_path_name (0, win32_path_name);
|
||||
}
|
||||
|
||||
void
|
||||
fhandler_base::reset_unix_path_name (const char *unix_path)
|
||||
{
|
||||
cfree (unix_path_name);
|
||||
unix_path_name = cstrdup (unix_path);
|
||||
}
|
||||
|
||||
/* Detect if we are sitting at EOF for conditions where Windows
|
||||
returns an error but UNIX doesn't. */
|
||||
static int __stdcall
|
||||
|
@ -1047,9 +1044,9 @@ fhandler_base::fhandler_base (DWORD devtype, int unit):
|
|||
fhandler_base::~fhandler_base (void)
|
||||
{
|
||||
if (unix_path_name != NULL)
|
||||
cfree (unix_path_name);
|
||||
cfree ((void *) unix_path_name);
|
||||
if (win32_path_name != NULL)
|
||||
cfree (win32_path_name);
|
||||
cfree ((void *) win32_path_name);
|
||||
if (rabuf)
|
||||
free (rabuf);
|
||||
unix_path_name = win32_path_name = NULL;
|
||||
|
|
|
@ -149,15 +149,13 @@ class fhandler_base
|
|||
size_t raixput;
|
||||
size_t rabuflen;
|
||||
|
||||
char *unix_path_name;
|
||||
char *win32_path_name;
|
||||
const char *unix_path_name;
|
||||
const char *win32_path_name;
|
||||
DWORD open_status;
|
||||
|
||||
public:
|
||||
void set_name (const char * unix_path, const char * win32_path = NULL,
|
||||
int unit = 0);
|
||||
void set_name (const char * unix_path, const char *win32_path = NULL, int unit = 0);
|
||||
|
||||
void reset_unix_path_name (const char *);
|
||||
virtual fhandler_base& operator =(fhandler_base &x);
|
||||
fhandler_base (DWORD dev, int unit = 0);
|
||||
virtual ~fhandler_base ();
|
||||
|
|
|
@ -775,10 +775,10 @@ void
|
|||
fhandler_cygdrive::set_drives ()
|
||||
{
|
||||
const int len = 1 + 26 * DRVSZ;
|
||||
win32_path_name = (char *) crealloc (win32_path_name, len);
|
||||
char *p = (char *) crealloc ((void *) win32_path_name, len);
|
||||
|
||||
ndrives = GetLogicalDriveStrings (len, win32_path_name) / DRVSZ;
|
||||
pdrive = win32_path_name;
|
||||
win32_path_name = pdrive = p;
|
||||
ndrives = GetLogicalDriveStrings (len, p) / DRVSZ;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -248,7 +248,7 @@ int __stdcall
|
|||
fhandler_socket::fstat (struct __stat64 *buf, path_conv *pc)
|
||||
{
|
||||
fhandler_disk_file fh;
|
||||
fh.set_name (get_name (), get_win32_name ());
|
||||
fh.set_name (cstrdup (get_name ()), get_win32_name ());
|
||||
return fh.fstat (buf, pc);
|
||||
}
|
||||
|
||||
|
|
|
@ -251,7 +251,7 @@ mmap_record::alloc_fh ()
|
|||
the call to fork(). This requires creating a fhandler
|
||||
of the correct type to be sure to call the method of the
|
||||
correct class. */
|
||||
return cygheap->fdtab.build_fhandler (-1, get_device (), NULL);
|
||||
return cygheap->fdtab.build_fhandler (-1, get_device ());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -366,20 +366,12 @@ fs_info::update (const char *win32_path)
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
path_conv::clear_normalized_path ()
|
||||
char *
|
||||
path_conv::return_and_clear_normalized_path ()
|
||||
{
|
||||
// not thread safe
|
||||
if (normalized_path)
|
||||
{
|
||||
cfree (normalized_path);
|
||||
normalized_path = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
path_conv::~path_conv ()
|
||||
{
|
||||
clear_normalized_path ();
|
||||
char *s = normalized_path;
|
||||
normalized_path = NULL;
|
||||
return s;
|
||||
}
|
||||
|
||||
/* Convert an arbitrary path SRC to a pure Win32 path, suitable for
|
||||
|
@ -520,7 +512,7 @@ path_conv::check (const char *src, unsigned opt,
|
|||
{
|
||||
/* FIXME: Calling build_fhandler here is not the right way to handle this. */
|
||||
fhandler_virtual *fh =
|
||||
(fhandler_virtual *) cygheap->fdtab.build_fhandler (-1, devn, path_copy, NULL, unit);
|
||||
(fhandler_virtual *) cygheap->fdtab.build_fhandler (-1, devn, (const char *) path_copy, NULL, unit);
|
||||
int file_type = fh->exists ();
|
||||
switch (file_type)
|
||||
{
|
||||
|
@ -731,7 +723,6 @@ out:
|
|||
*tail = '/';
|
||||
normalized_path = cstrdup (path_copy);
|
||||
debug_printf ("path_copy %s", path_copy);
|
||||
opt ^= PC_POSIX;
|
||||
}
|
||||
/* Deal with Windows stupidity which considers filename\. to be valid
|
||||
even when "filename" is not a directory. */
|
||||
|
|
|
@ -134,7 +134,6 @@ class path_conv
|
|||
unit (0), fileattr (INVALID_FILE_ATTRIBUTES),
|
||||
normalized_path (NULL) {path[0] = '\0';}
|
||||
|
||||
~path_conv ();
|
||||
inline char *get_win32 () { return path; }
|
||||
operator char *() {return path;}
|
||||
operator const char *() {return path;}
|
||||
|
@ -147,7 +146,7 @@ class path_conv
|
|||
DWORD get_drive_type () {return fs.drive_type;}
|
||||
BOOL fs_fast_ea () {return fs.sym_opt & PC_CHECK_EA;}
|
||||
void set_path (const char *p) {strcpy (path, p);}
|
||||
void clear_normalized_path ();
|
||||
char *return_and_clear_normalized_path ();
|
||||
};
|
||||
|
||||
/* Symlink marker */
|
||||
|
|
Loading…
Reference in New Issue